Annotation of researchv9/jtools/src/sam/sam.h, revision 1.1.1.1

1.1       root        1: #include "errors.h"
                      2: 
                      3: #define        BLOCKSIZE       4096
                      4: #define        NDISC           5
                      5: #define        NBUFFILES       2+2*NDISC       /* undo+snarf+NDISC*(transcript+buf) */
                      6: 
                      7: #define        TRUE            1
                      8: #define        FALSE           0
                      9: 
                     10: #define        INFINITY        ((Posn)0x7FFFFFFFL)
                     11: #define        INCR            25
                     12: #define        SS              2       /* shorts are hardwired to two bytes in files */
                     13: 
                     14: #define        new(t, n)       ((t *)alloc(((ulong)(n)*sizeof(t))))
                     15: #define        gcnew(p, n)     ((void)gcalloc((ulong)(n)*sizeof((p)[0]), (long **)&(p)))
                     16: #define        gcrenew(p, n)   ((void)gcrealloc((uchar *)p, ((ulong)(n)*sizeof((p)[0]))))
                     17: 
                     18: typedef unsigned short ushort;
                     19: typedef unsigned long  ulong;
                     20: typedef unsigned char  uchar;
                     21: typedef long           Posn;           /* file position or address */
                     22: typedef        ushort          Mod;            /* modification number */
                     23: 
                     24: #include "mesg.h"
                     25: 
                     26: enum State{
                     27:        Clean=' ',
                     28:        Dirty='\'',
                     29:        Unread='-',
                     30: };
                     31: typedef struct File File;
                     32: typedef struct Range{
                     33:        Posn    p1, p2;
                     34: }Range;
                     35: typedef struct Address{
                     36:        Range   r;
                     37:        File    *f;
                     38: }Address;
                     39: typedef struct List{
                     40:        int     nalloc;
                     41:        int     nused;
                     42:        long    *ptr;           /* code depends on ptrs being same size as Posns */
                     43: }List;
                     44: typedef struct Block{
                     45:        short   bnum;           /* absolute number on disk */
                     46:        short   nbytes;         /* bytes stored in this block */
                     47: }Block;
                     48: typedef struct Discdesc{
                     49:        int     fd;             /* unix file descriptor of temp file */
                     50:        int     nbk;            /* high water mark */
                     51:        List    free;           /* array of free blocks */
                     52: }Discdesc;
                     53: typedef struct Disc{
                     54:        Discdesc *desc;         /* descriptor of temp file */
                     55:        Posn    nbytes;         /* bytes on disc file */
                     56:        struct{
                     57:                int     nalloc;
                     58:                int     nused;
                     59:                Block   *ptr;
                     60:        }block;                 /* array of used blocks (same shape as List) */
                     61: }Disc;
                     62: typedef struct String{
                     63:        short   n;
                     64:        short   size;
                     65:        uchar   *s;
                     66: }String;
                     67: typedef struct Buffer{
                     68:        Disc    *disc;          /* disc storage */
                     69:        Posn    nbytes;         /* total length of buffer */
                     70:        String  cache;          /* in-core storage for efficiency */
                     71:        Posn    c1, c2;         /* cache start and end positions in disc */
                     72:                                /* note: if dirty, cache is really c0, c0+cache.n */
                     73:        int     dirty;          /* cache dirty */
                     74: }Buffer;
                     75: #define        NGETC   128
                     76: struct File{
                     77:        Buffer  *buf;           /* cached disc storage */
                     78:        Buffer  *transcript;    /* what's been done */
                     79:        Posn    markp;          /* file pointer to start of latest change */
                     80:        Mod     mod;            /* modification stamp */
                     81:        Posn    nbytes;         /* total length of file */
                     82:        Posn    hiposn;         /* highest address touched this Mod */
                     83:        Address dot;            /* current position */
                     84:        Range   tdot;           /* what terminal thinks is current range */
                     85:        Range   mark;           /* tagged spot in text (don't confuse with Mark) */
                     86:        List    *rasp;          /* map of what terminal's got */
                     87:        String  name;           /* file name */
                     88:        short   tag;            /* for communicating with terminal */
                     89:        char    state;          /* Clean, Dirty, Unread */
                     90:        char    closeok;        /* ok to close file? */
                     91:        char    marked;         /* file has been Fmarked at least once; once
                     92:                                 * set, this will never go off as undo doesn't
                     93:                                 * revert to the dawn of time */
                     94:        long    inumber;        /* file from which it was read */
                     95:        long    date;           /* time stamp of unix file */
                     96:        Posn    cp1, cp2;       /* Write-behind cache positions and */
                     97:        String  cache;          /* string */
                     98:        uchar   getcbuf[NGETC];
                     99:        int     ngetc;
                    100:        int     getci;
                    101:        Posn    getcp;
                    102: };
                    103: typedef struct Filelist{
                    104:        int     nalloc;
                    105:        int     nused;
                    106:        File    **ptr;
                    107: }Filelist;
                    108: typedef struct Mark{
                    109:        Posn    p;
                    110:        Range   dot;
                    111:        Range   mark;
                    112:        Mod     m;
                    113:        short   s1;
                    114: }Mark;
                    115: typedef struct Regexp Regexp;
                    116: struct Regexp{
                    117:        String  text;
                    118: };
                    119: #define        Fgetc(f)  ((--(f)->ngetc<0)? Fgetcload(f, (f)->getcp) : (f)->getcbuf[(f)->getcp++, (f)->getci++])
                    120: #define        Fbgetc(f) (((f)->getci<=0)? Fbgetcload(f, (f)->getcp) : (f)->getcbuf[--(f)->getcp, --(f)->getci])
                    121: 
                    122: extern uchar   *alloc();
                    123: extern uchar   *gcalloc();
                    124: extern uchar   *gcrealloc();
                    125: extern char    *brk();
                    126: extern char    *sbrk();
                    127: extern Address address();
                    128: extern Address lineaddr();
                    129: extern Buffer  *Bopen();
                    130: extern Disc    *Dopen();
                    131: extern Discdesc        *Dstart();
                    132: extern File    *Fopen();
                    133: extern File    *newfile();
                    134: extern File    *lookfile();
                    135: extern File    *current();
                    136: extern Posn    getnum();
                    137: extern Posn    readio();
                    138: extern Posn    writeio();
                    139: extern Range   rdata();
                    140: extern String  *tempstr();
                    141: extern uchar   genbuf[];
                    142: extern char    *home;
                    143: extern int     io;
                    144: extern int     patset;
                    145: extern int     quitok;
                    146: extern Address addr;
                    147: extern Buffer  *undobuf;
                    148: extern Buffer  *snarfbuf;
                    149: extern Filelist        file;
                    150: extern Filelist        tempfile;
                    151: extern File    *cmd;
                    152: extern File    *curfile;
                    153: extern Mod     modnum;
                    154: extern Posn    cmdpt;
                    155: extern Posn    cmdptadv;
                    156: extern Range   sel;
                    157: extern String  cmdstr;
                    158: extern String  genstr;
                    159: extern String  lastpat;
                    160: extern String  lastregexp;
                    161: extern String  unixcmd;
                    162: extern int     dontcompact;
                    163: extern int     downloaded;
                    164: extern int     dounlock;
                    165: 
                    166: #define        compactok()     dontcompact=FALSE
                    167: #define        nocompact()     dontcompact=TRUE
                    168: 
                    169: #define        strcmp  mystrcmp
                    170: #define        strncmp mystrncmp
                    171: #define        strlen  mystrlen
                    172: extern char    *strcat();
                    173: extern char    *strchr();
                    174: 
                    175: #if    vax|mc68020             /* longs are addressable at byte boundaries */
                    176: #define        PUTPOSN(d,s)            *(Posn *)d = *(s), d+=sizeof(Posn)
                    177: #define GETPOSN(p,s)           p = *(Posn *)(s)
                    178: #else
                    179: #define        PUTPOSN(d,s)    { register char *P=(char *)(s);\
                    180:                          *d++= *P++;*d++= *P++;*d++= *P++;*d++= *P++; }
                    181: #define GETPOSN(p,s)   { long L; register uchar *P1=(s),*P2=(uchar *)&L;\
                    182:                        *P2++= *P1++;*P2++= *P1++;*P2++= *P1++;*P2++= *P1++;\
                    183:                        p = L; }
                    184: #endif
                    185: extern void exit();
                    186: 
                    187: #define        HIGHBIT 0x80
                    188: #ifdef SUN
                    189: #define strchr(s,c) ((char *)index(s,c))
                    190: #define bcopy(a,b,c,d) sambcopy(a,b,c,d)
                    191: #define Warning        int
                    192: #define Error  int
                    193: #endif

unix.superglobalmegacorp.com

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