1 /*- 2 * Copyright (c) 1979, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)REMOVE.c 8.1 (Berkeley) 06/06/93"; 10 #endif /* not lint */ 11 12 #include "h00vars.h" 13 14 REMOVE(name, namlim) 15 16 char *name; 17 long namlim; 18 { 19 register int cnt; 20 register int maxnamlen = namlim; 21 char namebuf[NAMSIZ]; 22 23 /* 24 * trim trailing blanks, and insure that the name 25 * will fit into the file structure 26 */ 27 for (cnt = 0; cnt < maxnamlen; cnt++) 28 if (name[cnt] == '\0' || name[cnt] == ' ') 29 break; 30 if (cnt >= NAMSIZ) { 31 ERROR("%s: File name too long\n", name); 32 return; 33 } 34 maxnamlen = cnt; 35 /* 36 * put the name into the buffer with null termination 37 */ 38 for (cnt = 0; cnt < maxnamlen; cnt++) 39 namebuf[cnt] = name[cnt]; 40 namebuf[cnt] = '\0'; 41 /* 42 * unlink the file 43 */ 44 if (unlink(namebuf)) { 45 PERROR("Could not remove ", namebuf); 46 return; 47 } 48 } 49