home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / fish / telecom / uucp_442 / src / lib / expand_path.c < prev    next >
C/C++ Source or Header  |  1990-10-08  |  753b  |  38 lines

  1.  
  2. /*
  3.  *  EXPAND_PATH.C
  4.  *
  5.  *  $Header: Beta:src/uucp/src/lib/RCS/lockfile.c,v 1.1 90/02/02 12:08:31 dillon Exp Locker: dillon $
  6.  */
  7.  
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include "config.h"
  11.  
  12. Prototype char *expand_path(const char *, const char *);
  13.  
  14. char *
  15. expand_path(const char *path, const char *file_name)
  16. {
  17.     register const char *p;
  18.     static char name[256];
  19.  
  20.     /*
  21.      * If the file_name is a full path name, use that.
  22.      */
  23.  
  24.     p = strchr(file_name, ':');
  25.  
  26.     if ((p != NULL) && (p != file_name))
  27.     return ((char *)file_name);
  28.  
  29.     /*
  30.      * If the path ends in ':' or '/', don't add separator!
  31.      */
  32.  
  33.     p = &path[strlen(path)-1];
  34.     sprintf(name, (*p == ':' || *p == '/') ? "%s%s" : "%s/%s", path, file_name);
  35.     return (name);
  36. }
  37.  
  38.