1: static char *rcsid = "$Header$";
   2: /*
   3:  * pcp - copy files
   4:  *
   5:  * Author: Peter J. Nicklin
   6:  */
   7: #include "bin.h"
   8: #include "macro.h"
   9: #include "null.h"
  10: #include "path.h"
  11: #include "yesno.h"
  12: 
  13: char *PGN = "pcp";          /* program name */
  14: 
  15: main(argc, argv)
  16:     int argc;
  17:     char **argv;
  18: {
  19:     extern int PPDEBUG;     /* project pathname debug flag */
  20:     char **nargv;           /* new argument list */
  21:     char *strsav();         /* save string somewhere */
  22:     int filecount = 0;      /* # of valid files or directories */
  23:     int nargi = 0;          /* new argument list index */
  24:     int xppath();           /* expand project pathname */
  25:     PATH pathbuf;           /* pathname struct buffer */
  26: 
  27:     nargv = argv;
  28:     nargv[nargi++] = "cp";
  29: 
  30:     {
  31:     register char *s;       /* option pointer */
  32:     while (--argc > 0 && **++argv == '-')
  33:         for (s = argv[0]+1; *s != '\0'; s++)
  34:             switch (*s)
  35:                 {
  36:                 case 'D':
  37:                     PPDEBUG = YES;
  38:                     break;
  39:                 default:
  40:                     nargv[nargi++] = *argv;
  41:                     break;
  42:                 }
  43:     }
  44:     if (argc < 2)
  45:         fatal("usage: %s [-i] f1 f2; or %s [-i] f1 ... fn d1", PGN, PGN);
  46: 
  47:     /* expand project pathnames and attach to new argument list */
  48:     for (; argc > 1; argc--, argv++)
  49:         if (xppath(*argv, &pathbuf) == -1)
  50:             patherr(*argv);
  51:         else switch (pathbuf.p_mode & P_IFMT)
  52:             {
  53:             case P_IFNEW:
  54:                 patherr(*argv);
  55:                 break;
  56:             case P_IFPDIR:
  57:                 warn("can't copy project directory %s", *argv);
  58:                 break;
  59:             case P_IFHOME:
  60:             case P_IFPROOT:
  61:                 warn("can't copy project %s", *argv);
  62:                 break;
  63:             default:
  64:                 nargv[nargi++] = strsav(pathbuf.p_path);
  65:                 filecount++;
  66:                 break;
  67:             }
  68: 
  69:     if (filecount == 0)
  70:         exit(1);
  71:     else if (xppath(*argv, &pathbuf) == -1)
  72:         {
  73:         patherr(*argv);
  74:         exit(1);
  75:         }
  76:     else    {
  77:         nargv[nargi++] = strsav(pathbuf.p_path);
  78:         nargv[nargi] = NULL;
  79:         }
  80: 
  81:     /* execute "cp" command */
  82:     execv(CP, nargv);
  83:     fatal("can't exec %s", CP);
  84: }

Defined functions

main defined in line 15; never used

Defined variables

PGN defined in line 13; used 2 times
  • in line 45(2)
rcsid defined in line 1; never used
Last modified: 1985-07-03
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 863
Valid CSS Valid XHTML 1.0 Strict