This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/2256: Internal compiler error in `find_function_data', at function.c:542
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/2256: Internal compiler error in `find_function_data', at function.c:542
- From: eric at randomtree dot org
- Date: 10 Mar 2001 22:53:29 -0000
- Reply-To: eric at randomtree dot org
>Number: 2256
>Category: c++
>Synopsis: Internal compiler error in `find_function_data', at function.c:542
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: ice-on-legal-code
>Submitter-Id: net
>Arrival-Date: Sat Mar 10 14:56:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: eric@randomtree.org
>Release: gcc version 2.95.2 19991024 (release)
>Organization:
>Environment:
MACHTYPE=i386-pc-openbsd2.7
SHLVL=1
SHELL=/usr/local/bin/bash
HOSTTYPE=i386
OSTYPE=openbsd2.7
>Description:
$ g++ -O2 -m486 -Wall -D_OS_BSD -save-temps -c http_parse.cc
http_parse.cc: In function `void process_request(int)':
http_parse.cc:57: Internal compiler error in `find_function_data', at function.c
:542
Please submit a full bug report.
See <URL:http://www.gnu.org/software/gcc/faq.html#bugreport> for instructions.
>How-To-Repeat:
See attached http_parse.ii
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="http_parse.ii"
Content-Disposition: inline; filename="http_parse.ii"
# 1 "http_parse.cc"
# 1 "decl.h" 1
# 1 "/usr/include/ctype.h" 1 3 4
# 1 "/usr/include/sys/cdefs.h" 1 3 4
# 1 "/usr/include/machine/cdefs.h" 1 3 4
# 38 "/usr/include/machine/cdefs.h" 3 4
# 53 "/usr/include/sys/cdefs.h" 2 3 4
# 110 "/usr/include/sys/cdefs.h" 3 4
# 46 "/usr/include/ctype.h" 2 3 4
extern const char *_ctype_;
extern const short *_tolower_tab_;
extern const short *_toupper_tab_;
extern "C" {
extern int isalnum (int) ;
extern int isalpha (int) ;
extern int iscntrl (int) ;
extern int isdigit (int) ;
extern int isgraph (int) ;
extern int islower (int) ;
extern int isprint (int) ;
extern int ispunct (int) ;
extern int isspace (int) ;
extern int isupper (int) ;
extern int isxdigit (int) ;
extern int tolower (int) ;
extern int toupper (int) ;
extern int isblank (int) ;
extern int isascii (int) ;
extern int toascii (int) ;
extern int _tolower (int) ;
extern int _toupper (int) ;
};
# 4 "decl.h" 2
# 1 "/usr/include/errno.h" 1 3 4
extern int errno;
extern int sys_nerr;
extern char *sys_errlist[];
# 5 "decl.h" 2
# 1 "/usr/include/fcntl.h" 1 3 4
# 1 "/usr/include/sys/types.h" 1 3 4
# 1 "/usr/include/machine/types.h" 1 3 4
typedef struct _physadr {
int r[1];
} *physadr;
typedef struct label_t {
int val[6];
} label_t;
typedef unsigned long vm_offset_t;
typedef unsigned long vm_size_t;
typedef unsigned long vaddr_t;
typedef unsigned long paddr_t;
typedef unsigned long vsize_t;
typedef unsigned long psize_t;
typedef signed char int8_t;
typedef unsigned char u_int8_t;
typedef unsigned char uint8_t;
typedef short int16_t;
typedef unsigned short u_int16_t;
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned int u_int32_t;
typedef unsigned int uint32_t;
typedef long long int64_t;
typedef unsigned long long u_int64_t;
typedef unsigned long long uint64_t;
typedef int32_t register_t;
# 48 "/usr/include/sys/types.h" 2 3 4
# 1 "/usr/include/machine/ansi.h" 1 3 4
# 50 "/usr/include/sys/types.h" 2 3 4
# 1 "/usr/include/machine/endian.h" 1 3 4
# 1 "/usr/include/sys/endian.h" 1 3 4
# 83 "/usr/include/sys/endian.h" 3 4
# 125 "/usr/include/sys/endian.h" 3 4
extern "C" {
u_int32_t htobe32 (u_int32_t) ;
u_int16_t htobe16 (u_int16_t) ;
u_int32_t betoh32 (u_int32_t) ;
u_int16_t betoh16 (u_int16_t) ;
u_int32_t htole32 (u_int32_t) ;
u_int16_t htole16 (u_int16_t) ;
u_int32_t letoh32 (u_int32_t) ;
u_int16_t letoh16 (u_int16_t) ;
};
# 180 "/usr/include/sys/endian.h" 3 4
# 68 "/usr/include/machine/endian.h" 2 3 4
# 51 "/usr/include/sys/types.h" 2 3 4
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;
typedef unsigned char unchar;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned long ulong;
typedef u_int64_t u_quad_t;
typedef int64_t quad_t;
typedef quad_t * qaddr_t;
typedef char * caddr_t;
typedef int32_t daddr_t;
typedef int32_t dev_t;
typedef u_int32_t fixpt_t;
typedef u_int32_t gid_t;
typedef u_int32_t ino_t;
typedef long key_t;
typedef u_int16_t mode_t;
typedef u_int16_t nlink_t;
typedef int32_t pid_t;
typedef quad_t rlim_t;
typedef int32_t segsz_t;
typedef int32_t swblk_t;
typedef u_int32_t uid_t;
typedef u_int32_t useconds_t;
typedef int32_t suseconds_t;
typedef u_int32_t in_addr_t;
typedef u_int16_t in_port_t;
typedef u_int8_t sa_family_t;
typedef u_int32_t socklen_t;
typedef unsigned long clock_t;
typedef unsigned int size_t;
typedef int ssize_t;
typedef int time_t;
typedef int clockid_t;
typedef int timer_t;
typedef long long off_t;
extern "C" {
off_t lseek (int, off_t, int) ;
int ftruncate (int, off_t) ;
int truncate (const char *, off_t) ;
};
typedef int32_t fd_mask;
typedef struct fd_set {
fd_mask fds_bits[((( 256 ) + (( (sizeof(fd_mask) * 8 ) ) - 1)) / ( (sizeof(fd_mask) * 8 ) )) ];
} fd_set;
# 205 "/usr/include/sys/types.h" 3 4
# 54 "/usr/include/fcntl.h" 2 3 4
# 124 "/usr/include/fcntl.h" 3 4
struct flock {
off_t l_start;
off_t l_len;
pid_t l_pid;
short l_type;
short l_whence;
};
extern "C" {
int open (const char *, int, ...) ;
int creat (const char *, mode_t) ;
int fcntl (int, int, ...) ;
int flock (int, int) ;
};
# 6 "decl.h" 2
# 1 "/usr/include/g++/fstream.h" 1 3
#pragma interface
# 1 "/usr/include/g++/iostream.h" 1 3
#pragma interface
# 1 "/usr/include/g++/streambuf.h" 1 3
#pragma interface
extern "C" {
# 1 "/usr/include/g++/libio.h" 1 3
# 1 "/usr/include/g++/_G_config.h" 1 3
typedef int _G_int8_t __attribute__((__mode__(__QI__)));
typedef unsigned int _G_uint8_t __attribute__((__mode__(__QI__)));
typedef int _G_int16_t __attribute__((__mode__(__HI__)));
typedef unsigned int _G_uint16_t __attribute__((__mode__(__HI__)));
typedef int _G_int32_t __attribute__((__mode__(__SI__)));
typedef unsigned int _G_uint32_t __attribute__((__mode__(__SI__)));
typedef int _G_int64_t __attribute__((__mode__(__DI__)));
typedef unsigned int _G_uint64_t __attribute__((__mode__(__DI__)));
__extension__ typedef long long _G_llong;
__extension__ typedef unsigned long long _G_ullong;
typedef unsigned long _G_clock_t;
typedef int _G_dev_t;
typedef _G_llong _G_fpos_t;
typedef unsigned int _G_gid_t;
typedef unsigned int _G_ino_t;
typedef unsigned short _G_mode_t;
typedef unsigned short _G_nlink_t;
typedef _G_llong _G_off_t;
typedef int _G_pid_t;
typedef int _G_ptrdiff_t;
typedef unsigned int _G_sigset_t;
typedef unsigned int _G_size_t;
typedef int _G_time_t;
typedef unsigned int _G_uid_t;
typedef int _G_wchar_t;
typedef int _G_ssize_t;
typedef int _G_wint_t;
typedef char * _G_va_list;
# 1 "/usr/include/stddef.h" 1 3 4
typedef int ptrdiff_t;
# 86 "/usr/include/g++/_G_config.h" 2 3
# 30 "/usr/include/g++/libio.h" 2 3
# 55 "/usr/include/g++/libio.h" 3
# 67 "/usr/include/g++/libio.h" 3
# 104 "/usr/include/g++/libio.h" 3
struct _IO_jump_t; struct _IO_FILE;
# 174 "/usr/include/g++/libio.h" 3
typedef void _IO_lock_t;
struct _IO_marker {
struct _IO_marker *_next;
struct _IO_FILE *_sbuf;
int _pos;
# 207 "/usr/include/g++/libio.h" 3
};
struct _IO_FILE {
int _flags;
char* _IO_read_ptr;
char* _IO_read_end;
char* _IO_read_base;
char* _IO_write_base;
char* _IO_write_ptr;
char* _IO_write_end;
char* _IO_buf_base;
char* _IO_buf_end;
char *_IO_save_base;
char *_IO_backup_base;
char *_IO_save_end;
struct _IO_marker *_markers;
struct _IO_FILE *_chain;
int _fileno;
int _blksize;
_G_off_t _offset;
unsigned short _cur_column;
char _unused;
char _shortbuf[1];
};
struct _IO_FILE_plus;
extern struct _IO_FILE_plus _IO_stdin_, _IO_stdout_, _IO_stderr_;
typedef struct
{
_G_ssize_t (*read) (struct _IO_FILE *, void *, _G_ssize_t ) ;
_G_ssize_t (*write) (struct _IO_FILE *, const void *, _G_ssize_t ) ;
_G_fpos_t (*seek) (struct _IO_FILE *, _G_off_t , int) ;
int (*close) (struct _IO_FILE *) ;
} _IO_cookie_io_functions_t;
struct _IO_cookie_file
{
struct _IO_FILE file;
const void *vtable;
void *cookie;
_IO_cookie_io_functions_t io_functions;
};
extern "C" {
extern int __underflow (_IO_FILE *) ;
extern int __uflow (_IO_FILE *) ;
extern int __overflow (_IO_FILE *, int) ;
extern int _IO_getc (_IO_FILE *__fp) ;
extern int _IO_putc (int __c, _IO_FILE *__fp) ;
extern int _IO_feof (_IO_FILE *__fp) ;
extern int _IO_ferror (_IO_FILE *__fp) ;
extern int _IO_peekc_locked (_IO_FILE *__fp) ;
extern void _IO_flockfile (_IO_FILE *) ;
extern void _IO_funlockfile (_IO_FILE *) ;
extern int _IO_ftrylockfile (_IO_FILE *) ;
extern int _IO_vfscanf (_IO_FILE *, const char *, _G_va_list , int *) ;
extern int _IO_vfprintf (_IO_FILE *, const char *, _G_va_list ) ;
extern _G_ssize_t _IO_padn (_IO_FILE *, int, _G_ssize_t ) ;
extern _G_size_t _IO_sgetn (_IO_FILE *, void *, _G_size_t ) ;
extern _G_fpos_t _IO_seekoff (_IO_FILE *, _G_off_t , int, int) ;
extern _G_fpos_t _IO_seekpos (_IO_FILE *, _G_fpos_t , int) ;
extern void _IO_free_backup_area (_IO_FILE *) ;
}
# 36 "/usr/include/g++/streambuf.h" 2 3
}
extern "C++" {
class istream;
class ostream; class streambuf;
typedef _G_off_t streamoff;
typedef _G_fpos_t streampos;
typedef _G_ssize_t streamsize;
typedef unsigned long __fmtflags;
typedef unsigned char __iostate;
struct _ios_fields
{
streambuf *_strbuf;
ostream* _tie;
int _width;
__fmtflags _flags;
short _fill;
__iostate _state;
__iostate _exceptions;
int _precision;
void *_arrays;
};
# 124 "/usr/include/g++/streambuf.h" 3
class ios : public _ios_fields {
ios& operator=(ios&);
ios (const ios&);
public:
typedef __fmtflags fmtflags;
typedef int iostate;
typedef int openmode;
typedef _G_ssize_t streamsize;
enum io_state {
goodbit = 0 ,
eofbit = 1 ,
failbit = 2 ,
badbit = 4 };
enum open_mode {
in = 1 ,
out = 2 ,
ate = 4 ,
app = 8 ,
trunc = 16 ,
nocreate = 32 ,
noreplace = 64 ,
bin = 128 ,
binary = 128 };
enum seek_dir { beg, cur, end};
typedef enum seek_dir seekdir;
enum { skipws= 01 ,
left= 02 , right= 04 , internal= 010 ,
dec= 020 , oct= 040 , hex= 0100 ,
showbase= 0200 , showpoint= 0400 ,
uppercase= 01000 , showpos= 02000 ,
scientific= 04000 , fixed= 010000 ,
unitbuf= 020000 , stdio= 040000
};
enum {
basefield=dec+oct+hex,
floatfield = scientific+fixed,
adjustfield = left+right+internal
};
# 177 "/usr/include/g++/streambuf.h" 3
ostream* tie() const { return _tie; }
ostream* tie(ostream* val) { ostream* save=_tie; _tie=val; return save; }
short fill() const { return _fill; }
short fill(short newf)
{short oldf = _fill; _fill = newf; return oldf;}
fmtflags flags() const { return _flags; }
fmtflags flags(fmtflags new_val) {
fmtflags old_val = _flags; _flags = new_val; return old_val; }
int precision() const { return _precision; }
int precision(int newp) {
unsigned short oldp = _precision; _precision = (unsigned short)newp;
return oldp; }
fmtflags setf(fmtflags val) {
fmtflags oldbits = _flags;
_flags |= val; return oldbits; }
fmtflags setf(fmtflags val, fmtflags mask) {
fmtflags oldbits = _flags;
_flags = (_flags & ~mask) | (val & mask); return oldbits; }
fmtflags unsetf(fmtflags mask) {
fmtflags oldbits = _flags;
_flags &= ~mask; return oldbits; }
int width() const { return _width; }
int width(int val) { int save = _width; _width = val; return save; }
void _throw_failure() const { }
void clear(iostate state = 0) {
_state = _strbuf ? state : state|badbit;
if (_state & _exceptions) _throw_failure(); }
void set(iostate flag) { _state |= flag;
if (_state & _exceptions) _throw_failure(); }
void setstate(iostate flag) { _state |= flag;
if (_state & _exceptions) _throw_failure(); }
int good() const { return _state == 0; }
int eof() const { return _state & ios::eofbit; }
int fail() const { return _state & (ios::badbit|ios::failbit); }
int bad() const { return _state & ios::badbit; }
iostate rdstate() const { return _state; }
operator void*() const { return fail() ? (void*)0 : (void*)(-1); }
int operator!() const { return fail(); }
iostate exceptions() const { return _exceptions; }
void exceptions(iostate enable) {
_exceptions = enable;
if (_state & _exceptions) _throw_failure(); }
streambuf* rdbuf() const { return _strbuf; }
streambuf* rdbuf(streambuf *_s) {
streambuf *_old = _strbuf; _strbuf = _s; clear (); return _old; }
static int sync_with_stdio(int on);
static void sync_with_stdio() { sync_with_stdio(1); }
static fmtflags bitalloc();
static int xalloc();
void*& pword(int);
void* pword(int) const;
long& iword(int);
long iword(int) const;
class Init {
public:
Init () { }
};
protected:
inline ios(streambuf* sb = 0, ostream* tie_to = 0);
inline virtual ~ios();
inline void init(streambuf* sb, ostream* tie = 0);
};
typedef ios::seek_dir _seek_dir;
class streammarker : private _IO_marker {
friend class streambuf;
void set_offset(int offset) { _pos = offset; }
public:
streammarker(streambuf *sb);
~streammarker();
int saving() { return 1; }
int delta(streammarker&);
int delta();
};
struct streambuf : public _IO_FILE {
friend class ios;
friend class istream;
friend class ostream;
friend class streammarker;
const void *&_vtable() { return *(const void**)((_IO_FILE*)this + 1); }
protected:
static streambuf* _list_all;
_IO_FILE*& xchain() { return _chain; }
void _un_link();
void _link_in();
char* gptr() const
{ return _flags & 0x100 ? _IO_save_base : _IO_read_ptr; }
char* pptr() const { return _IO_write_ptr; }
char* egptr() const
{ return _flags & 0x100 ? _IO_save_end : _IO_read_end; }
char* epptr() const { return _IO_write_end; }
char* pbase() const { return _IO_write_base; }
char* eback() const
{ return _flags & 0x100 ? _IO_save_base : _IO_read_base;}
char* base() const { return _IO_buf_base; }
char* ebuf() const { return _IO_buf_end; }
int blen() const { return _IO_buf_end - _IO_buf_base; }
void xput_char(char c) { *_IO_write_ptr++ = c; }
int xflags() { return _flags ; }
int xflags(int f) {int fl = _flags ; _flags = f; return fl;}
void xsetflags(int f) { _flags |= f; }
void xsetflags(int f, int mask)
{ _flags = (_flags & ~mask) | (f & mask); }
void gbump(int n)
{ _flags & 0x100 ? (_IO_save_base+=n):(_IO_read_ptr+=n);}
void pbump(int n) { _IO_write_ptr += n; }
void setb(char* b, char* eb, int a=0);
void setp(char* p, char* ep)
{ _IO_write_base=_IO_write_ptr=p; _IO_write_end=ep; }
void setg(char* eb, char* g, char *eg) {
if (_flags & 0x100 ) _IO_free_backup_area(this);
_IO_read_base = eb; _IO_read_ptr = g; _IO_read_end = eg; }
char *shortbuf() { return _shortbuf; }
int in_backup() { return _flags & 0x100 ; }
char *Gbase() { return in_backup() ? _IO_save_base : _IO_read_base; }
char *eGptr() { return in_backup() ? _IO_save_end : _IO_read_end; }
char *Bbase() { return in_backup() ? _IO_read_base : _IO_save_base; }
char *Bptr() { return _IO_backup_base; }
char *eBptr() { return in_backup() ? _IO_read_end : _IO_save_end; }
char *Nbase() { return _IO_save_base; }
char *eNptr() { return _IO_save_end; }
int have_backup() { return _IO_save_base != __null ; }
int have_markers() { return _markers != __null ; }
void free_backup_area();
void unsave_markers();
int put_mode() { return _flags & 0x800 ; }
int switch_to_get_mode();
streambuf(int flags=0);
public:
static int flush_all();
static void flush_all_linebuffered();
virtual ~streambuf();
virtual int overflow(int c = (-1) );
virtual int underflow();
virtual int uflow();
virtual int pbackfail(int c);
virtual streamsize xsputn(const char* s, streamsize n);
virtual streamsize xsgetn(char* s, streamsize n);
virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out);
streampos pubseekoff(streamoff o, _seek_dir d, int mode=ios::in|ios::out)
{ return _IO_seekoff (this, o, d, mode); }
streampos pubseekpos(streampos pos, int mode = ios::in|ios::out)
{ return _IO_seekpos (this, pos, mode); }
streampos sseekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
streampos sseekpos(streampos pos, int mode = ios::in|ios::out);
virtual streambuf* setbuf(char* p, int len);
virtual int sync();
virtual int doallocate();
int seekmark(streammarker& mark, int delta = 0);
int sputbackc(char c);
int sungetc();
int unbuffered() { return _flags & 2 ? 1 : 0; }
int linebuffered() { return _flags & 0x200 ? 1 : 0; }
void unbuffered(int i)
{ if (i) _flags |= 2 ; else _flags &= ~2 ; }
void linebuffered(int i)
{ if (i) _flags |= 0x200 ; else _flags &= ~0x200 ; }
int allocate() {
if (base() || unbuffered()) return 0;
else return doallocate(); }
void allocbuf() { if (base() == __null ) doallocbuf(); }
void doallocbuf();
int in_avail() { return _IO_read_end - _IO_read_ptr; }
int out_waiting() { return _IO_write_ptr - _IO_write_base; }
streamsize sputn(const char* s, streamsize n) { return xsputn(s, n); }
streamsize padn(char pad, streamsize n) { return _IO_padn(this, pad, n); }
streamsize sgetn(char* s, streamsize n) { return _IO_sgetn(this, s, n); }
int ignore(int);
int get_column();
int set_column(int);
long sgetline(char* buf, _G_size_t n, char delim, int putback_delim);
int sputc(int c) { return _IO_putc(c, this); }
int sbumpc() { return _IO_getc(this); }
int sgetc() { return (( this )->_IO_read_ptr >= ( this )->_IO_read_end && __underflow ( this ) == (-1) ? (-1) : *(unsigned char *) ( this )->_IO_read_ptr) ; }
int snextc() {
if (_IO_read_ptr >= _IO_read_end && __underflow(this) == (-1) )
return (-1) ;
else return _IO_read_ptr++, sgetc(); }
void stossc() { if (_IO_read_ptr < _IO_read_end) _IO_read_ptr++; }
int vscan(char const *fmt0, _G_va_list ap, ios* stream = __null );
int scan(char const *fmt0 ...);
int vform(char const *fmt0, _G_va_list ap);
int form(char const *fmt0 ...);
virtual streamsize sys_read(char* buf, streamsize size);
virtual streamsize sys_write(const char*, streamsize);
virtual streampos sys_seek(streamoff, _seek_dir);
virtual int sys_close();
virtual int sys_stat(void*);
};
class filebuf : public streambuf {
protected:
void init();
public:
static const int openprot;
filebuf();
filebuf(int fd);
filebuf(int fd, char* p, int len);
~filebuf();
filebuf* attach(int fd);
filebuf* open(const char *filename, const char *mode);
filebuf* open(const char *filename, ios::openmode mode, int prot = 0664);
virtual int underflow();
virtual int overflow(int c = (-1) );
int is_open() const { return _fileno >= 0; }
int fd() const { return is_open() ? _fileno : (-1) ; }
filebuf* close();
virtual int doallocate();
virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
virtual streambuf* setbuf(char* p, int len);
streamsize xsputn(const char* s, streamsize n);
streamsize xsgetn(char* s, streamsize n);
virtual int sync();
protected:
int is_reading() { return eback() != egptr(); }
char* cur_ptr() { return is_reading() ? gptr() : pptr(); }
char* file_ptr() { return eGptr(); }
virtual streamsize sys_read(char* buf, streamsize size);
virtual streampos sys_seek(streamoff, _seek_dir);
virtual streamsize sys_write(const char*, streamsize);
virtual int sys_stat(void*);
virtual int sys_close();
};
inline void ios::init(streambuf* sb, ostream* tie_to) {
_state = sb ? ios::goodbit : ios::badbit; _exceptions=0;
_strbuf=sb; _tie = tie_to; _width=0; _fill=' ';
_flags=ios::skipws|ios::dec;
_precision=6; _arrays = 0; }
inline ios::ios(streambuf* sb, ostream* tie_to) { init(sb, tie_to); }
inline ios::~ios() {
operator delete[] (_arrays);
}
}
# 31 "/usr/include/g++/iostream.h" 2 3
extern "C++" {
class istream; class ostream;
typedef ios& (*__manip)(ios&);
typedef istream& (*__imanip)(istream&);
typedef ostream& (*__omanip)(ostream&);
extern istream& ws(istream& ins);
extern ostream& flush(ostream& outs);
extern ostream& endl(ostream& outs);
extern ostream& ends(ostream& outs);
class ostream : virtual public ios
{
void do_osfx();
public:
ostream() { }
ostream(streambuf* sb, ostream* tied= __null );
int opfx() {
if (!good()) return 0;
else { if (_tie) _tie->flush(); ; return 1;} }
void osfx() { ;
if (flags() & (ios::unitbuf|ios::stdio))
do_osfx(); }
ostream& flush();
ostream& put(char c) { _strbuf->sputc(c); return *this; }
ostream& write(const char *s, streamsize n);
ostream& write(const unsigned char *s, streamsize n)
{ return write((const char*)s, n);}
ostream& write(const signed char *s, streamsize n)
{ return write((const char*)s, n);}
ostream& write(const void *s, streamsize n)
{ return write((const char*)s, n);}
ostream& seekp(streampos);
ostream& seekp(streamoff, _seek_dir);
streampos tellp();
ostream& form(const char *format ...);
ostream& vform(const char *format, _G_va_list args);
ostream& operator<<(char c);
ostream& operator<<(unsigned char c) { return (*this) << (char)c; }
ostream& operator<<(signed char c) { return (*this) << (char)c; }
ostream& operator<<(const char *s);
ostream& operator<<(const unsigned char *s)
{ return (*this) << (const char*)s; }
ostream& operator<<(const signed char *s)
{ return (*this) << (const char*)s; }
ostream& operator<<(const void *p);
ostream& operator<<(int n);
ostream& operator<<(unsigned int n);
ostream& operator<<(long n);
ostream& operator<<(unsigned long n);
__extension__ ostream& operator<<(long long n);
__extension__ ostream& operator<<(unsigned long long n);
ostream& operator<<(short n) {return operator<<((int)n);}
ostream& operator<<(unsigned short n) {return operator<<((unsigned int)n);}
ostream& operator<<(bool b) { return operator<<((int)b); }
ostream& operator<<(double n);
ostream& operator<<(float n) { return operator<<((double)n); }
ostream& operator<<(long double n) { return operator<<((double)n); }
ostream& operator<<(__omanip func) { return (*func)(*this); }
ostream& operator<<(__manip func) {(*func)(*this); return *this;}
ostream& operator<<(streambuf*);
};
class istream : virtual public ios
{
protected:
_G_size_t _gcount;
int _skip_ws();
public:
istream(): _gcount (0) { }
istream(streambuf* sb, ostream*tied= __null );
istream& get(char* ptr, int len, char delim = '\n');
istream& get(unsigned char* ptr, int len, char delim = '\n')
{ return get((char*)ptr, len, delim); }
istream& get(char& c);
istream& get(unsigned char& c) { return get((char&)c); }
istream& getline(char* ptr, int len, char delim = '\n');
istream& getline(unsigned char* ptr, int len, char delim = '\n')
{ return getline((char*)ptr, len, delim); }
istream& get(signed char& c) { return get((char&)c); }
istream& get(signed char* ptr, int len, char delim = '\n')
{ return get((char*)ptr, len, delim); }
istream& getline(signed char* ptr, int len, char delim = '\n')
{ return getline((char*)ptr, len, delim); }
istream& read(char *ptr, streamsize n);
istream& read(unsigned char *ptr, streamsize n)
{ return read((char*)ptr, n); }
istream& read(signed char *ptr, streamsize n)
{ return read((char*)ptr, n); }
istream& read(void *ptr, streamsize n)
{ return read((char*)ptr, n); }
istream& get(streambuf& sb, char delim = '\n');
istream& gets(char **s, char delim = '\n');
int ipfx(int need = 0) {
if (!good()) { set(ios::failbit); return 0; }
else {
;
if (_tie && (need == 0 || rdbuf()->in_avail() < need)) _tie->flush();
if (!need && (flags() & ios::skipws)) return _skip_ws();
else return 1;
}
}
int ipfx0() {
if (!good()) { set(ios::failbit); return 0; }
else {
;
if (_tie) _tie->flush();
if (flags() & ios::skipws) return _skip_ws();
else return 1;
}
}
int ipfx1() {
if (!good()) { set(ios::failbit); return 0; }
else {
;
if (_tie && rdbuf()->in_avail() == 0) _tie->flush();
return 1;
}
}
void isfx() { ; }
int get() { if (!ipfx1()) return (-1) ;
else { int ch = _strbuf->sbumpc();
if (ch == (-1) ) set(ios::eofbit);
isfx();
return ch;
} }
int peek();
_G_size_t gcount() { return _gcount; }
istream& ignore(int n=1, int delim = (-1) );
int sync ();
istream& seekg(streampos);
istream& seekg(streamoff, _seek_dir);
streampos tellg();
istream& putback(char ch) {
if (good() && _strbuf->sputbackc(ch) == (-1) ) clear(ios::badbit);
return *this;}
istream& unget() {
if (good() && _strbuf->sungetc() == (-1) ) clear(ios::badbit);
return *this;}
istream& scan(const char *format ...);
istream& vscan(const char *format, _G_va_list args);
istream& operator>>(char*);
istream& operator>>(unsigned char* p) { return operator>>((char*)p); }
istream& operator>>(signed char*p) { return operator>>((char*)p); }
istream& operator>>(char& c);
istream& operator>>(unsigned char& c) {return operator>>((char&)c);}
istream& operator>>(signed char& c) {return operator>>((char&)c);}
istream& operator>>(int&);
istream& operator>>(long&);
__extension__ istream& operator>>(long long&);
__extension__ istream& operator>>(unsigned long long&);
istream& operator>>(short&);
istream& operator>>(unsigned int&);
istream& operator>>(unsigned long&);
istream& operator>>(unsigned short&);
istream& operator>>(bool&);
istream& operator>>(float&);
istream& operator>>(double&);
istream& operator>>(long double&);
istream& operator>>( __manip func) {(*func)(*this); return *this;}
istream& operator>>(__imanip func) { return (*func)(*this); }
istream& operator>>(streambuf*);
};
class iostream : public istream, public ostream
{
public:
iostream() { }
iostream(streambuf* sb, ostream*tied= __null );
};
class _IO_istream_withassign : public istream {
public:
_IO_istream_withassign& operator=(istream&);
_IO_istream_withassign& operator=(_IO_istream_withassign& rhs)
{ return operator= (static_cast<istream&> (rhs)); }
};
class _IO_ostream_withassign : public ostream {
public:
_IO_ostream_withassign& operator=(ostream&);
_IO_ostream_withassign& operator=(_IO_ostream_withassign& rhs)
{ return operator= (static_cast<ostream&> (rhs)); }
};
extern _IO_istream_withassign cin;
extern _IO_ostream_withassign cout, cerr;
extern _IO_ostream_withassign clog
;
extern istream& lock(istream& ins);
extern istream& unlock(istream& ins);
extern ostream& lock(ostream& outs);
extern ostream& unlock(ostream& outs);
struct Iostream_init { } ;
inline ios& dec(ios& i)
{ i.setf(ios::dec, ios::dec|ios::hex|ios::oct); return i; }
inline ios& hex(ios& i)
{ i.setf(ios::hex, ios::dec|ios::hex|ios::oct); return i; }
inline ios& oct(ios& i)
{ i.setf(ios::oct, ios::dec|ios::hex|ios::oct); return i; }
}
# 30 "/usr/include/g++/fstream.h" 2 3
extern "C++" {
class fstreambase : virtual public ios {
mutable filebuf __my_fb;
void __fb_init ();
public:
fstreambase();
fstreambase(int fd);
fstreambase(int fd, char *p, int l);
fstreambase(const char *name, int mode, int prot=0664);
void close();
filebuf* rdbuf() const { return &__my_fb; }
void open(const char *name, int mode, int prot=0664);
int is_open() const { return rdbuf()->is_open(); }
void setbuf(char *ptr, int len) { rdbuf()->setbuf(ptr, len); }
void attach(int fd);
};
class ifstream : public fstreambase, public istream {
public:
ifstream() : fstreambase() { }
ifstream(int fd) : fstreambase(fd) { }
ifstream(int fd, char *p, int l) : fstreambase(fd, p, l) { }
ifstream(const char *name, int mode=ios::in, int prot=0664)
: fstreambase(name, mode, prot) { }
void open(const char *name, int mode=ios::in, int prot=0664)
{ fstreambase::open(name, mode, prot); }
};
class ofstream : public fstreambase, public ostream {
public:
ofstream() : fstreambase() { }
ofstream(int fd) : fstreambase(fd) { }
ofstream(int fd, char *p, int l) : fstreambase(fd, p, l) { }
ofstream(const char *name, int mode=ios::out, int prot=0664)
: fstreambase(name, mode, prot) { }
void open(const char *name, int mode=ios::out, int prot=0664)
{ fstreambase::open(name, mode, prot); }
};
class fstream : public fstreambase, public iostream {
public:
fstream() : fstreambase() { }
fstream(int fd) : fstreambase(fd) { }
fstream(const char *name, int mode, int prot=0664)
: fstreambase(name, mode, prot) { }
fstream(int fd, char *p, int l) : fstreambase(fd, p, l) { }
void open(const char *name, int mode, int prot=0664)
{ fstreambase::open(name, mode, prot); }
};
}
# 7 "decl.h" 2
# 1 "/usr/include/netdb.h" 1 3 4
# 1 "/usr/include/sys/param.h" 1 3 4
# 1 "/usr/include/sys/simplelock.h" 1 3 4
struct simplelock {
int lock_data;
};
# 105 "/usr/include/sys/simplelock.h" 3 4
# 61 "/usr/include/sys/param.h" 2 3 4
# 1 "/usr/include/sys/syslimits.h" 1 3 4
# 71 "/usr/include/sys/param.h" 2 3 4
# 1 "/usr/include/sys/signal.h" 1 3 4
# 1 "/usr/include/machine/signal.h" 1 3 4
typedef int sig_atomic_t;
# 1 "/usr/include/machine/trap.h" 1 3 4
# 47 "/usr/include/machine/signal.h" 2 3 4
struct sigcontext {
int sc_gs;
int sc_fs;
int sc_es;
int sc_ds;
int sc_edi;
int sc_esi;
int sc_ebp;
int sc_ebx;
int sc_edx;
int sc_ecx;
int sc_eax;
int sc_eip;
int sc_cs;
int sc_eflags;
int sc_esp;
int sc_ss;
int sc_onstack;
int sc_mask;
int sc_trapno;
int sc_err;
};
# 48 "/usr/include/sys/signal.h" 2 3 4
typedef unsigned int sigset_t;
# 1 "/usr/include/sys/siginfo.h" 1 3 4
union sigval {
int sival_int;
void *sival_ptr;
};
# 128 "/usr/include/sys/siginfo.h" 3 4
# 1 "/usr/include/sys/time.h" 1 3 4
struct timeval {
long tv_sec;
long tv_usec;
};
struct timespec {
time_t tv_sec;
long tv_nsec;
};
struct timezone {
int tz_minuteswest;
int tz_dsttime;
};
# 98 "/usr/include/sys/time.h" 3 4
# 107 "/usr/include/sys/time.h" 3 4
# 124 "/usr/include/sys/time.h" 3 4
# 133 "/usr/include/sys/time.h" 3 4
struct itimerval {
struct timeval it_interval;
struct timeval it_value;
};
struct clockinfo {
int hz;
int tick;
int tickadj;
int stathz;
int profhz;
};
# 1 "/usr/include/time.h" 1 3 4
struct tm {
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
long tm_gmtoff;
char *tm_zone;
};
extern "C" {
char *asctime (const struct tm *) ;
clock_t clock (void) ;
char *ctime (const time_t *) ;
double difftime (time_t, time_t) ;
struct tm *gmtime (const time_t *) ;
struct tm *localtime (const time_t *) ;
time_t mktime (struct tm *) ;
size_t strftime (char *, size_t, const char *, const struct tm *) ;
char *strptime (const char *, const char *, struct tm *) ;
time_t time (time_t *) ;
char *asctime_r (const struct tm *, char *) ;
char *ctime_r (const time_t *, char *) ;
struct tm *gmtime_r (const time_t *, struct tm *) ;
struct tm *localtime_r (const time_t *, struct tm *) ;
extern char *tzname[2];
void tzset (void) ;
char *timezone (int, int) ;
void tzsetwall (void) ;
};
# 172 "/usr/include/sys/time.h" 2 3 4
extern "C" {
int adjtime (const struct timeval *, struct timeval *) ;
int clock_getres (clockid_t, struct timespec *) ;
int clock_gettime (clockid_t, struct timespec *) ;
int clock_settime (clockid_t, const struct timespec *) ;
int futimes (int, const struct timeval *) ;
int getitimer (int, struct itimerval *) ;
int gettimeofday (struct timeval *, struct timezone *) ;
int nanosleep (const struct timespec *, struct timespec *) ;
int setitimer (int, const struct itimerval *, struct itimerval *) ;
int settimeofday (const struct timeval *, const struct timezone *) ;
int utimes (const char *, const struct timeval *) ;
};
# 133 "/usr/include/sys/siginfo.h" 2 3 4
typedef struct {
int si_signo;
int si_code;
int si_errno;
union {
int _pad[((128 / sizeof (int)) - 3) ];
struct {
pid_t _pid;
union {
struct {
uid_t _uid;
union sigval _value;
} _kill;
struct {
clock_t _utime;
int _status;
clock_t _stime;
} _cld;
} _pdata;
} _proc;
struct {
caddr_t _addr;
int _trapno;
} _fault;
# 174 "/usr/include/sys/siginfo.h" 3 4
} _data;
} siginfo_t;
# 112 "/usr/include/sys/signal.h" 2 3 4
struct sigaction {
union {
void (*__sa_handler) (int) ;
void (*__sa_sigaction) (int, siginfo_t *, void *) ;
} __sigaction_u;
sigset_t sa_mask;
int sa_flags;
};
typedef void (*sig_t) (int) ;
struct sigaltstack {
void *ss_sp;
int ss_size;
int ss_flags;
};
struct sigvec {
void (*sv_handler) (int) ;
int sv_mask;
int sv_flags;
};
struct sigstack {
void *ss_sp;
int ss_onstack;
};
extern "C" {
void (*signal (int, void (*) (int) ) ) (int) ;
};
# 95 "/usr/include/sys/param.h" 2 3 4
# 1 "/usr/include/machine/param.h" 1 3 4
# 98 "/usr/include/sys/param.h" 2 3 4
# 1 "/usr/include/machine/limits.h" 1 3 4
# 99 "/usr/include/sys/param.h" 2 3 4
# 75 "/usr/include/netdb.h" 2 3 4
extern int h_errno;
struct hostent {
char *h_name;
char **h_aliases;
int h_addrtype;
int h_length;
char **h_addr_list;
};
struct netent {
char *n_name;
char **n_aliases;
int n_addrtype;
in_addr_t n_net;
};
struct servent {
char *s_name;
char **s_aliases;
int s_port;
char *s_proto;
};
struct protoent {
char *p_name;
char **p_aliases;
int p_proto;
};
struct addrinfo {
int ai_flags;
int ai_family;
int ai_socktype;
int ai_protocol;
int ai_addrlen;
struct sockaddr *ai_addr;
char *ai_canonname;
struct addrinfo *ai_next;
};
extern "C" {
void endhostent (void) ;
void endnetent (void) ;
void endprotoent (void) ;
void endservent (void) ;
struct hostent *gethostbyaddr (const char *, int, int) ;
struct hostent *gethostbyname (const char *) ;
struct hostent *gethostbyname2 (const char *, int) ;
struct hostent *gethostent (void) ;
struct netent *getnetbyaddr (in_addr_t, int) ;
struct netent *getnetbyname (const char *) ;
struct netent *getnetent (void) ;
struct protoent *getprotobyname (const char *) ;
struct protoent *getprotobynumber (int) ;
struct protoent *getprotoent (void) ;
struct servent *getservbyname (const char *, const char *) ;
struct servent *getservbyport (int, const char *) ;
struct servent *getservent (void) ;
void herror (const char *) ;
const char *hstrerror (int) ;
void sethostent (int) ;
void setnetent (int) ;
void setprotoent (int) ;
void setservent (int) ;
int getaddrinfo (const char *name, const char *service,
const struct addrinfo *req, struct addrinfo **pai) ;
void freeaddrinfo (struct addrinfo *ai) ;
int getnameinfo (const struct sockaddr *sa, size_t addrlen,
char *host, size_t hostlen, char *serv, size_t servlen,
int flags) ;
char *gai_strerror (int ecode) ;
int net_addrcmp (struct sockaddr *, struct sockaddr *) ;
};
# 236 "/usr/include/netdb.h" 3 4
# 9 "decl.h" 2
# 1 "/usr/include/netinet/in.h" 1 3 4
struct in_addr {
in_addr_t s_addr;
};
struct sockaddr_in {
u_int8_t sin_len;
sa_family_t sin_family;
in_port_t sin_port;
struct in_addr sin_addr;
int8_t sin_zero[8];
};
struct ip_opts {
struct in_addr ip_dst;
int8_t Ip_opts[40];
};
struct ip_mreq {
struct in_addr imr_multiaddr;
struct in_addr imr_interface;
};
# 416 "/usr/include/netinet/in.h" 3 4
# 479 "/usr/include/netinet/in.h" 3 4
# 1 "/usr/include/netinet6/in6.h" 1 3 4
# 1 "/usr/include/sys/queue.h" 1 3 4
# 333 "/usr/include/sys/queue.h" 3 4
# 350 "/usr/include/sys/queue.h" 3 4
# 376 "/usr/include/sys/queue.h" 3 4
# 433 "/usr/include/sys/queue.h" 3 4
# 443 "/usr/include/sys/queue.h" 3 4
# 453 "/usr/include/sys/queue.h" 3 4
# 463 "/usr/include/sys/queue.h" 3 4
# 476 "/usr/include/sys/queue.h" 3 4
# 489 "/usr/include/sys/queue.h" 3 4
# 75 "/usr/include/netinet6/in6.h" 2 3 4
struct in6_addr {
union {
u_int8_t __u6_addr8[16];
u_int16_t __u6_addr16[8];
u_int32_t __u6_addr32[4];
} __u6_addr;
};
struct sockaddr_in6 {
u_int8_t sin6_len;
sa_family_t sin6_family;
in_port_t sin6_port;
u_int32_t sin6_flowinfo;
struct in6_addr sin6_addr;
u_int32_t sin6_scope_id;
};
# 166 "/usr/include/netinet6/in6.h" 3 4
# 199 "/usr/include/netinet6/in6.h" 3 4
extern const struct in6_addr in6addr_any;
extern const struct in6_addr in6addr_loopback;
extern const struct in6_addr in6addr_nodelocal_allnodes;
extern const struct in6_addr in6addr_linklocal_allnodes;
extern const struct in6_addr in6addr_linklocal_allrouters;
# 333 "/usr/include/netinet6/in6.h" 3 4
struct route_in6 {
struct rtentry *ro_rt;
struct sockaddr_in6 ro_dst;
};
struct ipv6_mreq {
struct in6_addr ipv6mr_multiaddr;
u_int ipv6mr_interface;
};
struct in6_pktinfo {
struct in6_addr ipi6_addr;
u_int ipi6_ifindex;
};
# 508 "/usr/include/netinet6/in6.h" 3 4
# 566 "/usr/include/netinet6/in6.h" 3 4
# 592 "/usr/include/netinet6/in6.h" 3 4
extern "C" {
struct cmsghdr;
extern int inet6_option_space(int);
extern int inet6_option_init(void *, struct cmsghdr **, int);
extern int inet6_option_append(struct cmsghdr *, const u_int8_t *, int, int);
extern u_int8_t *inet6_option_alloc(struct cmsghdr *, int, int, int);
extern int inet6_option_next(const struct cmsghdr *, u_int8_t **);
extern int inet6_option_find(const struct cmsghdr *, u_int8_t **, int);
extern size_t inet6_rthdr_space (int, int) ;
extern struct cmsghdr *inet6_rthdr_init (void *, int) ;
extern int inet6_rthdr_add (struct cmsghdr *, const struct in6_addr *,
unsigned int) ;
extern int inet6_rthdr_lasthop (struct cmsghdr *, unsigned int) ;
extern int inet6_rthdr_segments (const struct cmsghdr *) ;
extern struct in6_addr *inet6_rthdr_getaddr (struct cmsghdr *, int) ;
extern int inet6_rthdr_getflags (const struct cmsghdr *, int) ;
};
# 482 "/usr/include/netinet/in.h" 2 3 4
extern "C" {
int bindresvport (int, struct sockaddr_in *) ;
struct sockaddr;
int bindresvport_sa (int, struct sockaddr *) ;
};
# 506 "/usr/include/netinet/in.h" 3 4
# 10 "decl.h" 2
# 1 "/usr/include/signal.h" 1 3 4
extern const char * const sys_signame[32 ];
extern const char * const sys_siglist[32 ];
extern "C" {
int raise (int) ;
int kill (pid_t, int) ;
int sigaction (int, const struct sigaction *, struct sigaction *) ;
int sigaddset (sigset_t *, int) ;
int sigdelset (sigset_t *, int) ;
int sigemptyset (sigset_t *) ;
int sigfillset (sigset_t *) ;
int sigismember (const sigset_t *, int) ;
int sigpending (sigset_t *) ;
int sigprocmask (int, const sigset_t *, sigset_t *) ;
int sigsuspend (const sigset_t *) ;
extern inline int sigaddset(sigset_t *set, int signo) {
extern int errno;
if (signo <= 0 || signo >= 32 ) {
errno = 22;
return -1;
}
*set |= (1 << ((signo)-1));
return (0);
}
extern inline int sigdelset(sigset_t *set, int signo) {
extern int errno;
if (signo <= 0 || signo >= 32 ) {
errno = 22;
return -1;
}
*set &= ~(1 << ((signo)-1));
return (0);
}
extern inline int sigismember(const sigset_t *set, int signo) {
extern int errno;
if (signo <= 0 || signo >= 32 ) {
errno = 22;
return -1;
}
return ((*set & (1 << ((signo)-1))) != 0);
}
int killpg (pid_t, int) ;
int sigblock (int) ;
int siginterrupt (int, int) ;
int sigpause (int) ;
int sigreturn (struct sigcontext *) ;
int sigsetmask (int) ;
int sigstack (const struct sigstack *, struct sigstack *) ;
int sigaltstack (const struct sigaltstack *, struct sigaltstack *) ;
int sigvec (int, struct sigvec *, struct sigvec *) ;
void psignal (unsigned int, const char *) ;
int sigwait (const sigset_t *, int *) ;
};
# 11 "decl.h" 2
# 1 "/usr/include/stdio.h" 1 3 4
typedef off_t fpos_t;
struct __sbuf {
unsigned char *_base;
int _size;
};
typedef struct __sFILE {
unsigned char *_p;
int _r;
int _w;
short _flags;
short _file;
struct __sbuf _bf;
int _lbfsize;
void *_cookie;
int (*_close) (void *) ;
int (*_read) (void *, char *, int) ;
fpos_t (*_seek) (void *, fpos_t, int) ;
int (*_write) (void *, const char *, int) ;
struct __sbuf _ub;
unsigned char *_up;
int _ur;
unsigned char _ubuf[3];
unsigned char _nbuf[1];
struct __sbuf _lb;
int _blksize;
fpos_t _offset;
} FILE;
extern "C" {
extern FILE __sF[];
};
extern "C" {
void clearerr (FILE *) ;
int fclose (FILE *) ;
int feof (FILE *) ;
int ferror (FILE *) ;
int fflush (FILE *) ;
int fgetc (FILE *) ;
int fgetpos (FILE *, fpos_t *) ;
char *fgets (char *, int, FILE *) ;
FILE *fopen (const char *, const char *) ;
int fprintf (FILE *, const char *, ...) ;
int fputc (int, FILE *) ;
int fputs (const char *, FILE *) ;
size_t fread (void *, size_t, size_t, FILE *) ;
FILE *freopen (const char *, const char *, FILE *) ;
int fscanf (FILE *, const char *, ...) ;
int fseek (FILE *, long, int) ;
int fseeko (FILE *, off_t, int) ;
int fsetpos (FILE *, const fpos_t *) ;
long ftell (FILE *) ;
off_t ftello (FILE *) ;
size_t fwrite (const void *, size_t, size_t, FILE *) ;
int getc (FILE *) ;
int getchar (void) ;
char *gets (char *) ;
void perror (const char *) ;
int printf (const char *, ...) ;
int putc (int, FILE *) ;
int putchar (int) ;
int puts (const char *) ;
int remove (const char *) ;
int rename (const char *, const char *) ;
void rewind (FILE *) ;
int scanf (const char *, ...) ;
void setbuf (FILE *, char *) ;
int setvbuf (FILE *, char *, int, size_t) ;
int sprintf (char *, const char *, ...) ;
int sscanf (const char *, const char *, ...) ;
FILE *tmpfile (void) ;
char *tmpnam (char *) ;
int ungetc (int, FILE *) ;
int vfprintf (FILE *, const char *, char * ) ;
int vprintf (const char *, char * ) ;
int vsprintf (char *, const char *, char * ) ;
};
extern "C" {
char *ctermid (char *) ;
char *ctermid_r (char *) ;
char *cuserid (char *) ;
FILE *fdopen (int, const char *) ;
int fileno (FILE *) ;
void flockfile (FILE *) ;
int ftrylockfile (FILE *) ;
void funlockfile (FILE *) ;
void _flockfile_debug (FILE *, const char *, int) ;
int getc_unlocked (FILE *) ;
int putc_unlocked (int, FILE *) ;
int getchar_unlocked (void) ;
int putchar_unlocked (int) ;
};
extern "C" {
int asprintf (char **, const char *, ...)
__attribute__((format (printf, 2, 3)));
char *fgetln (FILE *, size_t *) ;
int fpurge (FILE *) ;
int getw (FILE *) ;
int pclose (FILE *) ;
FILE *popen (const char *, const char *) ;
int putw (int, FILE *) ;
void setbuffer (FILE *, char *, int) ;
int setlinebuf (FILE *) ;
char *tempnam (const char *, const char *) ;
int snprintf (char *, size_t, const char *, ...)
__attribute__((format (printf, 3, 4)));
int vasprintf (char **, const char *, char * )
__attribute__((format (printf, 2, 0)));
int vsnprintf (char *, size_t, const char *, char * )
__attribute__((format (printf, 3, 0)));
int vscanf (const char *, char * )
__attribute__((format (scanf, 1, 0)));
int vsscanf (const char *, const char *, char * )
__attribute__((format (scanf, 2, 0)));
};
extern "C" {
FILE *funopen (const void *,
int (*)(void *, char *, int),
int (*)(void *, const char *, int),
fpos_t (*)(void *, fpos_t, int),
int (*)(void *)) ;
};
extern "C" {
int __srget (FILE *) ;
int __svfscanf (FILE *, const char *, char * ) ;
int __swbuf (int, FILE *) ;
};
static inline int __sputc(int _c, FILE *_p) {
if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
return (*_p->_p++ = _c);
else
return (__swbuf(_c, _p));
}
# 382 "/usr/include/stdio.h" 3 4
# 12 "decl.h" 2
# 1 "/usr/include/stdlib.h" 1 3 4
typedef struct {
int quot;
int rem;
} div_t;
typedef struct {
long quot;
long rem;
} ldiv_t;
typedef struct {
quad_t quot;
quad_t rem;
} qdiv_t;
extern "C" {
void abort (void) ;
int abs (int) ;
int atexit (void (*)(void)) ;
double atof (const char *) ;
int atoi (const char *) ;
long atol (const char *) ;
void *bsearch (const void *, const void *, size_t,
size_t, int (*)(const void *, const void *)) ;
void *calloc (size_t, size_t) ;
div_t div (int, int) ;
void exit (int) ;
void free (void *) ;
char *getenv (const char *) ;
long labs (long) ;
ldiv_t ldiv (long, long) ;
void *malloc (size_t) ;
void qsort (void *, size_t, size_t,
int (*)(const void *, const void *)) ;
int rand (void) ;
int rand_r (unsigned int *) ;
void *realloc (void *, size_t) ;
void srand (unsigned) ;
double strtod (const char *, char **) ;
long strtol (const char *, char **, int) ;
unsigned long
strtoul (const char *, char **, int) ;
int system (const char *) ;
int mblen (const char *, size_t) ;
size_t mbstowcs (wchar_t *, const char *, size_t) ;
int wctomb (char *, wchar_t) ;
int mbtowc (wchar_t *, const char *, size_t) ;
size_t wcstombs (char *, const wchar_t *, size_t) ;
void *alloca (size_t) ;
char *getbsize (int *, long *) ;
char *cgetcap (char *, const char *, int) ;
int cgetclose (void) ;
int cgetent (char **, char **, const char *) ;
int cgetfirst (char **, char **) ;
int cgetmatch (char *, const char *) ;
int cgetnext (char **, char **) ;
int cgetnum (char *, const char *, long *) ;
int cgetset (const char *) ;
int cgetstr (char *, const char *, char **) ;
int cgetustr (char *, const char *, char **) ;
int daemon (int, int) ;
char *devname (int, int) ;
int getloadavg (double [], int) ;
long a64l (const char *) ;
char *l64a (long) ;
void cfree (void *) ;
int getopt (int, char * const *, const char *) ;
extern char *optarg;
extern int opterr;
extern int optind;
extern int optopt;
extern int optreset;
int getsubopt (char **, char * const *, char **) ;
extern char *suboptarg;
int heapsort (void *, size_t, size_t,
int (*)(const void *, const void *)) ;
int mergesort (void *, size_t, size_t,
int (*)(const void *, const void *)) ;
int radixsort (const unsigned char **, int, const unsigned char *,
unsigned) ;
int sradixsort (const unsigned char **, int, const unsigned char *,
unsigned) ;
char *initstate (unsigned int, char *, size_t) ;
long random (void) ;
char *realpath (const char *, char *) ;
char *setstate (const char *) ;
void srandom (unsigned int) ;
void srandomdev (void) ;
int putenv (const char *) ;
int setenv (const char *, const char *, int) ;
void unsetenv (const char *) ;
void setproctitle (const char *, ...) ;
quad_t qabs (quad_t) ;
qdiv_t qdiv (quad_t, quad_t) ;
quad_t strtoq (const char *, char **, int) ;
u_quad_t strtouq (const char *, char **, int) ;
double drand48 (void) ;
double erand48 (unsigned short[3]) ;
long jrand48 (unsigned short[3]) ;
void lcong48 (unsigned short[7]) ;
long lrand48 (void) ;
long mrand48 (void) ;
long nrand48 (unsigned short[3]) ;
unsigned short *seed48 (unsigned short[3]) ;
void srand48 (long) ;
u_int32_t arc4random (void) ;
void arc4random_stir (void) ;
void arc4random_addrandom (unsigned char *, int) ;
};
# 13 "decl.h" 2
# 1 "/usr/include/string.h" 1 3 4
extern "C" {
void *memchr (const void *, int, size_t) ;
int memcmp (const void *, const void *, size_t) ;
void *memcpy (void *, const void *, size_t) ;
void *memmove (void *, const void *, size_t) ;
void *memset (void *, int, size_t) ;
char *strcat (char *, const char *) ;
char *strchr (const char *, int) ;
int strcmp (const char *, const char *) ;
int strcoll (const char *, const char *) ;
char *strcpy (char *, const char *) ;
size_t strcspn (const char *, const char *) ;
char *strerror (int) ;
size_t strlen (const char *) ;
char *strncat (char *, const char *, size_t) ;
int strncmp (const char *, const char *, size_t) ;
char *strncpy (char *, const char *, size_t) ;
char *strpbrk (const char *, const char *) ;
char *strrchr (const char *, int) ;
size_t strspn (const char *, const char *) ;
char *strstr (const char *, const char *) ;
char *strtok (char *, const char *) ;
char *strtok_r (char *, const char *, char **) ;
size_t strxfrm (char *, const char *, size_t) ;
int bcmp (const void *, const void *, size_t) ;
void bcopy (const void *, void *, size_t) ;
void bzero (void *, size_t) ;
int ffs (int) ;
char *index (const char *, int) ;
void *memccpy (void *, const void *, int, size_t) ;
char *rindex (const char *, int) ;
int strcasecmp (const char *, const char *) ;
char *strdup (const char *) ;
size_t strlcat (char *, const char *, size_t) ;
size_t strlcpy (char *, const char *, size_t) ;
void strmode (int, char *) ;
int strncasecmp (const char *, const char *, size_t) ;
char *strsep (char **, const char *) ;
char *strsignal (int) ;
};
# 14 "decl.h" 2
# 1 "/usr/include/g++/strstream.h" 1 3
#pragma interface
# 1 "/usr/include/g++/strfile.h" 1 3
typedef void *(*_IO_alloc_type) (_G_size_t ) ;
typedef void (*_IO_free_type) (void*) ;
struct _IO_str_fields
{
_IO_alloc_type _allocate_buffer;
_IO_free_type _free_buffer;
};
struct _IO_streambuf
{
struct _IO_FILE _f;
const void *_vtable;
};
typedef struct _IO_strfile_
{
struct _IO_streambuf _sbf;
struct _IO_str_fields _s;
} _IO_strfile;
# 33 "/usr/include/g++/strstream.h" 2 3
extern "C++" {
class strstreambuf : public streambuf
{
struct _IO_str_fields _s;
friend class istrstream;
void init_dynamic(_IO_alloc_type alloc, _IO_free_type free,
int initial_size = 0);
void init_static(char *ptr, int size, char *pstart);
void init_readonly(const char *ptr, int size);
protected:
virtual int overflow(int = (-1) );
virtual int underflow();
virtual int pbackfail(int c);
public:
virtual ~strstreambuf();
strstreambuf() { init_dynamic(0, 0); }
strstreambuf(int initial_size) { init_dynamic(0, 0, initial_size); }
strstreambuf(void *(*alloc)(_G_size_t ), void (*free)(void*))
{ init_dynamic(alloc, free); }
strstreambuf(char *ptr, int size, char *pstart = __null )
{ init_static(ptr, size, pstart); }
strstreambuf(unsigned char *ptr, int size, unsigned char *pstart = __null )
{ init_static((char*)ptr, size, (char*)pstart); }
strstreambuf(const char *ptr, int size)
{ init_readonly(ptr, size); }
strstreambuf(const unsigned char *ptr, int size)
{ init_readonly((const char*)ptr, size); }
strstreambuf(signed char *ptr, int size, signed char *pstart = __null )
{ init_static((char*)ptr, size, (char*)pstart); }
strstreambuf(const signed char *ptr, int size)
{ init_readonly((const char*)ptr, size); }
int frozen() { return _flags & 1 ? 1 : 0; }
void freeze(int n=1)
{ if ((( this )->_s._allocate_buffer != (_IO_alloc_type)0) )
{ if (n) _flags |= 1 ; else _flags &= ~1 ; } }
_G_ssize_t pcount();
char *str();
virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
};
class strstreambase : virtual public ios {
protected:
strstreambuf __my_sb;
public:
strstreambuf* rdbuf() { return &__my_sb; }
protected:
strstreambase() { init (&__my_sb); }
strstreambase(char *cp, int n, int mode=ios::out);
};
class istrstream : public strstreambase, public istream {
public:
istrstream(const char*, int=0);
};
class ostrstream : public strstreambase, public ostream {
public:
ostrstream() { }
ostrstream(char *cp, int n, int mode=ios::out) :strstreambase(cp,n,mode){}
_G_ssize_t pcount() { return ((strstreambuf*)_strbuf)->pcount(); }
char *str() { return ((strstreambuf*)_strbuf)->str(); }
void freeze(int n = 1) { ((strstreambuf*)_strbuf)->freeze(n); }
int frozen() { return ((strstreambuf*)_strbuf)->frozen(); }
};
class strstream : public strstreambase, public iostream {
public:
strstream() { }
strstream(char *cp, int n, int mode=ios::out) :strstreambase(cp,n,mode){}
_G_ssize_t pcount() { return ((strstreambuf*)_strbuf)->pcount(); }
char *str() { return ((strstreambuf*)_strbuf)->str(); }
void freeze(int n = 1) { ((strstreambuf*)_strbuf)->freeze(n); }
int frozen() { return ((strstreambuf*)_strbuf)->frozen(); }
};
}
# 15 "decl.h" 2
# 1 "/usr/include/syslog.h" 1 3 4
# 88 "/usr/include/syslog.h" 3 4
# 145 "/usr/include/syslog.h" 3 4
extern "C" {
void closelog (void) ;
void openlog (const char *, int, int) ;
int setlogmask (int) ;
void syslog (int, const char *, ...)
__attribute__((__format__(__printf__,2,3)));
void vsyslog (int, const char *, char * ) ;
};
# 200 "/usr/include/syslog.h" 3 4
# 16 "decl.h" 2
# 1 "/usr/include/sys/socket.h" 1 3 4
# 1 "/usr/include/machine/param.h" 1 3 4
# 45 "/usr/include/sys/socket.h" 2 3 4
struct linger {
int l_onoff;
int l_linger;
};
struct sockaddr {
u_int8_t sa_len;
sa_family_t sa_family;
char sa_data[14];
};
struct sockaddr_storage {
u_int8_t ss_len;
sa_family_t ss_family;
u_char __ss_pad1[6];
u_int64_t __ss_pad2;
u_char __ss_pad3[240];
};
struct sockproto {
u_short sp_family;
u_short sp_protocol;
};
struct sockcred {
uid_t sc_uid;
uid_t sc_euid;
gid_t sc_gid;
gid_t sc_egid;
int sc_ngroups;
gid_t sc_groups[1];
};
# 285 "/usr/include/sys/socket.h" 3 4
struct msghdr {
caddr_t msg_name;
socklen_t msg_namelen;
struct iovec *msg_iov;
u_int msg_iovlen;
caddr_t msg_control;
socklen_t msg_controllen;
int msg_flags;
};
struct cmsghdr {
socklen_t cmsg_len;
int cmsg_level;
int cmsg_type;
};
struct osockaddr {
u_short sa_family;
char sa_data[14];
};
struct omsghdr {
caddr_t msg_name;
int msg_namelen;
struct iovec *msg_iov;
int msg_iovlen;
caddr_t msg_accrights;
int msg_accrightslen;
};
extern "C" {
int accept (int, struct sockaddr *, socklen_t *) ;
int bind (int, const struct sockaddr *, socklen_t) ;
int connect (int, const struct sockaddr *, socklen_t) ;
int getpeername (int, struct sockaddr *, socklen_t *) ;
int getsockname (int, struct sockaddr *, socklen_t *) ;
int getsockopt (int, int, int, void *, socklen_t *) ;
int listen (int, int) ;
ssize_t recv (int, void *, size_t, int) ;
ssize_t recvfrom (int, void *, size_t, int, struct sockaddr *, socklen_t *) ;
ssize_t recvmsg (int, struct msghdr *, int) ;
ssize_t send (int, const void *, size_t, int) ;
ssize_t sendto (int, const void *,
size_t, int, const struct sockaddr *, socklen_t) ;
ssize_t sendmsg (int, const struct msghdr *, int) ;
int setsockopt (int, int, int, const void *, socklen_t) ;
int shutdown (int, int) ;
int socket (int, int, int) ;
int socketpair (int, int, int, int *) ;
};
# 433 "/usr/include/sys/socket.h" 3 4
# 17 "decl.h" 2
# 1 "/usr/include/sys/wait.h" 1 3 4
union wait {
int w_status;
struct {
unsigned int w_Termsig:7,
w_Coredump:1,
w_Retcode:8,
w_Filler:16;
} w_T;
struct {
unsigned int w_Stopval:8,
w_Stopsig:8,
w_Filler:16;
} w_S;
};
extern "C" {
struct rusage;
pid_t wait (int *) ;
pid_t waitpid (pid_t, int *, int) ;
pid_t wait3 (int *, int, struct rusage *) ;
pid_t wait4 (pid_t, int *, int, struct rusage *) ;
};
# 19 "decl.h" 2
# 1 "/usr/include/unistd.h" 1 3 4
# 1 "/usr/include/sys/unistd.h" 1 3 4
# 44 "/usr/include/unistd.h" 2 3 4
extern "C" {
void _exit (int) __attribute__((noreturn));
int access (const char *, int) ;
unsigned int alarm (unsigned int) ;
int chdir (const char *) ;
int chown (const char *, uid_t, gid_t) ;
int close (int) ;
size_t confstr (int, char *, size_t) ;
char *cuserid (char *) ;
int dup (int) ;
int dup2 (int, int) ;
int execl (const char *, const char *, ...) ;
int execle (const char *, const char *, ...) ;
int execlp (const char *, const char *, ...) ;
int execv (const char *, char * const *) ;
int execve (const char *, char * const *, char * const *) ;
int execvp (const char *, char * const *) ;
pid_t fork (void) ;
long fpathconf (int, int) ;
char *getcwd (char *, size_t) ;
gid_t getegid (void) ;
uid_t geteuid (void) ;
gid_t getgid (void) ;
int getgroups (int, gid_t *) ;
char *getlogin (void) ;
int getlogin_r (char *, size_t) ;
pid_t getpgrp (void) ;
pid_t getpid (void) ;
pid_t getpgid (pid_t) ;
pid_t getppid (void) ;
uid_t getuid (void) ;
int isatty (int) ;
int link (const char *, const char *) ;
off_t lseek (int, off_t, int) ;
long pathconf (const char *, int) ;
int pause (void) ;
int pipe (int *) ;
ssize_t read (int, void *, size_t) ;
int rmdir (const char *) ;
int setgid (gid_t) ;
int setpgid (pid_t, pid_t) ;
pid_t setsid (void) ;
int setuid (uid_t) ;
unsigned int sleep (unsigned int) ;
long sysconf (int) ;
pid_t tcgetpgrp (int) ;
int tcsetpgrp (int, pid_t) ;
char *ttyname (int) ;
int ttyname_r (int, char *, size_t) ;
int unlink (const char *) ;
ssize_t write (int, const void *, size_t) ;
ssize_t pread (int, void *, size_t, off_t) ;
ssize_t pwrite (int, const void *, size_t, off_t) ;
int acct (const char *) ;
char *brk (const char *) ;
int chroot (const char *) ;
char *crypt (const char *, const char *) ;
int des_cipher (const char *, char *, long, int) ;
int des_setkey (const char *key) ;
int encrypt (char *, int) ;
void endusershell (void) ;
int exect (const char *, char * const *, char * const *) ;
int fchdir (int) ;
int fchown (int, uid_t, gid_t) ;
int fsync (int) ;
int ftruncate (int, off_t) ;
int getdomainname (char *, size_t) ;
int getdtablesize (void) ;
int getgrouplist (const char *, gid_t, gid_t *, int *) ;
long gethostid (void) ;
int gethostname (char *, size_t) ;
mode_t getmode (const void *, mode_t) ;
int getpagesize (void) ;
char *getpass (const char *) ;
char *getusershell (void) ;
char *getwd (char *) ;
int initgroups (const char *, gid_t) ;
int iruserok (u_int32_t, int, const char *, const char *) ;
int iruserok_sa (const void *, int, int, const char *, const char *) ;
int lchown (const char *, uid_t, gid_t) ;
char *mkdtemp (char *) ;
int mkstemp (char *) ;
int mkstemps (char *, int) ;
char *mktemp (char *) ;
int nfssvc (int, void *) ;
int nice (int) ;
void psignal (unsigned int, const char *) ;
extern const char * const sys_siglist[];
int profil (char *, size_t, unsigned long, unsigned int) ;
int rcmd (char **, int, const char *,
const char *, const char *, int *) ;
int rcmd_af (char **, int, const char *,
const char *, const char *, int *, int) ;
int rcmdsh (char **, int, const char *,
const char *, const char *, char *) ;
char *re_comp (const char *) ;
int re_exec (const char *) ;
int readlink (const char *, char *, size_t) ;
int reboot (int) ;
int revoke (const char *) ;
int rfork (int opts) ;
int rresvport (int *) ;
int rresvport_af (int *, int) ;
int ruserok (const char *, int, const char *, const char *) ;
int quotactl (const char *, int, int, char *) ;
char *sbrk (int) ;
int select (int, fd_set *, fd_set *, fd_set *, struct timeval *) ;
int setdomainname (const char *, size_t) ;
int setegid (gid_t) ;
int seteuid (uid_t) ;
int setgroups (int, const gid_t *) ;
int sethostid (long) ;
int sethostname (const char *, size_t) ;
int setkey (const char *) ;
int setlogin (const char *) ;
void *setmode (const char *) ;
int setpgrp (pid_t pid, pid_t pgrp) ;
int setregid (int, int) ;
int setreuid (int, int) ;
int setrgid (gid_t) ;
int setruid (uid_t) ;
void setusershell (void) ;
void swab (const void *, void *, size_t) ;
int swapon (const char *) ;
int swapctl (int cmd, const void *arg, int misc) ;
int symlink (const char *, const char *) ;
void sync (void) ;
int syscall (int, ...) ;
int truncate (const char *, off_t) ;
int ttyslot (void) ;
unsigned int ualarm (unsigned int, unsigned int) ;
int undelete (const char *) ;
int usleep (useconds_t) ;
void *valloc (size_t) ;
pid_t vfork (void) ;
int issetugid (void) ;
int getopt (int, char * const *, const char *) ;
extern char *optarg;
extern int opterr;
extern int optind;
extern int optopt;
extern int optreset;
int getsubopt (char **, char * const *, char **) ;
extern char *suboptarg;
int lockf (int, int, off_t) ;
};
# 20 "decl.h" 2
extern volatile sig_atomic_t keep_going;
extern char conf_file[256];
extern int listenport;
extern char content_base[256];
extern char default_file[256];
extern int checkflag;
extern char log_file[256];
extern const char *app_name;
extern const char *version;
extern const int MAXHOSTNAME;
extern const int MAXPATH;
enum HTTP_METHODS { HTTP_METHOD_NONE, HTTP_METHOD_UNKNOWN,
HTTP_METHOD_GET, HTTP_METHOD_POST };
# 1 "reqinfo.h" 1
# 1 "decl.h" 1
# 57 "decl.h"
# 4 "reqinfo.h" 2
class CReqInfo {
protected:
struct info_list {
char *info_name;
char *info_val;
info_list *next;
};
info_list *m_list;
public:
CReqInfo();
~CReqInfo();
char *getVal(const char *);
void setVal(const char *, const char *);
};
# 39 "decl.h" 2
# 1 "httprequest.h" 1
# 1 "decl.h" 1
# 57 "decl.h"
# 4 "httprequest.h" 2
class CHTTPRequest {
public:
HTTP_METHODS method;
unsigned int proto_major;
unsigned int proto_minor;
CReqInfo reqinfo;
char path[MAXPATH];
char query[MAXPATH];
CHTTPRequest();
~CHTTPRequest();
};
# 40 "decl.h" 2
void hangup_handler(int signum);
void termination_handler(int signum);
void init_daemon();
void child_handler(int);
int establish(unsigned short);
int read_sock(int, char *, int);
int write_sock(const int, const char *);
void process_request(int);
void print_stock_response(int, int);
void log_request(const char *);
int check_path(const char *);
void send_file(const char *);
void handle_post(CHTTPRequest *);
# 1 "http_parse.cc" 2
char* trim(char* string) {
int l = strlen(string);
while (l >= 0 && string[l] <= ' ') {
string[l--] = 0;
}
return string;
}
void process_request(int client) {
socklen_t len;
struct sockaddr_in sin;
struct hostent *host;
len = sizeof sin;
if (getpeername(client, (struct sockaddr *) &sin, &len) < 0)
syslog(3 , "Unable to get the peer name of the client: %m");
else {
if ((host = gethostbyaddr((char *) &sin.sin_addr, sizeof sin.sin_addr,
2 )) == __null )
syslog(3 , "Unable to gethostbyaddr(): %m");
else
syslog(5 , "Accepted connection from %s", host->h_name);
}
int opts = fcntl(client,3 );
if (opts < 0) {
syslog(3 , "fcntl(s, F_GETFL): %m");
exit(1 );
}
opts = (opts & ~0x0004 );
if (fcntl(client,4 ,opts) < 0) {
syslog(3 , "fcntl(s, F_SETFL, opts): %m");
exit(1 );
}
char buffer[513], *method = "get", *path, *http_ver, *tmpbuffer, *request;
int bcount = 0;
while ((bcount = read_sock(client, buffer, 512)) > 0) {
buffer[bcount] = '\0';
tmpbuffer = new char[strlen(buffer) + bcount];
strcpy(tmpbuffer, buffer);
request = tmpbuffer;
}
log_request(request);
char line[1024];
strncpy(line, buffer, (strchr(buffer, '\r')-1-buffer < 1024 ?
strchr(buffer, '\r')-1-buffer : 1024));
CHTTPRequest request;
if (!strncasecmp("GET ", line, 4)) {
request.method = HTTP_METHOD_GET;
line += 4;
}
else if (!strncasecmp("POST ", method, 5)) {
request.method = HTTP_METHOD_POST;
line += 5;
}
else if (!strncasecmp("HTTP/", method, 5))
request.method = HTTP_METHOD_NONE;
else
request.method = HTTP_METHOD_UNKNOWN;
char* proto = strstr(line, "HTTP/");
if (proto) {
size_t s = strspn(proto+5, "0123456789.");
if (s && s == strlen(proto+5)) {
sscanf(proto+5, "%hd.%hd", &(request.proto_major), &(request.proto_minor));
*proto = 0;
trim(line);
}
}
while (((_ctype_ + 1)[(unsigned char)( line[0] )] & 0x08 )
line++;
char *query = strchr(line, '?');
query[0] = '\0';
strncpy(req.path, line, MAXPATH);
char *linebreak = strchr(line, '\r');
linebreak[0] = '\0';
strncpy(req.query, query+1, MAXPATH);
linebreak[0] = '\r';
char *colon, header[512];
linebreak = buffer;
while ((linebreak = strstr(linebreak, "\r"))) {
if (linebreak[1] = '\n')
linebreak += 2;
else if (linebreak[1] = '\0')
break;
else
linebreak++;
strncpy(line, linebreak, strchr(linebreak, '\r')-1-linebreak);
line[strchr(linebreak, '\r')-1-linebreak] = '\0';
colon = strchr(line, ':');
colon[0] = '\0';
while (((_ctype_ + 1)[(unsigned char)( line[0] )] & 0x08 )
line++;
request.reqinfo.setVal(line, colon+1);
}
int path_allowed = check_path(request.path);
switch(request.method) {
case HTTP_METHOD_NONE:
print_stock_response(client, 400);
break;
case HTTP_METHOD_UNKNOWN:
print_stock_response(client, 501);
break;
case HTTP_METHOD_GET:
case HTTP_METHOD_POST:
switch (path_allowed) {
case -1:
print_stock_response(client, 403);
break;
case 0:
print_stock_response(client, 404);
break;
case 1:
break;
}
if (HTTP_METHOD_GET == request.method)
send_file(request.path);
else
handle_post(&request);
break;
}
close(client);
}
void print_stock_response(int client, int resp_num) {
switch (resp_num) {
case 400:
write_sock(client, "HTTP/1.0 400 Bad Request\r\n");
break;
case 401:
write_sock(client, "HTTP/1.0 401 Unauthorized\r\n");
break;
case 403:
write_sock(client, "HTTP/1.0 403 Forbidden\r\n");
break;
case 404:
write_sock(client, "HTTP/1.0 404 Not Found\r\n");
break;
case 500:
write_sock(client, "HTTP/1.0 500 Internal Server Error\r\n");
break;
case 501:
write_sock(client, "HTTP/1.0 501 Not Implemented\r\n");
break;
}
char resp_line[64];
sprintf(resp_line, "Server: %s/%s\r\n", app_name, version);
write_sock(client, resp_line);
}