Annotation of researchv9/jerq/include/pads.pri, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.