home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / hacking / internet / desc03.sh / pathname.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-04  |  867 b   |  37 lines

  1. /* pathname.c -    Construct a pathname from a directory and basename
  2.  *
  3.  * SYNOPSIS
  4.  *    char *pathname (char *directory, char *name)
  5.  *
  6.  * RETURNS
  7.  *    Returns "directory" + "/" + "name" (copied into static
  8.  *    storage), or a pointer to "name" if "directory" is null.
  9.  *
  10.  * Copyright (c) 1991, 1992 Tim Cook.
  11.  * Non-profit distribution allowed.  See README for details.
  12.  */
  13.  
  14. static char rcsid[] = "$Id: pathname.c,v 1.1 1992/12/02 03:48:38 tim Exp $";
  15.  
  16. #include "config.h"
  17. #include <sys/param.h>
  18.  
  19. #ifndef MAXPATHLEN
  20. #define MAXPATHLEN    1024
  21. #endif
  22.  
  23.  
  24. char *pathname (directory, name)
  25.    char *directory, *name ;
  26. {
  27.    static char return_value[MAXPATHLEN+1] ;
  28.  
  29.    if (directory && *directory != EOS) {
  30.       strcpy (return_value, directory) ;
  31.       strcat (return_value, "/") ;
  32.       strcat (return_value, name) ;
  33.       return return_value ; }
  34.    else
  35.       return name ;
  36.    }
  37.