home *** CD-ROM | disk | FTP | other *** search
- /*
- * Name: getpath -- return the full usenet path of the given name
- *
- * Paramaters: sysname (input) -- The system name to be expanded
- * pathname (output) The usenet path of the given system name
- * pathfile (input) the file to search for the system name
- *
- * Returns: EX_OK -- path found
- * EX_NOHOST -- path not found
- * EX_NOINPUT-- unable to open usemap
- *
- * Author: J. Donnelly 3/82
- *
- */
-
- /* 22-jun-83 Sheppard
- * modified to rewind path file (if open), rather than open again
- *
- * $Log: getpath.c,v $
- * Revision 1.9 85/11/14 20:21:49 sob
- * Added #ifdef DEBUG to allow compilation without DEBUG
- *
- * Revision 1.8 85/11/08 03:04:49 sob
- * release version
- *
- * Revision 1.7 85/09/30 02:47:40 sob
- * Altered to use path filename from global variable.
- *
- * Revision 1.6 85/08/03 00:48:57 UUCP
- * Cleaned up with lint.
- * Stan Barber
- *
- * Revision 1.5 85/07/19 17:45:13 UUCP
- * Added \t as a valid seperation character for the database
- * in the non DBM case. This is what pathalias uses.
- *
- * Revision 1.4 85/07/19 16:44:07 UUCP
- * revised to return proper things in accordance with sysexits
- * Stan
- *
- * Revision 1.3 85/07/11 19:30:31 sob
- * added "uuconf.h" include file and deleted duplicated information
- *
- * Revision 1.2 85/07/10 18:30:59 sob
- * updated to add DBM capabilities
- * Stan Barber, Baylor College of Medicine
- *
- * Revision 1.1 85/07/10 18:03:28 sob
- * Initial revision
- *
- */
-
- #include "uuconf.h"
-
- static char rcsid[] = "$Header: getpath.c,v 1.9 85/11/14 20:21:49 sob Exp $";
-
-
-
- FILE * fopen (), *in;
-
- getpath (sysname, pathname)
- char *sysname, *pathname;
- {
- char name[NAMESIZ],*p,t;
-
- #ifdef DBM
- datum lhs,rhs;
- #endif
- #ifdef DEBUG
- if (Debug>2)
- printf("In getpath: Sysname = %s, Pathfile = %s\n",sysname,paths);
- #endif
- #ifdef DBM
- if (dbminit(paths) <0) return(EX_NOINPUT);
- lhs.dptr = sysname;
- lhs.dsize = strlen(sysname)+1;
- rhs = fetch(lhs);
- if (rhs.dptr == NULL) return(EX_NOHOST); /* no name found */
- strcpy(pathname,rhs.dptr);
- return(EX_OK); /* system name found */
-
- #else
- if (in == NULL) {
- if ((in = fopen(paths, "r")) == NULL)
- return(EX_NOINPUT);
- }
- else
- rewind(in);
-
- for (;;)
- {
- p = &name[0];
- while ((t = getc(in)) != EOF && (*p++ = t) != ' ' && t != '\t'); /* read the system name */
- if( t == EOF) return(EX_NOHOST);
- *--p = '\0'; /* set end of string */
- p = &name[0];
- #ifdef DEBUG
- if (Debug>4) printf("Found %s\n",p);
- #endif
- if (strcmp (p,sysname) == 0)
- break;
- while ((getc (in) != '\n')); /* skip this path */
- }
-
- p = pathname; /* save start loc of pathname */
- while ((*pathname++ = getc (in)) != '\n');
- *--pathname = '\0';
- pathname = p;
- return(EX_OK); /* system name found */
- #endif
- }
-