1: #include "uucp.h"
   2: #include <sys/types.h>
   3: #include <sys/stat.h>
   4: 
   5: 
   6: /*******
   7:  *	expfile(file)	expand file name
   8:  *	char *file;
   9:  *
  10:  *	return codes:  none
  11:  */
  12: 
  13: expfile(file)
  14: char *file;
  15: {
  16:     char *fpart;
  17:     char user[20], *up;
  18:     char full[100];
  19:     int uid;
  20: 
  21:     switch(file[0]) {
  22:     case '/':
  23:         return;
  24:     case '~':
  25:         for (fpart = file + 1, up = user; *fpart != '\0'
  26:             && *fpart != '/'; fpart++)
  27:                 *up++ = *fpart;
  28:         *up = '\0';
  29:         if (gninfo(user, &uid, full) != 0) {
  30:             strcpy(full, Spool);
  31:         }
  32: 
  33:         strcat(full, fpart);
  34:         strcpy(file, full);
  35:         return;
  36:     default:
  37:         strcpy(full, Wrkdir);
  38:         strcat(full, "/");
  39:         strcat(full, file);
  40:         strcpy(file, full);
  41:         return;
  42:     }
  43: }
  44: 
  45: 
  46: /***
  47:  *	isdir(name)	check if directory name
  48:  *	char *name;
  49:  *
  50:  *	return codes:  0 - not directory  |  1 - is directory
  51:  */
  52: 
  53: isdir(name)
  54: char *name;
  55: {
  56:     int ret;
  57:     struct stat s;
  58: 
  59:     ret = stat(name, &s);
  60:     if (ret < 0)
  61:         return(0);
  62:     if ((s.st_mode & S_IFMT) == S_IFDIR)
  63:         return(1);
  64:     return(0);
  65: }
  66: 
  67: 
  68: /***
  69:  *	mkdirs(name)	make all necessary directories
  70:  *	char *name;
  71:  *
  72:  *	return 0  |  FAIL
  73:  */
  74: 
  75: mkdirs(name)
  76: char *name;
  77: {
  78:     int ret;
  79:     char cmd[100], dir[100], *p;
  80: 
  81:     for (p = dir + 1;; p++) {
  82:         strcpy(dir, name);
  83:         if ((p = index(p, '/')) == NULL)
  84:             return(0);
  85:         *p = '\0';
  86:         if (isdir(dir))
  87:             continue;
  88:         sprintf(cmd, "mkdir %s", dir);
  89:         DEBUG(4, "mkdir - %s\n", dir);
  90:         ret = shio(cmd, NULL, NULL, User);
  91:         if (ret != 0)
  92:             return(FAIL);
  93:     }
  94: }

Defined functions

expfile defined in line 13; used 24 times
isdir defined in line 53; used 4 times
mkdirs defined in line 75; used 1 times
Last modified: 1979-01-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 589
Valid CSS Valid XHTML 1.0 Strict