11694Smckusick /* Copyright (c) 1979 Regents of the University of California */ 21694Smckusick 3*3869Smckusic static char sccsid[] = "@(#)REMOVE.c 1.3 06/10/81"; 41694Smckusick 51694Smckusick #include "h00vars.h" 61694Smckusick 73025Smckusic REMOVE(name, namlim) 81694Smckusick 91694Smckusick char *name; 103025Smckusic long namlim; 111694Smckusick { 121694Smckusick register int cnt; 133025Smckusic register int maxnamlen = namlim; 141694Smckusick char namebuf[NAMSIZ]; 151694Smckusick 161694Smckusick /* 171694Smckusick * trim trailing blanks, and insure that the name 181694Smckusick * will fit into the file structure 191694Smckusick */ 201694Smckusick for (cnt = 0; cnt < maxnamlen; ) 211694Smckusick if (name[cnt] == '\0' || name[cnt++] == ' ') 221694Smckusick break; 231694Smckusick if (cnt >= NAMSIZ) { 24*3869Smckusic ERROR("%s: File name too long\n", name); 251694Smckusick return; 261694Smckusick } 271694Smckusick maxnamlen = cnt; 281694Smckusick /* 291694Smckusick * put the name into the buffer with null termination 301694Smckusick */ 311694Smckusick for (cnt = 0; cnt < maxnamlen; cnt++) 321694Smckusick namebuf[cnt] = name[cnt]; 331694Smckusick namebuf[cnt] = '\0'; 341694Smckusick /* 351694Smckusick * unlink the file 361694Smckusick */ 371694Smckusick if (unlink(namebuf)) { 38*3869Smckusic PERROR("Could not remove ", namebuf); 391694Smckusick return; 401694Smckusick } 411694Smckusick } 42