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