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