- if (NULL == (cfg_comm = tr_comm_lookup((TR_INSTANCE *)tids->cookie, orig_req->comm))) {
- fprintf(stderr, "tr_tids_req_hander: Request for unknown comm: %s.\n", orig_req->comm->buf);
- tids_send_err_response(tids, orig_req, "Unknown community");
- return -1;
+/* argp global parameters */
+const char *argp_program_bug_address=PACKAGE_BUGREPORT; /* bug reporting address */
+
+/* doc strings */
+static const char doc[]=PACKAGE_NAME " - Moonshot Trust Router " PACKAGE_VERSION;
+static const char arg_doc[]=""; /* string describing arguments, if any */
+
+/* define the options here. Fields are:
+ * { long-name, short-name, variable name, options, help description } */
+static const struct argp_option cmdline_options[] = {
+ { "config-dir", 'c', "DIR", 0, "Specify configuration file location (default is current directory)"},
+ { "config-validate", 'C', NULL, 0, "Validate configuration files and exit"},
+ { "version", 1, NULL, 0, "Print version information and exit"},
+ { NULL }
+};
+
+/* structure for communicating with option parser */
+struct cmdline_args {
+ int version_requested;
+ int validate_config_and_exit;
+ char *config_dir;
+};
+
+/* parser for individual options - fills in a struct cmdline_args */
+static error_t parse_option(int key, char *arg, struct argp_state *state)
+{
+ /* get a shorthand to the command line argument structure, part of state */
+ struct cmdline_args *arguments=state->input;
+
+ switch (key) {
+ case 'c':
+ if (arg == NULL) {
+ /* somehow we got called without an argument */
+ return ARGP_ERR_UNKNOWN;
+ }
+ arguments->config_dir=arg;
+ break;
+
+ case 1:
+ arguments->version_requested=1;
+ break;
+
+ case 'C':
+ arguments->validate_config_and_exit=1;
+ break;
+
+ default:
+ return ARGP_ERR_UNKNOWN;