|
|
1.1 ! root 1: #ifndef PADS_H ! 2: #define PADS_H ! 3: ! 4: typedef unsigned short Attrib; ! 5: >pri ! 6: #define PADS_VERSION 0x851021 /* YYMMDD */ ! 7: #define CARTE 0x80 ! 8: #define NUMERIC 1 ! 9: > ! 10: #undef major ! 11: #undef minor ! 12: #ifndef PADS_TERM ! 13: int strlen(char*), ! 14: strcmp(char*,char*), ! 15: read(int,char*,int), ! 16: write(int,char*,int), ! 17: ioctl(int,int ...); ! 18: char *strcpy(char*,char*), ! 19: *sbrk(int); ! 20: ! 21: #define PRINTF_TYPES char * ... ! 22: #define PRINTF_ARGS char *fmt ... ! 23: #define FMT(i) ( ((int*)&fmt)[i] ) ! 24: #define PRINTF_COPY\ ! 25: (fmt?fmt:""), FMT(1),FMT(2),FMT(3),FMT(4),FMT(5),FMT(6),FMT(7),FMT(8) ! 26: ! 27: #ifdef TRACE ! 28: #define OK(x) if( !ok() ) PadsError(__SRC__); ! 29: #define VOK if( !ok() ) PadsError(__SRC__); ! 30: #define IF_LIVE(x) { if( x ) PadsError(__SRC__); } if(0) ! 31: #define SRCFILE(f) static __SRC__ = f; ! 32: typedef int (*PFI)(); ! 33: PFI trace_fcn(char*,int), trace_ptr; ! 34: #define trace (!(trace_ptr=trace_fcn(__SRC__,__LINE__))) ? 0 : (*trace_ptr) ! 35: #else ! 36: #define OK(x) { if( !ok() ) return x; } ! 37: #define VOK { if( !ok() ) return ; } ! 38: #define IF_LIVE(x) if( x ) ! 39: #define SRCFILE(f) ! 40: #define trace if( 0 ) ! 41: #endif ! 42: ! 43: class Index { ! 44: public: ! 45: unsigned char major; ! 46: unsigned char minor; ! 47: Index() { major = minor = 0; } ! 48: Index(int i) { major = i>>8; minor = i&0xFF; } ! 49: Index(int j, int n ) { major = j; minor = n; } ! 50: short sht(); /* don't inline sht() - sht() etc */ ! 51: int null(); ! 52: }; ! 53: extern Index ZIndex; ! 54: >pri ! 55: class Carte { ! 56: public: ! 57: unsigned char size; /* host.size != term.size */ ! 58: unsigned char attrib; ! 59: unsigned char items; ! 60: unsigned char width; ! 61: struct Index bin[1]; ! 62: Carte() {}; ! 63: }; ! 64: > ! 65: #else ! 66: typedef unsigned short Index; ! 67: #define MJR(i) ((i)>>8) ! 68: #define MNR(i) ((i)&0xFF) ! 69: typedef struct Carte Carte; ! 70: typedef enum Protocol Protocol; ! 71: struct Carte { ! 72: unsigned char size; /* host.size != term.size */ ! 73: unsigned char attrib; ! 74: short width; ! 75: Index bin[1]; ! 76: }; ! 77: #endif ! 78: ! 79: #define SELECTLINE ((Attrib)0x0001) ! 80: #define SORTED ((Attrib)0x0002) ! 81: #define ACCEPT_KBD ((Attrib)0x0004) ! 82: #define FOLD ((Attrib)0x0008) ! 83: #define TRUNCATE ((Attrib)0x0010) ! 84: #define USERCLOSE ((Attrib)0x0020) ! 85: #define DONT_CUT ((Attrib)0x0040) ! 86: #define FLUSHLINE ((Attrib)0x0080) /* should not be required */ ! 87: #define FAKELINE ((Attrib)0x0100) ! 88: #define USERCUT ((Attrib)0x0200) ! 89: #define DONT_CLOSE ((Attrib)0x0400) ! 90: #define NO_TILDE ((Attrib)0x0800) ! 91: #define DONT_DIRTY ((Attrib)0x1000) ! 92: ! 93: #ifndef PADS_TERM ! 94: char *sf(PRINTF_TYPES); ! 95: char *PadsInit(char* = 0); ! 96: void PadsServe(long = 0); ! 97: void NewHelp(); ! 98: void NewPadStats(); ! 99: class PadRcv; ! 100: typedef void (PadRcv::*Action)(...); ! 101: void Pick(char*,Action,long); ! 102: long UniqueKey(); ! 103: Index NumericRange(short,short); ! 104: void PadsWarn(PRINTF_TYPES); ! 105: //extern char *TapTo; ! 106: >pri ! 107: void PadsError(PRINTF_TYPES); ! 108: > ! 109: ! 110: class PadRcv { friend Remote; friend Pad; ! 111: short oid; ! 112: short magic; ! 113: int isvalid(); ! 114: public: ! 115: PadRcv(); ! 116: ~PadRcv(); ! 117: void invalidate(); ! 118: virtual int disc(); ! 119: virtual char *kbd(char*); ! 120: virtual char *help(); ! 121: virtual void numeric(long); ! 122: virtual void userclose(); ! 123: virtual void cycle(); ! 124: virtual void linereq(long,Attrib=0); ! 125: virtual int accept(Action); ! 126: virtual void usercut(); ! 127: }; ! 128: ! 129: class Pad { ! 130: >pub ! 131: char pub_filler[24]; ! 132: >pri ! 133: PadRcv *_object; ! 134: char *_name; ! 135: char *_banner; ! 136: Attrib _attributes; ! 137: char _unused[2]; ! 138: long _lines; ! 139: void termop(enum Protocol); ! 140: long errorkey; ! 141: void nameorbanner(enum Protocol, PRINTF_TYPES); ! 142: > ! 143: public: ! 144: int ok(); ! 145: Pad(PadRcv *); ! 146: ~Pad(); ! 147: void alarm(short=0); ! 148: void banner(PRINTF_TYPES); ! 149: void clear(); ! 150: void dump(); ! 151: void error(PRINTF_TYPES); ! 152: void insert(class Line&); ! 153: void insert(long, Attrib, PadRcv*, Index, PRINTF_TYPES); ! 154: void insert(long, Attrib, PadRcv*, class Menu&, PRINTF_TYPES); ! 155: void insert(long, Attrib, PRINTF_TYPES); ! 156: void insert(long, PRINTF_TYPES); ! 157: void lines(long); ! 158: void makecurrent(); ! 159: void makegap(long,long); ! 160: void menu(Index); ! 161: void menu(class Menu&); ! 162: void name(PRINTF_TYPES); ! 163: void options(Attrib, Attrib=0); ! 164: void tabs(short); ! 165: void removeline(long); ! 166: void createline(long,long); ! 167: void createline(long); ! 168: }; ! 169: ! 170: class Line { ! 171: public: ! 172: int ok(); ! 173: Line(); ! 174: PadRcv *object; ! 175: char *text; ! 176: long key; ! 177: Attrib attributes; ! 178: Index carte; ! 179: }; ! 180: >pri ! 181: class IList { ! 182: friend Menu; ! 183: Index index; ! 184: IList *next; ! 185: public: ! 186: IList(Index i, IList *n) { index = i; next = n; } ! 187: }; ! 188: ! 189: class Item { ! 190: public: ! 191: char *text; ! 192: Action action; ! 193: long opand; ! 194: Item(char*,Action,long); ! 195: Item(); /* ever used ? */ ! 196: }; ! 197: > ! 198: class Menu { ! 199: >pub ! 200: char pub_filler[8]; ! 201: >pri ! 202: IList *list; ! 203: int size; ! 204: void dump(); ! 205: > ! 206: public: ! 207: Menu(); ! 208: ~Menu(); ! 209: Menu( char*, Action=0, long=0 ); ! 210: Index index( char* =0, Action=0, long=0 ); ! 211: void first( char*, Action=0, long=0 ); ! 212: void first( Index ); ! 213: void last( char*, Action=0, long=0 ); ! 214: void last( Index ); ! 215: void sort( char*, Action=0, long=0 ); ! 216: void sort( Index ); ! 217: }; ! 218: ! 219: >pri ! 220: class Binary { ! 221: public: ! 222: Binary *left; ! 223: Binary *right; ! 224: Index index; ! 225: Binary() {} ! 226: }; ! 227: ! 228: class Cache { ! 229: friend ItemCache; ! 230: friend CarteCache; ! 231: Binary *root; ! 232: Index current; ! 233: Index SIZE; ! 234: public: ! 235: Cache(unsigned char,unsigned char); ! 236: int ok(); ! 237: }; ! 238: ! 239: class ItemCache : public Cache { ! 240: Item ***cache; ! 241: public: ! 242: ItemCache(); ! 243: Index place(Item); ! 244: Item *take(Index); ! 245: }; ! 246: ! 247: class CarteCache : public Cache { ! 248: Carte ***cache; ! 249: public: ! 250: CarteCache(); ! 251: Index place(Carte*); ! 252: Carte *take(Index); ! 253: Index numeric(short,short); ! 254: void cartelimits(Carte*); ! 255: }; ! 256: ! 257: extern ItemCache *ICache; ! 258: extern CarteCache *CCache; ! 259: > ! 260: #endif ! 261: ! 262: >pri ! 263: #define CARTESIZE(s) (sizeof(Carte) + (s)*sizeof(Index)) ! 264: ! 265: enum Protocol { ! 266: P_UCHAR = 1, ! 267: P_SHORT = 2, ! 268: P_LONG = 4, ! 269: ! 270: P_CACHEOP = 0x10, ! 271: P_I_DEFINE = 0x11, ! 272: P_I_CACHE = 0x12, ! 273: P_C_DEFINE = 0x13, ! 274: P_C_CACHE = 0x14, ! 275: ! 276: P_STRING = 0x20, ! 277: P_INDEX = 0x21, ! 278: ! 279: P_PADDEF = 0x30, ! 280: P_ATTRIBUTE = 0x31, ! 281: P_BANNER = 0x32, ! 282: P_CARTE = 0x33, ! 283: P_LINES = 0x34, ! 284: P_NAME = 0x35, ! 285: P_TABS = 0x36, ! 286: ! 287: P_PADOP = 0x40, ! 288: P_ACTION = 0x41, ! 289: P_ALARM = 0x42, ! 290: P_CLEAR = 0x43, ! 291: P_CYCLE = 0x44, ! 292: P_DELETE = 0x45, ! 293: P_KBDSTR = 0x46, ! 294: P_LINE = 0x47, ! 295: P_LINEREQ = 0x48, ! 296: P_MAKECURRENT = 0x49, ! 297: P_MAKEGAP = 0x4A, ! 298: P_NEXTLINE = 0x4B, ! 299: P_NUMERIC = 0x4C, ! 300: P_USERCLOSE = 0x4D, ! 301: P_CREATELINE = 0x4E, ! 302: P_REMOVELINE = 0x4F, ! 303: ! 304: P_HOSTSTATE = 0x50, ! 305: P_BUSY = 0x51, ! 306: P_IDLE = 0x52, ! 307: ! 308: P_USERCUT = 0x5F, ! 309: ! 310: P_PICK = 0x60, ! 311: ! 312: P_HELPSTR = 0x70, ! 313: P_SHELL = 0x71, ! 314: ! 315: P_VERSION = 0x80, ! 316: }; ! 317: ! 318: #ifdef PADS_TERM ! 319: long RcvLong(); ! 320: short RcvShort(); ! 321: unsigned char RcvUChar(); ! 322: char *RcvString(); ! 323: ! 324: void SendLong(); ! 325: void SendShort(); ! 326: void SendUChar(); ! 327: void SendString(); ! 328: #else ! 329: #include <CC/stdio.h> ! 330: FILE *Popen(char*,char*); ! 331: int Pclose(FILE*); ! 332: ! 333: class Remote { ! 334: public: ! 335: int fd; ! 336: int pktbase; ! 337: int pktsize; ! 338: unsigned char writebuffer[2048]; ! 339: ! 340: long shiftin(int); ! 341: void shiftout(int, long); ! 342: int writesize; ! 343: void err(char * = 0); ! 344: int get(); ! 345: void checkproto(int p); ! 346: void put(char c); ! 347: void proto(int p); ! 348: ! 349: long rcvlong(); ! 350: short rcvshort(); ! 351: unsigned char rcvuchar(); ! 352: PadRcv *rcvobj(); ! 353: ! 354: void sendlong(long); ! 355: void sendobj(PadRcv*); ! 356: void sendshort(short); ! 357: void senduchar(unsigned char); ! 358: char *rcvstring(char*); ! 359: void sendstring(char*); ! 360: ! 361: void pktstart(char); ! 362: void pktend(); ! 363: void pktflush(); ! 364: ! 365: void share(); ! 366: ! 367: Remote(char*); ! 368: Remote(int); ! 369: }; ! 370: ! 371: extern Remote *R; ! 372: ! 373: #endif ! 374: > ! 375: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.