home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume21 / coda / part02.Z / part02 / server.h < prev   
Encoding:
C/C++ Source or Header  |  1990-04-08  |  5.3 KB  |  236 lines

  1. /*
  2. **  Copyright 1989 BBN Systems and Technologies Corporation.
  3. **  All Rights Reserved.
  4. **  This is free software, and may be distributed under the terms of the
  5. **  GNU Public License; see the file COPYING for more details.
  6. **
  7. **  Header file for CODA server.
  8. **  $Header: server.h,v 2.0 90/03/23 14:42:01 rsalz Exp $
  9. */
  10. /* SUPPRESS 223 *//* Nested comment */
  11. #include <stdio.h>
  12. #include <sys/types.h>
  13.  
  14.  
  15. /*
  16. **  Constants, compilation control, et cetera.
  17. */
  18.  
  19. /* Assorted constants. */
  20. #define TRUE        1        /* Any non-zero value        */
  21. #define FALSE        0        /* Must be zero            */
  22. #define BADPARSE    1        /* Returned by YACC; must be 1    */
  23. #define SIZE        256        /* String buffer size        */
  24. #define MAXPATH        1024        /* Maximum pathname length    */
  25. #define HOST_DELTA    10        /* Clump for growing host array    */
  26. #define CLASS_DELTA    10        /* Clump for class arrays    */
  27. #define ITEM_DELTA    50        /* Clump for those other things    */
  28. #define SCAN_PING    200        /* How often to say we're alive    */
  29. #define FASTDEPTH    6        /* How far before closedir()?    */
  30. #define FW_NOFURTHER    1        /* FileWalker, go no further    */
  31. #define FW_PROCEED    2        /* FileWalker, keep going    */
  32. #define FW_EXIT        3        /* FileWalker, exit and pop up    */
  33.  
  34. /* Compile in RCS id strings? */
  35. #ifndef    SABER
  36. #define RCSID
  37. #endif    /* SABER */
  38.  
  39. /* Give up after this many seconds of inactivity. */
  40. #define TIMEOUT        (30 * 60)
  41.  
  42. /* Default name of the log file. */
  43. #define LOGFILE        "/usr/spool/log/codalog"
  44.  
  45. /* Default name of the file to read. */
  46. #define CONTROLFILE    "Codafile"
  47.  
  48. /* Name of the built-in class that contains all hosts except UnknownHost. */
  49. #define ALL        "_ALL"
  50.  
  51. /* Default name if host name isn't found. */
  52. #define GUESTHOST    "_ANYHOST"
  53.  
  54. /* Return type of a signal-handling function. */
  55. typedef int        CATCHER;    /* .. */
  56. /* typedef void        CATCHER;    /* .. */
  57.  
  58. /* Hide routines that can be hidden? */
  59. #define STATIC        static        /* .. */
  60. /*efine STATIC        /* NULL */    /* .. */
  61.  
  62. #define WHITE(c)    ((c) == ' ' || (c) == '\t')
  63.  
  64. /* Shut up, okay? */
  65. #ifdef    lint
  66. #undef putc
  67. #undef putchar
  68. #undef ungetc
  69. #undef RCSID
  70. #endif    /* lint */
  71.  
  72. /* Memory allocation. */
  73. #define NEW(T, c)        \
  74.     ((T *)malloc((unsigned int)(sizeof (T) * (c))))
  75. #define GROW(p, T, c)        \
  76.     ((T *)realloc((char *)p, (unsigned int)(sizeof (T) * (c))))
  77. #define COPY(p)            \
  78.     strcpy(NEW(char, strlen(p) + 1), p)
  79.  
  80. /* Fast front-end for string comparison. */
  81. #define EQ(p, q)        \
  82.     ((p) == (q) || ((p)[0] == (q)[0] && strcmp((p), (q)) == 0))
  83.  
  84.  
  85.  
  86. /*
  87. **  List of server commands.
  88. */
  89. typedef enum _COMMAND {
  90.     CMDgoto,
  91.     CMDhelp,
  92.     CMDhost,
  93.     CMDlist,
  94.     CMDmesg,
  95.     CMDquit,
  96.     CMDread,
  97.     CMDroot,
  98.     CMDsend,
  99.     CMDuser,
  100.     CMD_time
  101. } COMMAND;
  102.  
  103.  
  104. /*
  105. **  Is it, or is it not?
  106. */
  107. typedef int    BOOL;
  108.  
  109.  
  110. /*
  111. **  A linked list of strings.
  112. */
  113. typedef struct _STRLIST {
  114.     struct _STRLIST    *Next;
  115.     char        *Value;
  116. } STRLIST;
  117.  
  118.  
  119. /*
  120. **  An exception is a pattern for either files or a directory that is
  121. **  valid for a class of hosts.
  122. */
  123. typedef struct _EXCEPTION {
  124.     struct _EXCEPTION    *Next;
  125.     STRLIST        *Value;
  126.     BOOL        Directory;
  127.     char        *Class;
  128. } EXCEPTION;
  129.  
  130.  
  131. /*
  132. **  A directory list is a linked list of pathnames and their exceptions.
  133. */
  134. typedef struct _DIRLIST {
  135.     struct _DIRLIST    *Next;
  136.     char        *Value;
  137.     BOOL        Directory;
  138.     EXCEPTION        *Exceptions;
  139. } DIRLIST;
  140.  
  141.  
  142. /*
  143. **  A block has a name, whether it is part of the default list, a list of
  144. **  files, and a class that it is valid for.
  145. */
  146. typedef struct _BLOCK {
  147.     struct _BLOCK    *Next;
  148.     char        *Name;
  149.     BOOL        Excluded;
  150.     DIRLIST        *Directories;
  151.     char        *Class;
  152. } BLOCK;
  153.  
  154.  
  155. /*
  156. **  An item is something that can be sent to a client.  It has permissions,
  157. **  a modification time, and might be a directory.
  158. */
  159. typedef struct _ITEM {
  160.     char        *Name;
  161.     int            Uid;
  162.     int            Gid;
  163.     BOOL        Directory;
  164.     long        Size;
  165.     time_t        Time;
  166.     int            Mode;
  167. } ITEM;
  168.  
  169.  
  170. /*
  171. **  Data is declared everywhere, lives oncewhere.
  172. */
  173. #ifdef    MAINLINE
  174. #define EXTERN        /* NULL */
  175. #else
  176. #define EXTERN        extern
  177. #endif    /* MAINLINE */
  178.  
  179. EXTERN BLOCK    BaseBlock;        /* Chain of known blocks    */
  180. EXTERN BOOL    AllowBinaries;        /* Don't check for a.out files?    */
  181. EXTERN BOOL    Rooted;            /* Can client set the root?    */
  182. extern char    UnknownHost[];        /* Name of the unknown host    */
  183. extern char    *LogFile;        /* Name of the log file        */
  184. EXTERN char    *TheHost;        /* Host that called us        */
  185. EXTERN char    *TheRoot;        /* Root for relative pathnames    */
  186. EXTERN int    HaveErrors;        /* Failed to parse Codafile?    */
  187. EXTERN ITEM    *BaseItem;        /* Array of things to send    */
  188. EXTERN int    NumItem;        /* Size of said array        */
  189.  
  190. /* Our routines. */
  191. BLOCK        *FindBlock();
  192. ITEM        *FindItem();
  193. char        *strerror();
  194. int        HostIsInClass();
  195. int        yyopen();
  196. int        yyparse();
  197. void        Ack();
  198. void        AddClassesToClass();
  199. void        AddHostToClass();
  200. void        AddItemToList();
  201. void        Data();
  202. void        DefineBlock();
  203. void        DefineHost();
  204. void        ListFiles();
  205. void        LogClose();
  206. void        LogOpen();
  207. void        LogReadfile();
  208. void        LogSentItem();
  209. void        LogText();
  210. void        Message();
  211. void        Nack();
  212. void        ResetItem();
  213. void        ResetStorage();
  214. void        SendFile();
  215. void        SortItem();
  216. void        Uppercase();
  217. void        yyclose();
  218. void        yyerror();
  219.  
  220. /* From the C library. */
  221. extern int    errno;
  222. extern int    optind;
  223. extern time_t    time();
  224. extern char    *optarg;
  225. extern char    *bsearch();
  226. extern char    *crypt();
  227. extern char    *getwd();
  228. extern char    *malloc();
  229. extern char    *realloc();
  230. extern char    *sprintf();        /* Too painful, my ass        */
  231. extern char    *strcat();
  232. extern char    *strchr();
  233. extern char    *strcpy();
  234. extern char    *strncpy();
  235. extern char    *strrchr();
  236.