1*1694Smckusick /* Copyright (c) 1979 Regents of the University of California */
2*1694Smckusick 
3*1694Smckusick static char sccsid[] = "@(#)REMOVE.c 1.1 10/30/80";
4*1694Smckusick 
5*1694Smckusick #include "h00vars.h"
6*1694Smckusick #include "h01errs.h"
7*1694Smckusick 
8*1694Smckusick REMOVE(name, maxnamlen)
9*1694Smckusick 
10*1694Smckusick 	char			*name;
11*1694Smckusick 	int			maxnamlen;
12*1694Smckusick {
13*1694Smckusick 	register int	cnt;
14*1694Smckusick 	char		namebuf[NAMSIZ];
15*1694Smckusick 
16*1694Smckusick 	/*
17*1694Smckusick 	 * trim trailing blanks, and insure that the name
18*1694Smckusick 	 * will fit into the file structure
19*1694Smckusick 	 */
20*1694Smckusick 	for (cnt = 0; cnt < maxnamlen; )
21*1694Smckusick 		if (name[cnt] == '\0' || name[cnt++] == ' ')
22*1694Smckusick 			break;
23*1694Smckusick 	if (cnt >= NAMSIZ) {
24*1694Smckusick 		ERROR(ENAMESIZE, name);
25*1694Smckusick 		return;
26*1694Smckusick 	}
27*1694Smckusick 	maxnamlen = cnt;
28*1694Smckusick 	/*
29*1694Smckusick 	 * put the name into the buffer with null termination
30*1694Smckusick 	 */
31*1694Smckusick 	for (cnt = 0; cnt < maxnamlen; cnt++)
32*1694Smckusick 		namebuf[cnt] = name[cnt];
33*1694Smckusick 	namebuf[cnt] = '\0';
34*1694Smckusick 	/*
35*1694Smckusick 	 * unlink the file
36*1694Smckusick 	 */
37*1694Smckusick 	if (unlink(namebuf)) {
38*1694Smckusick 		ERROR(EREMOVE, namebuf);
39*1694Smckusick 		return;
40*1694Smckusick 	}
41*1694Smckusick }
42