home *** CD-ROM | disk | FTP | other *** search
/ Super Net 1 / SUPERNET_1.iso / PC / OTROS / UNIX / ARCHIE / CLIENTS / ARCHIE-1.2 / PFS.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-14  |  14.0 KB  |  377 lines

  1. /*
  2.  * Copyright (c) 1989, 1990, 1991 by the University of Washington
  3.  *
  4.  * For copying and distribution information, please see the file
  5.  * <copyright.h>.
  6.  */
  7.  
  8. #include <copyright.h>
  9.  
  10. #ifdef VMS
  11. # include <vms.h>
  12. #else /* not VMS */
  13. # ifndef _TYPES_
  14. #  include <sys/types.h>
  15. # endif /* _TYPES_ */
  16. # ifndef IN_H
  17. #  include <netinet/in.h> 
  18. #  define IN_H
  19. # endif
  20. #endif /* VMS */
  21.  
  22. #ifndef NULL
  23. # ifdef MSDOS
  24. #  include <stdio.h>
  25. # else
  26. #  define NULL 0
  27. # endif /* MSDOS */
  28. #endif /* NULL */
  29.  
  30. #define        PFS_RELEASE    "Beta.4.2E"
  31. #define        PFS_SW_ID    "B42E"
  32.  
  33. /* moved up for vdir_init */
  34. #define ZERO(p)        bzero((char *)(p), sizeof(*(p)))
  35.  
  36. /* General Definitions */
  37.  
  38. #define        MAX_PTXT_LEN    1250     /* Max length of PTEXT structure   */
  39. #define        MAX_PTXT_HDR    32       /* Max offset for start            */
  40. #define        P_ERR_STRING_SZ 100     /* Size of error string        */
  41. #define        MAX_VPATH    1024     /* Max length of virtual pathname  */
  42.  
  43. /* Definition of text structure used to pass text around */
  44.  
  45. struct ptext {
  46.     int            length;          /* Length of text (from start)    */
  47.     char        *start;          /* Start of text            */
  48.     char        dat[MAX_PTXT_LEN+2*MAX_PTXT_HDR];/* The data itself */
  49.     unsigned long     mbz;          /* ZERO to catch runaway strings  */
  50.     struct ptext    *previous;        /* Previous element in list       */
  51.     struct ptext    *next;          /* Next element in linked list    */
  52.     int            seq;          /* Sequence Number            */
  53. };
  54.  
  55. typedef struct ptext *PTEXT;
  56. typedef struct ptext PTEXT_ST;
  57.  
  58. /* Request structure: maintains information about server requests */
  59. struct preq {
  60.     int            cid;          /* Connection ID                  */
  61.     short        priority;      /* Connection priority            */
  62.     int            pf_priority;      /* Priority assigned by pri_func  */
  63.     int            recv_tot;      /* Total # of packets received    */
  64.     int            trns_tot;      /* Total # of packets to transmit */
  65.     struct ptext    *cpkt;          /* Current packet being filled in */
  66.     struct ptext    *recv;          /* Received packets               */
  67.     struct ptext    *trns;          /* Transmitted packets            */
  68.     int            rcvd_thru;      /* Received all packets through # */
  69.     struct preq        *previous;        /* Previous element in list       */
  70.     struct preq        *next;          /* Next element in linked list    */
  71.     struct sockaddr_in    fromto;       /* Sender/Destination            */
  72. };
  73.  
  74. typedef struct preq *PREQ;
  75. typedef struct preq PREQ_ST;
  76.  
  77.  
  78. /* Definition of structure containing information on virtual link */
  79.  
  80. struct vlink {
  81.     int            dontfree;      /* Flag: don't free this link     */
  82.     char        *name;          /* Component of path name        */
  83.     char        linktype;      /* L = Link, U = Union, N= Native */
  84.     int            expanded;      /* Has a union link been expanded */
  85.     char        *type;            /* Type of object pointed to      */
  86.     struct vlink    *filters;      /* Filters associated with link   */
  87.     struct vlink    *replicas;      /* Replicas (* see comment below) */
  88.     char        *hosttype;      /* Type of hostname            */
  89.     char        *host;          /* Files physical location        */
  90.     char        *nametype;      /* Type of filename            */
  91.     char        *filename;      /* System level filename        */
  92.     long        version;      /* Version number of destination  */
  93.     long        f_magic_no;      /* File's magic number        */
  94.     struct acl        *acl;          /* ACL for link            */
  95.     long        dest_exp;      /* Expiration for dest of link    */
  96.     long        link_exp;      /* Expiration of link itself      */
  97.     char        *args;          /* Arguments if this is a filter  */
  98.     struct pattrib    *lattrib;      /* Attributes associated w/ link  */
  99.     struct pfile    *f_info;      /* Info to be assoicated w/ file  */
  100.     struct vlink    *previous;        /* Previous elt in linked list    */
  101.     struct vlink    *next;          /* Next element in linked list    */
  102. };
  103.  
  104. typedef struct vlink *VLINK;
  105. typedef struct vlink VLINK_ST;
  106.  
  107. /* * Note that vlink->replicas is not really a list of replicas of the  */
  108. /*   object.  Instead, it is a list of the objects returned during name */
  109. /*   resolution that share the same name as the current object.  Such   */
  110. /*   an object should only be considered a replica if it also shares    */
  111. /*   the same non-zero magic number.                                    */
  112.  
  113. /* Definition of structure continiaing virtual directory information    */
  114.  
  115. struct vdir {
  116.     int            version;      /* Version of local directory fmt  */
  117.     int            inc_native;      /* Include the native directory    */
  118.     long        magic_no;      /* Magic number of current file    */
  119.     struct acl        *dacl;            /* Default acl for links in dir    */
  120.     struct pfile    *f_info;      /* Directory file info             */
  121.     struct vlink    *links;          /* The directory entries         */
  122.     struct vlink    *lastlink;      /* Last directory entry            */
  123.     struct vlink    *ulinks;      /* The entries for union links     */
  124.     struct vdir        *previous;        /* Previous element in linked list */
  125.     struct vdir        *next;          /* Next element in linked list     */
  126. };
  127.  
  128. typedef struct vdir *PVDIR;
  129. typedef struct vdir VDIR_ST;
  130.  
  131. /* Initialize directory */
  132. #define vdir_init(dir)  ZERO(dir)
  133. /* XXX: was
  134.  
  135.   dir->version = 0;     dir->inc_native = 0; \
  136.   dir->magic_no = 0;    dir->f_info = NULL; \
  137.   dir->links = NULL;    dir->lastlink = NULL; \
  138.   dir->ulinks = NULL;   dir->dacl = NULL; \
  139.   dir->previous = NULL; dir->next = NULL;
  140. */
  141.  
  142. #define vdir_copy(d1,d2) d2->version = d1->version; \
  143.                          d2->inc_native = d1->inc_native; \
  144.                          d2->magic_no = d1->magic_no; \
  145.                  d2->f_info = d1->f_info; \
  146.                          d2->links = d1->links; \
  147.                          d2->lastlink = d1->lastlink; \
  148.                          d2->ulinks = d1->ulinks; \
  149.                          d2->dacl = d1->dacl; \
  150.                          d2->previous = d1->previous; \
  151.                          d2->next = d1->next; 
  152.                          
  153. /* Values of ->inc_native in vdir structure */
  154. #define VDIN_REALONLY    -1   /* Include native files, but not . and ..       */
  155. #define VDIN_NONATIVE     0   /* Do not include files from native directory   */
  156. #define VDIN_INCLNATIVE     1   /* Include files from native directory          */
  157. #define VDIN_NATIVEONLY  2   /* All entries in directory are from native dir */
  158. #define VDIN_PSEUDO      3   /* Directory is not real                        */
  159.  
  160.  
  161. /* Definition of structure containing information on a specific file */
  162.  
  163. union avalue {
  164.     char        *ascii;        /* Character string                */
  165.     struct vlink    *link;        /* A link               */
  166. };
  167.  
  168.  
  169. struct pattrib {
  170.     char        precedence;    /* Precedence for link attribute   */
  171.     char        *aname;        /* Name of the attribute           */
  172.     char        *avtype;    /* Type of the attribute value     */
  173.     union avalue    value;        /* Attribute Value                 */
  174.     struct pattrib    *previous;      /* Previous element in linked list */
  175.     struct pattrib    *next;        /* Next element in linked list     */
  176. };
  177.  
  178. typedef struct pattrib *PATTRIB;
  179. typedef struct pattrib PATTRIB_ST;
  180.  
  181. #define     ATR_PREC_OBJECT  'O'   /* Authoritative answer for object */
  182. #define     ATR_PREC_LINK    'L'   /* Authoritative answer for link   */
  183. #define     ATR_PREC_CACHED  'C'   /* Object info cached w/ link      */
  184. #define     ATR_PREC_REPLACE 'R'   /* From link (replaces O)          */
  185. #define     ATR_PREC_ADD     'A'   /* From link (additional value)    */
  186.  
  187. /* **** Incomplete **** */
  188. struct pfile {
  189.     int            version;      /* Version of local finfo format   */
  190.     long        f_magic_no;      /* Magic number of current file    */
  191.     long        exp;          /* Expiration date of timeout      */
  192.     long        ttl;          /* Time to live after reference    */
  193.     long        last_ref;      /* Time of last reference          */
  194.     struct vlink    *forward;      /* List of forwarding pointers     */
  195.     struct vlink    *backlinks;      /* Partial list of back links      */
  196.     struct pattrib    *attributes;      /* List of file attributes         */
  197.     struct pfile    *previous;        /* Previous element in linked list */
  198.     struct pfile    *next;          /* Next element in linked list     */
  199. };
  200.  
  201. typedef struct pfile *PFILE;
  202. typedef struct pfile PFILE_ST;
  203.  
  204. /* Definition of structure contining an access control list entry */
  205.  
  206. struct acl {
  207.     int            acetype;      /* Access Contol Entry type       */
  208.     char        *atype;           /* Authentication type            */
  209.     char        *rights;          /* Rights                         */
  210.     char        *principals;      /* Authorized principals          */
  211.     struct restrict     *restrictions;    /* Restrictions on use            */
  212.     struct acl        *previous;        /* Previous elt in linked list    */
  213.     struct acl        *next;          /* Next element in linked list    */
  214. };
  215. typedef struct acl *ACL;
  216. typedef struct acl ACL_ST;
  217.  
  218. #define ACL_NONE        0         /* Nobody authorized by ths entry */
  219. #define ACL_DEFAULT        1         /* System default                 */
  220. #define ACL_SYSTEM        2         /* System administrator           */
  221. #define ACL_OWNER               3         /* Directory owner                */
  222. #define ACL_DIRECTORY           4         /* Same as directory              */
  223. #define ACL_ANY                 5         /* Any user                       */
  224. #define ACL_AUTHENT             6         /* Authenticated principal        */
  225. #define ACL_LGROUP              7         /* Local group                    */
  226. #define ACL_GROUP               8         /* External group                 */
  227. #define ACL_ASRTHOST            10        /* Check host and asserted userid */
  228. #define ACL_TRSTHOST            11        /* ASRTHOST from privileged port  */
  229.  
  230.  
  231. /* Definition of structure contining access restrictions */
  232. /* for future extensions                                 */
  233. struct restrict {
  234.     struct acl        *previous;        /* Previous elt in linked list    */
  235.     struct acl        *next;          /* Next element in linked list    */
  236. };
  237.  
  238. /* Definitions for send_to_dirsrv */
  239. #define    CLIENT_DIRSRV_TIMEOUT        4    /* time between retries      */
  240. #define CLIENT_DIRSRV_BACKOFF(x)  (2 * x)    /* Backoff algorithm         */
  241. #define CLIENT_DIRSRV_RETRY        3    /* retry this many times     */
  242.  
  243. /* Definitions for rd_vlink and rd_vdir */
  244. #define        SYMLINK_NESTING 10       /* Max nesting depth for sym links */
  245.  
  246. /* Definition fo check_acl */
  247. #define        ACL_NESTING     10       /* Max depth for ACL group nesting */
  248.  
  249. /* Flags for mk_vdir */
  250. #define         MKVD_LPRIV     1   /* Minimize privs for creator in new ACL    */
  251.  
  252. /* Flags for get_vdir */
  253. #define         GVD_UNION      0    /* Do not expand union links              */
  254. #define      GVD_EXPAND     1   /* Expand union links locally             */
  255. #define         GVD_LREMEXP    3   /* Request remote expansion of local links   */
  256. #define         GVD_REMEXP     7   /* Request remote expansion of all links     */
  257. #define         GVD_VERIFY     8    /* Only verify args are for a directory      */
  258. #define      GVD_FIND       16   /* Stop expanding when match is found        */
  259. #define         GVD_ATTRIB    32   /* Request attributes from remote server     */
  260. #define         GVD_NOSORT       64   /* Do not sort links when adding to dir      */
  261.  
  262. /* Flags for rd_vdir */
  263. #define         RVD_UNION      GVD_UNION
  264. #define         RVD_EXPAND     GVD_EXPAND 
  265. #define         RVD_LREMEXP    GVD_LREMEXP
  266. #define         RVD_REMEXP     GVD_REMEXP
  267. #define         RVD_DFILE_ONLY GVD_VERIFY /* Only return ptr to dir file        */
  268. #define      RVD_FIND       GVD_FIND   
  269. #define      RVD_ATTRIB     GVD_ATTRIB
  270. #define         RVD_NOSORT        GVD_NOSORT
  271. #define         RVD_NOCACHE    128
  272.  
  273. /* Flags for add_vlink */
  274. #define         AVL_UNION      1   /* Link is a union link                      */
  275.  
  276. /* Flags for vl_insert */
  277. #define         VLI_NOCONFLICT 0   /* Do not insert links w/ conflicting names  */
  278. #define      VLI_ALLOW_CONF 1   /* Allow links with conflicting names        */
  279. #define         VLI_NOSORT     2   /* Allow conflicts and don't sort            */
  280.  
  281. /* Flags for mapname */
  282. #define      MAP_READWRITE  0   /* Named file to be read and written         */
  283. #define         MAP_READONLY   1   /* Named file to be read only                */
  284.  
  285. /* Flags for modify_acl */
  286. #define         MACL_NOSYSTEM   0x01
  287. #define      MACL_NOSELF     0x02
  288. #define      MACL_DEFAULT    0x08
  289. #define      MACL_SET        0x0C
  290. #define      MACL_INSERT     0x14
  291. #define      MACL_DELETE     0x10
  292. #define      MACL_ADD        0x1C
  293. #define      MACL_SUBTRACT   0x18
  294. #define      MACL_LINK       0x00
  295. #define      MACL_DIRECTORY  0x20
  296. #define      MACL_OBJECT     0x60
  297. #define      MACL_INCLUDE    0x40
  298.  
  299. #define      MACL_OP    (MACL_DEFAULT|MACL_SET|MACL_INSERT|\
  300.              MACL_DELETE|MACL_ADD|MACL_SUBTRACT)
  301.  
  302. #define      MACL_OTYPE (MACL_LINK|MACL_DIRECTORY|MACL_OBJECT|MACL_INCLUDE)
  303.  
  304. /* Flags for dsrdir */
  305. #define DSRD_ATTRIBUTES                      0x1 /* Fill in attributes for links */
  306.  
  307. /* Access methods returned by Pget_am */
  308. #define P_AM_ERROR            0
  309. #define P_AM_FTP            1
  310. #define P_AM_AFTP            2  /* Anonymous FTP  */
  311. #define P_AM_NFS            4
  312. #define P_AM_KNFS            8  /* Kerberized NFS */
  313. #define P_AM_AFS               16
  314.  
  315. /* Return codes */
  316.  
  317. #define        PSUCCESS    0
  318. #define        PFAILURE    255
  319.  
  320. /* Hush up warnings.  */
  321. void vllfree();
  322.  
  323. /* Procedures in libpfs.a */
  324.  
  325. char *pget_wdhost(), *pget_wdfile(), *pget_wd(), *pget_hdhost();
  326. char *pget_hdfile(), *pget_hd(), *pget_rdhost(), *pget_rdfile();
  327. char *pget_dhost(), *pget_dfile(), *pget_vsname(), *nlsindex();
  328. char *sindex(), *strtok(), *nxtline(), *unquote(), *stcopy();
  329. char *stcopyr(), *readheader(), *month_sname();
  330.  
  331. long        asntotime();
  332. void        procquery();
  333.  
  334. PTEXT        ptalloc();
  335. PTEXT        dirsend();
  336. void        ptfree();
  337. void        ptlfree();
  338.  
  339. PREQ        pralloc();
  340. PREQ        get_next_request();
  341.  
  342. VLINK        rd_slink();
  343. VLINK        rd_vlink();
  344. VLINK        vl_delete();
  345. VLINK        vlalloc();
  346. VLINK        vlcopy();
  347. void        vlfree();
  348.  
  349. PFILE        pfalloc();
  350.  
  351. PATTRIB         parse_attribute();
  352. PATTRIB         atalloc();
  353. PATTRIB     pget_at();
  354. void        atfree();
  355. void        atlfree();
  356.  
  357. ACL             acalloc();
  358. ACL             get_acl();
  359.  
  360. void        stfree();
  361.  
  362. /* Miscellaneous useful definitions */
  363. #ifndef TRUE
  364. #define TRUE        1
  365. #define FALSE        0
  366. #endif
  367.  
  368. #define AUTHORIZED      1
  369. #define NOT_AUTHORIZED  0
  370. #define NEG_AUTHORIZED  -1
  371.  
  372. #ifndef NULL
  373. #define NULL        0
  374. #endif
  375.  
  376. #define FAILED        -1
  377.