home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 4 / CDPD_IV.bin / networking / uucp / amigauucpsrc / lib / expand_path.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-29  |  651 b   |  37 lines

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