+/* Program version and bug report address. */
+
+const char *argp_program_version = PACKAGE_VERSION;
+const char *argp_program_bug_address = PACKAGE_BUGREPORT;
+
+/* Documentation strings. */
+
+static const char rnetclient_doc[] =
+ "Send the Brazilian Income Tax Report to the Brazilian "
+ "Tax Authority";
+static const char rnetclient_args_doc[] =
+ "[-d|--declaration] FILE";
+
+/* Description and definition of each option accepted by the program. */
+
+static const struct argp_option rnetclient_options_desc[] = {
+ { "declaration", 'd', "FILE", 0,
+ "The Income Tax Report file that will be sent.",
+ 0 },
+
+ { NULL },
+};
+
+struct rnetclient_args {
+ /* File representing the declaration. */
+ char *input_file;
+};
+
+/* Parser for command line arguments. */
+
+static error_t rnetclient_parse_opt(int key, char *arg, struct argp_state *state)
+{
+ struct rnetclient_args *a = state->input;
+ switch (key) {
+ case 'd':
+ /* The user has explicitly provided a filename through
+ the '-d' switch. */
+ a->input_file = arg;
+ break;
+
+ case ARGP_KEY_ARG:
+ /* The user has possibly provided a filename without
+ using any switches (e.g., by running './rnetclient
+ file'). */
+ a->input_file = arg;
+ break;
+
+ case ARGP_KEY_END:
+ /* We have reached the end of the argument parsing.
+ Let's check if the user has provided a filename. */
+ if (a->input_file == NULL)
+ argp_error(state,
+ "You need to provide the Income Tax Declaration "
+ "filename.");
+ }
+
+ return 0;
+}
+
+/* Control struct used by argp. */
+
+static struct argp rnetclient_argp = {
+ rnetclient_options_desc,
+ rnetclient_parse_opt,
+ rnetclient_args_doc,
+ rnetclient_doc,
+ NULL, NULL, NULL
+};
+