home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / gopher / Unix / xgopher.1.3 / gopher.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-30  |  4.6 KB  |  157 lines

  1. /* gopher.h
  2.    main gopher data structures */
  3.  
  4.      /*---------------------------------------------------------------*/
  5.      /* Xgopher        version 1.3     08 April 1993                  */
  6.      /*                version 1.2     20 November 1992               */
  7.      /*                version 1.1     20 April 1992                  */
  8.      /*                version 1.0     04 March 1992                  */
  9.      /* X window system client for the University of Minnesota        */
  10.      /*                                Internet Gopher System.        */
  11.      /* Allan Tuchman, University of Illinois at Urbana-Champaign     */
  12.      /*                Computing and Communications Services Office   */
  13.      /* Copyright 1992, 1993 by                                       */
  14.      /*           the Board of Trustees of the University of Illinois */
  15.      /* Permission is granted to freely copy and redistribute this    */
  16.      /* software with the copyright notice intact.                    */
  17.      /*---------------------------------------------------------------*/
  18.  
  19.  
  20. #ifndef G_GOPHER_H
  21. #define G_GOPHER_H
  22.  
  23. #include "conf.h"
  24.  
  25. #define BOOLEAN        int        /* for TRUE/FALSE variables */
  26.  
  27. typedef    long    gopherTime;
  28. #define    NOT_LOADED    -99        /* special "time" */
  29.  
  30. typedef enum { copyTypeUnspec, copyTypeNone, copyTypeAscii,
  31.            copyTypeBinaryEOF } copyType;
  32.  
  33.  
  34. /* =======================================================================*/
  35.  
  36. typedef struct accessListItemStruct {
  37.         char            *address;
  38.         BOOLEAN         numeric;
  39.         struct accessListItemStruct   *next;
  40. } accessListItem;
  41.  
  42. typedef accessListItem *accessList;
  43.  
  44. /* =======================================================================*/
  45.  
  46. #define vStringValue(vs) (vs)->data
  47.  
  48. typedef struct vStringStruct {
  49.     int    len;            /* allocated length */
  50.     char    *data;            /* string value */
  51.     } vString;
  52.  
  53. /* =======================================================================*/
  54. /* subclass type data for gopher item */
  55.  
  56. typedef struct subClassInfoStruct {
  57.     char    *typeName;
  58.     char    *typePrefix;
  59.     accessList    *hostList;        /* access restricted list */
  60.     BOOLEAN    (*checkAccess)();    /* to see if item can be accessed */
  61.     BOOLEAN (*copyProc)();        /* to copy an item */
  62.     copyType copyDataType;        /* data type of network data */
  63.     BOOLEAN    (*processItem)();    /* to process (fetch) an item */
  64.     void    (*initProc)();        /* class initialize procedure */
  65.     void    (*doneProc)();        /* class terminate procedure */
  66.     void    (*restartProc)();    /* clean up class for restart */
  67.     } scInfo;
  68.  
  69.  
  70. /* =======================================================================*/
  71.  
  72. /* gopherItem reflects the gopher directory structure of the protocol 
  73.    plus a link to create lists of items. */
  74.  
  75. typedef struct gopherItemStruct {
  76.     char        type;
  77.     char        userStringAndPrefix[PREFIX_LEN + USER_STRING_LEN];
  78.     vString        selector;
  79.     char        host[HOST_STRING_LEN];
  80.     int        port;
  81.     BOOLEAN        plus;
  82.     BOOLEAN        accessOk;
  83.     scInfo        *sc;
  84.     struct gopherItemStruct *next;
  85.     } gopherItem, *gopherItemP;
  86.  
  87. /* header for a list of gopherItem's */
  88.  
  89. typedef struct gopherItemListStruct {
  90.     gopherItemP    first;
  91.     gopherItemP    last;
  92.     } gopherItemList, *gopherItemListP;
  93.  
  94. /* userStringAndPrefix contains two strings concatenated together.
  95.    The components, prefix and userString, are accesses with these macros. */
  96.  
  97. #define USER_STRING_PREFIX(gi)    ((gi)->userStringAndPrefix)
  98. #define USER_STRING(gi)        (((gi)->userStringAndPrefix)+PREFIX_LEN)
  99.  
  100. #define PREFIX(gi, p) {int i; char *c=(gi)->userStringAndPrefix;\
  101.             for (i=0;i<PREFIX_LEN;i++) *c++ = *(p+i);}
  102.  
  103.  
  104.  
  105.  
  106. /* Types of objects returned from a server */
  107.  
  108. #define A_FILE        '0'
  109. #define A_DIRECTORY    '1'
  110. #define A_CSO        '2'
  111. #define A_ERROR        '3'
  112. #define A_MAC_BINHEX    '4'
  113. #define A_DOS_BINHEX    '5'
  114. #define A_UNIX_UUENCODE    '6'
  115. #define A_INDEX        '7'
  116. #define A_TELNET    '8'
  117. #define A_BINARY    '9'
  118. #define A_IMAGE        'I'
  119. #define A_TN3270    'T'
  120. #define A_DUP_SERVER    '+'
  121. #define A_SOUND        's'
  122. #define A_EXTENDED    '='
  123. #define A_UNKNOWN    '?'
  124. #define A_EOI        '.'
  125.  
  126. #define A_BADREAD    '@'
  127.  
  128.  
  129. /* =======================================================================*/
  130.  
  131. /* gopher directory data structures */
  132.  
  133. /* gopherDir maintains the contents of a directory, and the
  134.    information required to reobtain the directory when necessary.
  135.    The data structure reflects a bi-directional linked list of the
  136.    user's traversal of gopher-space. */
  137.  
  138. typedef struct gopherDirStruct {
  139.     struct gopherDirStruct    *previous;
  140.     struct gopherDirStruct    *next;
  141.     gopherItemP        selectorItem;
  142.     gopherItemList        contents;
  143.     gopherTime        created;     
  144.     } gopherDir, *gopherDirP;
  145.  
  146.  
  147. /* header for a list of gopherDir's */
  148.  
  149. typedef struct gopherDirListStruct {
  150.         gopherDirP     first;
  151.         gopherDirP     last;
  152.         } gopherDirList, *gopherDirListP;
  153.  
  154.  
  155.  
  156. #endif /* G_GOPHER_H */
  157.