From: Jeff Law Date: Tue, 3 Aug 1999 09:12:27 +0000 (-0600) Subject: Remove questionable files X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cb585cfa2e921884cbf8fae075019eb43908e68b;p=gcc.git Remove questionable files From-SVN: r28456 --- diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash19.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash19.C deleted file mode 100644 index de46668484b..00000000000 --- a/gcc/testsuite/g++.old-deja/g++.brendan/crash19.C +++ /dev/null @@ -1,1704 +0,0 @@ -// Special g++ Options: -// Build don't link: -// GROUPS passed old-abort -typedef unsigned long _G_clock_t; -typedef long _G_dev_t; -typedef long int _G_fpos_t; -typedef long _G_gid_t; -typedef unsigned long _G_ino_t; -typedef unsigned short _G_mode_t; -typedef short _G_nlink_t; -typedef long _G_off_t; -typedef long _G_pid_t; -typedef int _G_ptrdiff_t; -typedef int _G_sigset_t; -typedef unsigned int _G_size_t; -typedef long _G_time_t; -typedef long _G_uid_t; -typedef unsigned int _G_wchar_t; -typedef int _G_ssize_t; -typedef double * _G_va_list; -class ostream; class streambuf; class backupbuf; -extern "C" int __underflow(streambuf*); -extern "C" int __overflow(streambuf*, int); -typedef _G_off_t streamoff; -typedef _G_off_t streampos; -typedef unsigned long __fmtflags; -typedef unsigned char __iostate; -struct _ios_fields { - streambuf *_strbuf; - ostream* _tie; - int _width; - __fmtflags _flags; - _G_wchar_t _fill; - __iostate _state; - __iostate _exceptions; - int _precision; -}; -enum state_value { - _good = 0 , - _eof = 1 , - _fail = 2 , - _bad = 4 }; -enum open_mode { - input = 1 , - output = 2 , - atend = 4 , - append = 8 }; -class ios : public _ios_fields { - public: - typedef __fmtflags fmtflags; - typedef int iostate; - typedef int openmode; - 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 }; - enum seek_dir { beg, cur, end}; - 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, - dont_close=0x80000000 - }; - enum { - basefield=dec+oct+hex, - floatfield = scientific+fixed, - adjustfield = left+right+internal - }; - ostream* tie() const { return _tie; } - ostream* tie(ostream* val) { ostream* save=_tie; _tie=val; return save; } - _G_wchar_t fill() const { return (_G_wchar_t)_fill; } - _G_wchar_t fill(_G_wchar_t newf) - {_G_wchar_t oldf = (_G_wchar_t)_fill; _fill = (char)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 & mask; - _flags &= ~mask; return oldbits; } - int width() const { return _width; } - int width(int val) { int save = _width; _width = val; return save; } - void _throw_failure() { } - streambuf* rdbuf() const { return _strbuf; } - 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(); } - 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 exception(iostate enable) { - iostate old = _exceptions; _exceptions = enable; - if (_state & _exceptions) _throw_failure(); - return old; } - static int sync_with_stdio(int on); - static void sync_with_stdio() { sync_with_stdio(1); } - void unset(state_value flag) { _state &= ~flag; } - void close(); - int is_open(); - int readable(); - int writable(); - protected: - ios(streambuf* sb = 0, ostream* tie = 0); - virtual ~ios(); - void init(streambuf* sb) { _state=0; _strbuf=sb; } -}; -typedef ios::seek_dir _seek_dir; -class streammarker { - friend class streambuf; - friend int __underflow(streambuf*); - struct streammarker *_next; - streambuf *_sbuf; - streampos _spos; - void set_streampos(streampos sp) { _spos = sp; } - void set_offset(int offset) { _pos = offset; _spos = (streampos)(-2); } - int _pos; - public: - streammarker(streambuf *sb); - ~streammarker(); - int saving() { return _spos == -2; } - int delta(streammarker&); - int delta(); -}; -struct __streambuf { - int _flags; - char* _gptr; - char* _egptr; - char* _eback; - char* _pbase; // ERROR - inacessible - char* _pptr; // ERROR - inacessible - char* _epptr; - char* _base; - char* _ebuf; - struct streambuf *_chain; - friend class streammarker; - char *_other_gbase; - char *_aux_limit; - char *_other_egptr; - streammarker *_markers; - unsigned short _cur_column; - char _unused; - char _shortbuf[1]; -}; -extern unsigned __adjust_column(unsigned start, const char *line, int count); -struct streambuf : private __streambuf { - friend class ios; - friend class istream; - friend class ostream; - friend class streammarker; - friend int __underflow(streambuf*); - protected: - static streambuf* _list_all; - streambuf*& xchain() { return _chain; } - void _un_link(); - void _link_in(); - char* gptr() const { return _gptr; } - char* pptr() const { return _pptr; } - char* egptr() const { return _egptr; } - char* epptr() const { return _epptr; } - char* pbase() const { return _pbase; } - char* eback() const { return _eback; } - char* base() const { return _base; } - char* ebuf() const { return _ebuf; } - int blen() const { return _ebuf - _base; } - void xput_char(char c) { *_pptr++ = 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) { _gptr += n; } - void pbump(int n) { _pptr += n; } - void setb(char* b, char* eb, int a=0); - void setp(char* p, char* ep) { _pbase=_pptr=p; _epptr=ep; } - void setg(char* eb, char* g, char *eg) { _eback=eb; _gptr=g; _egptr=eg; } - char *shortbuf() { return _shortbuf; } - int in_backup() { return _flags & 0x100 ; } - char *Gbase() { return in_backup() ? _other_gbase : _eback; } - char *eGptr() { return in_backup() ? _other_egptr : _egptr; } - char *Bbase() { return in_backup() ? _eback : _other_gbase; } - char *Bptr() { return _aux_limit; } - char *eBptr() { return in_backup() ? _egptr : _other_egptr; } - char *Nbase() { return _other_gbase; } - char *eNptr() { return _other_egptr; } - int have_backup() { return _other_gbase != __null ; } - int have_markers() { return _markers != __null ; } - int _least_marker(); - void switch_to_main_get_area(); - void switch_to_backup_area(); - 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 int underflow() = 0; - virtual int overflow(int c = (-1) ) = 0; - virtual int doallocate(); - virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out); - virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out); - int seekmark(streammarker& mark, int delta = 0); - int sputbackc(char c); - int sungetc(); - virtual ~streambuf(); - 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(); - virtual int sync(); - virtual int pbackfail(int c); - virtual streambuf* setbuf(char* p, int len); - int in_avail() { return _egptr - _gptr; } - int out_waiting() { return _pptr - _pbase; } - virtual int xsputn(const char* s, int n); - int sputn(const char* s, int n) { return xsputn(s, n); } - int padn(char pad, int n); - virtual int xsgetn(char* s, int n); - int sgetn(char* s, int n) { return xsgetn(s, n); } - int ignore(int); - virtual int get_column(); - virtual int set_column(int); - long sgetline(char* buf, _G_size_t n, char delim, int putback_delim); - int sbumpc() { - if (_gptr >= _egptr && __underflow(this) == (-1) ) return (-1) ; - else return *(unsigned char*)_gptr++; } - int sgetc() { - if (_gptr >= _egptr && __underflow(this) == (-1) ) return (-1) ; - else return *(unsigned char*)_gptr; } - int snextc() { - if (_gptr >= _egptr && __underflow(this) == (-1) ) return (-1) ; - return _gptr++, sgetc(); } - int sputc(int c) { - if (_pptr >= _epptr) return __overflow(this, (unsigned char)c); - else return *_pptr++ = c, (unsigned char)c; } - void stossc() { if (_gptr < _egptr) _gptr++; } - 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 ...); -}; -class backupbuf : public streambuf { - friend class streammarker; - protected: - backupbuf(int flags=0) : streambuf(flags| 0x4000 ) { } - public: - virtual int pbackfail(int c); - virtual int underflow(); - virtual int overflow(int c = (-1) ); -}; -struct __file_fields { - short _fileno; - int _blksize; - _G_fpos_t _offset; -}; -class filebuf : public backupbuf { - protected: - struct __file_fields _fb; - 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 _fb._fileno >= 0; } - int fd() const { return is_open() ? _fb._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); - int xsputn(const char* s, int n); - int xsgetn(char* s, int n); - virtual int sync(); - protected: - int is_reading() { return eback() != egptr(); } - char* cur_ptr() { return is_reading() ? gptr() : pptr(); } - char* file_ptr() { return eGptr(); } - int do_write(const char *data, int to_do); - int do_flush() { return do_write(_pbase, _pptr-_pbase); }// ERROR - - virtual _G_ssize_t sys_read(char* buf, _G_size_t size); - virtual _G_fpos_t sys_seek(_G_fpos_t, _seek_dir); - virtual _G_ssize_t sys_write(const void*, long); - virtual int sys_stat(void*); - virtual int sys_close(); -}; -inline ios::ios(streambuf* sb , ostream* tie ) { - _state = sb ? ios::goodbit : ios::badbit; _exceptions=0; - _strbuf=sb; _tie = tie; _width=0; _fill=' '; - _flags=ios::skipws|ios::dec; _precision=6; } -inline ios::~ios() { - if (!(_flags & (unsigned int)ios::dont_close)) delete _strbuf; } -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(); } - streambuf* ostreambuf() const { return _strbuf; } - ostream& flush(); - ostream& put(char c) { _strbuf->sputc(c); return *this; } - ostream& put(unsigned char c) { return put((char)c); } - ostream& write(const char *s, int n); - ostream& write(const unsigned char *s, int n) { return write((const char*)s, n);} - ostream& put(signed char c) { return put((char)c); } - ostream& write(const signed char *s, int n) { return write((const char*)s, n);} - ostream& write(const void *s, int 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<<(void *p); - ostream& operator<<(int n); - ostream& operator<<(unsigned int n); - ostream& operator<<(long n); - ostream& operator<<(unsigned long n); - ostream& operator<<(long long n); - 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<<(double n); - ostream& operator<<(float 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 -{ - _G_ssize_t _gcount; - int _skip_ws(); - public: - istream() { _gcount = 0; } - istream(streambuf* sb, ostream*tied=__null ); - streambuf* istreambuf() const { return _strbuf; } - 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, int n); - istream& read(unsigned char *ptr, int n) { return read((char*)ptr, n); } - istream& read(signed char *ptr, int n) { return read((char*)ptr, n); } - istream& read(void *ptr, int n) { return read((char*)ptr, n); } - istream& get(streambuf& sb, char delim = '\n'); - istream& gets(char **s, char delim = '\n'); - int ipfx(int need) { - if (!good()) { set(ios::failbit); return 0; } - if (_tie && (need == 0 || rdbuf()->in_avail() < need)) _tie->flush(); - if (!need && (flags() & ios::skipws)) return _skip_ws(); - return 1; - } - int ipfx0() { - if (!good()) { set(ios::failbit); return 0; } - if (_tie) _tie->flush(); - if (flags() & ios::skipws) return _skip_ws(); - return 1; - } - int ipfx1() { - if (!good()) { set(ios::failbit); return 0; } - if (_tie && rdbuf()->in_avail() == 0) _tie->flush(); - return 1; - } - int get() { if (!ipfx1()) return (-1) ; - int ch = _strbuf->sbumpc(); - if (ch == (-1) ) set(ios::eofbit); - return ch; } - int peek() { if (!ipfx1()) return (-1) ; - int ch = _strbuf->sgetc(); - if (ch == (-1) ) set(ios::eofbit); - return ch; } - _G_ssize_t gcount() { return _gcount; } - istream& ignore(int n=1, int delim = (-1) ); - 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& unget(char ch) { return putback(ch); } - int skip(int i); - 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&); - istream& operator>>(long long&); - istream& operator>>(short&); - istream& operator>>(unsigned int&); - istream& operator>>(unsigned long&); - istream& operator>>(unsigned long long&); - istream& operator>>(unsigned short&); - istream& operator>>(float&); - istream& operator>>(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 -{ - _G_ssize_t _gcount; - public: - iostream() { _gcount = 0; } - iostream(streambuf* sb, ostream*tied=__null ); -}; -extern istream cin; -extern ostream cout, cerr, clog; -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; } -extern char* form(const char*, ...); -extern char* dec(long, int=0); -extern char* dec(int, int=0); -extern char* dec(unsigned long, int=0); -extern char* dec(unsigned int, int=0); -extern char* hex(long, int=0); -extern char* hex(int, int=0); -extern char* hex(unsigned long, int=0); -extern char* hex(unsigned int, int=0); -extern char* oct(long, int=0); -extern char* oct(int, int=0); -extern char* oct(unsigned long, int=0); -extern char* oct(unsigned int, int=0); -inline istream& WS(istream& str) { return ws(str); } -typedef double *__gnuc_va_list; -extern "C" { - typedef struct { - int __cnt; - unsigned char *__ptr; - unsigned char *__base; - unsigned short __flag; - unsigned char __fileL; - unsigned char __fileH; - } FILE; - typedef struct { - int __cnt; - unsigned char *__ptr; - unsigned char *__base; - unsigned short __flag; - unsigned char __fileL; - unsigned char __fileH; - unsigned char *__bufendp; - unsigned char __smbuf[8 ]; - } _FILEX; - typedef unsigned int size_t; - typedef long int fpos_t; - typedef double *__va_list; - extern FILE __iob[]; - extern int remove(const char *); - extern int rename(const char *, const char *); - extern FILE *tmpfile(void); - extern char *tmpnam(char *); - extern int fclose(FILE *); - extern int fflush(FILE *); - extern FILE *fopen(const char *, const char *); - extern FILE *freopen(const char *, const char *, FILE *); - extern void setbuf(FILE *, char *); - extern int setvbuf(FILE *, char *, int, size_t); - extern int fprintf(FILE *, const char *, ...); - extern int fscanf(FILE *, const char *,...); - extern int printf(const char *,...); - extern int scanf(const char *,...); - extern int sprintf(char *, const char *,...); - extern int sscanf(const char *, const char *,...); - extern int vprintf(const char *, __va_list); - extern int vfprintf(FILE *, const char *, __va_list); - extern int vsprintf(char *, const char *, __va_list); - extern int fgetc(FILE *); - extern char *fgets(char *, int, FILE *); - extern int fputc(int, FILE *); - extern int fputs(const char *, FILE *); - extern int getc(FILE *); - extern int getchar(void); - extern char *gets(char *); - extern int putc(int, FILE *); - extern int putchar(int); - extern int puts(const char *); - extern int ungetc(int, FILE *); - extern int fgetpos(FILE *, fpos_t *); - extern int fseek(FILE *, long int, int); - extern int fsetpos(FILE *, const fpos_t *); - extern long int ftell(FILE *); - extern void rewind(FILE *); - extern void clearerr(FILE *); - extern int feof(FILE *); - extern int ferror(FILE *); - extern void perror(const char *); - extern size_t fread(void *, size_t, size_t, FILE *); - extern size_t fwrite(const void *, size_t, size_t, FILE *); - extern int __flsbuf(unsigned char, FILE *); - extern int __filbuf(FILE *); - extern int fileno(FILE *); - extern FILE *fdopen(int, const char *); - extern int getw(FILE *); - extern int putw(int, FILE *); - extern int pclose(FILE *); - extern FILE *popen(const char *, const char *); - extern char *tempnam(const char *, const char *); - extern char *ctermid(char *); - extern char *cuserid(char *); - extern int nl_fprintf(FILE *, const char * ,...); - extern int nl_fscanf(FILE *, const char * ,...); - extern int nl_printf(const char * ,...); - extern int nl_scanf(const char * ,...); - extern int nl_sprintf(char *, const char * ,...); - extern int nl_sscanf(const char *, const char * ,...); - extern unsigned char *__bufendtab[]; -} -extern "C" { - extern int __nl_char_size; - typedef struct { - int quot; - int rem; - } div_t; - typedef struct { - long int quot; - long int rem; - } ldiv_t; - typedef unsigned int wchar_t; - extern double atof(const char *); - extern int atoi(const char *); - extern long int atol(const char *); - extern double strtod(const char *, char **); - extern long int strtol(const char *, char **, int); - extern unsigned long int strtoul(const char *, char **, int); - extern int rand(void); - extern void srand(unsigned int); - extern int atexit(void (*) (void)); - extern void exit(int); - extern char *getenv(const char *); - extern int system(const char *); - inline int abs(int d) { return (d>0)?d:-d; } - extern div_t div(int, int); - extern ldiv_t ldiv(long int, long int); - extern long int labs(long int); - extern int mblen(const char *, size_t); - extern int mbtowc(wchar_t *, const char *, size_t); - extern int wctomb(char *, wchar_t); - extern size_t mbstowcs(wchar_t *, const char *, size_t); - extern size_t wcstombs(char *, const wchar_t *, size_t); - extern void free(void *); - extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *)); - extern void abort(void); - extern void *bsearch(const void *, const void *, size_t, size_t, int (*) (const void *, const void *)); - extern void *calloc(size_t, size_t); - extern void *malloc(size_t); - extern void *realloc(void *, size_t); - extern void setkey(const char *); - extern void lcong48( unsigned short [] ); - extern double wcstod( const wchar_t *, wchar_t ** ); - extern long wcstol( const wchar_t *, wchar_t **, int ); - extern unsigned long wcstoul( const wchar_t *, wchar_t **, int ); - extern double drand48(void); - extern double erand48(unsigned short []); - extern long jrand48(unsigned short []); - extern long lrand48(void); - extern long mrand48(void); - extern long nrand48(unsigned short []); - extern void srand48(long); - extern unsigned short *seed48(unsigned short []); - extern int putenv(const char *); - extern int clearenv(void); - extern int getopt(int, char * const [], const char *); - extern char *getpass(const char *); - extern char *optarg; - extern int optind; - extern int opterr; - struct mallinfo { - int arena; - int ordblks; - int smblks; - int hblks; - int hblkhd; - int usmblks; - int fsmblks; - int uordblks; - int fordblks; - int keepcost; - }; - typedef struct { - unsigned int word1, word2, word3, word4; - } long_double; -extern "C" { - typedef long gid_t; - typedef long uid_t; - struct passwd { - char *pw_name; - char *pw_passwd; - uid_t pw_uid; - gid_t pw_gid; - char *pw_age; - char *pw_comment; - char *pw_gecos; - char *pw_dir; - char *pw_shell; - long pw_audid; - int pw_audflg; - }; - extern struct passwd *getpwuid(uid_t); - extern struct passwd *getpwnam(const char *); - struct s_passwd { - char *pw_name; - char *pw_passwd; - char *pw_age; - long pw_audid; - int pw_audflg; - }; - struct comment { - char *c_dept; - char *c_name; - char *c_acct; - char *c_bin; - }; - extern void setpwent(void); - extern void endpwent(void); - extern struct passwd *getpwent(void); - extern struct passwd *fgetpwent(FILE *); - extern struct s_passwd *getspwent(void); - extern struct s_passwd *getspwuid(int); - extern struct s_passwd *getspwaid(int); - extern struct s_passwd *getspwnam(char *); - extern struct s_passwd *fgetspwent(FILE *); -} -extern int errno; - extern "C" { - extern int errno; - } -extern "C" { - extern void perror(const char*); - extern int sys_nerr; - extern char *sys_errlist[]; - extern char *strerror (int); -} - extern const char *fcvt(double, size_t, int *, int *); - extern char *gcvt(double, size_t, char *); - extern char *ecvt(double, size_t, int *, int *); - extern char *nl_gcvt(double, size_t, char *, int); - extern char *_ldecvt(long_double, size_t, int *, int *); - extern char *_ldfcvt(long_double, size_t, int *, int *); - extern char *_ldgcvt(long_double, size_t, char *); - extern int getpw(int, char *); - extern long a64l(const char *); - extern char *l64a(long); - extern void l3tol(long *, const char *, int); - extern void ltol3(char *, const long *, int); - extern char *getmsg(int, int, int, char *, int); - extern double nl_atof(const char *, int); - extern double nl_strtod(const char *, char **, int); - extern char *ltostr(long, int); - extern char *ultostr(unsigned long, int); - extern char *ltoa(long); - extern char *ultoa(unsigned long); - extern void memorymap(int); - extern struct mallinfo mallinfo(void); - extern int mallopt(int, int); -} -typedef void * POINTER; -typedef FILE * FILE_PTR; -typedef void (*DISPLAYER) (POINTER obj, FILE_PTR fp, FILE_PTR errorFile) ; -typedef void (*DESTROYER) (POINTER obj, FILE_PTR errorFile) ; -typedef void (*RCOUNT_INC) (POINTER obj, FILE_PTR errorFile) ; -typedef int (*COMPARE) (POINTER obj1, POINTER obj2) ; -typedef unsigned long (*HASH_ADDR) (POINTER obj, FILE_PTR errorFile) ; -typedef unsigned long (*HASH_SKIP) (POINTER obj, FILE_PTR errorFile) ; -typedef POINTER - (*ACCESS_FCT) (POINTER target, POINTER sample, FILE_PTR errorFile) ; -typedef POINTER DATA_PTR; - typedef long dev_t; - typedef unsigned long ino_t; - typedef unsigned short mode_t; - typedef short nlink_t; - typedef long off_t; - typedef long pid_t; - typedef long time_t; - typedef int ssize_t; - typedef unsigned short __site_t; - typedef unsigned short __cnode_t; - typedef unsigned long clock_t; - typedef long key_t; - typedef unsigned short __ushort; - typedef long __daddr_t; - typedef char *__caddr_t; - typedef long __swblk_t; - typedef unsigned char u_char; - typedef unsigned short u_short; - typedef unsigned int u_int; - typedef unsigned long u_long; - typedef unsigned int uint; - typedef unsigned short ushort; - typedef __swblk_t swblk_t; - typedef __daddr_t daddr_t; - typedef __site_t site_t; - typedef __cnode_t cnode_t; - typedef __caddr_t caddr_t; - typedef long paddr_t; - typedef short cnt_t; - typedef unsigned int space_t; - typedef unsigned int prot_t; - typedef unsigned long cdno_t; - typedef unsigned short use_t; - typedef struct _physadr { int r[1]; } *physadr; - typedef struct _quad { long val[2]; } quad; - typedef short cpu_t; - typedef struct label_t { - int lbl_rp; - int lbl_sp; - int lbl_s[17]; - int lbl_ss[1]; - double lbl_sf[4]; - } label_t; - typedef char *dm_message; - typedef long aid_t; - typedef pid_t sid_t; - typedef long fd_mask; - typedef struct fd_set { - fd_mask fds_bits[ ((( 2048 )+(( (sizeof(fd_mask) * 8) )-1))/( (sizeof(fd_mask) * 8) )) ]; - } fd_set; -POINTER malloc (size_t size ) ; -POINTER calloc (size_t n , size_t size ) ; -void free (POINTER c ) ; -void mem_report (void ) ; -typedef int BOOLEAN; -typedef enum -{ - eNoErrors = -1, - eUnknownProcessingError = 0, - eAlgorithmFailure = 100, - eAlreadyLocked = 200, - eAttCount = 300, - eAttRedefinition = 400, - eBasicMatrixError = 500, - eBadAddress = 600, - eBadAttribute = 700, - eBadFileNumber = 800, - eBadMode = 900, - eBadVersion = 1000, - eColumnError = 1100, - eConstraintError = 1200, - eLBConstraintError = 1300, - eUBConstraintError = 1400, - eDatabaseError = 1500, - eDataExists = 1600, - eDataNotFound = 1700, - eDictError = 1800, - eDiffAtt = 1900, - eDomain = 2000, - eDuplicateAtt = 2100, - eDuplicateKey = 2200, - eElementMismatch = 2300, - eEmptyAtt = 2400, - eEmptyDict = 2450, - eEmptyLink = 2500, - eEmptyQueue = 2600, - eEmptyStack = 2700, - eEntityExists = 2800, - eEntityNotFound = 2900, - eEtaComputeError = 3000, - eEtaFileError = 3100, - eEtaInverseConsistency = 3200, - eFileExists = 3300, - eFileNotFound = 3400, - eFunctionMismatch = 3500, - eFunctionNotAvailable = 3600, - eFunctionNotFound = 3700, - eFunctionTypeConflict = 3800, - eGraphError = 3900, - eIllegalBMatrixOp = 4000, - eIllegalData = 4100, - eIllegalDeletion = 4200, - eIllegalDictOp = 4300, - eIllegalEtaFileOp = 4400, - eIllegalFunctionRequest = 4500, - eIllegalFunctionType = 4600, - eIllegalGraphOp = 4700, - eIllegalGraphType = 4800, - eIllegalIndex = 4900, - eIllegalInsertion = 5000, - eIllegalListOp = 5100, - eIllegalLPTokenOp = 5200, - eIllegalLPTokenType = 5300, - eIllegalMatrixOp = 5400, - eIllegalMatrixSize = 5500, - eIllegalMatrixState = 5600, - eIllegalMatrixType = 5700, - eIllegalNBMatrixOp = 5800, - eIllegalOperation = 5900, - eIllegalOption = 6000, - eIllegalOverload = 6100, - eIllegalSeek = 6200, - eIllegalType = 6300, - eIllegalVectorOp = 6400, - eIllegalVectorType = 6500, - eIllFormedADT = 6600, - eInconsistentData = 6700, - eInternalError = 6800, - eInUse = 6900, - eInvalidArgument = 7000, - eInvalidAtt = 7100, - eInvalidData = 7200, - eInvalidIndex = 7300, - eInvalidMatrixOp = 7400, - eInvalidOperation = 7500, - eInvalidOption = 7600, - eInvalidParam = 7700, - eInvalidVectorOp = 7800, - eKeyNotFound = 7900, - eLinkNotEmpty = 8000, - eListError = 8100, - eLockAccess = 8200, - eLockExists = 8300, - eLockNotFound = 8400, - eLockReadOnly = 8500, - eLockTrunc = 8600, - eLPTokenError = 8700, - eLPTokenMisuse = 8800, - eMatrixError = 8900, - eMatrixMismatch = 9000, - eMatrixMultiplicationError = 9100, - eMissingData = 9200, - eMysteryError = 9300, - eNameTooLong = 9400, - eNeverLocked = 9500, - eNoAccess = 9600, - eNoLockReq = 9800, - eNoMoreAtt = 9900, - eNoMoreElements = 10000, - eNonBasicMatrixError = 10100, - eNonInvertibleMatrix = 10200, - eNonsenseData = 10300, - eNoSuchKey = 10400, - eNotEnoughSpace = 10500, - eNotFetched = 10600, - eNotLocked = 10700, - eNotSupported = 10800, - eNullPointer = 10900, - eNullInternalPointer = 11000, - eNullCompare = 11050, - eNullData = 11070, - eNullDestroyer = 11100, - eNullDisplayer = 11200, - eNullFunction = 11300, - eRemove = 11400, - eRoundoff = 11500, - eQueueNotEmpty = 11600, - eSparseGraphError = 11700, - eStackError = 11800, - eStackNotEmpty = 11900, - eTLRSProceduralError = 12000, - eTooManyAtt = 12100, - eTooManyLocks = 12200, - eTypeConflict = 12300, - eUnexpectedType = 12400, - eUnixError = 12500, - eVectorMismatch = 12600, - eProcessingError = 15000, - eActionKludge = 15100, - eNotImplemented = 15200, - eNotStable = 15300, - eNotReleased = 15400, - eBeingWorkedOn = 15500 -} eErrorState; -extern "C" { -extern eErrorState spider_errno; -extern char err_string[]; -POINTER mallocate (size_t n ) ; -size_t pagesize (void ) ; -POINTER page_mallocate (void ) ; -POINTER make_memory_token (int size , int page_cnt, const char *name) ; -POINTER mem_malloc (POINTER mptr ) ; -void mem_free (POINTER mptr , POINTER obj ) ; -const char *get_double_string (char *buffer , double num ) ; -int spider_strcat (const char *proc , char *str1 , const char *str2 , int maxlen ) ; -void init_errors (void ) ; -void append_abort (const char *proc ) ; -void append_message (const char *proc , const char *msg ) ; -void set_errno (eErrorState err ) ; -void spider_perror (const char *proc , FILE_PTR errorFile ) ; -void append_not_implemented (const char *proc , int *target_errno ) ; -const char *GetBooleanString (BOOLEAN bool ) ;// ERROR - use of bool as identifier -double truncate_value (double x , double epsilon ) ; -double log2 (double x ) ; -int ceil_log2 (double x ) ; -int floor_log2 (double x ) ; -} -extern "C" { -extern char char80[], char128[], char160[], char512[]; -extern char char1000[], char2000[]; -extern char char320[]; -BOOLEAN Get_EM_StderrFlag (void ) ; -void Set_EM_StderrFlag (BOOLEAN printToStderr ) ; -void CheckReleaseState (eErrorState releaseState , const char *procName, FILE_PTR errorFile ) ; -void PrintErrorString (const char *errorString , FILE_PTR errorFile ) ; -const char *get_error_header (eErrorState errorState ) ; -void print_error_header (eErrorState errorState , FILE_PTR errorFile ) ; -void PrintErrorMessage (eErrorState errorState , const char *message , FILE_PTR errorFile ) ; -} -extern "C" { -extern short show_increment_rcount; -extern int errno; -extern int bmk_errno; -extern int ck_errno; -extern int db_errno; -extern int dict_errno; -extern int glh_errno; -extern int graph_errno; -extern int hash_errno; -extern int link_errno; -extern int lp_errno; -extern int matrix_errno; -extern int nbmk_errno; -extern int network_errno; -extern int queue_errno; -extern int set_kernel_errno; -extern int stack_errno; -} -extern "C" { -const char *spider_version_string (void ) ; -int spider_version (void ) ; -const char *spider_errstring (void ) ; -void append_perror (const char *s ) ; -void unix_perror (const char *s ) ; -} -typedef struct node a_dict_node, * DICT_NODE; -struct node { - POINTER info; - DICT_NODE left; - DICT_NODE right; - DICT_NODE prev; - DICT_NODE next; -}; -typedef struct tree a_dict, * DICT; -struct tree { - int size; - COMPARE comp; - DICT_NODE header; - DICT_NODE last_accessed; - DICT_NODE list_head; - DICT_NODE list_tail; -}; -typedef enum { PREORDER = -1, INORDER, POSTORDER } traversal_t; -extern "C" { -void dict_set_nopages (int desired_nopages ) ; -void dict_err (void ) ; -const char *traversal_string (traversal_t tr ) ; -DICT make_dictionary (COMPARE cmp ) ; -int dict_insert (POINTER item , DICT dict ) ; -int dict_delete (POINTER item , DICT dict ) ; -POINTER dict_access (POINTER item , DICT dict ) ; -POINTER dict_low (DICT dict ) ; -POINTER dict_nlow (DICT dict ) ; -POINTER dict_big (DICT dict ) ; -POINTER dict_nbig (DICT dict ) ; -POINTER dict_first (DICT dict ) ; -POINTER dict_next (DICT dict ) ; -POINTER dict_last (DICT dict ) ; -POINTER dict_prev (DICT dict ) ; -int clear_dictionary (DICT dict , DESTROYER destroy , FILE *errorFile ) ; -int dict_size (const a_dict *dict ) ; -POINTER dict_elem (int index , DICT dict ) ; -int dict_compare (DICT d1 , DICT d2 ) ; -DICT dict_copy (DICT di , COMPARE cmp ) ; -int dict_change_compare (DICT di , COMPARE cmp ) ; -int dict_height (DICT di ) ; -void dict_print_stats (FILE *fp , DICT di ) ; -void dict_print (FILE *fp , DICT di , traversal_t tr , DISPLAYER display ) ; -const char *dict_version (void ) ; -void init_dict_errors (void ) ; -const char *dict_errstring (void ) ; -void dict_append_perror (const char *s ) ; -void dict_perror (const char *s ) ; -extern int dict_errno; -} -typedef struct q_item { - struct q_item *next; - POINTER data; -} a_q_item, *Q_ITEM; -typedef struct { - int rcount; - Q_ITEM first; - Q_ITEM last; - int count; -} a_queue, *QUEUE; -extern "C" { -void queue_err (void) ; -void queue_set_nopages (int desired_nopages) ; -QUEUE make_queue (void ) ; -POINTER queue_look (const a_queue * Q ) ; -POINTER queue_last (const a_queue * Q ) ; -POINTER queue_remove (QUEUE Q ) ; -int queue_append (QUEUE Q , POINTER data ) ; -int queue_size (const a_queue * Q ) ; -void queue_destroy (POINTER ptr , FILE_PTR errorFile ) ; -void IncrementQRCount (POINTER ptr , FILE_PTR errorFile ) ; -const char *queue_version (void ) ; -void init_queue_errors (void ) ; -const char *queue_errstring (void ) ; -void queue_append_perror (const char *s ) ; -void queue_perror (const char *s ) ; -extern int queue_errno; -} -typedef struct s_item { - struct s_item *next; - POINTER data; -} a_s_item, *S_ITEM; -typedef struct stack { - int rcount; - S_ITEM top; - int count; -} a_stack, *STACK; -extern "C" { -void stack_err (void) ; -void stack_set_nopages (int desired_nopages) ; -STACK make_stack (void ) ; -POINTER stack_look (const a_stack * S ) ; -POINTER stack_pop (STACK S ) ; -int stack_push (STACK S , POINTER data ) ; -int stack_size (const a_stack * S ) ; -void stack_destroy (POINTER ptr , FILE_PTR errorFile ) ; -void IncrementSRCount (POINTER ptr , FILE_PTR errorFile ) ; -const char *stack_version (void ) ; -void init_stack_errors (void ) ; -const char *stack_errstring (void ) ; -void stack_append_perror (const char *s ) ; -void stack_perror (const char *s ) ; -extern int stack_errno; -} -typedef const char *(*STRINGER)(const void *ptr); -int default_compare(const void *p1, const void *p2); -void default_displayer(const void *ptr, FILE *fp, FILE *errorFile); -const char *default_stringer(const void *ptr); -const char *object_stringer(const void *ptr); -class object { - static long current_id; - static long next_id(); -protected: - void display2(ostream &fp = cout) const; - long id; -public: - object() { id = next_id(); } - object(const object &obj) { id = next_id(); } - virtual ~object() - { - if (799 >= 999 ) cout << "~object() executing..." << '\n'; ; - } - object & operator = (const object & obj) - { - return( *this ); - } - virtual int compare(const void *p2) const; - virtual void display(ostream & fp = cout) const - { - display2(fp); - } - operator char *() const; -}; -ostream & operator << (ostream & fp, object & obj); -int operator < (object & obj1, object & obj2); -int operator <= (object & obj1, object & obj2); -int operator > (object & obj1, object & obj2); -int operator >= (object & obj1, object & obj2); -int operator == (object & obj1, object & obj2); -int operator != (object & obj1, object & obj2); -void null_destroy(void *p, FILE *errorFile); -void object_destroy(void *p, FILE *errorFile); -int object_compare(const void *p1, const void *p2); -void object_display(const void *p, FILE *fp, FILE *errorFile); -class dict : public object { - class internal { - public: - DICT di; - int errno; - COMPARE compare_f; - DISPLAYER display_f; - DESTROYER destroy_f; - STRINGER string_f; - int count; - void append_error(int expr, const char *proc) - { - if (expr) dict_append_perror(proc); - errno = dict_errno; - } - void obj_error(int expr, const char *proc, const void *obj) - { - if (expr) { - dict_append_perror((*string_f)(obj)); - dict_append_perror(proc); - } - errno = dict_errno; - } - internal(COMPARE cmp, DESTROYER destroyer, - DISPLAYER displayer, STRINGER str_f) - {// ERROR - candidate for bad call - if (799 >= 800 ) cout << "Creating new dictionary..." << '\n'; ; - if (cmp == __null ) cmp = (COMPARE) &default_compare; - if (displayer == __null ) displayer = (DISPLAYER) &default_displayer; - if (str_f == __null ) str_f = &default_stringer; - compare_f = cmp; - display_f = displayer; - destroy_f = destroyer; - string_f = str_f; - di = make_dictionary(compare_f); - append_error(di == __null , "dict internal"); - if (di == __null ) { - dict_perror("build dictionary"); - exit(errno); - } - count = 1; - } - ~internal() - { - if (799 >= 800 ) cout << "dict ~internal executing" << '\n'; ; - int err = clear_dictionary(di, destroy_f, (&__iob[2]) ); - append_error(err, "clear dictionary"); - if (err) dict_perror("dict ~internal"); - free((void *)di); - } - };// ERROR - candidate list for bad call - internal *rep; -protected: - int & errno() { return( rep->errno ); } - COMPARE compare_f() { return( rep->compare_f ); } - DISPLAYER display_f() { return( rep->display_f ); } - DESTROYER destroy_f() { return( rep->destroy_f ); } - STRINGER string_f() { return( rep->string_f ); } - void append_error(int expr, const char *proc) - { - rep->append_error(expr, proc); - } - void obj_error(int expr, const char *proc, const void *obj) - { - rep->obj_error(expr, proc, obj); - } -public: - static int err; - static int val; - static void *p; - dict() - { - if (799 >= 800 ) cout << "Default constructor executing..." << '\n'; ; - rep = new internal( &default_compare, &null_destroy, - &default_displayer, &default_stringer);// ERROR - no matching fn call - } - dict(COMPARE cmp, - DESTROYER destroyer = __null , - DISPLAYER displayer = &default_displayer, - STRINGER str_f = &default_stringer) - {// ERROR - invalid type for default argument -- not expecting const - rep = new internal(cmp, destroyer, displayer, str_f); - } - dict(const dict &di2) - { - rep = di2.rep; - rep->count ++; - if (799 >= 800 ) cout << "Incrementing count to " << rep->count << '\n'; ; - } - dict & operator = (const dict &di2) - { - di2.rep->count ++; - if (799 >= 800 ) cout << "Incrementing di2 count to " << di2.rep->count << '\n'; ; - if (799 >= 800 ) cout << "Decrementing lvalue count to " << rep->count-1 << '\n'; ; - if (--rep->count <= 0) { - delete rep; - } - rep = di2.rep; - return( *this ); - } - ~dict() - { - if (799 >= 800 ) cout << "~dict executing..." << '\n'; ; - if (799 >= 800 ) cout << "Decrementing dict::internal count to " << rep->count-1 << '\n'; ; - if (--rep->count <= 0) delete rep; - } - int insert(POINTER item) - { - err = dict_insert(item, rep->di); - obj_error(err, "insert", item); - return errno(); - } - int remove(POINTER item) - { - err = dict_delete(item, rep->di); - obj_error(err, "remove", item); - return errno(); - } - POINTER access(POINTER item) - { - p = dict_access(item, rep->di); - obj_error(p == __null , "access", item); - return(p); - } - POINTER low() - { - p = dict_low(rep->di); - append_error(p == __null , "low"); - return(p); - } - POINTER nlow() - { - p = dict_nlow(rep->di); - append_error(p == __null , "nlow"); - return(p); - } - POINTER big() - { - p = dict_big(rep->di); - append_error(p == __null , "big"); - return(p); - } - POINTER nbig() - { - p = dict_nbig(rep->di); - append_error(p == __null , "nbig"); - return(p); - } - POINTER first() - { - p = dict_first(rep->di); - append_error(p == __null , "first"); - return(p); - } - POINTER last() - { - p = dict_last(rep->di); - append_error(p == __null , "last"); - return(p); - } - POINTER next() - { - p = dict_next(rep->di); - append_error(p == __null , "next"); - return(p); - } - POINTER prev() - { - p = dict_prev(rep->di); - append_error(p == __null , "prev"); - return(p); - } - int clear(DESTROYER destroy, FILE *fp = (&__iob[2]) ) - { - err = clear_dictionary(rep->di, destroy, fp); - append_error(err, "clear"); - return errno(); - } - int clear(FILE *fp = (&__iob[2]) ) - { - err = clear_dictionary(rep->di, rep->destroy_f, fp); - append_error(err, "clear"); - return errno(); - } - int size() - { - val = dict_size(rep->di); - append_error(val < 0, "size"); - return(val); - } - POINTER elem(int index) - { - p = dict_elem(index, rep->di); - append_error(p == __null , "elem"); - return(p); - } - int compare(dict &di2) - { - val = dict_compare(rep->di, di2.rep->di); - return(val); - } - int height() - { - val = dict_height(rep->di); - append_error(val < 0, "height"); - return(val); - } - const char * version() - { - return( dict_version() ); - } - void display(FILE *fp = (&__iob[1]) ) - { - dict_print_stats(fp, rep->di); - } - void print(FILE *fp = (&__iob[1]) , traversal_t tr = INORDER) - { - fprintf(fp, "====== DICTIONARY (count=%d) ======\n", - rep->count); - dict_print(fp, rep->di, tr, rep->display_f); - } - void print(traversal_t tr, FILE *fp = (&__iob[1]) ) - { - fprintf(fp, "====== DICTIONARY (count=%d) ======\n", - rep->count); - dict_print(fp, rep->di, tr, rep->display_f); - } - void error(const char *s = "class dict") - { - dict_errno = errno(); - dict_perror(s); - errno() = 0; - } - void error_append(const char *s = "class dict") - { - dict_append_perror(s); - } - const char * errstring() - { - return( dict_errstring() ); - } -}; -ostream & operator << (ostream & fp, traversal_t tr); -class queue : public object { - class internal { - public: - QUEUE Q; - QUEUE Q2; - int errno; - DISPLAYER display_f; - DESTROYER destroy_f; - STRINGER string_f; - int count; - int swap() - { - QUEUE tmp = Q; - Q = Q2; - Q2 = tmp; - } - void append_error(int expr, const char *proc) - { - if (expr) queue_append_perror(proc); - errno = queue_errno; - } - void obj_error(int expr, const char *proc, const void *obj) - { - if (expr) { - queue_append_perror((*string_f)(obj)); - queue_append_perror(proc); - } - errno = queue_errno; - } - internal(DESTROYER destroyer, - DISPLAYER displayer, STRINGER str_f) - {// ERROR - candidate for bad call - if (799 >= 800 ) cout << "Creating new queue..." << '\n'; ; - if (displayer == __null ) displayer = (DISPLAYER) &default_displayer; - if (str_f == __null ) str_f = &default_stringer; - display_f = displayer; - destroy_f = destroyer; - string_f = str_f; - Q = make_queue(); - append_error(Q == __null , "queue internal"); - errno = queue_errno; - if (Q == __null ) { - queue_perror("build queue"); - exit(errno); - } - Q2 = make_queue(); - append_error(Q2 == __null , "queue internal"); - if (Q2 == __null ) { - queue_perror("build second queue"); - exit(errno); - } - count = 1; - } - ~internal() - { - if (799 >= 800 ) cout << "queue ~internal executing" << '\n'; ; - while ((p = queue_remove(Q)) != __null ) { - if (destroy_f != __null ) { - (*destroy_f)((POINTER)&p, (&__iob[2]) ); - } - } - queue_errno = 0; - queue_destroy((POINTER)&Q, (&__iob[2]) ); - if (queue_errno) { - append_error(queue_errno, - "queue_destroy(Q)"); - queue_perror("queue ~internal"); - } - queue_errno = 0; - queue_destroy((POINTER)&Q2, (&__iob[2]) ); - if (queue_errno) { - append_error(queue_errno, - "queue_destroy(Q2)"); - queue_perror("queue ~internal"); - } - } - };// ERROR - list of candidates for bad call - internal *rep; -protected: - int & errno() { return( rep->errno ); } - DISPLAYER display_f() { return( rep->display_f ); } - DESTROYER destroy_f() { return( rep->destroy_f ); } - STRINGER string_f() { return( rep->string_f ); } - void append_error(int expr, const char *proc) - { - rep->append_error(expr, proc); - } - void obj_error(int expr, const char *proc, const void *obj) - { - rep->obj_error(expr, proc, obj); - } -public: - static int err; - static int val; - static void *p; - queue() - { - if (799 >= 800 ) cout << "Default constructor executing..." << '\n'; ; - rep = new internal( &null_destroy, - &default_displayer, &default_stringer);// ERROR - no matching fn for call - } - queue(DESTROYER destroyer = __null , - DISPLAYER displayer = &default_displayer, - STRINGER str_f = &default_stringer) - {// ERROR - invalid type for default argument -- not expecting const - rep = new internal(destroyer, displayer, str_f); - } - queue(const queue &Q2) - { - rep = Q2.rep; - rep->count ++; - if (799 >= 800 ) cout << "Incrementing count to " << rep->count << '\n'; ; - } - queue & operator = (const queue &Q2) - { - Q2.rep->count ++; - if (799 >= 800 ) cout << "Incrementing Q2 count to " << Q2.rep->count << '\n'; ; - if (799 >= 800 ) cout << "Decrementing lvalue count to " << rep->count-1 << '\n'; ; - if (--rep->count <= 0) { - delete rep; - } - rep = Q2.rep; - return( *this ); - } - ~queue() - { - if (799 >= 800 ) cout << "~queue executing..." << '\n'; ; - if (799 >= 800 ) cout << "Decrementing queue::internal count to " << rep->count-1 << '\n'; ; - if (--rep->count <= 0) delete rep; - } - void error(const char *s = "class queue") - { - queue_errno = errno(); - queue_perror(s); - errno() = 0; - } - void error_append(const char *s = "class queue") - { - queue_append_perror(s); - } - const char * errstring() - { - return( queue_errstring() ); - } - int append(POINTER item) - { - err = queue_append(rep->Q, (POINTER)item); - obj_error(err, "append", item); - return errno(); - } - POINTER remove() - { - p = queue_remove(rep->Q); - append_error(p == __null , "remove"); - return(p); - } - POINTER look(POINTER item) - { - p = queue_look(rep->Q); - append_error(p == __null , "look"); - return(p); - } - POINTER last(POINTER item) - { - p = queue_last(rep->Q); - append_error(p == __null , "last"); - return(p); - } - int size() - { - val = queue_size(rep->Q); - append_error(val < 0, "size"); - return(val); - } - const char * version() - { - return( queue_version() ); - } - void display(FILE *fp = (&__iob[1]) ) - { - int i = 1; - POINTER ptr; - fprintf(fp, "====== QUEUE DISPLAY (size %d) ======\n", - size()); - while (ptr = remove()) { - err = queue_append(rep->Q2, ptr); - if (err) { - obj_error(err, "append", ptr); - error("queue_append(rep->Q2)"); - } - fprintf(fp, "[%d] ", i++); - (*rep->display_f)(ptr, fp, (&__iob[2]) ); - } - rep->swap(); - } -}; -long object::current_id = 0; -long object::next_id() -{ - return( ++current_id ); -} -void object::display2(ostream & fp) const -{ - fp << "object #" << id; -} -ostream & operator << (ostream & fp, object & obj) -{ - obj.display(fp); - return(fp); -} -int object::compare(const void *p2) const -{ - const object & z2 = *(const object *) p2; - if (799 >= 1000 ) cout << "*** object::compare " << *this << " with " << z2 << '\n'; ; - return( id - z2.id ); -} -int operator < (object & obj1, object & obj2) -{ - if (obj1.compare( &obj2 ) < 0) return(1); - else return(0); -} -int operator <= (object & obj1, object & obj2) -{ - if (obj1.compare( &obj2 ) <= 0) return(1); - else return(0); -} -int operator > (object & obj1, object & obj2) -{ - if (obj1.compare( &obj2 ) > 0) return(1); - else return(0); -} -int operator >= (object & obj1, object & obj2) -{ - if (obj1.compare( &obj2 ) >= 0) return(1); - else return(0); -} -int operator == (object & obj1, object & obj2) -{ - if (obj1.compare( &obj2 ) == 0) return(1); - else return(0); -} -int operator != (object & obj1, object & obj2) -{ - if (obj1.compare( &obj2 ) != 0) return(1); - else return(0); -} -void null_destroy(void *p, FILE *errorFile) -{ -} -int object_compare(const void *p1, const void *p2) -{ - const object *obj1 = (const object *) p1; - if (799 >= 1000 ) cout << "*** Comparing " << *obj1 << " to address " << long(p2) << '\n'; ; - return( obj1->compare(p2) ); -} -void object_display(const void *p, FILE *fp, FILE *errorFile) -{ - cout << *(object *)p << '\n'; -} -void object_destroy(void *p, FILE *errorFile) -{ - object **pObj = (object **)p; - object *obj = *pObj; - if (obj == __null ) { - if (799 >= 10 ) cout << "+ object_destroy: NIL object passed in" << '\n'; ; - return; - } - if (799 >= 998 ) cout << "+ object_destroy: delete obj:" << '\n'; ; - if (799 >= 998 ) cout << *obj << '\n'; ; - if (799 >= 998 ) cout << "====================================================" << '\n'; ; - delete obj; - *pObj = __null ; -} -int default_compare(const void *p1, const void *p2) -{ - long L1 = long(p1); - long L2 = long(p2); - if (799 >= 1000 ) cout << "+ default_compare " << long(p1) << ',' << long(p2) << '\n'; ; - if (L1 < L2) return(-1); - else if (L1 > L2) return(1); - else return(0); -} -const char * default_stringer(const void *ptr) -{ - static char buf[100]; - sprintf(buf, "ADDRESS %lu", (unsigned long)ptr); - return(buf); -} -void default_displayer(const void *ptr, FILE *fp, FILE *errorFile) -{ - fprintf(fp, "%s\n", default_stringer(ptr)); -} -object::operator char *() const -{ - const int max = 10; - const int maxChar = 16; - static char buf[max][maxChar]; - static int index = 0; - char *s = buf[index++ % max]; - sprintf(s, "object #%d", id); - return(s); -} -const char * object_stringer(const void *ptr) -{ - object & obj = *(object *)ptr; - return((char *)obj); -} -int dict::err; -int dict::val; -POINTER dict::p; -ostream & operator << (ostream & fp, traversal_t tr) -{ - fp << traversal_string(tr); - return(fp); -} -int queue::err; -int queue::val; -POINTER queue::p; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash59.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash59.C deleted file mode 100644 index ab6e5599d6a..00000000000 --- a/gcc/testsuite/g++.old-deja/g++.brendan/crash59.C +++ /dev/null @@ -1,1374 +0,0 @@ -// Build don't link: -// Special g++ Options: -w -// GROUPS passed old-abort -typedef char * __gnuc_va_list; -void va_end (__gnuc_va_list); -enum __va_type_classes { - __no_type_class = -1, - __void_type_class, - __integer_type_class, - __char_type_class, - __enumeral_type_class, - __boolean_type_class, - __pointer_type_class, - __reference_type_class, - __offset_type_class, - __real_type_class, - __complex_type_class, - __function_type_class, - __method_type_class, - __record_type_class, - __union_type_class, - __array_type_class, - __string_type_class, - __set_type_class, - __file_type_class, - __lang_type_class -}; -typedef __gnuc_va_list va_list; -typedef int jmp_buf[9 ]; -typedef int sigjmp_buf[9 +1]; -int setjmp (jmp_buf) ; -int _setjmp (jmp_buf) ; -int sigsetjmp (sigjmp_buf, int) ; -void longjmp (jmp_buf, int) ; -void _longjmp (jmp_buf, int) ; -void siglongjmp (sigjmp_buf, int) ; -const int BOR_C_DIR = 0; -const int BOR_C_REV = 1; -const int BOR_C = 0x1; -const int BOR_BD_DIR = (0<<1); -const int BOR_BD_REV = (1<<1); -const int BOR_BD = 0x2; -const int SERVICE_DATA = (1<<( 0 )) ; -const int SERVICE_CLASS1 = (1<<( 1 )) ; -const int SERVICE_CLASS2 = (1<<( 2 )) ; -const int SERVICE_CLASS20 = (1<<( 3 )) ; -const int SERVICE_VOICE = (1<<( 8 )) ; -const int SERVICE_ALL = (1<<( 9 )) -1; -const int VR_NORMAL = 0; -const int VR_FINE = 1; -const int VR_ALL = (1<<( VR_FINE+1 )) -1; -const int BR_2400 = 0; -const int BR_4800 = 1; -const int BR_7200 = 2; -const int BR_9600 = 3; -const int BR_12000 = 4; -const int BR_14400 = 5; -const int BR_ALL = (1<<( BR_14400+1 )) -1; -const int WD_1728 = 0; -const int WD_2048 = 1; -const int WD_2432 = 2; -const int WD_1216 = 3; -const int WD_864 = 4; -const int WD_ALL = (1<<( WD_864+1 )) -1; -const int LN_A4 = 0; -const int LN_B4 = 1; -const int LN_INF = 2; -const int LN_ALL = (1<<( LN_INF+1 )) -1; -const int DF_1DMR = 0; -const int DF_2DMR = 1; -const int DF_2DMRUNCOMP = 2; -const int DF_2DMMR = 3; -const int DF_ALL = (1<<( DF_2DMMR+1 )) -1; -const int EC_DISABLE = 0; -const int EC_ENABLE = 1; -const int EC_ALL = 0x3; -const int BF_DISABLE = 0; -const int BF_ENABLE = 1; -const int BF_ALL = 0x3; -const int ST_0MS = 0; -const int ST_5MS = 1; -const int ST_10MS2 = 2; -const int ST_10MS = 3; -const int ST_20MS2 = 4; -const int ST_20MS = 5; -const int ST_40MS2 = 6; -const int ST_40MS = 7; -const int ST_ALL = (1<<( ST_40MS+1 )) -1; -const int PPM_MPS = 0; -const int PPM_EOM = 1; -const int PPM_EOP = 2; -const int PPM_PRI_MPS = 4; -const int PPM_PRI_EOM = 5; -const int PPM_PRI_EOP = 6; -const int PPR_MCF = 1; -const int PPR_RTN = 2; -const int PPR_RTP = 3; -const int PPR_PIN = 4; -const int PPR_PIP = 5; -const int DLE = 16; -const int SUB = 26; -const int ETX = 3; -const int DC1 = 17; -const int DC2 = 18; -const int CAN = 24; -typedef int sigset_t; -typedef unsigned int speed_t; -typedef unsigned long tcflag_t; -typedef unsigned char cc_t; -typedef int pid_t; -typedef unsigned short mode_t; -typedef short nlink_t; -typedef long clock_t; -typedef long time_t; -typedef __SIZE_TYPE__ size_t; -typedef int ptrdiff_t; -typedef __wchar_t wchar_t; -extern unsigned int _mb_cur_max; -extern void abort( ); -extern int abs (int) ; -extern double atof (const char *) ; -extern int atoi (const char *) ; -extern long int atol (const char *) ; -extern char * bsearch (const void *, const void *, long unsigned int , long unsigned int , int (*) (const void *, const void *)) ; -extern void * calloc (long unsigned int , long unsigned int ) ; -extern void exit (int) ; -extern void free (void *) ; -extern char * getenv (const char *) ; -extern void * malloc (long unsigned int ) ; -extern int qsort (void *, long unsigned int , long unsigned int , int (*) (const void *, const void *)) ; -extern int rand( ); -extern void * realloc (void *, long unsigned int ) ; -extern int srand (unsigned int) ; -extern int mbtowc (__wchar_t *, const char *, long unsigned int ) ; -extern int wctomb (char *, __wchar_t ) ; -extern size_t mbstowcs (__wchar_t *, const char *, long unsigned int ) ; -extern size_t wcstombs (char *, const __wchar_t *, long unsigned int ) ; -extern int atexit (void (*) (void)); -extern long int labs (long int); -extern int putenv (char *); -extern double strtod (const char *, char **); -extern long int strtol (const char *, char **, int); -extern long unsigned int strtoul (const char *, char **, int); -extern int system (const char *); -extern char * strcat (char *, const char *) ; -extern char * strchr (const char *, int) ; -extern int strcmp (const char *, const char *) ; -extern char * strcpy (char *, const char *) ; -extern size_t strcspn (const char *, const char *) ; -extern char * strdup (const char *) ; -extern size_t strlen (const char *) ; -extern char * strncat (char *, const char *, long unsigned int ) ; -extern int strncmp (const char *, const char *, long unsigned int ) ; -extern char * strncpy (char *, const char *, long unsigned int ) ; -extern char * strpbrk (const char *, const char *) ; -extern char * strrchr (const char *, int) ; -extern size_t strspn (const char *, const char *) ; -extern char * strstr (const char *, const char *) ; -extern char * strtok (char *, const char *) ; -extern void * memchr (const void *, int, long unsigned int ); -extern int memcmp (const void *, const void *, long unsigned int ); -extern void * memcpy (void *, const void *, long unsigned int ); -extern void * memmove (void *, const void *, long unsigned int ); -extern void * memset (void *, int, long unsigned int ); -extern int strcoll (const char *, const char *); -extern char * strerror (int); -extern long unsigned int strxfrm (char *, const char *, long unsigned int ); -extern "C" { -extern void __eprintf (const char *, const char *, unsigned, const char *); -} -extern struct _iobuf { - int _cnt; - unsigned char *_ptr; - unsigned char *_base; - int _bufsiz; - short _flag; - char _file; -} _iob[]; -extern struct _iobuf *fopen (const char *, const char *) ; -extern struct _iobuf *fdopen (int, const char *) ; -extern struct _iobuf *freopen (const char *, const char *, struct _iobuf *) ; -extern struct _iobuf *popen (const char *, const char *) ; -extern struct _iobuf *tmpfile(); -extern long ftell (struct _iobuf *) ; -extern char *fgets (char *, int, struct _iobuf *) ; -extern char *gets (char *) ; -extern char *sprintf (char *, const char *, ...) ; -extern char *ctermid (char *) ; -extern char *cuserid (char *) ; -extern char *tempnam (const char *, const char *) ; -extern char *tmpnam (char *) ; -extern int fclose (struct _iobuf *); -extern int fflush (struct _iobuf *); -extern int fgetc (struct _iobuf *); -extern int fgetpos (struct _iobuf *, long *); -extern int fprintf (struct _iobuf *, const char *, ...); -extern int fputc (int, struct _iobuf *); -extern int fputs (const char *, struct _iobuf *); -extern long unsigned int fread (void *, long unsigned int , long unsigned int , struct _iobuf *); -extern int fscanf (struct _iobuf *, const char *, ...); -extern int fseek (struct _iobuf *, long int, int); -extern int fsetpos (struct _iobuf *, const long *); -extern long unsigned int fwrite (const void *, long unsigned int , long unsigned int , struct _iobuf *); -extern int pclose (struct _iobuf *); -extern void perror (const char *); -extern int printf (const char *, ...); -extern int puts (const char *); -extern int remove (const char *); -extern int rename (const char *, const char *); -extern void rewind (struct _iobuf *); -extern int scanf (const char *, ...); -extern void setbuf (struct _iobuf *, char *); -extern int setvbuf (struct _iobuf *, char *, int, long unsigned int ); -extern int sscanf (const char *, const char *, ...); -extern int vprintf (const char *, __gnuc_va_list); -extern int vsprintf (char *, const char *, __gnuc_va_list); -extern int vfprintf (struct _iobuf *, const char *, __gnuc_va_list); -extern int ungetc (int, struct _iobuf *); -extern int _flsbuf (unsigned int, struct _iobuf *); -extern int _filbuf (struct _iobuf *); -typedef long _G_clock_t; -typedef short _G_dev_t; -typedef long _G_fpos_t; -typedef unsigned short _G_gid_t; -typedef unsigned long _G_ino_t; -typedef unsigned short _G_mode_t; -typedef short _G_nlink_t; -typedef long _G_off_t; -typedef int _G_pid_t; -typedef int _G_ptrdiff_t; -typedef int _G_sigset_t; -typedef long unsigned int _G_size_t; -typedef long _G_time_t; -typedef unsigned short _G_uid_t; -typedef __wchar_t _G_wchar_t; -typedef int _G_ssize_t; -typedef int _G_wint_t; -typedef char * _G_va_list; -typedef signed char _G_int8_t; -typedef unsigned char _G_uint8_t; -typedef short _G_int16_t; -typedef unsigned short _G_uint16_t; -typedef long _G_int32_t; -typedef unsigned long _G_uint32_t; -const size_t NPOS = (size_t)(-1); -typedef void fvoid_t(); -typedef _G_wint_t wint_t; -enum capacity { default_size, reserve }; -extern "C" fvoid_t *set_new_handler(fvoid_t *); -extern fvoid_t *__new_handler; -extern "C" void __default_new_handler(); -inline void *operator new(size_t, void *place) { return place; } -inline void *operator new[](size_t, void *place) { return place; } -typedef unsigned char u_char; -typedef unsigned short u_short; -typedef unsigned int u_int; -typedef unsigned long u_long; -typedef unsigned short ushort; -typedef unsigned int uint; -typedef struct _physadr_t { int r[1]; } *physadr_t; -typedef struct label_t { - int val[2]; -} label_t; -typedef struct _quad_t { long val[2]; } quad_t; -typedef long daddr_t; -typedef char * caddr_t; -typedef unsigned long ino_t; -typedef short dev_t; -typedef long off_t; -typedef unsigned short uid_t; -typedef unsigned short gid_t; -typedef long key_t; -typedef char * addr_t; -typedef long fd_mask; -typedef struct fd_set { - fd_mask fds_bits[((( 256 )+(( (sizeof (fd_mask) * 8 ) )-1))/( (sizeof (fd_mask) * 8 ) )) ]; -} fd_set; -extern "C" { -extern int mkstemp(char *); -extern int strncasecmp(const char*, const char*, size_t); -extern int strcasecmp(const char*, const char*); -extern long random(void); -extern int seteuid(uid_t); -extern int setegid(gid_t); -extern int ftruncate(int, off_t); -extern int getdtablesize(void); -struct fd_set; -struct timeval; -extern int select(int,struct fd_set*,struct fd_set*,struct fd_set*,struct timeval*); -extern int ioctl(int, int, ...); -extern int fchown(int, uid_t, gid_t); -extern int gethostname(char*, int); -extern char* optarg; -extern int opterr; -extern int optind; -extern char* mktemp(char*); -extern void syslog(int, const char*, ...); -extern void vsyslog(int, const char*, va_list); -extern void closelog(void); -extern void openlog(const char*, int, int); -extern int fchmod(int, mode_t); -struct timezone; -struct timeval; -extern int gettimeofday(struct timeval*, struct timezone*); -extern void endpwent(void); -extern int getpeername(int,void*,int*); -extern int getsockname(int,void*,int*); -extern int socket(int, int, int); -extern int connect(int, const void*, int); -extern int flock(int, int); -} -typedef unsigned char fxBool; -inline int fxmin(int a, int b) { return (a < b) ? a : b; } -inline u_long fxmin(u_long a, u_long b) { return (a < b) ? a : b; } -inline u_int fxmin(u_int a, u_int b) { return (a < b) ? a : b; } -inline int fxmax(int a, int b) { return (a > b) ? a : b; } -inline u_long fxmax(u_long a, u_long b) { return (a > b) ? a : b; } -inline u_int fxmax(u_int a, u_int b) { return (a > b) ? a : b; } -extern "C" void _fxassert(const char*, const char*, int); -class fxObj { -public: - fxObj(); - virtual ~fxObj(); - void inc(); - void dec(); - u_long getReferenceCount(); - virtual const char* className() const; - int compare(const fxObj *) const; - virtual void subClassMustDefine(const char* method) const; -protected: - u_long referenceCount; -}; -inline fxObj::fxObj() { referenceCount = 0; } -inline void fxObj::inc() { ++referenceCount; } -inline void fxObj::dec() { - if ( referenceCount>0 ); else _fxassert( "Bogus object reference count" ,"../util/Obj.h",54); ; - if (0 >= --referenceCount) delete this; -} -inline u_long fxObj::getReferenceCount() { return referenceCount; } -class fxStr; -class fxTempStr { -public: - fxTempStr(fxTempStr const &other); - ~fxTempStr(); - friend fxTempStr operator|(fxStr const&, fxStr const&); - friend fxTempStr operator|(fxStr const&, char const*); - friend fxTempStr operator|(char const*, fxStr const&); - friend fxTempStr& operator|(const fxTempStr&, fxStr const& b); - friend fxTempStr& operator|(const fxTempStr&, char const* b); - operator char*() const; - operator int() const; - operator float() const; - operator double() const; - u_int length() const; -protected: - char indata[100]; - char* data; - u_int slength; - friend class fxStr; - fxTempStr(char const *, u_int, char const *, u_int); - fxTempStr& concat(char const* b, u_int bl); -}; -inline fxTempStr::operator char*() const { return data; } -inline fxTempStr::operator int() const { return atoi(data); } -inline fxTempStr::operator float() const { return float(atof(data)); } -inline fxTempStr::operator double() const { return double(atof(data)); } -inline u_int fxTempStr::length() const { return slength - 1; } -class fxStr { - friend class fxTempStr; -public: - fxStr(u_int l=0); - fxStr(char const *s); - fxStr(char const *s, u_int len); - fxStr(fxStr const&); - fxStr(int, char const* format); - fxStr(long, char const* format); - fxStr(float, char const* format); - fxStr(double, char const* format); - fxStr(const fxTempStr&); - ~fxStr(); - u_long hash() const; - operator char*() const - { return data; } - operator int() const - { return atoi(data); } - operator float() const - { return float(atof(data)); } - operator double() const - { return double(atof(data)); } - u_int length() const { return slength-1; } - char& operator[](u_int i) const - { if ( i=(fxStr const&, fxStr const&); - friend fxBool operator>=(fxStr const&, char const*); - friend fxBool operator>=(char const*, fxStr const&); - friend fxBool operator<=(fxStr const&, fxStr const&); - friend fxBool operator<=(fxStr const&, char const*); - friend fxBool operator<=(char const*, fxStr const&); - friend fxBool operator>(fxStr const&, fxStr const&); - friend fxBool operator>(fxStr const&, char const*); - friend fxBool operator>(char const*, fxStr const&); - friend fxBool operator<(fxStr const&, fxStr const&); - friend fxBool operator<(fxStr const&, char const*); - friend fxBool operator<(char const*, fxStr const&); - int compare(fxStr const *a) const { return ::compare(*this, *a); } - friend int compare(fxStr const&, fxStr const&); - friend int compare(fxStr const&, char const*); - friend int compare(char const*, fxStr const&); - friend fxTempStr& operator|(const fxTempStr&, fxStr const&); - friend fxTempStr& operator|(const fxTempStr&, char const*); - friend fxTempStr operator|(fxStr const&, fxStr const&); - friend fxTempStr operator|(fxStr const&, char const*); - friend fxTempStr operator|(char const*, fxStr const&); - fxStr copy() const; - fxStr extract(u_int start,u_int len) const; - fxStr cut(u_int start,u_int len); - fxStr head(u_int) const; - fxStr tail(u_int) const; - void lowercase(u_int posn=0, u_int len=0); - void raisecase(u_int posn=0, u_int len=0); - void remove(u_int posn,u_int len=1); - void resize(u_int len, fxBool reallocate = ((fxBool)0) ); - void setMaxLength(u_int maxlen); - void append(char a); - void append(char const *s, u_int len=0); - void append(const fxTempStr& s) - { append((char*)s, s.slength-1); } - void append(fxStr const& s) - { append((char*)s, s.slength-1); } - void insert(char a, u_int posn=0); - void insert(char const *, u_int posn=0, u_int len=0); - void insert(const fxTempStr& s, u_int posn=0) - { insert((char*)s, posn, s.slength-1); } - void insert(fxStr const& s, u_int posn=0) - { insert((char*)s, posn, s.slength-1); } - u_int next(u_int posn, char delimiter) const; - u_int next(u_int posn, char const *delimiters, u_int len=0) const; - u_int next(u_int posn, fxStr const& delimiters) const - { return next(posn, (char*)delimiters, delimiters.slength-1); } - u_int nextR(u_int posn, char delimiter) const; - u_int nextR(u_int posn, char const*, u_int len=0) const; - u_int nextR(u_int posn, fxStr const& delimiters) const - { return nextR(posn, (char*)delimiters, delimiters.slength-1); } - u_int skip(u_int posn, char a) const; - u_int skip(u_int posn, char const *, u_int len=0) const; - u_int skip(u_int posn, fxStr const& delimiters) const - { return skip(posn, (char*)delimiters, delimiters.slength-1); } - u_int skipR(u_int posn, char a) const; - u_int skipR(u_int posn, char const *, u_int len=0) const; - u_int skipR(u_int posn, fxStr const& delimiters) const - { return skipR(posn, (char*)delimiters, delimiters.slength-1); } - fxStr token(u_int & posn, char delimiter) const; - fxStr token(u_int & posn, char const * delimiters, - u_int delimiters_len = 0) const; - fxStr token(u_int & posn, fxStr const & delimiters) const - { return token(posn, delimiters.data, delimiters.slength-1); } - fxStr tokenR(u_int & posn, char delimiter) const; - fxStr tokenR(u_int & posn, char const * delimiters, - u_int delimiters_len = 0) const; - fxStr tokenR(u_int & posn, fxStr const & delimiters) const - { return tokenR(posn, delimiters.data, delimiters.slength-1); } -protected: - u_int slength; - char * data; - static char emptyString; - void fxStr::resizeInternal(u_int); - int findEndBuffer(const char *, u_int buflen) const; - int findBuffer(const char *buf, u_int buflen) const; - void bracketBuffer(const char *, u_int buflen, int &, int &) const; -}; -struct Class2Params { - u_int vr; - u_int br; - u_int wd; - u_int ln; - u_int df; - u_int ec; - u_int bf; - u_int st; - static u_int vrDISTab[2]; - static u_int dfDISTab[4]; - static u_int wdDISTab[8]; - static u_int lnDISTab[3]; - static u_int stDISTab[8]; - static u_int stDCSTab[8]; - static u_int brDISTab[8]; - static u_int brDCSTab[8]; - static u_int DISvrTab[2]; - static u_int DISdfTab[2]; - static u_int DISwdTab[4]; - static u_int DISlnTab[4]; - static u_int DISstTab[8]; - static u_int DISbrTab[16]; - static u_int DCSbrTab[16]; - static const char* bitRateNames[8]; - static const char* dataFormatNames[4]; - static const char* vresNames[2]; - static const char* pageWidthNames[8]; - static const char* pageLengthNames[4]; - static const char* scanlineTimeNames[8]; - Class2Params(); - int operator==(const Class2Params&) const; - int operator!=(const Class2Params&) const; - fxStr cmd() const; - void setFromDIS(u_int dis, u_int xinfo = 0); - void setFromDCS(u_int dcs, u_int xinfo = 0); - u_int getDCS() const; - fxBool is2D() const; - u_int pageWidth() const; - u_int transferSize(u_int ms) const; - u_int minScanlineSize() const; - fxStr encode() const; - void decode(const fxStr&); -}; -typedef struct { - unsigned short tiff_magic; - unsigned short tiff_version; - unsigned long tiff_diroff; -} TIFFHeader; -typedef struct { - unsigned short tdir_tag; - unsigned short tdir_type; - unsigned long tdir_count; - unsigned long tdir_offset; -} TIFFDirEntry; -typedef enum { - TIFF_NOTYPE = 0, - TIFF_BYTE = 1, - TIFF_ASCII = 2, - TIFF_SHORT = 3, - TIFF_LONG = 4, - TIFF_RATIONAL = 5, - TIFF_SBYTE = 6, - TIFF_UNDEFINED = 7, - TIFF_SSHORT = 8, - TIFF_SLONG = 9, - TIFF_SRATIONAL = 10, - TIFF_FLOAT = 11, - TIFF_DOUBLE = 12 -} TIFFDataType; -typedef struct tiff TIFF; -extern int fclose (struct _iobuf *); -extern int fflush (struct _iobuf *); -extern int fgetc (struct _iobuf *); -extern int fgetpos (struct _iobuf *, long *); -extern int fprintf (struct _iobuf *, const char *, ...); -extern int fputc (int, struct _iobuf *); -extern int fputs (const char *, struct _iobuf *); -extern long unsigned int fread (void *, long unsigned int , long unsigned int , struct _iobuf *); -extern int fscanf (struct _iobuf *, const char *, ...); -extern int fseek (struct _iobuf *, long int, int); -extern int fsetpos (struct _iobuf *, const long *); -extern long unsigned int fwrite (const void *, long unsigned int , long unsigned int , struct _iobuf *); -extern int pclose (struct _iobuf *); -extern void perror (const char *); -extern int printf (const char *, ...); -extern int puts (const char *); -extern int remove (const char *); -extern int rename (const char *, const char *); -extern void rewind (struct _iobuf *); -extern int scanf (const char *, ...); -extern void setbuf (struct _iobuf *, char *); -extern int setvbuf (struct _iobuf *, char *, int, long unsigned int ); -extern int sscanf (const char *, const char *, ...); -extern int vprintf (const char *, __gnuc_va_list); -extern int vsprintf (char *, const char *, __gnuc_va_list); -extern int vfprintf (struct _iobuf *, const char *, __gnuc_va_list); -extern int ungetc (int, struct _iobuf *); -extern int _flsbuf (unsigned int, struct _iobuf *); -extern int _filbuf (struct _iobuf *); -typedef void (*TIFFErrorHandler)(const char* module, const char* fmt, va_list); -typedef int (*TIFFReadWriteProc)(void*, char*, unsigned long); -typedef long (*TIFFSeekProc)(void*, long, int); -typedef int (*TIFFCloseProc)(void*); -typedef long (*TIFFSizeProc)(void*); -typedef int (*TIFFMapFileProc)(void*, char**, long*); -typedef void (*TIFFUnmapFileProc)(void*, char*, long); -extern "C" { -extern const char* TIFFGetVersion(); -extern void TIFFClose(TIFF*); -extern int TIFFFlush(TIFF*); -extern int TIFFFlushData(TIFF*); -extern int TIFFGetField(TIFF*, unsigned int, ...); -extern int TIFFVGetField(TIFF*, unsigned int, va_list); -extern int TIFFGetFieldDefaulted(TIFF*, unsigned int, ...); -extern int TIFFVGetFieldDefaulted(TIFF*, unsigned int, va_list); -extern int TIFFReadDirectory(TIFF*); -extern unsigned long TIFFScanlineSize(TIFF*); -extern unsigned long TIFFStripSize(TIFF*); -extern unsigned long TIFFVStripSize(TIFF*, unsigned long); -extern unsigned long TIFFTileRowSize(TIFF*); -extern unsigned long TIFFTileSize(TIFF*); -extern unsigned long TIFFVTileSize(TIFF*, unsigned long); -extern int TIFFFileno(TIFF*); -extern int TIFFGetMode(TIFF*); -extern int TIFFIsTiled(TIFF*); -extern long TIFFCurrentRow(TIFF*); -extern int TIFFCurrentDirectory(TIFF*); -extern int TIFFCurrentStrip(TIFF*); -extern int TIFFCurrentTile(TIFF*); -extern int TIFFReadBufferSetup(TIFF*, char*, unsigned long); -extern int TIFFLastDirectory(TIFF*); -extern int TIFFSetDirectory(TIFF*, int); -extern int TIFFSetField(TIFF*, unsigned int, ...); -extern int TIFFVSetField(TIFF*, unsigned int, va_list); -extern int TIFFWriteDirectory(TIFF *); -extern void TIFFPrintDirectory(TIFF*, struct _iobuf *, long = 0); -extern int TIFFReadScanline(TIFF*, unsigned char*, unsigned, unsigned = 0); -extern int TIFFWriteScanline(TIFF*, unsigned char*, unsigned, unsigned = 0); -extern int TIFFReadRGBAImage(TIFF*, - unsigned long, unsigned long, unsigned long*, int stop = 0); -extern TIFF* TIFFOpen(const char*, const char*); -extern TIFF* TIFFFdOpen(int, const char*, const char*); -extern TIFF* TIFFClientOpen(const char* name, const char* mode, - void* clientdata, - TIFFReadWriteProc readproc, TIFFReadWriteProc writeproc, - TIFFSeekProc seekproc, TIFFCloseProc closeproc, - TIFFSizeProc sizeproc, - TIFFMapFileProc mapproc, TIFFUnmapFileProc unmapproc); -extern const char* TIFFFileName(TIFF*); -extern void TIFFError(const char*, const char*, ...); -extern void TIFFWarning(const char*, const char*, ...); -extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler handler); -extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler handler); -extern unsigned int TIFFComputeTile(TIFF*, - unsigned long, unsigned long, unsigned long, unsigned int); -extern int TIFFCheckTile(TIFF*, - unsigned long, unsigned long, unsigned long, unsigned); -extern unsigned int TIFFNumberOfTiles(TIFF*); -extern int TIFFReadTile(TIFF*, - unsigned char*, - unsigned long, unsigned long, unsigned long, - unsigned int); -extern int TIFFWriteTile(TIFF*, - unsigned char*, - unsigned long, unsigned long, unsigned long, - unsigned int); -extern unsigned int TIFFComputeStrip(TIFF*, unsigned long, unsigned int); -extern unsigned int TIFFNumberOfStrips(TIFF*); -extern int TIFFReadEncodedStrip(TIFF*, unsigned, unsigned char*, unsigned long); -extern int TIFFReadRawStrip(TIFF*, unsigned, unsigned char*, unsigned long); -extern int TIFFReadEncodedTile(TIFF*, unsigned, unsigned char*, unsigned long); -extern int TIFFReadRawTile(TIFF*, unsigned, unsigned char*, unsigned long); -extern int TIFFWriteEncodedStrip(TIFF*, unsigned, unsigned char*, unsigned long); -extern int TIFFWriteRawStrip(TIFF*, unsigned, unsigned char*, unsigned long); -extern int TIFFWriteEncodedTile(TIFF*, unsigned, unsigned char*, unsigned long); -extern int TIFFWriteRawTile(TIFF*, unsigned, unsigned char*, unsigned long); -extern void TIFFSetWriteOffset(TIFF*, unsigned long); -extern void TIFFSwabShort(unsigned short *); -extern void TIFFSwabLong(unsigned long *); -extern void TIFFSwabArrayOfShort(unsigned short *, unsigned long); -extern void TIFFSwabArrayOfLong(unsigned long *, unsigned long); -extern void TIFFReverseBits(unsigned char *, unsigned long); -extern const unsigned char* TIFFGetBitRevTable(int); -} -struct G3Base { - short data; - short bit; - fxBool is2D; - enum { G3_1D, G3_2D } tag; - const u_char* bitmap; - static const u_char zeroruns[256]; - static const u_char oneruns[256]; - static int findspan(const u_char**, int, int, const u_char*); - static int finddiff(const u_char*, int, int); - static void fillspan(u_char* cp, int x, int count); - void setup(const u_char*, fxBool is2d); -}; -class fxStackBuffer; -class G3Decoder : private G3Base { -private: - short bytePending; - short prevByte; - u_char* refline; - fxStackBuffer* recvBuf; - fxBool decode1DRow(u_char*, u_int); - fxBool decode2DRow(u_char*, u_int); - int nextBit(); - void ungetBit(); - int nextByte(); - int decodeWhiteRun(); - int decodeBlackRun(); - int decodeUncompCode(); - void skipToEOL(int len); -protected: - G3Decoder(); - void raiseEOF(); - void raiseRTC(); - void setPendingByte(u_char); - virtual int decodeNextByte() = 0; - void setRefLine(u_char*); - u_char* getRefLine(); - virtual void invalidCode(const char* type, int x); - virtual void prematureEOL(const char* type, int x); - virtual void badPixelCount(const char* type, int x); - virtual void badDecodingState(const char* type, int x); -public: - sigjmp_buf jmpEOF; - sigjmp_buf jmpRTC; - virtual ~G3Decoder(); - void setupDecoder(u_int, fxBool is2D); - void decode(void* raster, u_int w, u_int h); - void skip(u_int h); - void skipLeader(); - fxBool decodeRow(void* scanline, u_int w); - void skipRow(); - fxBool isLastRow1D(); - fxBool isNextRow1D(); - fxBool isByteAligned(); - void setRecvBuf(fxStackBuffer&); - fxStackBuffer* getRecvBuf(); - void flushRecvBuf(); -}; -inline void G3Decoder::setRecvBuf(fxStackBuffer& b){ recvBuf = &b; } -inline fxStackBuffer* G3Decoder::getRecvBuf() { return recvBuf; } -inline void G3Decoder::setRefLine(u_char* b) { refline = b; } -inline u_char* G3Decoder::getRefLine() { return refline; } -inline fxBool G3Decoder::isLastRow1D() { return tag == G3_1D; } -enum FaxSendStatus { - send_retry, - send_failed, - send_done, - send_reformat, -}; -class FaxServer; -class FaxMachineInfo; -class ModemConfig; -class fxStackBuffer; -class FaxFont; -class FaxRequest; -typedef unsigned int CallStatus; -typedef unsigned int CallType; -typedef unsigned int AnswerType; -typedef unsigned int SpeakerVolume; -typedef unsigned int ATResponse; -typedef unsigned int BaudRate; -typedef unsigned int FlowControl; -typedef unsigned int SetAction; -typedef struct { - const char* msg; - u_short len; - ATResponse expect; - CallStatus status; - CallType type; -} AnswerMsg; -class FaxModem : public G3Decoder { -public: - static FaxModem* deduceModem(FaxServer&, const ModemConfig& config); - enum { - OK = 0, - BUSY = 1, - NOCARRIER = 2, - NOANSWER = 3, - NODIALTONE = 4, - ERROR = 5, - FAILURE = 6, - NOFCON = 7, - DATACONN = 8, - }; - enum { - CALLTYPE_ERROR = 0, - CALLTYPE_DATA = 1, - CALLTYPE_FAX = 2, - CALLTYPE_VOICE = 3, - CALLTYPE_UNKNOWN = 4, - }; - enum { - OFF = 0, - QUIET = 1, - LOW = 2, - MEDIUM = 3, - HIGH = 4, - }; - enum { - BR0 = 0, - BR300 = 1, - BR1200 = 2, - BR2400 = 3, - BR4800 = 4, - BR9600 = 5, - BR19200 = 6, - BR38400 = 7, - BR57600 = 8, - BR76800 = 9, - }; - enum { - FLOW_NONE = 0, - FLOW_XONXOFF = 1, - FLOW_RTSCTS = 2 - }; - enum { - ACT_NOW = 0, - ACT_DRAIN = 1, - ACT_FLUSH = 2, - }; - enum { - ANSTYPE_ANY = 0, - ANSTYPE_DATA = 1, - ANSTYPE_FAX = 2, - ANSTYPE_VOICE = 3, - }; - enum { - AT_NOTHING = 0, - AT_OK = 1, - AT_CONNECT = 2, - AT_NOANSWER = 3, - AT_NOCARRIER = 4, - AT_NODIALTONE = 5, - AT_BUSY = 6, - AT_OFFHOOK = 7, - AT_RING = 8, - AT_ERROR = 9, - AT_EMPTYLINE = 10, - AT_TIMEOUT = 11, - AT_OTHER = 12, - }; -private: - FaxServer& server; - fxStr resetCmds; - long dataTimeout; - BaudRate rate; - FlowControl iFlow; - FlowControl oFlow; - u_int pageNumber; - FaxFont* tagLineFont; - u_int tagLineSlop; - fxStr tagLine; - u_int tagLineFields; - void setupTagLine(const FaxRequest&); - u_int cblc; - fxBool lastRowBad; - u_long recvEOLCount; - u_long recvBadLineCount; - u_long recvConsecutiveBadLineCount; - u_int recvCC; - fxStackBuffer* recvBuf; - u_long savedWriteOff; - void recvRow(TIFF* tif, fxStackBuffer& row, u_char* buf); - void invalidCode(const char* type, int x); - void prematureEOL(const char* type, int x); - void badPixelCount(const char* type, int x); - void badDecodingState(const char* type, int x); -protected: - const ModemConfig& conf; - FlowControl flowControl; - u_int modemServices; - fxStr modemMfr; - fxStr modemModel; - fxStr modemRevision; - Class2Params modemParams; - char rbuf[1024]; - ATResponse lastResponse; - fxStr mfrQueryCmd; - fxStr modelQueryCmd; - fxStr revQueryCmd; - static const char* serviceNames[9]; - static const u_char digitMap[12*2+1]; - static const char* callStatus[9]; - FaxModem(FaxServer&, const ModemConfig&); - virtual fxBool selectBaudRate(BaudRate max, FlowControl i, FlowControl o); - virtual fxBool setupModem() = 0; - virtual fxBool setupManufacturer(fxStr& mfr); - virtual fxBool setupModel(fxStr& model); - virtual fxBool setupRevision(fxStr& rev); - fxBool doQuery(const fxStr& queryCmd, fxStr& result, long ms = 30*1000); - virtual const AnswerMsg* findAnswer(const char* s); - virtual CallType answerResponse(fxStr& emsg); - virtual CallStatus dialResponse(fxStr& emsg) = 0; - void setDataTimeout(long secs, u_int br); - long getDataTimeout() const; - void pause(u_int ms); - void countPage(); - void modemTrace(const char* fmt, ...); - void modemSupports(const char* fmt, ...); - void modemCapability(const char* fmt, ...); - void protoTrace(const char* fmt, ...); - void recvTrace(const char* fmt, ...); - void copyQualityTrace(const char* fmt, ...); - void serverTrace(const char* fmt, ...); - void traceBits(u_int bits, const char* bitNames[]); - void traceModemParams(); - void tracePPR(const char* dir, u_int ppr); - void tracePPM(const char* dir, u_int ppm); - void trimModemLine(char buf[], int& cc); - int getModemLine(char buf[], u_int bufSize, long ms = 0); - void beginTimedTransfer(); - void endTimedTransfer(); - fxBool wasTimeout(); - void setTimeout(fxBool); - void flushModemInput(); - fxBool putModem(void* data, int n, long ms = 0); - fxBool putModemData(void* data, int n); - fxBool putModemDLEData(const u_char* data, u_int, - const u_char* brev, long ms); - fxBool putModemLine(const char* cp); - int getModemChar(long ms = 0); - int getModemDataChar(); - void startTimeout(long ms); - void stopTimeout(const char* whichdir); - static const char* ATresponses[13]; - virtual ATResponse atResponse(char* buf, long ms = 30*1000); - virtual fxBool waitFor(ATResponse wanted, long ms = 30*1000); - fxBool atCmd(const fxStr& cmd, ATResponse = AT_OK, long ms = 30*1000); - fxBool atQuery(const char* what, u_int& v, long ms = 30*1000); - fxBool atQuery(const char* what, fxStr& v, long ms = 30*1000); - u_int fromHex(const char*, int = -1); - fxStr toHex(int, int ndigits); - fxBool parseRange(const char*, u_int&); - fxBool vparseRange(const char*, int nargs ...); - fxBool vatFaxCmd(ATResponse resp, const char* cmd ... ); - fxBool sendBreak(fxBool pause); - fxBool setBaudRate(BaudRate rate); - fxBool setBaudRate(BaudRate rate, FlowControl i, FlowControl o); - fxBool setXONXOFF(FlowControl i, FlowControl o, SetAction); - fxBool setDTR(fxBool on); - fxBool setInputBuffering(fxBool on); - fxBool modemStopOutput(); - FlowControl getInputFlow(); - FlowControl getOutputFlow(); - fxBool getProtocolTracing(); - fxBool getHDLCTracing(); - FaxSendStatus sendSetupParams(TIFF*, Class2Params&, - FaxMachineInfo&, fxStr&); - fxBool recvCheckTSI(const fxStr&); - void recvCSI(fxStr&); - void recvDCS(Class2Params&); - void recvNSF(u_int nsf); - void recvSetupPage(TIFF* tif, long group3opts, int fillOrder); - void recvResetPage(TIFF* tif); - fxBool abortRequested(); - fxBool decodePPM(const fxStr& pph, u_int& ppm, fxStr& emsg); - fxBool recvPageDLEData(TIFF* tif, fxBool checkQuality, - const Class2Params& params, fxStr& emsg); - virtual void abortPageRecv() = 0; - virtual int decodeNextByte(); - fxBool checkQuality(); - fxBool isQualityOK(const Class2Params&); - u_long getRecvEOLCount() const; - u_long getRecvBadLineCount() const; - u_long getRecvConsecutiveBadLineCount() const; - fxBool setupTagLineSlop(const Class2Params&); - u_int getTagLineSlop() const; - u_char* imageTagLine(u_char* buf, u_int fillorder, const Class2Params&); -public: - virtual ~FaxModem(); - virtual fxBool dataService(); - virtual fxBool voiceService(); - virtual fxBool sync(long ms = 0); - virtual fxBool reset(long ms = 5*1000); - virtual void hangup(); - virtual void setSpeakerVolume(SpeakerVolume); - virtual void setLID(const fxStr& number) = 0; - const fxStr& getModel() const; - const fxStr& getManufacturer() const; - const fxStr& getRevision() const; - virtual fxBool supports2D() const; - virtual fxBool supportsEOLPadding() const; - virtual fxBool supportsVRes(float res) const; - virtual fxBool supportsPageWidth(u_int w) const; - virtual fxBool supportsPageLength(u_int l) const; - virtual fxBool supportsPolling() const; - virtual int selectSignallingRate(int br) const; - u_int getBestSignallingRate() const; - u_int getBestScanlineTime() const; - virtual int selectScanlineTime(int st) const; - u_int getBestVRes() const; - u_int getBestDataFormat() const; - u_int getBestPageWidth() const; - u_int getBestPageLength() const; - u_int modemDIS() const; - virtual CallStatus dial(const char* number, - const Class2Params& dis, fxStr& emsg); - virtual void sendBegin(const FaxRequest&); - virtual fxBool getPrologue(Class2Params&, - u_int& nsf, fxStr& csi, fxBool& hasDoc) = 0; - virtual void sendSetupPhaseB(); - virtual FaxSendStatus sendPhaseB(TIFF*, Class2Params&, FaxMachineInfo&, - fxStr& pph, fxStr& emsg) = 0; - virtual void sendEnd(); - virtual void sendAbort() = 0; - virtual fxBool waitForRings(u_int rings); - virtual CallType answerCall(AnswerType, fxStr& emsg); - virtual fxBool recvBegin(fxStr& emsg) = 0; - virtual fxBool recvPage(TIFF*, int& ppm, fxStr& em) = 0; - virtual fxBool recvEnd(fxStr& emsg) = 0; - virtual void recvAbort() = 0; - virtual fxBool requestToPoll() = 0; - virtual fxBool pollBegin(const fxStr& pollID, fxStr& emsg) = 0; -}; -inline long FaxModem::getDataTimeout() const { return dataTimeout; } -inline const fxStr& FaxModem::getModel() const { return modemModel; } -inline const fxStr& FaxModem::getManufacturer() const { return modemMfr; } -inline const fxStr& FaxModem::getRevision() const { return modemRevision; } -inline FlowControl FaxModem::getInputFlow() { return iFlow; } -inline FlowControl FaxModem::getOutputFlow() { return oFlow; } -inline u_int FaxModem::getTagLineSlop() const { return tagLineSlop; } -struct ModemConfig { - fxStr type; - fxStr resetCmds; - fxStr dialCmd; - fxStr answerAnyCmd; - fxStr answerDataCmd; - fxStr answerFaxCmd; - fxStr answerVoiceCmd; - fxStr flowControlCmd; - fxStr setupDTRCmd; - fxStr setupDCDCmd; - fxStr setupAACmd; - fxStr noAutoAnswerCmd; - fxStr setVolumeCmd[5]; - fxStr echoOffCmd; - fxStr verboseResultsCmd; - fxStr resultCodesCmd; - fxStr onHookCmd; - fxStr softResetCmd; - fxStr waitTimeCmd; - fxStr pauseTimeCmd; - fxStr mfrQueryCmd; - fxStr modelQueryCmd; - fxStr revQueryCmd; - fxStr answerAnyBeginCmd; - fxStr answerDataBeginCmd; - fxStr answerFaxBeginCmd; - fxStr answerVoiceBeginCmd; - fxStr sendBeginCmd; - u_int t1Timer; - u_int t2Timer; - u_int t4Timer; - u_int dialResponseTimeout; - u_int answerResponseTimeout; - u_int pageStartTimeout; - u_int pageDoneTimeout; - fxStr class1Cmd; - u_int class1TCFResponseDelay; - u_int class1SendPPMDelay; - u_int class1SendTCFDelay; - u_int class1TrainingRecovery; - u_int class1RecvAbortOK; - u_int class1FrameOverhead; - u_int class1RecvIdentTimer; - u_int class1TCFMaxNonZero; - u_int class1TCFMinRun; - fxStr class2Cmd; - fxStr class2DCCQueryCmd; - fxStr class2CQQueryCmd; - fxStr class2BORCmd; - fxStr class2RELCmd; - fxStr class2CQCmd; - fxStr class2AbortCmd; - fxStr class2TBCCmd; - fxStr class2CRCmd; - fxStr class2PHCTOCmd; - fxStr class2BUGCmd; - fxStr class2LIDCmd; - fxStr class2DCCCmd; - fxStr class2DISCmd; - fxStr class2DDISCmd; - fxStr class2CIGCmd; - fxStr class2SPLCmd; - fxStr class2PTSCmd; - fxStr class2RecvDataTrigger; - fxBool class2XmitWaitForXON; - fxStr class2PIECmd; - fxStr class2NRCmd; - FlowControl flowControl; - BaudRate maxRate; - u_int recvFillOrder; - u_int sendFillOrder; - u_int frameFillOrder; - u_int resetDelay; - u_int baudRateDelay; - u_int maxPacketSize; - u_int interPacketDelay; - u_int percentGoodLines; - u_int maxConsecutiveBadLines; - fxBool waitForConnect; - fxStr tagLineFmt; - fxStr tagLineFontFile; - ModemConfig(); - ~ModemConfig(); - fxBool parseItem(const char* tag, const char* value); - void setVolumeCmds(const fxStr& value); - fxStr parseATCmd(const char*); -}; -ModemConfig::ModemConfig() - : type("unknown") - , dialCmd("DT%s") - , noAutoAnswerCmd("S0=0") - , echoOffCmd("E0") - , verboseResultsCmd("V1") - , resultCodesCmd("Q0") - , onHookCmd("H0") - , softResetCmd("Z") - , waitTimeCmd("S7=30") - , pauseTimeCmd("S8=2") - , class1Cmd("+FCLASS=1") - , class2CQQueryCmd("+FCQ=?") - , tagLineFmt("From %%n|%c|Page %%p of %%t") -{ - class2XmitWaitForXON = ((fxBool)1) ; - setVolumeCmds("M0 L0M1 L1M1 L2M1 L3M1"); - answerAnyCmd = "A"; - flowControl = FaxModem::FLOW_NONE; - maxRate = FaxModem::BR19200; - sendFillOrder = 2 ; - recvFillOrder = 2 ; - frameFillOrder = 2 ; - resetDelay = 2600; - baudRateDelay = 0; - t1Timer = ((35+5)*1000) ; - t2Timer = ((6+1)*1000) ; - t4Timer = 3100 ; - dialResponseTimeout = 3*60*1000; - answerResponseTimeout = 3*60*1000; - pageStartTimeout = 3*60*1000; - pageDoneTimeout = 3*60*1000; - class1TCFResponseDelay = 75; - class1SendPPMDelay = 75; - class1SendTCFDelay = 75; - class1TrainingRecovery = 1500; - class1RecvAbortOK = 200; - class1FrameOverhead = 4; - class1RecvIdentTimer = t1Timer; - class1TCFMinRun = (2*1500 )/3; - class1TCFMaxNonZero = 10; - maxPacketSize = 16*1024; - interPacketDelay = 0; - waitForConnect = ((fxBool)0) ; - percentGoodLines = 95; - maxConsecutiveBadLines = 5; -} -ModemConfig::~ModemConfig() -{ -} -static fxBool getBoolean(const char* cp) - { return ((strcasecmp( cp , "on" )==0) || (strcasecmp( cp , "yes" )==0) ); } -static BaudRate -findRate(const char* cp) -{ - static const struct { - const char* name; - BaudRate br; - } rates[] = { - { "300", FaxModem::BR300 }, - { "1200", FaxModem::BR1200 }, - { "2400", FaxModem::BR2400 }, - { "4800", FaxModem::BR4800 }, - { "9600", FaxModem::BR9600 }, - { "19200", FaxModem::BR19200 }, - { "38400", FaxModem::BR38400 }, - { "57600", FaxModem::BR57600 }, - { "76800", FaxModem::BR76800 }, - }; - for (int i = (sizeof ( rates ) / sizeof ( rates [0])) -1; i >= 0; i--) - if ((strcasecmp( cp , rates[i].name )==0) ) - return (rates[i].br); - return (FaxModem::BR0); -} -static BaudRate -getRate(const char* cp) -{ - BaudRate br = findRate(cp); - if (br == FaxModem::BR0) { - syslog(3 , "Unknown baud rate \"%s\", using 19200", cp); - br = FaxModem::BR19200; - } - return (br); -} -static u_int -getFill(const char* cp) -{ - if ((strcasecmp( cp , "LSB2MSB" )==0) ) - return (2 ); - else if ((strcasecmp( cp , "MSB2LSB" )==0) ) - return (1 ); - else { - syslog(3 , "Unknown fill order \"%s\"", cp); - return ((u_int) -1); - } -} -static FlowControl -getFlow(const char* cp) -{ - if ((strcasecmp( cp , "xonxoff" )==0) ) - return (FaxModem::FLOW_XONXOFF); - else if ((strcasecmp( cp , "rtscts" )==0) ) - return (FaxModem::FLOW_RTSCTS); - else if ((strcasecmp( cp , "none" )==0) ) - return (FaxModem::FLOW_NONE); - else { - syslog(3 , "Unknown flow control \"%s\", using xonxoff", cp); - return (FaxModem::FLOW_XONXOFF); - } -} -void -ModemConfig::setVolumeCmds(const fxStr& tag) -{ - u_int l = 0; - for (int i = FaxModem::OFF; i <= FaxModem::HIGH; i++) { - fxStr tmp = tag.token(l, " \t"); - setVolumeCmd[i] = parseATCmd(tmp); - } -} -fxStr -ModemConfig::parseATCmd(const char* cp) -{ - fxStr cmd(cp); - u_int pos = 0; - while ((pos = cmd.next(pos, '<')) != cmd.length()) { - u_int epos = pos+1; - fxStr esc = cmd.token(epos, '>'); - esc.lowercase(); - char ecode; - if (esc == "xon") - ecode = (0x80|0xf) ; - else if (esc == "rts") - ecode = (0x80|0xe) ; - else if (esc == "none") - ecode = (0x80|0xd) ; - else if (esc == "") - ecode = '<'; - else { - BaudRate br = findRate(esc); - if (br == FaxModem::BR0) { - syslog(3 , "Unknown AT escape code \"%s\"", (char*) esc); - pos = epos; - continue; - } - ecode = 0x80| ((int)( br )) ; - } - cmd.remove(pos, epos-pos); - cmd.insert(ecode, pos); - } - return (cmd); -} -static const struct { - const char* name; - fxStr ModemConfig::* p; -} atcmds[] = { - { "ModemAnswerCmd", &ModemConfig::answerAnyCmd }, - { "ModemAnswerAnyCmd", &ModemConfig::answerAnyCmd }, - { "ModemAnswerFaxCmd", &ModemConfig::answerFaxCmd }, - { "ModemAnswerDataCmd", &ModemConfig::answerDataCmd }, - { "ModemAnswerVoiceCmd", &ModemConfig::answerVoiceCmd }, - { "ModemAnswerFaxBeginCmd", &ModemConfig::answerFaxBeginCmd }, - { "ModemAnswerDataBeginCmd", &ModemConfig::answerDataBeginCmd }, - { "ModemAnswerVoiceBeginCmd", &ModemConfig::answerVoiceBeginCmd }, - { "ModemResetCmds", &ModemConfig::resetCmds }, - { "ModemResetCmd", &ModemConfig::resetCmds }, - { "ModemDialCmd", &ModemConfig::dialCmd }, - { "ModemFlowControlCmd", &ModemConfig::flowControlCmd }, - { "ModemSetupAACmd", &ModemConfig::setupAACmd }, - { "ModemSetupDTRCmd", &ModemConfig::setupDTRCmd }, - { "ModemSetupDCDCmd", &ModemConfig::setupDCDCmd }, - { "ModemNoAutoAnswerCmd", &ModemConfig::noAutoAnswerCmd }, - { "ModemEchoOffCmd", &ModemConfig::echoOffCmd }, - { "ModemVerboseResultsCmd", &ModemConfig::verboseResultsCmd }, - { "ModemResultCodesCmd", &ModemConfig::resultCodesCmd }, - { "ModemOnHookCmd", &ModemConfig::onHookCmd }, - { "ModemSoftResetCmd", &ModemConfig::softResetCmd }, - { "ModemWaitTimeCmd", &ModemConfig::waitTimeCmd }, - { "ModemCommaPauseTimeCmd", &ModemConfig::pauseTimeCmd }, - { "ModemMfrQueryCmd", &ModemConfig::mfrQueryCmd }, - { "ModemModelQueryCmd", &ModemConfig::modelQueryCmd }, - { "ModemRevQueryCmd", &ModemConfig::revQueryCmd }, - { "ModemSendBeginCmd", &ModemConfig::sendBeginCmd }, - { "Class1Cmd", &ModemConfig::class1Cmd }, - { "Class2Cmd", &ModemConfig::class2Cmd }, - { "Class2BORCmd", &ModemConfig::class2BORCmd }, - { "Class2RELCmd", &ModemConfig::class2RELCmd }, - { "Class2CQCmd", &ModemConfig::class2CQCmd }, - { "Class2AbortCmd", &ModemConfig::class2AbortCmd }, - { "Class2CQQueryCmd", &ModemConfig::class2CQQueryCmd }, - { "Class2DCCQueryCmd", &ModemConfig::class2DCCQueryCmd }, - { "Class2TBCCmd", &ModemConfig::class2TBCCmd }, - { "Class2CRCmd", &ModemConfig::class2CRCmd }, - { "Class2PHCTOCmd", &ModemConfig::class2PHCTOCmd }, - { "Class2BUGCmd", &ModemConfig::class2BUGCmd }, - { "Class2LIDCmd", &ModemConfig::class2LIDCmd }, - { "Class2DCCCmd", &ModemConfig::class2DCCCmd }, - { "Class2DISCmd", &ModemConfig::class2DISCmd }, - { "Class2DDISCmd", &ModemConfig::class2DDISCmd }, - { "Class2CIGCmd", &ModemConfig::class2CIGCmd }, - { "Class2PTSCmd", &ModemConfig::class2PTSCmd }, - { "Class2SPLCmd", &ModemConfig::class2SPLCmd }, - { "Class2PIECmd", &ModemConfig::class2PIECmd }, - { "Class2NRCmd", &ModemConfig::class2NRCmd }, - { "TagLineFont", &ModemConfig::tagLineFontFile }, - { "TagLineFormat", &ModemConfig::tagLineFmt }, -}; -static const struct { - const char* name; - u_int ModemConfig::* p; -} fillorders[] = { - { "ModemRecvFillOrder", &ModemConfig::recvFillOrder }, - { "ModemSendFillOrder", &ModemConfig::sendFillOrder }, - { "ModemFrameFillOrder", &ModemConfig::frameFillOrder }, -}; -static const struct { - const char* name; - u_int ModemConfig::* p; -} numbers[] = { - { "ModemResetDelay", &ModemConfig::resetDelay }, - { "ModemBaudRateDelay", &ModemConfig::baudRateDelay }, - { "ModemMaxPacketSize", &ModemConfig::maxPacketSize }, - { "ModemInterPacketDelay", &ModemConfig::interPacketDelay }, - { "FaxT1Timer", &ModemConfig::t1Timer }, - { "FaxT2Timer", &ModemConfig::t2Timer }, - { "FaxT4Timer", &ModemConfig::t4Timer }, - { "ModemDialResponseTimeout", &ModemConfig::dialResponseTimeout }, - { "ModemAnswerResponseTimeout", &ModemConfig::answerResponseTimeout }, - { "ModemPageStartTimeout", &ModemConfig::pageStartTimeout }, - { "ModemPageDoneTimeout", &ModemConfig::pageDoneTimeout }, - { "Class1TCFResponseDelay", &ModemConfig::class1TCFResponseDelay }, - { "Class1SendPPMDelay", &ModemConfig::class1SendPPMDelay }, - { "Class1SendTCFDelay", &ModemConfig::class1SendTCFDelay }, - { "Class1TrainingRecovery", &ModemConfig::class1TrainingRecovery }, - { "Class1RecvAbortOK", &ModemConfig::class1RecvAbortOK }, - { "Class1FrameOverhead", &ModemConfig::class1FrameOverhead }, - { "Class1RecvIdentTimer", &ModemConfig::class1RecvIdentTimer }, - { "Class1TCFMaxNonZero", &ModemConfig::class1TCFMaxNonZero }, - { "Class1TCFMinRun", &ModemConfig::class1TCFMinRun }, - { "PercentGoodLines", &ModemConfig::percentGoodLines }, - { "MaxConsecutiveBadLines", &ModemConfig::maxConsecutiveBadLines }, -}; -fxBool -ModemConfig::parseItem(const char* tag, const char* value) -{ - int i; - for (i = (sizeof ( atcmds ) / sizeof ( atcmds [0])) -1; i >= 0; i--) - if ((strcasecmp( tag , atcmds[i].name )==0) ) { - (*this).*atcmds[i].p = parseATCmd(value); - return (((fxBool)1) ); - } - for (i = (sizeof ( fillorders ) / sizeof ( fillorders [0])) -1; i >= 0 ; i--) - if ((strcasecmp( tag , fillorders[i].name )==0) ) { - (*this).*fillorders[i].p = getFill(value); - return (((fxBool)1) ); - } - for (i = (sizeof ( numbers ) / sizeof ( numbers [0])) -1; i >= 0 ; i--) - if ((strcasecmp( tag , numbers[i].name )==0) ) { - (*this).*numbers[i].p = atoi(value); - return (((fxBool)1) ); - } - fxBool recognized = ((fxBool)1) ; - if ((strcasecmp( tag , "ModemType" )==0) ) - type = value; - else if ((strcasecmp( tag , "ModemSetVolumeCmd" )==0) ) - setVolumeCmds(value); - else if ((strcasecmp( tag , "ModemFlowControl" )==0) ) - flowControl = getFlow(value); - else if ((strcasecmp( tag , "ModemMaxRate" )==0) || (strcasecmp( tag , "ModemRate" )==0) ) - maxRate = getRate(value); - else if ((strcasecmp( tag , "ModemWaitForConnect" )==0) ) - waitForConnect = getBoolean(value); - else if ((strcasecmp( tag , "Class2RecvDataTrigger" )==0) ) - class2RecvDataTrigger = value; - else if ((strcasecmp( tag , "Class2XmitWaitForXON" )==0) ) - class2XmitWaitForXON = getBoolean(value); - else - recognized = ((fxBool)0) ; - return (recognized); -}