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