1 /* cmd-id-tagging-defaults.c
2  *
3  ****************************************************************
4  * Copyright (C) 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-id-tagging-defaults.h"
15 
16 
17 
18 static t_uchar * usage = "[options]";
19 static t_uchar * version_string = (cfg__std__package " from regexps.com\n"
20                                    "\n"
21                                    "Copyright 2003 Tom Lord\n"
22                                    "\n"
23                                    "This is free software; see the source for copying conditions.\n"
24                                    "There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n"
25                                    "PARTICULAR PURPOSE.\n"
26                                    "\n"
27                                    "Report bugs to " cfg__tla_bug_mail ".\n"
28                                    "\n"
29                                    cfg__std__release_id_string
30                                    "\n");
31 
32 #define OPTS(OP) \
33   OP (opt_help_msg, "h", "help", 0, \
34       "Display a help message and exit.") \
35   OP (opt_long_help, "H", 0, 0, \
36       "Display a verbose help message and exit.") \
37   OP (opt_version, "V", "version", 0, \
38       "Display a release identifier string\n" \
39       "and exit.")
40 
41 t_uchar arch_cmd_id_tagging_defaults_help[] = ("print the default =tagging-method contents\n"
42                                             "Print the boilerplate contents that are used to initialize new\n"
43                                             "=tagging-method files.\n");
44 
45 enum options
46 {
47   OPTS (OPT_ENUM)
48 };
49 
50 static struct opt_desc opts[] =
51 {
52   OPTS (OPT_DESC)
53     {-1, 0, 0, 0, 0}
54 };
55 
56 
57 
58 int
arch_cmd_id_tagging_defaults(t_uchar * program_name,int argc,char * argv[])59 arch_cmd_id_tagging_defaults (t_uchar * program_name, int argc, char * argv[])
60 {
61   int o;
62   struct opt_parsed * option;
63 
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_id_tagging_defaults_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 != 1)
91     goto usage_error;
92 
93   {
94     t_uchar * it = 0;
95 
96     it = arch_default_id_tagging_method_contents (arch_unspecified_id_tagging);
97     safe_printfmt (1, "%s", it);
98 
99     lim_free (0, it);
100   }
101 
102   return 0;
103 }
104 
105 
106 
107 
108 /* tag: Tom Lord Sun Jun  8 17:08:52 2003 (cmd-tagging-defaults.c)
109  */
110