Initial revision
[ssr] / StraySrc / Utilities / c / ssrclean
1 /*
2 * ssrclean.c
3 *
4 * Delete lots of files (saves typing in Makefiles)
5 *
6 * © 1998 Straylight/Edgeware
7 */
8
9 /*----- Licensing note ----------------------------------------------------*
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2, or (at your option)
14 * any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, write to the Free Software Foundation,
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 */
25
26 /*----- Header files ------------------------------------------------------*/
27
28 #include <stddef.h>
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32
33 #include "swis.h"
34 #include "swiv.h"
35
36 #include "cmdr.h"
37
38 /*----- Install programs --------------------------------------------------*/
39
40 static int exitstat = 0; /* Exit status */
41
42 /* -- @wipe@ --- *
43 *
44 * Arguments: @const char *f@ = pointer to filename
45 *
46 * Returns: ---
47 *
48 * Use: Expunges a file.
49 */
50
51 static void wipe(const char *f)
52 {
53 _kernel_oserror *e;
54
55 e = _swix(OS_FSControl, _in(0) | _in(1) | _in(3), 27, f, 0);
56 if (e) {
57 fprintf(stderr, "ssrclean: error deleting `%s': %s\n",
58 f, e->errmess);
59 exitstat = 1;
60 }
61 }
62
63 /* --- @main@ --- *
64 *
65 * Arguments: @int argc@ = number of arguments
66 * @char *argv[]@ = list of arguments
67 *
68 * Returns: Zero if all went well
69 *
70 * Use: Deletes files. This is an `rm' rip-off
71 */
72
73 int main(int argc, char *argv[])
74 {
75 int i;
76
77 /* --- Expand wildcards in the arguments --- */
78
79 cmdreplace(&argc, &argv);
80
81 /* --- Report an error if there aren't enough arguments --- */
82
83 if (argc < 2) {
84 fprintf(stderr, "Usage: ssrclean FILE [FILE...]\n");
85 exit(1);
86 }
87
88 /* --- Wipe things --- */
89
90 for (i = 1; i < argc; i++)
91 wipe(argv[i]);
92
93 /* --- Done --- */
94
95 return (exitstat);
96 }
97
98 /*----- That's all, folks -------------------------------------------------*/