1 /* cmd-delete-id.c
2 *
3 ****************************************************************
4 * Copyright (C) 2001, 2002, 2003 Tom Lord
5 *
6 * See the file "COPYING" for further information about
7 * the copyright and warranty status of this work.
8 */
9
10
11 #include "config-options.h"
12 #include "hackerlab/cmd/main.h"
13 #include "tla/libarch/inv-ids.h"
14 #include "tla/libarch/cmd.h"
15 #include "tla/libarch/cmd-delete-id.h"
16
17
18
19 static t_uchar * usage = "[options] file ...";
20 static t_uchar * version_string = (cfg__std__package " from regexps.com\n"
21 "\n"
22 "Copyright 2001, 2002, 2003 Tom Lord\n"
23 "\n"
24 "This is free software; see the source for copying conditions.\n"
25 "There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n"
26 "PARTICULAR PURPOSE.\n"
27 "\n"
28 "Report bugs to " cfg__tla_bug_mail ".\n"
29 "\n"
30 cfg__std__release_id_string
31 "\n");
32
33 #define OPTS(OP) \
34 OP (opt_help_msg, "h", "help", 0, \
35 "Display a help message and exit.") \
36 OP (opt_long_help, "H", 0, 0, \
37 "Display a verbose help message and exit.") \
38 OP (opt_version, "V", "version", 0, \
39 "Display a release identifier string\n" \
40 "and exit.")
41
42 t_uchar arch_cmd_delete_id_help[] = ("remove an explicit inventory id\n"
43 "Remove an explicit inventory id for FILE (which may be a\n"
44 "regular file, symbolic link, or directory).\n");
45
46 enum options
47 {
48 OPTS (OPT_ENUM)
49 };
50
51 static struct opt_desc opts[] =
52 {
53 OPTS (OPT_DESC)
54 {-1, 0, 0, 0, 0}
55 };
56
57
58
59 int
arch_cmd_delete_id(t_uchar * program_name,int argc,char * argv[])60 arch_cmd_delete_id (t_uchar * program_name, int argc, char * argv[])
61 {
62 int o;
63 struct opt_parsed * option;
64
65 safe_buffer_fd (1, 0, O_WRONLY, 0);
66
67 option = 0;
68
69 while (1)
70 {
71 o = opt_standard (lim_use_must_malloc, &option, opts, &argc, argv, program_name, usage, version_string, arch_cmd_delete_id_help, opt_help_msg, opt_long_help, opt_version);
72 if (o == opt_none)
73 break;
74 switch (o)
75 {
76 default:
77 safe_printfmt (2, "unhandled option `%s'\n", option->opt_string);
78 panic ("internal error parsing arguments");
79
80 usage_error:
81 opt_usage (2, argv[0], program_name, usage, 1);
82 exit (1);
83
84 /* bogus_arg: */
85 safe_printfmt (2, "ill-formed argument for `%s' (`%s')\n", option->opt_string, option->arg_string);
86 goto usage_error;
87 }
88 }
89
90 if (argc < 2)
91 goto usage_error;
92
93 {
94 int a;
95
96 for (a = 1; a < argc; ++a)
97 {
98 t_uchar * file;
99
100 file = argv[a];
101 arch_delete_explicit_id (file);
102 }
103 }
104
105
106 return 0;
107 }
108
109
110
111 /* tag: Tom Lord Wed May 14 12:24:43 2003 (delete-tag.c)
112 */
113