# include "../hdr/defines.h" # include "../hdr/had.h" SCCSID(@(#)admin.c 4.1); /* Program to create new SCCS files and change parameters of existing ones. Arguments to the program may appear in any order and consist of keyletters, which begin with '-', and named files. Named files which do not exist are created and their parameters are initialized according to the given keyletter arguments, or are given default values if the corresponding keyletters were not supplied. Named files which do exist have those parameters corresponding to given key-letter arguments changed and other parameters are left as is. If a directory is given as an argument, each SCCS file within the directory is processed as if it had been specifically named. If a name of '-' is given, the standard input is read for a list of names of SCCS files to be processed. Non-SCCS files are ignored. Files created are given mode 444. */ # define MINR 1 /* minimum release number */ # define MAXR 9999 /* maximum release number */ # define MAXNAMES 9 # define COPY 0 # define NOCOPY 1 char *ifile, *tfile; char *z; /* for validation program name */ char had[26], had_flag[26], rm_flag[26]; char *Comments, *Mrs; char Valpgm[] "/usr/local/val"; int irel, fexists, num_files; int VFLAG 0; int Domrs; char *Sflags[]; char *anames[MAXNAMES], *enames[MAXNAMES]; char *flag_p[26]; int asub, esub; int check_id; int Did_id; main(argc,argv) int argc; char *argv[]; { register int j; register char *p; char c, f; int i, testklt; extern admin(); extern int Fcnt; struct sid sid; /* Set flags for 'fatal' to issue message, call clean-up routine and terminate processing. */ Fflags = FTLMSG | FTLCLN | FTLEXIT; testklt = 1; /* The following loop processes keyletters and arguments. Note that these are processed only once for each invocation of 'main'. */ for(j=1; j 5) || (i < MINR) || (i > MAXR)) fatal("floor out of range (ad23)"); break; case CEILFLAG: /* ceiling */ if ((i = patoi(p)) == -1) fatal("ceiling not numeric (ad24)"); if ((size(p) > 5) || (i < MINR) || (i > MAXR)) fatal("ceiling out of range (ad25)"); break; case DEFTFLAG: /* default sid */ if (!(*p)) fatal("no default sid (ad14)"); chksid(sid_ab(p,&sid),&sid); break; case TYPEFLAG: /* type */ case MODFLAG: /* module name */ if (!(*p)) fatal(sprintf(Error, "flag %c has no value (ad2)",f)); break; default: fatal("unknown flag (ad3)"); } if (had_flag[f - 'a']++) fatal("flag twice (ad4)"); flag_p[f - 'a'] = p; break; case 'r': /* initial release number supplied */ if ((irel = patoi(p)) == -1) fatal("r arg not numeric (ad6)"); if ((size(p) > 5) || (irel < MINR) || (irel > MAXR)) fatal("r out of range (ad7)"); break; case 'n': /* creating new SCCS file */ case 'h': /* only check hash of file */ case 'z': /* zero the input hash */ break; case 'a': /* user-name allowed to make deltas */ testklt = 0; if (!(*p)) fatal("bad a argument (ad8)"); if (asub > MAXNAMES) fatal("too many 'a' keyletters (ad9)"); anames[asub++] = p; break; case 'e': /* user-name to be removed */ testklt = 0; if (!(*p)) fatal("bad e argument (ad10)"); if (esub > MAXNAMES) fatal("too many 'e' keyletters (ad11)"); enames[esub++] = p; break; default: fatal("unknown key letter (cm1)"); } if (had[c - 'a']++ && testklt++) fatal("key letter twice (cm2)"); argv[j] = 0; } else num_files++; if (num_files == 0) fatal("missing file arg (cm3)"); if (HADI && num_files > 1) /* only one file allowed with `i' */ fatal("more than one file (ad15)"); setsig(); /* Change flags for 'fatal' so that it will return to this routine (main) instead of terminating processing. */ Fflags =& ~FTLEXIT; Fflags =| FTLJMP; /* Call 'admin' routine for each file argument. */ for (j=1; jd_datetime,p); while (*p++) ; --p; *p++ = ' '; copy("by",p); while (*p++) ; --p; *p++ = ' '; copy(dt->d_pgmr,p); while (*p++) ; --p; *p++ = '\n'; *p = 0; return(str); } putmrs(pkt) struct packet *pkt; { register char **argv; char str[64]; extern char *Varg[]; for (argv = &Varg[VSTART]; *argv; argv++) putline(pkt,sprintf(str,"%c%c %s\n",CTLCHAR,MRNUM,*argv)); }