Esempio n. 1
0
File: tester.c Progetto: jre/upart
void
testfiles(FILE *idx)
{
	char *bad, *name, *fullname, *imgfile, *outfile, *errfile, *exitfile;
	char *newoutfile, *newerrfile;
	int exitval, failed, failures, testcount;
	size_t i;

	printf("running tests...\n");

	bad = NULL;
	testcount = 0;
	failures = 0;
	while ((name = nextname(TESTINDEX_PATH, idx)) != NULL) {
		for (i = 0; i < NITEMS(flags); i++) {
			fullname = strjoin(name, flags[i], (void *)NULL);
			imgfile = strjoin(name, ".img", (void *)NULL);
			outfile = strjoin(fullname, ".out", (void *)NULL);
			errfile = strjoin(fullname, ".err", (void *)NULL);
			exitfile = strjoin(fullname, ".exit", (void *)NULL);
			newoutfile = strjoin("test-", fullname, ".out", (void *)NULL);
			newerrfile = strjoin("test-", fullname, ".err", (void *)NULL);

			rmfile(newoutfile);
			rmfile(newerrfile);
			exitval = runtest(flags[i], imgfile,
			    newoutfile, newerrfile);
			failed = 0;

			if (!checkexitval(fullname, exitval, exitfile))
				failed = 1;
			if (!checkfiles(fullname, outfile, newoutfile, 0))
				failed = 1;
			if (!checkfiles(fullname, errfile, newerrfile, 1))
				failed = 1;

			testcount++;
			if (failed) {
				failures++;
				bad = appendname(bad, fullname);
			}

			free(fullname);
			free(imgfile);
			free(outfile);
			free(errfile);
			free(exitfile);
			free(newoutfile);
			free(newerrfile);
		}
	}

	printf("%d tests failed out of %d total.\n", failures, testcount);
	if (failures != 0) {
		printf("The following tests failed:\n  %s\n", bad);
		exit(EXIT_FAILURE);
	}
}
Esempio n. 2
0
File: tester.c Progetto: jre/upart
void
regenfiles(FILE *idx)
{
	char *imgfile, *outfile, *errfile, *exitfile;
	int exitval;
	char *name;
	size_t i;

	while ((name = nextname(TESTINDEX_PATH, idx)) != NULL) {
		for (i = 0; i < NITEMS(flags); i++) {
			imgfile = strjoin(name, ".img", (void *)NULL);
			outfile = strjoin(name, flags[i], ".out", (void *)NULL);
			errfile = strjoin(name, flags[i], ".err", (void *)NULL);
			exitfile = strjoin(name, flags[i], ".exit", (void *)NULL);

			rmfile(outfile);
			rmfile(errfile);
			rmfile(exitfile);
			exitval = runtest(flags[i], imgfile, outfile, errfile);

			if (filesize(outfile) == 0)
				rmfile(outfile);
			if (filesize(errfile) == 0)
				rmfile(errfile);
			if (exitval != 0) {
				FILE *eh;

				if ((eh = fopen(exitfile, "w")) == NULL)
					fail("failed to open %s for writing",
					    exitfile);
				fprintf(eh, "%d\n", exitval);
				fclose(eh);
			}

			free(imgfile);
			free(outfile);
			free(errfile);
			free(exitfile);
		}
	}
}
Esempio n. 3
0
File: tester.c Progetto: jre/upart
void
cleanfiles(FILE *idx)
{
	char *name, *outfile, *errfile;
	size_t i;

	while ((name = nextname(TESTINDEX_PATH, idx)) != NULL) {
		printf("%s", RMFILE_DISPLAY);
		for (i = 0; i < NITEMS(flags); i++) {
			outfile = strjoin("test-", name, flags[i], ".out", (void *)NULL);
			errfile = strjoin("test-", name, flags[i], ".err", (void *)NULL);
			printf(" %s%s%s %s%s%s",
			    TESTDIR_PATH, DIRSEP_DISPLAY, outfile,
			    TESTDIR_PATH, DIRSEP_DISPLAY, errfile);
			rmfile(outfile);
			rmfile(errfile);
			free(outfile);
			free(errfile);
		}
		printf("\n");
	}
}
Esempio n. 4
0
/**
*******************************************************************************
  Function Name : delete_file()

  Description :	 

  Input :	

  Output :	none

  Note : 
*******************************************************************************
*/
U8 delete_file(U8 *name)
{
  DirList list;
  U8 retval = FILE_DELETED_SUCCESS;

  ls_openDir(&list,&efs.myFs,"/");
  if(rmfile(&efs.myFs,name) == -1)
  {
    retval = FILE_DELETED_NO_SUCH_FILE;
  }
  fs_umount(&efs.myFs);

  return retval;
}
Esempio n. 5
0
int
cfs_remove(const char *name)
{
  return (rmfile(&sdcard_efs.myFs,(euint8*)name) == 0) ? 0 : -1;
}
Esempio n. 6
0
int
putprinter(char *name, PRINTER *prbufp)
{
	register char *		path;
	register char *		stty;
	register char *		speed;

	int fdin, fdout;

	int			fld;

	char			buf[BUFSIZ];

	struct stat		statbuf1,
				statbuf2;


	badprinter = 0;

	if (!name || !*name) {
		errno = EINVAL;
		return (-1);
	}

	if (STREQU(NAME_ALL, name)) {
		errno = EINVAL;
		return (-1);
	}

	/*
	 * First go through the structure and see if we have
	 * anything strange.
	 */
	if (!okprinter(name, prbufp, 1)) {
		errno = EINVAL;
		return (-1);
	}

	if (!Lp_A_Printers || !Lp_A_Interfaces) {
		getadminpaths (LPUSER);
		if (!Lp_A_Printers || !Lp_A_Interfaces)
			return (0);
	}

	/*
	 * Create the parent directory for this printer
	 * if it doesn't yet exist.
	 */
	if (!(path = getprinterfile(name, (char *)0)))
		return (-1);
	if (Stat(path, &statbuf1) == 0) {
		if (!S_ISDIR(statbuf1.st_mode)) {
			Free (path);
			errno = ENOTDIR;
			return (-1);
		}
	} else if (errno != ENOENT || mkdir_lpdir(path, MODE_DIR) == -1) {
		Free (path);
		return (-1);
	}
	Free (path);

	/*
	 * Create the copy of the interface program, unless
	 * that would be silly or not desired.
	 * Conversely, make sure the interface program doesn't
	 * exist for a remote printer.
	 */
	if (prbufp->remote) {
		if (!(path = makepath(Lp_A_Interfaces, name, (char *)0)))
			return (-1);
		(void)rmfile (path);
		Free (path);
	}
	if (prbufp->interface && (ignprinter & BAD_INTERFACE) == 0) {
		if (Stat(prbufp->interface, &statbuf1) == -1)
			return (-1);
		if (!(path = makepath(Lp_A_Interfaces, name, (char *)0)))
			return (-1);
		if (
			Stat(path, &statbuf2) == -1
		     || statbuf1.st_dev != statbuf2.st_dev
		     || statbuf1.st_ino != statbuf2.st_ino
		) {
			register int		n;

			if ((fdin = open_locked(prbufp->interface, "r", 0)) < 0) {
				Free (path);
				return (-1);
			}
			if ((fdout = open_locked(path, "w", MODE_EXEC)) < 0) {
				Free (path);
				close(fdin);
				return (-1);
			}
			while ((n = read(fdin, buf, BUFSIZ)) > 0)
				write (fdout, buf,  n);
			close(fdout);
			close(fdin);
		}
		Free (path);
	}

#ifdef LP_USE_PAPI_ATTR
	/*
	 * Handle PPD (Postscript Printer Definition) file for printer
	 * if this printer has been configured with one
	 */
	if ((prbufp->ppd != NULL) && (ppdopt))
	{
		if (addPrintersPPD(name, prbufp) != 0)
		{
			/* failed to added the printers PPD file */
			return (-1);
		}
	}
#endif

	/*
	 * If this printer is dialed up, remove any baud rates
	 * from the stty option list and move the last one to
	 * the ".speed" member if the ".speed" member isn't already
	 * set. Conversely, if this printer is directly connected,
	 * move any value from the ".speed" member to the stty list.
	 */

	stty = (prbufp->stty? Strdup(prbufp->stty) : 0);
	if (prbufp->speed)
		speed = Strdup(prbufp->speed);
	else
		speed = 0;

	if (prbufp->dial_info && stty) {
		register char		*newstty,
					*p,
					*q;

		register int		len;

		if (!(q = newstty = Malloc(strlen(stty) + 1))) {
			Free (stty);
			errno = ENOMEM;
			return (-1);
		}
		newstty[0] = 0;	/* start with empty copy */

		for (
			p = strtok(stty, " ");
			p;
			p = strtok((char *)0, " ")
		) {
			len = strlen(p);
			if (strspn(p, "0123456789") == len) {
				/*
				 * If "prbufp->speed" isn't set, then
				 * use the speed we just found. Don't
				 * check "speed", because if more than
				 * one speed was given in the list, we
				 * want the last one.
				 */
				if (!prbufp->speed) {
					if (speed)
						Free (speed);
					speed = Strdup(p);
				}

			} else {
				/*
				 * Not a speed, so copy it to the
				 * new stty string.
				 */
				if (q != newstty)
					*q++ = ' ';
				strcpy (q, p);
				q += len;
			}
		}

		Free (stty);
		stty = newstty;

	} else if (!prbufp->dial_info && speed) {
		register char		*newstty;

		newstty = Malloc(strlen(stty) + 1 + strlen(speed) + 1);
		if (!newstty) {
			if (stty)
				Free (stty);
			errno = ENOMEM;
			return (-1);
		}

		if (stty) {
			strcpy (newstty, stty);
			strcat (newstty, " ");
			strcat (newstty, speed);
			Free (stty);
		} else
			strcpy (newstty, speed);
		Free (speed);
		speed = 0;

		stty = newstty;

	}

	/*
	 * Open the configuration file and write out the printer
	 * configuration.
	 */

	if (!(path = getprinterfile(name, CONFIGFILE))) {
		if (stty)
			Free (stty);
		if (speed)
			Free (speed);
		return (-1);
	}
	if ((fdout = open_locked(path, "w", MODE_READ)) < 0) {
		Free (path);
		if (stty)
			Free (stty);
		if (speed)
			Free (speed);
		return (-1);
	}
	Free (path);

	errno = 0;
	for (fld = 0; fld < PR_MAX; fld++) {
		if (prbufp->remote && !prtrheadings[fld].okremote)
			continue;

		switch (fld) {

#define HEAD	prtrheadings[fld].v

		case PR_BAN:
			{
				char *ptr = NAME_ON;

				switch (prbufp->banner) {
				case BAN_ALWAYS:
					ptr = NAME_ON;
					break;
				case BAN_NEVER:
					ptr = NAME_OFF;
					break;
				case BAN_OPTIONAL:
					ptr = NAME_OPTIONAL;
					break;
				}
				(void)fdprintf(fdout, "%s %s\n", HEAD, ptr);
			}
			break;

		case PR_CPI:
			print_sdn(fdout, HEAD, prbufp->cpi);
			break;

		case PR_CS:
			if (!emptylist(prbufp->char_sets))
				print_l(fdout, HEAD, prbufp->char_sets);
			break;

		case PR_ITYPES:
			/*
			 * Put out the header even if the list is empty,
			 * to distinguish no input types from the default.
			 */
			print_l(fdout, HEAD, prbufp->input_types);
			break;

		case PR_DEV:
			print_str(fdout, HEAD, prbufp->device);
			break;

		case PR_DIAL:
			print_str(fdout, HEAD, prbufp->dial_info);
			break;

		case PR_RECOV:
			print_str(fdout, HEAD, prbufp->fault_rec);
			break;

		case PR_INTFC:
			print_str(fdout, HEAD, prbufp->interface);
			break;

		case PR_LPI:
			print_sdn(fdout, HEAD, prbufp->lpi);
			break;

		case PR_LEN:
			print_sdn(fdout, HEAD, prbufp->plen);
			break;

		case PR_LOGIN:
			if (prbufp->login & LOG_IN)
				(void)fdprintf(fdout, "%s\n", HEAD);
			break;

		case PR_PTYPE:
		{
			char			**printer_types;

			/*
			 * For backward compatibility for those who
			 * use only "->printer_type", we have to play
			 * some games here.
			 */
			if (prbufp->printer_type && !prbufp->printer_types)
				printer_types = getlist(
					prbufp->printer_type,
					LP_WS,
					LP_SEP
				);
			else
				printer_types = prbufp->printer_types;

			if (!printer_types || !*printer_types)
				print_str(fdout, HEAD, NAME_UNKNOWN);
			else
				print_l(fdout, HEAD, printer_types);

			if (printer_types != prbufp->printer_types)
				freelist (printer_types);
			break;
		}

		case PR_REMOTE:
			print_str(fdout, HEAD, prbufp->remote);
			break;

		case PR_SPEED:
			print_str(fdout, HEAD, speed);
			break;

		case PR_STTY:
			print_str(fdout, HEAD, stty);
			break;

		case PR_WIDTH:
			print_sdn(fdout, HEAD, prbufp->pwid);
			break;

#if	defined(CAN_DO_MODULES)
		case PR_MODULES:
			/*
			 * Put out the header even if the list is empty,
			 * to distinguish no modules from the default.
			 */
			print_l(fdout, HEAD, prbufp->modules);
			break;
#endif

		case PR_OPTIONS:
			print_l(fdout, HEAD, prbufp->options);
			break;

		case PR_PPD:
		{
			print_str(fdout, HEAD, prbufp->ppd);
			break;
		}
		}

	}
	if (stty)
		Free (stty);
	if (speed)
		Free (speed);
	if (errno != 0) {
		close(fdout);
		return (-1);
	}
	close(fdout);

	/*
	 * If we have a description of the printer,
	 * write it out to a separate file.
	 */
	if (prbufp->description) {

		if (!(path = getprinterfile(name, COMMENTFILE)))
			return (-1);

		if (dumpstring(path, prbufp->description) == -1) {
			Free (path);
			return (-1);
		}
		Free (path);
	
	}

	/*
	 * Now write out the alert condition.
	 */
	if (
		prbufp->fault_alert.shcmd
	     && putalert(Lp_A_Printers, name, &(prbufp->fault_alert)) == -1
	)
		return (-1);

	return (0);
}
Esempio n. 7
0
static int
addPrintersPPD(char *name, PRINTER *prbufp)

