11694Smckusick /* Copyright (c) 1979 Regents of the University of California */
21694Smckusick 
3*3025Smckusic static char sccsid[] = "@(#)REMOVE.c 1.2 03/07/81";
41694Smckusick 
51694Smckusick #include "h00vars.h"
61694Smckusick #include "h01errs.h"
71694Smckusick 
8*3025Smckusic REMOVE(name, namlim)
91694Smckusick 
101694Smckusick 	char			*name;
11*3025Smckusic 	long			namlim;
121694Smckusick {
131694Smckusick 	register int	cnt;
14*3025Smckusic 	register int	maxnamlen = namlim;
151694Smckusick 	char		namebuf[NAMSIZ];
161694Smckusick 
171694Smckusick 	/*
181694Smckusick 	 * trim trailing blanks, and insure that the name
191694Smckusick 	 * will fit into the file structure
201694Smckusick 	 */
211694Smckusick 	for (cnt = 0; cnt < maxnamlen; )
221694Smckusick 		if (name[cnt] == '\0' || name[cnt++] == ' ')
231694Smckusick 			break;
241694Smckusick 	if (cnt >= NAMSIZ) {
251694Smckusick 		ERROR(ENAMESIZE, name);
261694Smckusick 		return;
271694Smckusick 	}
281694Smckusick 	maxnamlen = cnt;
291694Smckusick 	/*
301694Smckusick 	 * put the name into the buffer with null termination
311694Smckusick 	 */
321694Smckusick 	for (cnt = 0; cnt < maxnamlen; cnt++)
331694Smckusick 		namebuf[cnt] = name[cnt];
341694Smckusick 	namebuf[cnt] = '\0';
351694Smckusick 	/*
361694Smckusick 	 * unlink the file
371694Smckusick 	 */
381694Smckusick 	if (unlink(namebuf)) {
391694Smckusick 		ERROR(EREMOVE, namebuf);
401694Smckusick 		return;
411694Smckusick 	}
421694Smckusick }
43