static char vprmSCCSid
[] = "@(#)vprm.c 1.3\t%G%";
fprintf(stderr
, "usage: vprm [ id ... ] [ filename ... ] [ user ... ]\n");
/* Look for something to delete both in Varian and Versatec spool dirs. */
delete("Varian", "/usr/spool/vad", argc
, argv
);
delete("Versatec", "/usr/spool/vpd", argc
, argv
);
* Look through the argv list for things to delete.
delete(devname
, spooldir
, argc
, argv
)
char *devname
, *spooldir
, *argv
[];
DIR *dir
; /* The spool dir. */
struct direct
*dirp
; /* An entry read from the spool dir.*/
int deletion
= 0; /* Flag noting something has been deleted. */
/* Change to the spool directory. */
if (chdir(spooldir
) < 0) {
if ((dir
= opendir(".")) == NULL
) {
* Loop through the args and the spool dir, looking for a spool
* command file (has a prefix of 'df'),
* and trying to match it with the argument.
while ((dirp
= readdir(dir
)) != NULL
) {
if (dirp
->d_name
[0] == 'd' &&
dirp
->d_name
[1] == 'f' &&
delcheck(dirp
->d_name
, *argv
)) {
printf(" removing %s", &(dirp
->d_name
[3]));
printf(" nothing to remove\n");
* delcheck tries to match the given arg against the given command file in
* various ways. For instance, if dfname = 'dfa12345', then there is a match if
* arg == the name given on the L line of the file (the owner), or
* arg == the basename of a file given on a command line in the file.
* If there is a match, all the U (unlink) commands in the command file
* are executed, and then the command file itself is unlinked.
FILE *df
= NULL
; /* The command file. */
int delfile
= 0; /* A match was found, so do a deletion. */
char line
[256]; /* Command line in command file. */
if (strcmp(arg
, dfname
) == 0)
delfile
= 1; /* arg == 'dfa12345'. */
else if (strcmp(arg
, dfname
+3) == 0)
delfile
= 1; /* arg == '12345' (skip 'dfa'). */
else { /* No match; look inside on command lines. */
if ((df
= fopen(dfname
, "r")) == NULL
)
while (!delfile
&& getline(df
, line
)) {
if (strcmp(arg
, line
+1) == 0)
/* Check command line arg. */
if (strcmp (basename(arg
), basename(line
)) == 0)
if (df
== NULL
) /* File not open yet. */
/* Run through the command file, executing Unlink commands. */
while (getline(df
, line
)) {
unlink(dfname
); /* Now unlink the command file itself. */
while ((c
= getc(file
)) != '\n') {
* basename gets the final component of the given pathname. E.g. "c" in
lastname
= pathname
+ strlen(pathname
)-1; /* Move to last char in name. */
while (lastname
>= pathname
) {
return(pathname
); /* No /'s at all. */