{
	int result = 0;
	char *path = NULL;
	char *ppd = NULL;
	char  buf[BUFSIZ];
	struct stat statbuf;

	(void) snprintf(buf, sizeof (buf), "%s.ppd", name);
	if (prbufp->remote)
	{
		/* make sure the PPD file doesn't exist for a remote printer */
		if (!(path = makepath(ETCDIR, "ppd", buf, (char *)0)))
		{
			result = -1;
		}
		else
		{
			(void) rmfile(path);
		}
	}

	if ((result == 0) && (prbufp->ppd != NULL))
	{
		ppd = strdup(prbufp->ppd);

		if (ppd == NULL)
		{
			result = -1;
		}
		else
		{
			/* Check the PPD file given exists */

			if (Stat(ppd, &statbuf) == -1)
			{
				/*
				 * The given ppd files does not exist, but
				 * check if there is a zipped version of the
				 * file that we can use instead
				 */
				if (strstr(ppd, PPDZIP) != NULL)
				{
					/* this is a zipped file so exit */
					result = -1;
				}
				else
				{
					ppd = Realloc(ppd,
						strlen(ppd)+strlen(PPDZIP)+2);
					if (ppd != NULL)
					{
						ppd = strcat(ppd, PPDZIP);
						if (Stat(ppd, &statbuf) == -1)
						{
							/*
							 * this zipped version
							 * of the file does not
							 * exist either
							 */
							result = -1;
						}
					}
					else
					{
						result = -1;
					}
				}
			}
		}

		/*
		 * Create the copy of the PPD file for this printer
		 * unless that would be silly or not desired
		 */

		if (result == 0)
		{
			if (!(path = makepath(ETCDIR, "ppd", buf, (char *)0)))
			{
				result = -1;
			}
		}

		/*
		 * At this point we may have a zipped or unzipped ppd file, if
		 * it's unzipped just copy it otherwise unzip it to the
		 * printer's ppd file (/etc/lp/ppd/<printer>.ppd)
		 */

		if (result == 0)
		{
			if (strstr(ppd, PPDZIP) == NULL)
			{
				result = copyPPDFile(ppd, path);
			}
			else
			{
				result = unzipPPDFile(ppd, path);
			}

			(void) chown_lppath(path);
			(void) chmod(path, 0644);
		}

		if (ppd != NULL)
		{
			Free(ppd);
		}
		if (path != NULL)
		{
			Free(path);
		}
	}

	return (result);
} /* addPrintersPPD() */
Esempio n. 8
0
void IconList::directoryChanged(const QString &path)
{
	QDir new_dir (path);
	if(m_dir.absolutePath() != new_dir.absolutePath())
	{
		m_dir.setPath(path);
		m_dir.refresh();
		if(is_watching)
			stopWatching();
		startWatching();
	}
	if(!m_dir.exists())
		if(!ensureFolderPathExists(m_dir.absolutePath()))
			return;
	m_dir.refresh();
	auto new_list = m_dir.entryList(QDir::Files, QDir::Name);
	for (auto it = new_list.begin(); it != new_list.end(); it++)
	{
		QString &foo = (*it);
		foo = m_dir.filePath(foo);
	}
	auto new_set = new_list.toSet();
	QList<QString> current_list;
	for (auto &it : icons)
	{
		if (!it.has(MMCIcon::FileBased))
			continue;
		current_list.push_back(it.m_images[MMCIcon::FileBased].filename);
	}
	QSet<QString> current_set = current_list.toSet();

	QSet<QString> to_remove = current_set;
	to_remove -= new_set;

	QSet<QString> to_add = new_set;
	to_add -= current_set;

	for (auto remove : to_remove)
	{
		QLOG_INFO() << "Removing " << remove;
		QFileInfo rmfile(remove);
		QString key = rmfile.baseName();
		int idx = getIconIndex(key);
		if (idx == -1)
			continue;
		icons[idx].remove(MMCIcon::FileBased);
		if (icons[idx].type() == MMCIcon::ToBeDeleted)
		{
			beginRemoveRows(QModelIndex(), idx, idx);
			icons.remove(idx);
			reindex();
			endRemoveRows();
		}
		else
		{
			dataChanged(index(idx), index(idx));
		}
		m_watcher->removePath(remove);
		emit iconUpdated(key);
	}

	for (auto add : to_add)
	{
		QLOG_INFO() << "Adding " << add;
		QFileInfo addfile(add);
		QString key = addfile.baseName();
		if (addIcon(key, QString(), addfile.filePath(), MMCIcon::FileBased))
		{
			m_watcher->addPath(add);
			emit iconUpdated(key);
		}
	}
}
Esempio n. 9
0
int
main(int argc, char *argv[])
{
	char buf[BSIZ];
	int cmd, i = 2, verbose = 0;

	if (argc < 2) {
usage:
		fprintf(stderr, "%s -c [-v] [-g] [-W1|-W2] [-std=xxx] [-fpic|-fPIC] [-rpath <path>]"
				"<other arguments>\n", argv[0]);
		fprintf(stderr, "%s -l [-v] -libname <name> -libvers <vers> [-shared] [-soname] [-sovers] "
				"<other arguments>\n", argv[0]);
		fprintf(stderr, "%s -i [-m <mode>] <file1> <file2> <fileN> <dir>\n", argv[0]);
		fprintf(stderr, "%s -i -libname <name> -libvers <vers> [-m mode] <dir>\n", argv[0]);
		fprintf(stderr, "%s -u <dir> <file1> <file2> <fileN>\n", argv[0]);
		fprintf(stderr, "%s -u -libname <name> -libvers <vers> <srcdir>\n", argv[0]);
		fprintf(stderr, "%s -m <target>\n", argv[0]);
		return EXIT_FAILURE;
	}

	cmd = argv[1][1];
	if (argc > 2 && strcmp(argv[2], "-v") == 0) {
		verbose = 1;
		i++;
	}

	switch (cmd) {
		case 'c':
			if (argc < 3) {
				fprintf(stderr, "no compiler arguments provided\n");
				goto usage;
			}
			if (mkcccmd(buf, argc - i, argv + i) == -1) {
				fprintf(stderr, "failed to build command\n");
				return EXIT_FAILURE;
			}
			break;
		case 'l':
		case 'i':
		case 'u':
		case 'C':
			{
				const char *libname = NULL, *dir = NULL;
				char vbuf[255], *vers[3] = { NULL, NULL, NULL };

				for ( ; i < argc; i++) {
					if (strcmp(argv[i], "-libname") == 0) {
						if (++i == argc) goto usage;
						libname = argv[i];
					} else if (strcmp(argv[i], "-libvers") == 0) {
						char *vp = vbuf;
						int vi = 0;

						if (++i == argc) goto usage;
						strcpy(vbuf, argv[i]);
						vers[vi++] = vp;
						while (vi < 3 && *vp++) {
							if (*vp == '.') {
								*vp++ = '\0';
								vers[vi++] = vp;
							}
						}
					} else {
						break;
					}
				}
				if (i == argc && cmd != 'C') {
					ERR(EINVAL, "more arguments expected");
					goto usage;
				}

				switch (cmd) {
					case 'l':
						if (mklibcmd(buf, libname, vers, argc - i, argv + i) == -1) {
							return EXIT_FAILURE;
						}
						break;
					case 'i':
						if (doinst(libname, vers, argc - i, argv + i) == -1) {
							return EXIT_FAILURE;
						}
						return EXIT_SUCCESS;
					case 'u':
						dir = argv[argc - 1];
						argc--;
					case 'C':
						if (libname) {
							if (cmd != 'C') {
								if (arg_array[ARG_SOLNK2][0]) {
									slibprintf(buf, arg_array[ARG_SOLNK2], libname, vers);
									if (rmfile(dir, buf) == -1 && errno != ENOENT) return EXIT_FAILURE;
								}
								if (arg_array[ARG_SOLNK1][0]) {
									slibprintf(buf, arg_array[ARG_SOLNK1], libname, vers);
									if (rmfile(dir, buf) == -1 && errno != ENOENT) return EXIT_FAILURE;
								}
							}
							slibprintf(buf, arg_array[ARG_SOOUT], libname, vers);
							if (rmfile(dir, buf) == -1 && errno != ENOENT) return EXIT_FAILURE;
						} else {
							for ( ; i < argc; i++) {
								if (rmfile(dir, argv[i]) == -1 && errno != ENOENT) {
									return EXIT_FAILURE;
								}
							}
						}

						return EXIT_SUCCESS;
				}
			}
			break;
		case 'm':
			{
				char *bp = buf;
				bp += sprintf(bp, "make -f Makefile.%s", arg_array[ARG_PLATFO]);
				if (i < argc) {
					bp += sprintf(bp, " %s", argv[i]);
				}
			}
			break;
		default:
			fprintf(stderr, "first argument must be a command flag\n");
			goto usage;
	}

	/* run command */
	
	if (verbose) {
		fprintf(stderr, "%s\n", buf);
	}

	if (system(buf) == -1) {
		perror("system");
		return -1;
	}

	return EXIT_SUCCESS;
}
Esempio n. 10
0
static void
rm(size_t pend, const char *base, const int olddir, int ssub, int level)
{
	struct stat st;

	if (lstat(base, &st) < 0) {
		if (fflag == 0 || errno != ENOENT) {
			if (sysv3)
				fprintf(stderr, "%s: %s non-existent\n",
						progname, path);
			else
				fprintf(stderr, "%s: %s\n",
						path, strerror(errno));
			errcnt |= 4;
		}
		return;
	}
	if ((st.st_mode&S_IFMT) == S_IFDIR) {
		if (rflag) {
			struct direc *dp;
			struct getdb *db;
			int df, err;

			if (ssub == 0 && (iflag
#ifdef	SUS
					|| (!fflag && ontty &&
						access(base, W_OK) < 0)
#endif
					)) {
				msg("directory %s: ? ", path);
				if (confirm() == 0)
					return;
			}
			if ((df = open(base,
							O_RDONLY
#ifdef	O_DIRECTORY
							| O_DIRECTORY
#endif
#ifdef	O_NOFOLLOW
							| O_NOFOLLOW
#endif
						)) < 0 ||
					(db = getdb_alloc(base, df)) == NULL) {
				if (errno == EMFILE) {
					int	sres;

					sres = subproc(pend, base, level);
					if (sres >= 0) {
						errcnt |= sres;
						goto remove;
					}
				}
				/*
				 * Maybe the directory is empty and can just
				 * be removed.
				 */
				if (rmfile(base, &st) < 0) {
					fprintf(stderr,
						"%s: cannot read "
						"directory %s\n",
						progname, path);
					errcnt |= 4;
				}
				return;
			}
			if (fchdir(df) < 0) {
				if (rmfile(base, &st) < 0) {
					fprintf(stderr,
						"%s: cannot chdir to %s\n",
							progname, path);
					errcnt |= 4;
				}
				getdb_free(db);
				close(df);
				return;
			}
			setlevel(level, db, df);
			while ((dp = getdir(db, &err)) != NULL) {
				if (dp->d_name[0] == '.' &&
						(dp->d_name[1] == '\0' ||
						 dp->d_name[1] == '.' &&
						 dp->d_name[2] == '\0'))
					continue;
				rm(catpath(pend, dp->d_name), dp->d_name,
						df, 0, level + 1);
				path[pend] = '\0';
			}
			if (err) {
				fprintf(stderr,
					"%s: error reading directory %s\n",
					progname, path);
				errcnt |= 4;
			}
			if (olddir >= 0 && fchdir(olddir) < 0) {
				fprintf(stderr, "%s: cannot change backwards\n",
						progname);
				exit(1);
			}
			getdb_free(db);
			close(df);
		} else {
			fprintf(stderr, "%s: %s directory\n", progname, path);
			errcnt |= 1;
			return;
		}
	}
	if (ssub == 0)
	remove:	rmfile(base, &st);
}