home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-11-23 | 53.6 KB | 1,553 lines |
- Newsgroups: comp.sources.misc
- From: brendan@cs.widener.edu (Brendan Kehoe)
- Subject: v26i048: archie - A Prospero client for Archie, v1.2, Part03/05
- Message-ID: <1991Nov24.045421.4731@sparky.imd.sterling.com>
- X-Md4-Signature: eee4201dfe5a08250f4bcc7e2b7dad21
- Date: Sun, 24 Nov 1991 04:54:21 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: brendan@cs.widener.edu (Brendan Kehoe)
- Posting-number: Volume 26, Issue 48
- Archive-name: archie/part03
- Environment: UNIX, VMS
- Supersedes: archie: Volume 22, Issue 35-39
-
- #! /bin/sh
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # The tool that generated this appeared in the comp.sources.unix newsgroup;
- # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
- # Contents: ./aquery.c ./get_vdir.c ./perrmesg.c ./pfs.h
- # ./vms/network.h
- # Wrapped by kent@sparky on Wed Nov 20 18:23:44 1991
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 3 (of 5)."'
- if test -f './aquery.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'./aquery.c'\"
- else
- echo shar: Extracting \"'./aquery.c'\" \(7961 characters\)
- sed "s/^X//" >'./aquery.c' <<'END_OF_FILE'
- X/*
- X * aquery.c : Programmatic Prospero interface to Archie
- X *
- X * Copyright (c) 1991 by the University of Washington
- X *
- X * For copying and distribution information, please see the file
- X * <copyright.h>.
- X *
- X * Originally part of the Prospero Archie client by Clifford
- X * Neuman (bcn@isi.edu). Modifications, addition of programmatic interface,
- X * and new sorting code by George Ferguson (ferguson@cs.rochester.edu)
- X * and Brendan Kehoe (brendan@cs.widener.edu). MSDOS and OS2 modifications
- X * to use with PC/TCP by Mark Towfiq (towfiq@FTP.COM).
- X *
- X * v1.2.1 - 11/19/91 (mmt) - added MSDOS & OS2 stuff
- X * v1.2.0 - 09/17/91 (bpk) - added BULL & USG stuff, thanks to Jim Sillas
- X * v1.1.3 - 08/30/91 (bpk) - cast index()
- X * v1.1.2 - 08/20/91 (bcn) - make it do it properly (new invdatecmplink)
- X * v1.1.1 - 08/20/91 (bpk) - made sorting go inverted as we purport it does
- X */
- X#include <copyright.h>
- X
- X#include <stdio.h>
- X
- X#include <pfs.h>
- X#include <perrno.h>
- X#include <archie.h>
- X
- X#include <pmachine.h>
- X#ifdef NEED_STRING_H
- X# include <string.h> /* for char *index() */
- X#else
- X# include <strings.h> /* for char *index() */
- X#endif
- X
- Xstatic void translateArchieResponse();
- X
- Xextern int pwarn;
- Xextern char p_warn_string[];
- X
- X/*
- X * archie_query : Sends a request to _host_, telling it to search for
- X * _string_ using _query_type_ as the search method.
- X * No more than _max_hits_ matches are to be returned
- X * skipping over _offset_ matches.
- X *
- X * archie_query returns a linked list of virtual links.
- X * If _flags_ does not include AQ_NOTRANS, then the Archie
- X * responses will be translated. If _flags_ does not include
- X * AQ_NOSORT, then the list will be sorted using _cmp_proc_ to
- X * compare pairs of links. If _cmp_proc_ is NULL or AQ_DEFCMP,
- X * then the default comparison procedure, defcmplink(), is used
- X * sorting by host, then filename. If cmp_proc is AQ_INVDATECMP
- X * then invdatecmplink() is used, sorting inverted by date.
- X * otherwise a user-defined comparison procedure is called.
- X *
- X * archie_query returns NULL and sets perrno if the query
- X * failed. Note that it can return NULL with perrno == PSUCCESS
- X * if the query didn't fail but there were simply no matches.
- X *
- X * query_type: S Substring search ignoring case
- X * C Substring search with case significant
- X * R Regular expression search
- X * = Exact String Match
- X * s,c,e Tries exact match first and falls back to S, C, or R
- X * if not found.
- X *
- X * cmp_proc: AQ_DEFCMP Sort by host, then filename
- X * AQ_INVDATECMP Sort inverted by date
- X *
- X * flags: AQ_NOSORT Don't sort results
- X * AQ_NOTRANS Don't translate results
- X */
- XVLINK
- Xarchie_query(host,string,max_hits,offset,query_type,cmp_proc,flags)
- X char *host,*string;
- X int max_hits,offset;
- X char query_type;
- X int (*cmp_proc)();
- X int flags;
- X {
- X char qstring[MAX_VPATH]; /* For construting the query */
- X VLINK links; /* Matches returned by server */
- X VDIR_ST dir_st; /* Filled in by get_vdir */
- X VDIR dir= &dir_st;
- X
- X VLINK p,q,r,lowest,nextp,pnext,pprev;
- X int tmp;
- X
- X /* Set the cmp_proc if not given */
- X if (cmp_proc == NULL) cmp_proc = defcmplink;
- X
- X /* Make the query string */
- X sprintf(qstring,"ARCHIE/MATCH(%d,%d,%c)/%s",
- X max_hits,offset,query_type,string);
- X
- X /* Initialize Prospero structures */
- X perrno = PSUCCESS; *p_err_string = '\0';
- X pwarn = PNOWARN; *p_warn_string = '\0';
- X vdir_init(dir);
- X
- X /* Retrieve the list of matches, return error if there was one */
- X#if defined(MSDOS)
- X if(tmp = get_vdir(host, qstring, "", dir, (long)GVD_ATTRIB|GVD_NOSORT,
- X NULL, NULL)) {
- X#else
- X if(tmp = get_vdir(host,qstring,"",dir,GVD_ATTRIB|GVD_NOSORT,NULL,NULL)) {
- X# endif
- X perrno = tmp;
- X return(NULL);
- X }
- X
- X /* Save the links, and clear in dir in case it's used again */
- X links = dir->links; dir->links = NULL;
- X
- X /* As returned, list is sorted by suffix, and conflicting */
- X /* suffixes appear on a list of "replicas". We want to */
- X /* create a one-dimensional list sorted by host then filename */
- X /* and maybe by some other parameter */
- X
- X /* First flatten the doubly-linked list */
- X for (p = links; p != NULL; p = nextp) {
- X nextp = p->next;
- X if (p->replicas != NULL) {
- X p->next = p->replicas;
- X p->next->previous = p;
- X for (r = p->replicas; r->next != NULL; r = r->next)
- X /*EMPTY*/ ;
- X r->next = nextp;
- X nextp->previous = r;
- X p->replicas = NULL;
- X }
- X }
- X
- X /* Translate the filenames unless NOTRANS was given */
- X if (!(flags & AQ_NOTRANS))
- X for (p = links; p != NULL; p = p->next)
- X translateArchieResponse(p);
- X
- X /* If NOSORT given, then just hand it back */
- X if (flags & AQ_NOSORT) {
- X perrno = PSUCCESS;
- X return(links);
- X }
- X
- X /* Otherwise sort it using a selection sort and the given cmp_proc */
- X for (p = links; p != NULL; p = nextp) {
- X nextp = p->next;
- X lowest = p;
- X for (q = p->next; q != NULL; q = q->next)
- X if ((*cmp_proc)(q,lowest) < 0)
- X lowest = q;
- X if (p != lowest) {
- X /* swap the two links */
- X pnext = p->next;
- X pprev = p->previous;
- X if (lowest->next != NULL)
- X lowest->next->previous = p;
- X p->next = lowest->next;
- X if (nextp == lowest) {
- X p->previous = lowest;
- X } else {
- X lowest->previous->next = p;
- X p->previous = lowest->previous;
- X }
- X if (nextp == lowest) {
- X lowest->next = p;
- X } else {
- X pnext->previous = lowest;
- X lowest->next = pnext;
- X }
- X if (pprev != NULL)
- X pprev->next = lowest;
- X lowest->previous = pprev;
- X /* keep the head of the list in the right place */
- X if (links == p)
- X links = lowest;
- X }
- X }
- X
- X /* Return the links */
- X perrno = PSUCCESS;
- X return(links);
- X }
- X
- X/*
- X * translateArchieResponse:
- X *
- X * If the given link is for an archie-pseudo directory, fix it.
- X * This is called unless AQ_NOTRANS was given to archie_query().
- X */
- Xstatic void
- XtranslateArchieResponse(l)
- X VLINK l;
- X {
- X char *slash;
- X
- X if (strcmp(l->type,"DIRECTORY") == 0) {
- X if (strncmp(l->filename,"ARCHIE/HOST",11) == 0) {
- X l->type = stcopyr("EXTERNAL(AFTP,DIRECTORY)",l->type);
- X l->host = stcopyr(l->filename+12,l->host);
- X slash = (char *)index(l->host,'/');
- X if (slash) {
- X l->filename = stcopyr(slash,l->filename);
- X *slash++ = '\0';
- X } else
- X l->filename = stcopyr("",l->filename);
- X }
- X }
- X }
- X
- X/*
- X * defcmplink: The default link comparison function for sorting. Compares
- X * links p and q first by host then by filename. Returns < 0 if p
- X * belongs before q, > 0 if p belongs after q, and == 0 if their
- X * host and filename fields are identical.
- X */
- Xint
- Xdefcmplink(p,q)
- X VLINK p,q;
- X {
- X int result;
- X
- X if ((result=strcmp(p->host,q->host)) != 0)
- X return(result);
- X else
- X return(strcmp(p->filename,q->filename));
- X }
- X
- X/*
- X * invdatecmplink: An alternative comparison function for sorting that
- X * compares links p and q first by LAST-MODIFIED date,
- X * if they both have that attribute. If both links
- X * don't have that attribute or the dates are the
- X * same, it then calls defcmplink() and returns its
- X * value.
- X */
- Xint
- Xinvdatecmplink(p,q)
- X VLINK p,q;
- X {
- X PATTRIB pat,qat;
- X char *pdate,*qdate;
- X int result;
- X
- X pdate = qdate = NULL;
- X for (pat = p->lattrib; pat; pat = pat->next)
- X if(strcmp(pat->aname,"LAST-MODIFIED") == 0)
- X pdate = pat->value.ascii;
- X for (qat = q->lattrib; qat; qat = qat->next)
- X if(strcmp(qat->aname,"LAST-MODIFIED") == 0)
- X qdate = qat->value.ascii;
- X if(!pdate && !qdate) return(defcmplink(p,q));
- X if(!pdate) return(1);
- X if(!qdate) return(-1);
- X if((result=strcmp(qdate,pdate)) == 0) return(defcmplink(p,q));
- X else return(result);
- X }
- END_OF_FILE
- if test 7961 -ne `wc -c <'./aquery.c'`; then
- echo shar: \"'./aquery.c'\" unpacked with wrong size!
- fi
- # end of './aquery.c'
- fi
- if test -f './get_vdir.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'./get_vdir.c'\"
- else
- echo shar: Extracting \"'./get_vdir.c'\" \(14298 characters\)
- sed "s/^X//" >'./get_vdir.c' <<'END_OF_FILE'
- X/*
- X * Copyright (c) 1989, 1990, 1991 by the University of Washington
- X *
- X * For copying and distribution information, please see the file
- X * <copyright.h>.
- X *
- X * v1.2.2 - 11/19/91 (mmt) - added MSDOS & OS2 stuff
- X * v1.2.1 - 10/23/91 (bpk) - added missing code
- X * v1.2.0 - 09/17/91 (bpk) - added new get_vdir code
- X * v1.1.1 - 08/30/91 (bpk) - cast rindex()
- X */
- X
- X#include <copyright.h>
- X#include <stdio.h>
- X
- X#include <pfs.h>
- X#include <pprot.h>
- X#include <perrno.h>
- X#include <pcompat.h>
- X#include <pauthent.h>
- X#include <pmachine.h>
- X
- X#ifdef NEED_STRING_H
- X# include <string.h>
- X#else
- X# include <strings.h>
- X#endif
- X
- X#ifdef DEBUG
- Xextern int pfs_debug;
- X#endif
- X
- Xextern int pwarn;
- Xextern char p_warn_string[];
- Xextern int perrno;
- Xextern char p_err_string[];
- X
- X/*
- X * get_vdir - Get contents of a directory given its location
- X *
- X * GET_VDIR takes a directory location, a list of desired
- X * components, a pointer to a directory structure to be
- X * filled in, and flags. It then queries the appropriate
- X * directory server and retrieves the desired information.
- X *
- X * ARGS: dhost - Host on which directory resides
- X * dfile - Directory on that host
- X * components - The names from the directory we want
- X * dir - Structure to be filled in
- X * flags - Options. See FLAGS
- X * filters - filters to be applied to result
- X * acomp - Pointer to remaining components
- X *
- X * FLAGS: GVD_UNION - Do not expand union links
- X * GVD_EXPAND - Expand union links locally
- X * GVD_REMEXP - Request remote expansion (& local if refused)
- X * GVD_LREMEXP - Request remote expansion of local union links
- X * GVD_VERIFY - Only verify that args are for a directory
- X * GVD_ATTRIB - Request attributes from directory server
- X * GVD_NOSORT - Do not sort links when adding to directory
- X *
- X * RETURNS: PSUCCESS (0) or error code
- X * On some codes addition information in p_err_string
- X *
- X * NOTES: If acomp is non-null the string it points to might be modified
- X *
- X * If the directory passed as an argument already has
- X * links or union links, then those lists will be freed
- X * before the new contents are filled in.
- X *
- X * If a filter is passed to the procedure, and application of
- X * the filter results in additional union link, then those links
- X * will (or will not) be expanded as specified in the FLAGS field.
- X *
- X * If the list of components in NULL, or the null string, then
- X * get_vdir will return all links in the requested directory.
- X *
- X * BUGS: Doesn't process union links yet
- X * Doesn't process errors returned from server
- X * Doesn't expand union links if requested to
- X */
- Xint
- Xget_vdir(dhost,dfile,components,dir,flags,filters,acomp)
- X char *dhost; /* Host on which directory resides */
- X char *dfile; /* Name of file on that host */
- X char *components; /* Component name (wildcards allowed) */
- X VDIR dir; /* Structure to be filled in */
- X long flags; /* Flags */
- X VLINK filters; /* Filters to be applied to result */
- X char *acomp; /* Components left to be resolved */
- X {
- X PTEXT request; /* Text of request to dir server */
- X PTEXT resp; /* Response from dir server */
- X
- X char ulcomp[MAX_VPATH];/* Work space for new current component */
- X char *comp = components;
- X
- X VLINK cur_link = NULL;/* Current link being filled in */
- X VLINK exp = NULL; /* The current ulink being expanded */
- X VLINK pul = NULL; /* Prev union link (insert new one after it) */
- X VLINK l; /* Temp link pointer */
- X int mcomp; /* Flag - check multiple components */
- X int unresp; /* Flag - received unresolved response */
- X int getattrib = 0; /* Get attributes from server */
- X int vl_insert_flag; /* Flags to vl_insert */
- X
- X int fwdcnt = MAX_FWD_DEPTH;
- X
- X int no_links = 0; /* Count of number of links found */
- X
- X char options[40]; /* LIST option */
- X char *opt; /* After leading + */
- X
- X PAUTH authinfo;
- X
- X /* Treat null string like NULL (return entire directory) */
- X if(!components || !*components) comp = NULL;
- X
- X if(acomp && !filters) mcomp = 1;
- X else mcomp = 0;
- X
- X if(flags&GVD_ATTRIB) {
- X getattrib++;
- X flags &= (~GVD_ATTRIB);
- X }
- X
- X if(flags&GVD_NOSORT) vl_insert_flag = VLI_NOSORT;
- X else vl_insert_flag = VLI_ALLOW_CONF;
- X flags &= (~GVD_NOSORT);
- X
- X if(filters) comp = NULL;
- X
- X perrno = 0;
- X
- X authinfo = get_pauth(PFSA_UNAUTHENTICATED);
- X
- X *options = '\0';
- X
- X if(getattrib) {
- X strcat(options,"+ATTRIBUTES");
- X flags &= (~GVD_ATTRIB);
- X }
- X
- X if(!filters) { /* Can't do remote expansion if filters to be applied */
- X if(flags == GVD_REMEXP) strcat(options,"+EXPAND");
- X if(flags == GVD_LREMEXP) strcat(options,"+LEXPAND");
- X }
- X
- X /* If all we are doing is verifying that dfile is a directory */
- X /* then we do not want a big response from the directory */
- X /* server. A NOT-FOUND is sufficient. */
- X if(flags == GVD_VERIFY)
- X#ifdef NEWVERIFYOPT
- X strcat(options,"+VERIFY");
- X#else
- X comp = "%#$PRobably_nOn_existaNT$#%";
- X#endif
- X
- X if(*options) opt = options+1;
- X else opt = "''";
- X
- X startover:
- X request = ptalloc();
- X
- X sprintf(request->start,
- X "VERSION %d\nAUTHENTICATOR %s %s\nDIRECTORY ASCII %s\nLIST %s COMPONENTS %s%s%s\n",
- X VFPROT_VNO, authinfo->auth_type, authinfo->authenticator,
- X dfile,opt, (comp ? comp : ""), (mcomp ? "/" : ""),
- X (mcomp ? acomp : ""));
- X
- X request->length = strlen(request->start);
- X
- X#ifdef DEBUG
- X if(pfs_debug > 2)
- X fprintf(stderr,"Sending message to dirsrv:\n%s",request->start);
- X#endif
- X
- X#if defined(MSDOS)
- X resp = dirsend(request,dhost,0L);
- X#else
- X resp = dirsend(request,dhost,0);
- X#endif
- X
- X#ifdef DEBUG
- X if(pfs_debug && (resp == NULL)) {
- X fprintf(stderr,"Dirsend failed: %d\n",perrno);
- X }
- X#endif
- X
- X /* If we don't get a response, then if the requested */
- X /* directory, return error, if a ulink, mark it unexpanded */
- X if(resp == NULL) {
- X if(exp) exp->expanded = FAILED;
- X else return(perrno);
- X }
- X
- X unresp = 0;
- X
- X /* Here we must parse reponse and put in directory */
- X /* While looking at each packet */
- X while(resp) {
- X PTEXT vtmp;
- X char *line;
- X
- X vtmp = resp;
- X#ifdef DEBUG
- X if(pfs_debug > 3) fprintf(stderr,"%s\n",resp->start);
- X#endif
- X /* Look at each line in packet */
- X for(line = resp->start;line != NULL;line = nxtline(line)) {
- X switch (*line) {
- X
- X /* Temporary variables to hold link info */
- X char l_linktype;
- X char l_name[MAX_DIR_LINESIZE];
- X char l_type[MAX_DIR_LINESIZE];
- X char l_htype[MAX_DIR_LINESIZE];
- X char l_host[MAX_DIR_LINESIZE];
- X char l_ntype[MAX_DIR_LINESIZE];
- X char l_fname[MAX_DIR_LINESIZE];
- X int l_version;
- X char t_unresolved[MAX_DIR_LINESIZE];
- X int l_magic;
- X int tmp;
- X
- X case 'L': /* LINK or LINK-INFO */
- X if(strncmp(line,"LINK-INFO",9) == 0) {
- X PATTRIB at;
- X PATTRIB last_at;
- X at = parse_attribute(line);
- X if(!at) break;
- X
- X /* Cant have link info without a link */
- X if(!cur_link) {
- X perrno = DIRSRV_BAD_FORMAT;
- X atfree(at);
- X break;
- X }
- X
- X if(cur_link->lattrib) {
- X last_at = cur_link->lattrib;
- X while(last_at->next) last_at = last_at->next;
- X at->previous = last_at;
- X last_at->next = at;
- X }
- X else {
- X cur_link->lattrib = at;
- X at->previous = NULL;
- X }
- X break;
- X }
- X
- X /* Not LINK-INFO, must be LINK - if not check for error */
- X if(strncmp(line,"LINK",4) != 0) goto scanerr;
- X
- X /* If only verifying, don't want to change dir */
- X if(flags == GVD_VERIFY) {
- X break;
- X }
- X /* If first link and some links in dir, free them */
- X if(!no_links++) {
- X if(dir->links) vllfree(dir->links); dir->links=NULL;
- X if(dir->ulinks) vllfree(dir->ulinks); dir->ulinks=NULL;
- X }
- X
- X cur_link = vlalloc();
- X
- X /* parse and insert file info */
- X tmp = sscanf(line,"LINK %c %s %s %s %s %s %s %d %d", &l_linktype,
- X l_type, l_name, l_htype, l_host,
- X l_ntype, l_fname, &(cur_link->version),
- X &(cur_link->f_magic_no));
- X
- X if(tmp != 9) {
- X perrno = DIRSRV_BAD_FORMAT;
- X vlfree(cur_link);
- X break;
- X }
- X
- X cur_link->linktype = l_linktype;
- X cur_link->type = stcopyr(l_type,cur_link->type);
- X cur_link->name = stcopyr(unquote(l_name),cur_link->name);
- X cur_link->hosttype = stcopyr(l_htype,cur_link->hosttype);
- X cur_link->host = stcopyr(l_host,cur_link->host);
- X cur_link->nametype = stcopyr(l_ntype,cur_link->nametype);
- X cur_link->filename = stcopyr(l_fname,cur_link->filename);
- X
- X /* Double check to make sure we don't get */
- X /* back unwanted components */
- X /* OK to keep if special (URP) links */
- X /* or if mcomp specified */
- X if(!mcomp && (cur_link->linktype == 'L') &&
- X (!wcmatch(cur_link->name,comp))) {
- X vlfree(cur_link);
- X break;
- X }
- X
- X /* If other optional info was sent back, it must */
- X /* also be parsed before inserting link *** */
- X
- X
- X if(cur_link->linktype == 'L')
- X vl_insert(cur_link,dir,vl_insert_flag);
- X else {
- X tmp = ul_insert(cur_link,dir,pul);
- X
- X /* If inserted after pul, next one after cur_link */
- X if(pul && (!tmp || (tmp == UL_INSERT_SUPERSEDING)))
- X pul = cur_link;
- X }
- X
- X break;
- X
- X case 'F': /* FILTER, FAILURE or FORWARDED*/
- X /* FORWARDED */
- X if(strncmp(line,"FORWARDED",9) == 0) {
- X if(fwdcnt-- <= 0) {
- X ptlfree(resp);
- X perrno = PFS_MAX_FWD_DEPTH;
- X return(perrno);
- X }
- X /* parse and start over */
- X
- X tmp = sscanf(line,"FORWARDED %s %s %s %s %d %d",
- X l_htype,l_host,l_ntype,l_fname,
- X &l_version, &l_magic);
- X
- X dhost = stcopy(l_host);
- X dfile = stcopy(l_fname);
- X
- X if(tmp < 4) {
- X perrno = DIRSRV_BAD_FORMAT;
- X break;
- X }
- X
- X ptlfree(resp);
- X goto startover;
- X }
- X if(strncmp(line,"FILTER",6) != 0) goto scanerr;
- X break;
- X
- X
- X case 'M': /* MULTI-PACKET (processed by dirsend) */
- X case 'P': /* PACKET (processed by dirsend) */
- X break;
- X
- X case 'N': /* NOT-A-DIRECTORY or NONE-FOUND */
- X /* NONE-FOUND, we just have no links to insert */
- X /* It is not an error, but we must clear any */
- X /* old links in the directory arg */
- X if(strncmp(line,"NONE-FOUND",10) == 0) {
- X /* If only verifying, don't want to change dir */
- X if(flags == GVD_VERIFY) {
- X break;
- X }
- X
- X /* If first link and some links in dir, free them */
- X if(!no_links++) {
- X if(dir->links) vllfree(dir->links);
- X if(dir->ulinks) vllfree(dir->ulinks);
- X dir->links = NULL;
- X dir->ulinks = NULL;
- X }
- X break;
- X }
- X /* If NOT-A-DIRECTORY or anything else, scan error */
- X goto scanerr;
- X
- X case 'U': /* UNRESOLVED */
- X if(strncmp(line,"UNRESOLVED",10) != 0) {
- X goto scanerr;
- X }
- X tmp = sscanf(line,"UNRESOLVED %s", t_unresolved);
- X if(tmp < 1) {
- X perrno = DIRSRV_BAD_FORMAT;
- X break;
- X }
- X /* If multiple components were resolved */
- X if(strlen(t_unresolved) < strlen(acomp)) {
- X strcpy(ulcomp,acomp);
- X /* ulcomp is the components that were resolved */
- X *(ulcomp+strlen(acomp)-strlen(t_unresolved)-1) = '\0';
- X /* Comp gets the last component resolved */
- X comp = (char *) rindex(ulcomp,'/');
- X if(comp) comp++;
- X else comp = ulcomp;
- X /* Let rd_vdir know what remains */
- X strcpy(acomp,t_unresolved);
- X }
- X unresp = 1;
- X break;
- X
- X case 'V': /* VERSION-NOT-SUPPORTED */
- X if(strncmp(line,"VERSION-NOT-SUPPORTED",21) == 0) {
- X perrno = DIRSRV_BAD_VERS;
- X return(perrno);
- X }
- X goto scanerr;
- X
- X scanerr:
- X default:
- X if(*line && (tmp = scan_error(line))) {
- X ptlfree(resp);
- X return(tmp);
- X }
- X break;
- X }
- X }
- X
- X resp = resp->next;
- X
- X ptfree(vtmp);
- X }
- X
- X /* We sent multiple components and weren't told any */
- X /* were unresolved */
- X if(mcomp && !unresp) {
- X /* ulcomp is the components that were resolved */
- X strcpy(ulcomp,acomp);
- X /* Comp gets the last component resolved */
- X comp = (char *) rindex(ulcomp,'/');
- X if(comp) comp++;
- X else comp = ulcomp;
- X /* If we have union links to resolve, only one component remains */
- X mcomp = 0;
- X /* Let rd_vdir know what remains */
- X *acomp = '\0';
- X }
- X
- X /* If only verifying, we already know it is a directory */
- X if(flags == GVD_VERIFY) return(PSUCCESS);
- X
- X /* Don't return if matching was delayed by the need to filter */
- X /* if FIND specified, and dir->links is non null, then we have */
- X /* found a match, and should return. */
- X if((flags & GVD_FIND) && dir->links && (!filters))
- X return(PSUCCESS);
- X
- X /* If expand specified, and ulinks must be expanded, making sure */
- X /* that the order of the links is maintained properly */
- X
- Xexpand_ulinks:
- X
- X if((flags != GVD_UNION) && (flags != GVD_VERIFY)) {
- X
- X l = dir->ulinks;
- X
- X /* Find first unexpanded ulink */
- X while(l && l->expanded && (l->linktype == 'U')) l = l->next;
- X
- X /* Only expand if a FILE or DIRECTORY - Mark as */
- X /* failed otherwise */
- X /* We must still add support for symbolic ulinks */
- X if(l) {
- X if ((strcmp(l->type,"DIRECTORY") == 0) ||
- X (strcmp(l->type,"FILE") == 0)) {
- X l->expanded = TRUE;
- X exp = l;
- X pul = l;
- X dhost = l->host;
- X dfile = l->filename;
- X goto startover; /* was get_contents; */
- X }
- X else l->expanded = FAILED;
- X }
- X }
- X
- X /* Double check to make sure we don't get */
- X /* back unwanted components */
- X /* OK to keep if special (URP) links */
- X if(components && *components) {
- X l = dir->links;
- X while(l) {
- X VLINK ol;
- X if((l->linktype == 'L') && (!wcmatch(l->name,components))) {
- X if(l == dir->links)
- X dir->links = l->next;
- X else l->previous->next = l->next;
- X if(l->next) l->next->previous = l->previous;
- X ol = l;
- X l = l->next;
- X vlfree(ol);
- X }
- X else l = l->next;
- X }
- X }
- X
- X return(PSUCCESS);
- X }
- END_OF_FILE
- if test 14298 -ne `wc -c <'./get_vdir.c'`; then
- echo shar: \"'./get_vdir.c'\" unpacked with wrong size!
- fi
- # end of './get_vdir.c'
- fi
- if test -f './perrmesg.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'./perrmesg.c'\"
- else
- echo shar: Extracting \"'./perrmesg.c'\" \(9027 characters\)
- sed "s/^X//" >'./perrmesg.c' <<'END_OF_FILE'
- X/*
- X * Copyright (c) 1989, 1990, 1991 by the University of Washington
- X *
- X * For copying and distribution information, please see the file
- X * <copyright.h>.
- X */
- X
- X#include <copyright.h>
- X#include <perrno.h>
- X#include <stdio.h>
- X
- X/* This file and perrno.h should always be updated simultaneously */
- X
- Xint perrno = 0;
- Xint pwarn = 0;
- Xchar p_err_string[P_ERR_STRING_SZ];
- Xchar p_warn_string[P_ERR_STRING_SZ];
- X
- Xchar *p_err_text[256] = {
- X /* 0 */ "Success (prospero)",
- X /* 1 */ "Port unknown (dirsend)",
- X /* 2 */ "Can't open local UDP port (dirsend)",
- X /* 3 */ "Can't resolve hostname (dirsend)",
- X /* 4 */ "Unable to send entire message (dirsend)",
- X /* 5 */ "Timed out (dirsend)",
- X /* 6 */ "Recvfrom failed (dirsend)",
- X /* 7 */ "", /* 8 */ "", /* 9 */ "", /* 10 */ "",
- X /* 11 */ "Sendto failed (reply)",
- X /* 12 */ "", /* 13 */ "", /* 14 */ "", /* 15 */ "",
- X /* 16 */ "", /* 17 */ "", /* 18 */ "", /* 19 */ "",
- X /* 20 */ "",
- X /* 21 */ "Link already exists (vl_insert)",
- X /* 22 */ "Link with same name already exists (vl_insert)",
- X /* 23 */ "", /* 24 */ "",
- X /* 25 */ "Link already exists (ul_insert)",
- X /* 26 */ "Replacing existing link (ul_insert)",
- X /* 27 */ "Previous entry not found in dir->ulinks (ul_insert)",
- X /* 28 */ "", /* 29 */ "", /* 30 */ "", /* 31 */ "",
- X /* 32 */ "", /* 33 */ "", /* 34 */ "", /* 35 */ "",
- X /* 36 */ "", /* 37 */ "", /* 38 */ "", /* 39 */ "",
- X /* 40 */ "",
- X /* 41 */ "Temporary not found (rd_vdir)",
- X /* 42 */ "Namespace not closed with object (rd_vdir)",
- X /* 43 */ "Alias for namespace not defined (rd_vdir)",
- X /* 44 */ "Specified namespace not found (rd_vdir)",
- X /* 45 */ "", /* 46 */ "", /* 47 */ "", /* 48 */ "",
- X /* 49 */ "", /* 50 */ "",
- X /* 51 */ "File access method not supported (pfs_access)",
- X /* 52 */ "", /* 53 */ "", /* 54 */ "",
- X /* 55 */ "Pointer to cached copy - delete on close (pmap_cache)",
- X /* 56 */ "Unable to retrieve file (pmap_cache)",
- X /* 57 */ "", /* 58 */ "", /* 59 */ "", /* 60 */ "",
- X /* 61 */ "Directory already exists (mk_vdir)",
- X /* 62 */ "Link with same name already exists (mk_vdir)",
- X /* 63 */ "", /* 64 */ "",
- X /* 65 */ "Not a virtual system (vfsetenv)",
- X /* 66 */ "Can't find directory (vfsetenv)",
- X /* 67 */ "", /* 68 */ "", /* 69 */ "", /* 70 */ "",
- X /* 71 */ "Link already exists (add_vlink)",
- X /* 72 */ "Link with same name already exists (add_vlink)",
- X /* 73 */ "", /* 74 */ "", /* 75 */ "", /* 76 */ "",
- X /* 77 */ "", /* 78 */ "", /* 79 */ "", /* 80 */ "",
- X /* 81 */ "", /* 82 */ "", /* 83 */ "", /* 84 */ "",
- X /* 85 */ "", /* 86 */ "", /* 87 */ "", /* 88 */ "",
- X /* 89 */ "", /* 90 */ "", /* 91 */ "", /* 92 */ "",
- X /* 93 */ "", /* 94 */ "", /* 95 */ "", /* 96 */ "",
- X /* 97 */ "", /* 98 */ "", /* 99 */ "", /* 100 */ "",
- X /* 101 */ "", /* 102 */ "", /* 103 */ "", /* 104 */ "",
- X /* 105 */ "", /* 106 */ "", /* 107 */ "", /* 108 */ "",
- X /* 109 */ "", /* 110 */ "", /* 111 */ "", /* 112 */ "",
- X /* 113 */ "", /* 114 */ "", /* 115 */ "", /* 116 */ "",
- X /* 117 */ "", /* 118 */ "", /* 119 */ "", /* 120 */ "",
- X /* 121 */ "", /* 122 */ "", /* 123 */ "", /* 124 */ "",
- X /* 125 */ "", /* 126 */ "", /* 127 */ "", /* 128 */ "",
- X /* 129 */ "", /* 130 */ "", /* 131 */ "", /* 132 */ "",
- X /* 133 */ "", /* 134 */ "", /* 135 */ "", /* 136 */ "",
- X /* 137 */ "", /* 138 */ "", /* 139 */ "", /* 140 */ "",
- X /* 141 */ "", /* 142 */ "", /* 143 */ "", /* 144 */ "",
- X /* 145 */ "", /* 146 */ "", /* 147 */ "", /* 148 */ "",
- X /* 149 */ "", /* 150 */ "", /* 151 */ "", /* 152 */ "",
- X /* 153 */ "", /* 154 */ "", /* 155 */ "", /* 156 */ "",
- X /* 157 */ "", /* 158 */ "", /* 159 */ "", /* 160 */ "",
- X /* 161 */ "", /* 162 */ "", /* 163 */ "", /* 164 */ "",
- X /* 165 */ "", /* 166 */ "", /* 167 */ "", /* 168 */ "",
- X /* 169 */ "", /* 170 */ "", /* 171 */ "", /* 172 */ "",
- X /* 173 */ "", /* 174 */ "", /* 175 */ "", /* 176 */ "",
- X /* 177 */ "", /* 178 */ "", /* 179 */ "", /* 180 */ "",
- X /* 181 */ "", /* 182 */ "", /* 183 */ "", /* 184 */ "",
- X /* 185 */ "", /* 186 */ "", /* 187 */ "", /* 188 */ "",
- X /* 189 */ "", /* 190 */ "", /* 191 */ "", /* 192 */ "",
- X /* 193 */ "", /* 194 */ "", /* 195 */ "", /* 196 */ "",
- X /* 197 */ "", /* 198 */ "", /* 199 */ "", /* 200 */ "",
- X /* 201 */ "", /* 202 */ "", /* 203 */ "", /* 204 */ "",
- X /* 205 */ "", /* 206 */ "", /* 207 */ "", /* 208 */ "",
- X /* 209 */ "", /* 210 */ "", /* 211 */ "", /* 212 */ "",
- X /* 213 */ "", /* 214 */ "", /* 215 */ "", /* 216 */ "",
- X /* 217 */ "", /* 218 */ "", /* 219 */ "", /* 220 */ "",
- X /* 221 */ "", /* 222 */ "", /* 223 */ "", /* 224 */ "",
- X /* 225 */ "", /* 226 */ "", /* 227 */ "", /* 228 */ "",
- X /* 229 */ "",
- X /* 230 */ "File not found (prospero)",
- X /* 231 */ "Directory not found (prospero)",
- X /* 232 */ "Symbolic links nested too deep (prospero)",
- X /* 233 */ "Environment not initialized - source vfsetup.source then run vfsetup",
- X /* 234 */ "Can't traverse an external file (prospero)",
- X /* 235 */ "Forwarding chain is too long (prospero)",
- X /* 236 */ "", /* 237 */ "", /* 238 */ "", /* 239 */ "",
- X /* 240 */ "", /* 241 */ "",
- X /* 242 */ "Authentication required (prospero server)",
- X /* 243 */ "Not authorized (prospero server)",
- X /* 244 */ "Not found (prospero server)",
- X /* 245 */ "Bad version number (prospero server)",
- X /* 246 */ "Not a directory (prospero server)",
- X /* 247 */ "Already exists (prospero server)",
- X /* 248 */ "Link with same name already exists (prospero server)",
- X /* 249 */ "", /* 250 */ "",
- X /* 251 */ "Command not implemented on server (dirsrv)",
- X /* 252 */ "Bad format for response (dirsrv)",
- X /* 253 */ "Protocol error (prospero server)",
- X /* 254 */ "Unspecified server failure (prospero server)",
- X /* 255 */ "Generic Failure (prospero)"};
- X
- Xchar *p_warn_text[256] = {
- X /* 0 */ "No warning",
- X /* 1 */ "You are using an old version of this program",
- X /* 2 */ "From server",
- X /* 3 */ "Unrecognized line in response from server",
- X /* 4-254 */ "", "", "", "", "", "", "", "", "", "", "", "", "",
- X "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
- X "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
- X "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
- X "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
- X "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
- X "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
- X "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
- X "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
- X "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
- X "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
- X "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
- X "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
- X "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
- X "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
- X /* 255 */ ""};
- X
- X#ifndef ARCHIE
- Xperrmesg(prefix,no,text)
- X char *prefix;
- X int no;
- X char *text;
- X {
- X fprintf(stderr,"%s%s%s%s\n", (prefix ? prefix : ""),
- X (no ? p_err_text[no] : p_err_text[perrno]),
- X ((text ? (*text ? " - " : "") :
- X (!no && *p_err_string ? " - " : ""))),
- X (text ? text : (no ? "" : p_err_string)));
- X }
- X
- Xsperrmesg(buf,prefix,no,text)
- X char *buf;
- X char *prefix;
- X int no;
- X char *text;
- X {
- X sprintf(buf,"%s%s%s%s\n", (prefix ? prefix : ""),
- X (no ? p_err_text[no] : p_err_text[perrno]),
- X ((text ? (*text ? " - " : "") :
- X (!no && *p_err_string ? " - " : ""))),
- X (text ? text : (no ? "" : p_err_string)));
- X }
- X
- Xpwarnmesg(prefix,no,text)
- X char *prefix;
- X int no;
- X char *text;
- X {
- X fprintf(stderr,"%s%s%s%s\n", (prefix ? prefix : ""),
- X (no ? p_warn_text[no] : p_warn_text[pwarn]),
- X ((text ? (*text ? " - " : "") :
- X (!no && *p_warn_string ? " - " : ""))),
- X (text ? text : (no ? "" : p_warn_string)));
- X }
- X
- Xspwarnmesg(buf,prefix,no,text)
- X char *buf;
- X char *prefix;
- X int no;
- X char *text;
- X {
- X sprintf(buf,"%s%s%s%s\n", (prefix ? prefix : ""),
- X (no ? p_warn_text[no] : p_warn_text[pwarn]),
- X ((text ? (*text ? " - " : "") :
- X (!no && *p_warn_string ? " - " : ""))),
- X (text ? text : (no ? "" : p_warn_string)));
- X }
- X#endif
- END_OF_FILE
- if test 9027 -ne `wc -c <'./perrmesg.c'`; then
- echo shar: \"'./perrmesg.c'\" unpacked with wrong size!
- fi
- # end of './perrmesg.c'
- fi
- if test -f './pfs.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'./pfs.h'\"
- else
- echo shar: Extracting \"'./pfs.h'\" \(13858 characters\)
- sed "s/^X//" >'./pfs.h' <<'END_OF_FILE'
- X/*
- X * Copyright (c) 1989, 1990, 1991 by the University of Washington
- X *
- X * For copying and distribution information, please see the file
- X * <copyright.h>.
- X *
- X * v1.2.0 - 11/19/91 (mmt) - added MSDOS & OS2 stuff
- X * v1.1.2 - 08/30/91 (bpk) - added VMS support
- X * v1.1.1 - 08/20/91 (bpk) - 4.2 -> 4.2B
- X */
- X
- X#include <copyright.h>
- X
- X#ifdef VMS
- X# include <vms.h>
- X#else /* not VMS */
- X# ifndef _TYPES_
- X# include <sys/types.h>
- X# endif /* _TYPES_ */
- X# ifndef IN_H
- X# include <netinet/in.h>
- X# define IN_H
- X# endif
- X#endif /* VMS */
- X
- X#ifndef NULL
- X# if defined(MSDOS)
- X# include <stdio.h>
- X# else
- X# define NULL 0
- X# endif /* MSDOS */
- X#endif /* NULL */
- X
- X#define PFS_RELEASE "Beta.4.2D"
- X/* moved up for vdir_init */
- X#define ZERO(p) bzero((char *)(p), sizeof(*(p)))
- X
- X/* General Definitions */
- X
- X#define MAX_PTXT_LEN 1250 /* Max length of PTEXT structure */
- X#define MAX_PTXT_HDR 32 /* Max offset for start */
- X#define P_ERR_STRING_SZ 100 /* Size of error string */
- X#define MAX_VPATH 1024 /* Max length of virtual pathname */
- X
- X/* Definition of text structure used to pass text around */
- X
- Xstruct ptext {
- X int length; /* Length of text (from start) */
- X char *start; /* Start of text */
- X char dat[MAX_PTXT_LEN+2*MAX_PTXT_HDR];/* The data itself */
- X unsigned long mbz; /* ZERO to catch runaway strings */
- X struct ptext *previous; /* Previous element in list */
- X struct ptext *next; /* Next element in linked list */
- X int seq; /* Sequence Number */
- X};
- X
- Xtypedef struct ptext *PTEXT;
- Xtypedef struct ptext PTEXT_ST;
- X
- X/* Request structure: maintains information about server requests */
- Xstruct preq {
- X int cid; /* Connection ID */
- X short priority; /* Connection priority */
- X int pf_priority; /* Priority assigned by pri_func */
- X int recv_tot; /* Total # of packets received */
- X int trns_tot; /* Total # of packets to transmit */
- X struct ptext *cpkt; /* Current packet being filled in */
- X struct ptext *recv; /* Received packets */
- X struct ptext *trns; /* Transmitted packets */
- X int rcvd_thru; /* Received all packets through # */
- X struct preq *previous; /* Previous element in list */
- X struct preq *next; /* Next element in linked list */
- X struct sockaddr_in fromto; /* Sender/Destination */
- X};
- X
- Xtypedef struct preq *PREQ;
- Xtypedef struct preq PREQ_ST;
- X
- X
- X/* Definition of structure containing information on virtual link */
- X
- Xstruct vlink {
- X int dontfree; /* Flag: don't free this link */
- X char *name; /* Component of path name */
- X char linktype; /* L = Link, U = Union, N= Native */
- X int expanded; /* Has a union link been expanded */
- X char *type; /* Type of object pointed to */
- X struct vlink *filters; /* Filters associated with link */
- X struct vlink *replicas; /* Replicas (* see comment below) */
- X char *hosttype; /* Type of hostname */
- X char *host; /* Files physical location */
- X char *nametype; /* Type of filename */
- X char *filename; /* System level filename */
- X long version; /* Version number of destination */
- X long f_magic_no; /* File's magic number */
- X struct acl *acl; /* ACL for link */
- X long dest_exp; /* Expiration for dest of link */
- X long link_exp; /* Expiration of link itself */
- X char *args; /* Arguments if this is a filter */
- X struct pattrib *lattrib; /* Attributes associated w/ link */
- X struct pfile *f_info; /* Info to be assoicated w/ file */
- X struct vlink *previous; /* Previous elt in linked list */
- X struct vlink *next; /* Next element in linked list */
- X};
- X
- Xtypedef struct vlink *VLINK;
- Xtypedef struct vlink VLINK_ST;
- X
- X/* * Note that vlink->replicas is not really a list of replicas of the */
- X/* object. Instead, it is a list of the objects returned during name */
- X/* resolution that share the same name as the current object. Such */
- X/* an object should only be considered a replica if it also shares */
- X/* the same non-zero magic number. */
- X
- X/* Definition of structure continiaing virtual directory information */
- X
- Xstruct vdir {
- X int version; /* Version of local directory fmt */
- X int inc_native; /* Include the native directory */
- X long magic_no; /* Magic number of current file */
- X struct acl *dacl; /* Default acl for links in dir */
- X struct pfile *f_info; /* Directory file info */
- X struct vlink *links; /* The directory entries */
- X struct vlink *lastlink; /* Last directory entry */
- X struct vlink *ulinks; /* The entries for union links */
- X struct vdir *previous; /* Previous element in linked list */
- X struct vdir *next; /* Next element in linked list */
- X};
- X
- Xtypedef struct vdir *VDIR;
- Xtypedef struct vdir VDIR_ST;
- X
- X/* Initialize directory */
- X#define vdir_init(dir) ZERO(dir)
- X/* XXX: was
- X
- X dir->version = 0; dir->inc_native = 0; \
- X dir->magic_no = 0; dir->f_info = NULL; \
- X dir->links = NULL; dir->lastlink = NULL; \
- X dir->ulinks = NULL; dir->dacl = NULL; \
- X dir->previous = NULL; dir->next = NULL;
- X*/
- X
- X#define vdir_copy(d1,d2) d2->version = d1->version; \
- X d2->inc_native = d1->inc_native; \
- X d2->magic_no = d1->magic_no; \
- X d2->f_info = d1->f_info; \
- X d2->links = d1->links; \
- X d2->lastlink = d1->lastlink; \
- X d2->ulinks = d1->ulinks; \
- X d2->dacl = d1->dacl; \
- X d2->previous = d1->previous; \
- X d2->next = d1->next;
- X
- X/* Values of ->inc_native in vdir structure */
- X#define VDIN_REALONLY -1 /* Include native files, but not . and .. */
- X#define VDIN_NONATIVE 0 /* Do not include files from native directory */
- X#define VDIN_INCLNATIVE 1 /* Include files from native directory */
- X#define VDIN_NATIVEONLY 2 /* All entries in directory are from native dir */
- X#define VDIN_PSEUDO 3 /* Directory is not real */
- X
- X
- X/* Definition of structure containing information on a specific file */
- X
- Xunion avalue {
- X char *ascii; /* Character string */
- X struct vlink *link; /* A link */
- X};
- X
- X
- Xstruct pattrib {
- X char precedence; /* Precedence for link attribute */
- X char *aname; /* Name of the attribute */
- X char *avtype; /* Type of the attribute value */
- X union avalue value; /* Attribute Value */
- X struct pattrib *previous; /* Previous element in linked list */
- X struct pattrib *next; /* Next element in linked list */
- X};
- X
- Xtypedef struct pattrib *PATTRIB;
- Xtypedef struct pattrib PATTRIB_ST;
- X
- X#define ATR_PREC_OBJECT 'O' /* Authoritative answer for object */
- X#define ATR_PREC_LINK 'L' /* Authoritative answer for link */
- X#define ATR_PREC_CACHED 'C' /* Object info cached w/ link */
- X#define ATR_PREC_REPLACE 'R' /* From link (replaces O) */
- X#define ATR_PREC_ADD 'A' /* From link (additional value) */
- X
- X/* **** Incomplete **** */
- Xstruct pfile {
- X int version; /* Version of local finfo format */
- X long f_magic_no; /* Magic number of current file */
- X long exp; /* Expiration date of timeout */
- X long ttl; /* Time to live after reference */
- X long last_ref; /* Time of last reference */
- X struct vlink *forward; /* List of forwarding pointers */
- X struct vlink *backlinks; /* Partial list of back links */
- X struct pattrib *attributes; /* List of file attributes */
- X struct pfile *previous; /* Previous element in linked list */
- X struct pfile *next; /* Next element in linked list */
- X};
- X
- Xtypedef struct pfile *PFILE;
- Xtypedef struct pfile PFILE_ST;
- X
- X/* Definition of structure contining an access control list entry */
- X
- Xstruct acl {
- X int acetype; /* Access Contol Entry type */
- X char *atype; /* Authentication type */
- X char *rights; /* Rights */
- X char *principals; /* Authorized principals */
- X struct restrict *restrictions; /* Restrictions on use */
- X struct acl *previous; /* Previous elt in linked list */
- X struct acl *next; /* Next element in linked list */
- X};
- Xtypedef struct acl *ACL;
- Xtypedef struct acl ACL_ST;
- X
- X#define ACL_NONE 0 /* Nobody authorized by ths entry */
- X#define ACL_DEFAULT 1 /* System default */
- X#define ACL_SYSTEM 2 /* System administrator */
- X#define ACL_OWNER 3 /* Directory owner */
- X#define ACL_DIRECTORY 4 /* Same as directory */
- X#define ACL_ANY 5 /* Any user */
- X#define ACL_AUTHENT 6 /* Authenticated principal */
- X#define ACL_LGROUP 7 /* Local group */
- X#define ACL_GROUP 8 /* External group */
- X#define ACL_ASRTHOST 10 /* Check host and asserted userid */
- X#define ACL_TRSTHOST 11 /* ASRTHOST from privileged port */
- X
- X
- X/* Definition of structure contining access restrictions */
- X/* for future extensions */
- Xstruct restrict {
- X struct acl *previous; /* Previous elt in linked list */
- X struct acl *next; /* Next element in linked list */
- X};
- X
- X/* Definitions for send_to_dirsrv */
- X#define CLIENT_DIRSRV_TIMEOUT 4 /* time between retries */
- X#define CLIENT_DIRSRV_BACKOFF(x) (2 * x) /* Backoff algorithm */
- X#define CLIENT_DIRSRV_RETRY 3 /* retry this many times */
- X
- X/* Definitions for rd_vlink and rd_vdir */
- X#define SYMLINK_NESTING 10 /* Max nesting depth for sym links */
- X
- X/* Definition fo check_acl */
- X#define ACL_NESTING 10 /* Max depth for ACL group nesting */
- X
- X/* Flags for mk_vdir */
- X#define MKVD_LPRIV 1 /* Minimize privs for creator in new ACL */
- X
- X/* Flags for get_vdir */
- X#define GVD_UNION 0 /* Do not expand union links */
- X#define GVD_EXPAND 1 /* Expand union links locally */
- X#define GVD_LREMEXP 3 /* Request remote expansion of local links */
- X#define GVD_REMEXP 7 /* Request remote expansion of all links */
- X#define GVD_VERIFY 8 /* Only verify args are for a directory */
- X#define GVD_FIND 16 /* Stop expanding when match is found */
- X#define GVD_ATTRIB 32 /* Request attributes from remote server */
- X#define GVD_NOSORT 64 /* Do not sort links when adding to dir */
- X
- X/* Flags for rd_vdir */
- X#define RVD_UNION GVD_UNION
- X#define RVD_EXPAND GVD_EXPAND
- X#define RVD_LREMEXP GVD_LREMEXP
- X#define RVD_REMEXP GVD_REMEXP
- X#define RVD_DFILE_ONLY GVD_VERIFY /* Only return ptr to dir file */
- X#define RVD_FIND GVD_FIND
- X#define RVD_ATTRIB GVD_ATTRIB
- X#define RVD_NOSORT GVD_NOSORT
- X#define RVD_NOCACHE 128
- X
- X/* Flags for add_vlink */
- X#define AVL_UNION 1 /* Link is a union link */
- X
- X/* Flags for vl_insert */
- X#define VLI_NOCONFLICT 0 /* Do not insert links w/ conflicting names */
- X#define VLI_ALLOW_CONF 1 /* Allow links with conflicting names */
- X#define VLI_NOSORT 2 /* Allow conflicts and don't sort */
- X
- X/* Flags for mapname */
- X#define MAP_READWRITE 0 /* Named file to be read and written */
- X#define MAP_READONLY 1 /* Named file to be read only */
- X
- X/* Flags for modify_acl */
- X#define MACL_NOSYSTEM 0x01
- X#define MACL_NOSELF 0x02
- X#define MACL_DEFAULT 0x08
- X#define MACL_SET 0x0C
- X#define MACL_INSERT 0x14
- X#define MACL_DELETE 0x10
- X#define MACL_ADD 0x1C
- X#define MACL_SUBTRACT 0x18
- X#define MACL_LINK 0x00
- X#define MACL_DIRECTORY 0x20
- X#define MACL_OBJECT 0x60
- X#define MACL_INCLUDE 0x40
- X
- X#define MACL_OP (MACL_DEFAULT|MACL_SET|MACL_INSERT|\
- X MACL_DELETE|MACL_ADD|MACL_SUBTRACT)
- X
- X#define MACL_OTYPE (MACL_LINK|MACL_DIRECTORY|MACL_OBJECT|MACL_INCLUDE)
- X
- X/* Access methods returned by Pget_am */
- X#define P_AM_ERROR 0
- X#define P_AM_FTP 1
- X#define P_AM_AFTP 2 /* Anonymous FTP */
- X#define P_AM_NFS 4
- X#define P_AM_KNFS 8 /* Kerberized NFS */
- X#define P_AM_AFS 16
- X
- X/* Return codes */
- X
- X#define PSUCCESS 0
- X#define PFAILURE 255
- X
- X/* Hush up warnings. */
- Xvoid vllfree();
- X
- X/* Procedures in libpfs.a */
- X
- Xchar *pget_wdhost(), *pget_wdfile(), *pget_wd(), *pget_hdhost();
- Xchar *pget_hdfile(), *pget_hd(), *pget_rdhost(), *pget_rdfile();
- Xchar *pget_dhost(), *pget_dfile(), *pget_vsname(), *nlsindex();
- Xchar *sindex(), *strtok(), *nxtline(), *unquote(), *stcopy();
- Xchar *stcopyr(), *readheader(), *month_sname();
- X
- Xlong asntotime();
- X
- XPTEXT ptalloc();
- XPTEXT dirsend();
- X
- XPREQ pralloc();
- XPREQ get_next_request();
- X
- XVLINK rd_slink();
- XVLINK rd_vlink();
- XVLINK vl_delete();
- XVLINK vlalloc();
- XVLINK vlcopy();
- X
- XPFILE pfalloc();
- X
- XPATTRIB parse_attribute();
- XPATTRIB atalloc();
- XPATTRIB pget_at();
- X
- XACL acalloc();
- XACL get_acl();
- X
- X/* Miscellaneous useful definitions */
- X#ifndef TRUE
- X#define TRUE 1
- X#define FALSE 0
- X#endif
- X
- X#define AUTHORIZED 1
- X#define NOT_AUTHORIZED 0
- X#define NEG_AUTHORIZED -1
- X
- X#ifndef NULL
- X#define NULL 0
- X#endif
- X
- X#define FAILED -1
- END_OF_FILE
- if test 13858 -ne `wc -c <'./pfs.h'`; then
- echo shar: \"'./pfs.h'\" unpacked with wrong size!
- fi
- # end of './pfs.h'
- fi
- if test -f './vms/network.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'./vms/network.h'\"
- else
- echo shar: Extracting \"'./vms/network.h'\" \(4939 characters\)
- sed "s/^X//" >'./vms/network.h' <<'END_OF_FILE'
- X/* Miscellaneous things for the networking library. */
- X
- X/* Actually an itemlist_3, but can be used for itemlist_2's. */
- Xstruct itemlist
- X{
- X short length;
- X short code;
- X char *dataptr;
- X short *retlenptr;
- X};
- X
- Xunion socket_addr
- X{
- X struct sockaddr_in in;
- X};
- X
- X#define TCP$SEND (IO$_WRITEVBLK)
- X#define TCP$RECEIVE (IO$_READVBLK)
- X#define TCP$OPEN (IO$_CREATE)
- X#define TCP$CLOSE (IO$_DELETE)
- X#define TCP$ABORT (IO$_DEACCESS)
- X#define TCP$STATUS (IO$_ACPCONTROL)
- X#define TCP$INFO (IO$_MODIFY)
- X#define GTHST (IO$_SKIPFILE)
- X
- X#define IO$_SEND (IO$_WRITEVBLK)
- X#define IO$_RECEIVE (IO$_READVBLK)
- X#ifndef IO$S_FCODE
- X#define IO$S_FCODE 0x0006
- X#endif
- X#define IO$_SOCKET (IO$_ACCESS | (0 << IO$S_FCODE))
- X#define IO$_BIND (IO$_ACCESS | (1 << IO$S_FCODE))
- X#define IO$_LISTEN (IO$_ACCESS | (2 << IO$S_FCODE))
- X#define IO$_ACCEPT (IO$_ACCESS | (3 << IO$S_FCODE))
- X#define IO$_CONNECT (IO$_ACCESS | (4 << IO$S_FCODE))
- X#define IO$_SETSOCKOPT (IO$_ACCESS | (5 << IO$S_FCODE))
- X#define IO$_GETSOCKOPT (IO$_ACCESS | (6 << IO$S_FCODE))
- X#define IO$_IOCTL (IO$_ACCESS | (8 << IO$S_FCODE))
- X#define IO$_ACCEPT_WAIT (IO$_ACCESS | (10 << IO$S_FCODE))
- X#define IO$_NETWORK_PTY (IO$_ACCESS | (11 << IO$S_FCODE))
- X#define IO$_SHUTDOWN (IO$_ACCESS | (12 << IO$S_FCODE))
- X#define IO$_GETSOCKNAME (IO$_ACCESS | (13 << IO$S_FCODE))
- X#define SETCHAR_HANDOFF (1<<2)
- X
- X#define NFB$C_DECLNAME 0x15
- X
- X#define TIMER_EFN 1
- X#define TERM_EFN 2
- X#define BUF_SIZE 2000
- X
- X#define INITIALISED 0
- X#define ACTIVE_CONNECTION 1
- X#define PASSIVE_CONNECTION 2
- X#define LISTENING 3
- X#define HANDED_OFF 4
- X
- Xstatic struct fd_entry
- X{
- X unsigned short int channel; /* vms channel assigned to this socket */
- X unsigned short int iosb[4]; /* returned status block */
- X int fd_buff_size; /* number of chrs in buffer still to be read */
- X int accept_pending; /* a call is waiting to be accepted */
- X int connect_pending; /* a connect is outstanding*/
- X int connected; /* this descriptor is connected */
- X unsigned char *fd_buff; /* pointer to buffer dyn assigned */
- X unsigned char *fd_leftover; /* pointer to any chrs still to be read */
- X FILE *fptr; /* we need to assgn a file ptr for stream io */
- X int s; /* socket number - needed in the ast's */
- X int namelen; /* our socket address name */
- X union socket_addr name;
- X short int fromdummy; /* wg - accept wants an int - recvfrom wants a short!!*/
- X short int fromlen; /* the from socket address name */
- X union socket_addr from;
- X int tolen; /* wg - sendto wants an int*/
- X union socket_addr to; /* the to socket address name */
- X int passive; /* still needed because of x25 close ambig */
- X int backlog; /* backlog - not handled well! */
- X int domain; /* domain of socket AF_INET or AF_X25 */
- X int type; /* type of socket stream or datagram */
- X int protocol; /* protocol of socket - ignored */
- X int mbx_channel; /* mailbox channel - needed for x25 */
- X unsigned char mbx_buff[255]; /* mailbox buffer */
- X unsigned short int miosb[4]; /* mailbox status block */
- X int ncb_size; /* x25 connection information */
- X unsigned char ncb[128];
- X unsigned char masklen; /* x25 user data mask */
- X unsigned char mask[16];
- X int need_header; /* x25 header field gives data status if req*/
- X int send_type; /* x25 data packet type eg more bit set etc */
- X int status; /* status of socket */
- X int closed_by_remote; /* flag for remote dropouts */
- X int read_outstanding; /* flag so we don't hang two reads */
- X int cmu_open; /* flag to say whether a cmu open was hung */
- X int x25_listener; /* flag to say we are an x25 listener */
- X int oob_type; /* handles interrupt messages */
- X int mother; /* mother socket for X25 accepts */
- X int child; /* child socket for X25 accepts */
- X int no_more_accepts; /* don't accept anymore calls */
- X char int_data; /* interrupt data - only 1 char supported */
- X int non_blocking; /* don't block on a read if no data */
- X int sig_req; /* generate SIGIO on data ready */
- X struct itemlist rhost; /* descriptor pointing to "p[].from" info for UCX */
- X unsigned short ucx_accept_chan; /* Channel returned by a UCX accept via hang_an_accept */
- X} p[32];
- X
- X/* So we can handle select on terminal input. */
- Xstatic struct term_entry
- X{
- X int chan;
- X short int iosb[4];
- X short int char_available;
- X short int read_outstanding;
- X char c[1];
- X} terminal =
- X
- X{
- X -1, 0, 0, 0, 0, 0, 0
- X};
- X
- X#define CMU 1
- X#define WG 2
- X#define NONE 3
- X#define TGV 4
- X#define UCX 5
- Xstatic int tcp_make = 0;
- X
- Xstruct descriptor
- X{
- X int size;
- X char *ptr;
- X};
- X
- X/* Initialize certain things 1st time thru. */
- Xstatic int p_initialised = 0;
- X
- X/* A routine to point SIGALRM and SIGURG at. */
- Xstatic int
- Xsi_dummy ()
- X{
- X}
- Xstatic int (*alarm_function) () = si_dummy;
- Xstatic int (*sigurg_function) () = si_dummy;
- X
- XFILE *fdopen ();
- Xstatic set_tcp_make ();
- Xstatic char *getdevicename ();
- END_OF_FILE
- if test 4939 -ne `wc -c <'./vms/network.h'`; then
- echo shar: \"'./vms/network.h'\" unpacked with wrong size!
- fi
- # end of './vms/network.h'
- fi
- echo shar: End of archive 3 \(of 5\).
- cp /dev/null ark3isdone
- MISSING=""
- for I in 1 2 3 4 5 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 5 archives.
- rm -f ark[1-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-