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