1: 
   2: #include <stdio.h>
   3: #include <ctype.h>
   4: #include <strings.h>
   5: 
   6: main(argc,argv)
   7:     int argc;
   8:     char *argv[];
   9: 
  10: {
  11: 
  12: char cmd[1000];
  13: char *release;
  14: FILE *dirs;
  15: FILE *files;
  16: FILE *mover;
  17: FILE *popen();
  18: FILE *script;
  19: char dirname[1000];
  20: char filename[1000];
  21: char fixedname[1000];
  22: char fixedpath[1000];
  23: char tapename[10];
  24: char *scriptname = "UNPACK.COM";
  25: char *altscript = "/tmp/UNPACK.COMXXXXXX";
  26: char *startname = "AAAAAAAAA";
  27: int i;
  28: int j;
  29: char *k;
  30: int pathlen;
  31: int dot;
  32: int pipeout=0;
  33: 
  34:     if(argc < 2) usage();
  35:     if(*argv[1] == '-') {
  36:         mover = stdout;
  37:         pipeout=1;
  38:     } else {
  39:         mover = fopen("vmsprep.namelist","w");
  40:     }
  41:     strcpy(tapename,startname);
  42:     if(pipeout) {
  43:         mktemp(altscript);
  44:         script = fopen(altscript,"w");
  45:     } else {
  46:         script = fopen(scriptname,"w");
  47:     }
  48:     for(j=1;j<argc;j++) {
  49:         if(j==1 && *argv[j]=='-') continue;
  50:         release = argv[j];
  51:         strcpy(dirname,release);
  52:         for(k=index(dirname,'/');k;k=index(k+1,'/')) {
  53:             *k='\0';
  54:             fprintf(script,"$ CREATE/DIR [.%s] \n",dirname);
  55:             strcpy(dirname,release);
  56:         }
  57:         sprintf(cmd,
  58:             "find %s \\! \\( -name RCS -o -name \\*,v -o -name SCCS -o -name s.\\* \\) -type d -print\n", release);
  59:         dirs = popen(cmd,"r");
  60:         while(!feof(dirs)) {
  61:             *dirname = NULL;
  62:             fscanf(dirs," %s ",dirname);
  63:             if(*dirname == NULL) continue;
  64:             for(i=0;i<strlen(dirname);i++) {
  65:                 if(dirname[i]=='/') {
  66:                     dirname[i]='.';
  67:                 } else if (dirname[i]=='.') {
  68:                     dirname[i]='Z';
  69:                     fprintf(stderr,"vmsprep: warning - dot in filename illegal-");
  70:                     fprintf(stderr,"dot replaced by 'Z' %s\n",filename);
  71:                 } else if (!(isalpha(dirname[i]) || isdigit(dirname[i]))) {
  72:                     fprintf(stderr," error:  bad character in directory name %s\n",
  73:                             dirname);
  74:                 } else if(islower(dirname[i])) {
  75:                     dirname[i]=toupper(dirname[i]);
  76:                 }
  77:             }
  78:             fprintf(script,"$ CREATE/DIR [.%s] \n",dirname);
  79:         }
  80:         pclose(dirs);
  81: 
  82:         sprintf(cmd,
  83:             "find %s \\! \\( -name RCS -o -name \\*,v -o -name SCCS -o -name s.\\* \\) -type f -print\n", release);
  84:         files = popen(cmd,"r");
  85:         while(!feof(files)) {
  86:             fscanf(files," %s ",filename);
  87:             if(*filename == NULL) continue;
  88:             k = rindex(filename,'/') ;
  89:             if(k != 0) {
  90:                 pathlen = k - filename;
  91:             } else {
  92:                 pathlen=0;
  93:                 k = filename - 1;
  94:             }
  95:             strncpy(fixedpath,filename,pathlen);
  96:             fixedpath[pathlen]='\0';
  97:             strcpy(fixedname,k+1);
  98:             for(i=0;i<pathlen;i++) {
  99:                 if(fixedpath[i]=='/') {
 100:                     fixedpath[i]='.';
 101:                 } else if (fixedpath[i]=='.') {
 102:                     fixedpath[i]='Z';
 103:                 } else if (!(isalpha(fixedpath[i]) || isdigit(fixedpath[i]))) {
 104:                     fprintf(stderr," error:  bad character in file name %s\n",
 105:                             filename);
 106:                 } else if(islower(fixedpath[i])) {
 107:                     fixedpath[i]=toupper(fixedpath[i]);
 108:                 }
 109:             }
 110:             for(i=0;i<strlen(fixedname);i++) {
 111:                 if(fixedname[i]=='/') {
 112:                     fixedname[i]='.';
 113:                 } else if (fixedname[i]=='.') {
 114:                     dot++;
 115:                     if(dot != 1) fixedname[i]='Z';
 116:                 } else if (!(isalpha(fixedname[i]) || isdigit(fixedname[i]))) {
 117:                     fprintf(stderr," error:  bad character in file name %s\n",
 118:                             filename);
 119:                     fixedname[i]='Z';
 120:                 } else if(islower(fixedname[i])) {
 121:                     fixedname[i]=toupper(fixedname[i]);
 122:                 }
 123:             }
 124:             if(dot >1 )
 125:                 fprintf(stderr,"error:  too many dots in filename %s \n",
 126:                     fixedname);
 127:             sprintf(cmd,"%s %s.MOV\n", filename,tapename);
 128:             fprintf(mover,"%s",cmd);
 129:             if(*fixedpath != NULL) {
 130:                 fprintf(script,"$ RENAME %s.MOV [.%s]%s%s\n",tapename,fixedpath,
 131:                         fixedname,dot==0?".":"");
 132:             } else {
 133:                 fprintf(script,"$ RENAME %s.MOV []%s%s\n",tapename,fixedname,
 134:                         dot==0?".":"");
 135:             }
 136:             dot=0;
 137:             bumpname(tapename);
 138:         }
 139:     pclose(files);
 140:     }
 141:     fclose(script);
 142:     if(pipeout) fprintf(mover,"%s ",altscript);
 143:     fprintf(mover,"%s\n",scriptname);
 144:     fclose(mover);
 145: }
 146: 
 147: bumpname(name)
 148:     char name[10];
 149: 
 150: {
 151: int i;
 152:     for(i=8;i>=0;i--) {
 153:         name[i]++;
 154:         if(name[i] > 'Z') {
 155:             name[i] = 'A';
 156:         } else {
 157:             return;
 158:         }
 159:     }
 160: }
 161: usage() {
 162:     fprintf(stderr,"vmsprep:  usage:  vmsprep dirname [dirname...] \n");
 163:     exit();
 164: }

Defined functions

bumpname defined in line 147; used 1 times
main defined in line 6; never used
usage defined in line 161; used 1 times
  • in line 34
Last modified: 1985-08-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3318
Valid CSS Valid XHTML 1.0 Strict