if (strcmp(dirent->d_name, jobs[i]) == 0) {
if (jobs[i] != NULL && strcmp(dirent->d_name, jobs[i]) == 0) {
process_jobs(int argc, char **argv, int what){	struct stat stbuf;	struct dirent *dirent;	struct passwd *pw;	time_t runtimer;	uid_t *uids;	char **jobs, *ep, queue;	long l;	FILE *fp;	DIR *spool;	int job_matches, jobs_len, uids_len;	int error, i, ch, changed;	PRIV_START;	if (chdir(AT_DIR) != 0)		perr2("Cannot change to ", AT_DIR);	if ((spool = opendir(".")) == NULL)		perr2("Cannot open ", AT_DIR);	PRIV_END;	/* Convert argv into a list of jobs and uids. */	jobs = NULL;	uids = NULL;	jobs_len = uids_len = 0;	if (argc > 0) {		if ((jobs = malloc(sizeof(char *) * argc)) == NULL ||		    (uids = malloc(sizeof(uid_t) * argc)) == NULL)			panic("Insufficient virtual memory");		for (i = 0; i < argc; i++) {			l = strtol(argv[i], &ep, 10);			if (*ep == '.' && isalpha(*(ep + 1)) &&			    *(ep + 2) == '\0' && l > 0 && l < INT_MAX)				jobs[jobs_len++] = argv[i];			else if ((pw = getpwnam(argv[i])) != NULL) {				if (real_uid != pw->pw_uid && real_uid != 0) {					fprintf(stderr, "%s: Only the superuser"					    " may %s other users' jobs",					    ProgramName, what == ATRM					    ? "remove" : "view");					exit(ERROR_EXIT);				}				uids[uids_len++] = pw->pw_uid;			} else				panic2(argv[i], ": invalid user name");		}	}	/* Loop over every file in the directory */	changed = 0;	while ((dirent = readdir(spool)) != NULL) {		PRIV_START;		if (stat(dirent->d_name, &stbuf) != 0)			perr2("Cannot stat in ", AT_DIR);		PRIV_END;		if (stbuf.st_uid != real_uid && real_uid != 0)			continue;		l = strtol(dirent->d_name, &ep, 10);		if (*ep != '.' || !isalpha(*(ep + 1)) || *(ep + 2) != '\0' ||		    l < 0 || l >= INT_MAX)			continue;		runtimer = (time_t)l;		queue = *(ep + 1);		/* Check runtimer against argv; argc==0 means do all. */		job_matches = (argc == 0) ? 1 : 0;		if (!job_matches) {			for (i = 0; i < jobs_len; i++) {				if (strcmp(dirent->d_name, jobs[i]) == 0) {					jobs[i] = NULL;					job_matches = 1;					break;				}			}		}		if (!job_matches) {			for (i = 0; i < uids_len; i++) {				if (uids[i] == stbuf.st_uid) {					job_matches = 1;					break;				}			}		}		if (job_matches) {			switch (what) {			case ATRM:				PRIV_START;				if (!interactive ||				    (interactive && rmok(runtimer))) {					if (unlink(dirent->d_name) == 0)						changed = 1;					else						perr(dirent->d_name);					if (!force && !interactive)						fprintf(stderr,						    "%s removed\n",						    dirent->d_name);				}				PRIV_END;				break;			case CAT:				PRIV_START;				fp = fopen(dirent->d_name, "r");				PRIV_END;				if (!fp)					perr("Cannot open file");				while ((ch = getc(fp)) != EOF)					putchar(ch);				break;			default:				panic("Internal error");				break;			}		}	}	for (error = 0, i = 0; i < jobs_len; i++) {		if (jobs[i] != NULL) {			if (!force)				fprintf(stderr, "%s: %s: no such job",				    ProgramName, jobs[i]);			error++;		}	}	free(jobs);	free(uids);	/* If we modied the spool, poke cron so it knows to reload. */	if (changed) {		PRIV_START;		if (chdir(CRONDIR) != 0)			perror(CRONDIR);		else			poke_daemon(AT_DIR, RELOAD_AT);		PRIV_END;	}	return (error);}