diff --git a/examples/platform/posix/cmdline.c b/examples/platform/posix/cmdline.c index 15bb2d5ea..eaf3bfbc1 100644 --- a/examples/platform/posix/cmdline.c +++ b/examples/platform/posix/cmdline.c @@ -29,7 +29,7 @@ /* File autogenerated by gengetopt version 2.22.6 generated with the following command: - gengetopt -i cmdline.ggo + gengetopt -i cmdline.ggo The developers of gengetopt consider the fixed text that goes in all gengetopt output files to be in the public domain: @@ -56,50 +56,51 @@ const char *gengetopt_args_info_versiontext = ""; const char *gengetopt_args_info_description = ""; -const char *gengetopt_args_info_help[] = { - " -h, --help Print help and exit", - " -V, --version Print version and exit", - " --nodeid=INT Node ID", - " -S, --stdserial Use stdin/stdout for serial (default=on)", +const char *gengetopt_args_info_help[] = +{ + " -h, --help Print help and exit", + " -V, --version Print version and exit", + " --nodeid=INT Node ID", + " -S, --stdserial Use stdin/stdout for serial (default=on)", 0 }; typedef enum {ARG_NO - , ARG_FLAG - , ARG_INT -} cmdline_parser_arg_type; +, ARG_FLAG +, ARG_INT + } cmdline_parser_arg_type; static -void clear_given (struct gengetopt_args_info *args_info); +void clear_given(struct gengetopt_args_info *args_info); static -void clear_args (struct gengetopt_args_info *args_info); +void clear_args(struct gengetopt_args_info *args_info); static int -cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info, +cmdline_parser_internal(int argc, char **argv, struct gengetopt_args_info *args_info, struct cmdline_parser_params *params, const char *additional_error); static int -cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error); +cmdline_parser_required2(struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error); static char * -gengetopt_strdup (const char *s); +gengetopt_strdup(const char *s); static -void clear_given (struct gengetopt_args_info *args_info) +void clear_given(struct gengetopt_args_info *args_info) { - args_info->help_given = 0 ; - args_info->version_given = 0 ; - args_info->nodeid_given = 0 ; - args_info->stdserial_given = 0 ; + args_info->help_given = 0 ; + args_info->version_given = 0 ; + args_info->nodeid_given = 0 ; + args_info->stdserial_given = 0 ; } static -void clear_args (struct gengetopt_args_info *args_info) +void clear_args(struct gengetopt_args_info *args_info) { - FIX_UNUSED (args_info); - args_info->nodeid_orig = NULL; - args_info->stdserial_flag = 1; - + FIX_UNUSED(args_info); + args_info->nodeid_orig = NULL; + args_info->stdserial_flag = 1; + } static @@ -107,258 +108,295 @@ void init_args_info(struct gengetopt_args_info *args_info) { - args_info->help_help = gengetopt_args_info_help[0] ; - args_info->version_help = gengetopt_args_info_help[1] ; - args_info->nodeid_help = gengetopt_args_info_help[2] ; - args_info->stdserial_help = gengetopt_args_info_help[3] ; - + args_info->help_help = gengetopt_args_info_help[0] ; + args_info->version_help = gengetopt_args_info_help[1] ; + args_info->nodeid_help = gengetopt_args_info_help[2] ; + args_info->stdserial_help = gengetopt_args_info_help[3] ; + } void -cmdline_parser_print_version (void) +cmdline_parser_print_version(void) { - printf ("%s %s\n", - (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE), - CMDLINE_PARSER_VERSION); + printf("%s %s\n", + (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE), + CMDLINE_PARSER_VERSION); - if (strlen(gengetopt_args_info_versiontext) > 0) - printf("\n%s\n", gengetopt_args_info_versiontext); + if (strlen(gengetopt_args_info_versiontext) > 0) + { + printf("\n%s\n", gengetopt_args_info_versiontext); + } } -static void print_help_common(void) { - cmdline_parser_print_version (); +static void print_help_common(void) +{ + cmdline_parser_print_version(); - if (strlen(gengetopt_args_info_purpose) > 0) - printf("\n%s\n", gengetopt_args_info_purpose); + if (strlen(gengetopt_args_info_purpose) > 0) + { + printf("\n%s\n", gengetopt_args_info_purpose); + } - if (strlen(gengetopt_args_info_usage) > 0) - printf("\n%s\n", gengetopt_args_info_usage); + if (strlen(gengetopt_args_info_usage) > 0) + { + printf("\n%s\n", gengetopt_args_info_usage); + } - printf("\n"); + printf("\n"); - if (strlen(gengetopt_args_info_description) > 0) - printf("%s\n\n", gengetopt_args_info_description); + if (strlen(gengetopt_args_info_description) > 0) + { + printf("%s\n\n", gengetopt_args_info_description); + } } void -cmdline_parser_print_help (void) +cmdline_parser_print_help(void) { - int i = 0; - print_help_common(); - while (gengetopt_args_info_help[i]) - printf("%s\n", gengetopt_args_info_help[i++]); + int i = 0; + print_help_common(); + + while (gengetopt_args_info_help[i]) + { + printf("%s\n", gengetopt_args_info_help[i++]); + } } void -cmdline_parser_init (struct gengetopt_args_info *args_info) +cmdline_parser_init(struct gengetopt_args_info *args_info) { - clear_given (args_info); - clear_args (args_info); - init_args_info (args_info); + clear_given(args_info); + clear_args(args_info); + init_args_info(args_info); } void cmdline_parser_params_init(struct cmdline_parser_params *params) { - if (params) - { - params->override = 0; - params->initialize = 1; - params->check_required = 1; - params->check_ambiguity = 0; - params->print_errors = 1; + if (params) + { + params->override = 0; + params->initialize = 1; + params->check_required = 1; + params->check_ambiguity = 0; + params->print_errors = 1; } } struct cmdline_parser_params * cmdline_parser_params_create(void) { - struct cmdline_parser_params *params = - (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params)); - cmdline_parser_params_init(params); - return params; + struct cmdline_parser_params *params = + (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params)); + cmdline_parser_params_init(params); + return params; } static void -free_string_field (char **s) +free_string_field(char **s) { - if (*s) + if (*s) { - free (*s); - *s = 0; + free(*s); + *s = 0; } } static void -cmdline_parser_release (struct gengetopt_args_info *args_info) +cmdline_parser_release(struct gengetopt_args_info *args_info) { - free_string_field (&(args_info->nodeid_orig)); - - + free_string_field(&(args_info->nodeid_orig)); - clear_given (args_info); + + + clear_given(args_info); } static void write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[]) { - FIX_UNUSED (values); - if (arg) { - fprintf(outfile, "%s=\"%s\"\n", opt, arg); - } else { - fprintf(outfile, "%s\n", opt); - } + FIX_UNUSED(values); + + if (arg) + { + fprintf(outfile, "%s=\"%s\"\n", opt, arg); + } + else + { + fprintf(outfile, "%s\n", opt); + } } int cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info) { - int i = 0; + int i = 0; - if (!outfile) + if (!outfile) { - fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE); - return EXIT_FAILURE; + fprintf(stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE); + return EXIT_FAILURE; } - if (args_info->help_given) - write_into_file(outfile, "help", 0, 0 ); - if (args_info->version_given) - write_into_file(outfile, "version", 0, 0 ); - if (args_info->nodeid_given) - write_into_file(outfile, "nodeid", args_info->nodeid_orig, 0); - if (args_info->stdserial_given) - write_into_file(outfile, "stdserial", 0, 0 ); - + if (args_info->help_given) + { + write_into_file(outfile, "help", 0, 0); + } - i = EXIT_SUCCESS; - return i; + if (args_info->version_given) + { + write_into_file(outfile, "version", 0, 0); + } + + if (args_info->nodeid_given) + { + write_into_file(outfile, "nodeid", args_info->nodeid_orig, 0); + } + + if (args_info->stdserial_given) + { + write_into_file(outfile, "stdserial", 0, 0); + } + + + i = EXIT_SUCCESS; + return i; } int cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info) { - FILE *outfile; - int i = 0; + FILE *outfile; + int i = 0; - outfile = fopen(filename, "w"); + outfile = fopen(filename, "w"); - if (!outfile) + if (!outfile) { - fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename); - return EXIT_FAILURE; + fprintf(stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename); + return EXIT_FAILURE; } - i = cmdline_parser_dump(outfile, args_info); - fclose (outfile); + i = cmdline_parser_dump(outfile, args_info); + fclose(outfile); - return i; + return i; } void -cmdline_parser_free (struct gengetopt_args_info *args_info) +cmdline_parser_free(struct gengetopt_args_info *args_info) { - cmdline_parser_release (args_info); + cmdline_parser_release(args_info); } /** @brief replacement of strdup, which is not standard */ char * -gengetopt_strdup (const char *s) +gengetopt_strdup(const char *s) { - char *result = 0; - if (!s) + char *result = 0; + + if (!s) + { + return result; + } + + result = (char *)malloc(strlen(s) + 1); + + if (result == (char *)0) + { + return (char *)0; + } + + strcpy(result, s); return result; - - result = (char*)malloc(strlen(s) + 1); - if (result == (char*)0) - return (char*)0; - strcpy(result, s); - return result; } int -cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info) +cmdline_parser(int argc, char **argv, struct gengetopt_args_info *args_info) { - return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); + return cmdline_parser2(argc, argv, args_info, 0, 1, 1); } int -cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info, +cmdline_parser_ext(int argc, char **argv, struct gengetopt_args_info *args_info, struct cmdline_parser_params *params) { - int result; - result = cmdline_parser_internal (argc, argv, args_info, params, 0); + int result; + result = cmdline_parser_internal(argc, argv, args_info, params, 0); - if (result == EXIT_FAILURE) + if (result == EXIT_FAILURE) { - cmdline_parser_free (args_info); - exit (EXIT_FAILURE); + cmdline_parser_free(args_info); + exit(EXIT_FAILURE); } - - return result; + + return result; } int -cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) +cmdline_parser2(int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, + int check_required) { - int result; - struct cmdline_parser_params params; - - params.override = override; - params.initialize = initialize; - params.check_required = check_required; - params.check_ambiguity = 0; - params.print_errors = 1; + int result; + struct cmdline_parser_params params; - result = cmdline_parser_internal (argc, argv, args_info, ¶ms, 0); + params.override = override; + params.initialize = initialize; + params.check_required = check_required; + params.check_ambiguity = 0; + params.print_errors = 1; - if (result == EXIT_FAILURE) + result = cmdline_parser_internal(argc, argv, args_info, ¶ms, 0); + + if (result == EXIT_FAILURE) { - cmdline_parser_free (args_info); - exit (EXIT_FAILURE); + cmdline_parser_free(args_info); + exit(EXIT_FAILURE); } - - return result; + + return result; } int -cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name) +cmdline_parser_required(struct gengetopt_args_info *args_info, const char *prog_name) { - int result = EXIT_SUCCESS; + int result = EXIT_SUCCESS; - if (cmdline_parser_required2(args_info, prog_name, 0) > 0) - result = EXIT_FAILURE; - - if (result == EXIT_FAILURE) + if (cmdline_parser_required2(args_info, prog_name, 0) > 0) { - cmdline_parser_free (args_info); - exit (EXIT_FAILURE); + result = EXIT_FAILURE; } - - return result; + + if (result == EXIT_FAILURE) + { + cmdline_parser_free(args_info); + exit(EXIT_FAILURE); + } + + return result; } int -cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error) +cmdline_parser_required2(struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error) { - int error_occurred = 0; - FIX_UNUSED (additional_error); + int error_occurred = 0; + FIX_UNUSED(additional_error); - /* checks for required options */ - if (! args_info->nodeid_given) + /* checks for required options */ + if (! args_info->nodeid_given) { - fprintf (stderr, "%s: '--nodeid' option required%s\n", prog_name, (additional_error ? additional_error : "")); - error_occurred = 1; + fprintf(stderr, "%s: '--nodeid' option required%s\n", prog_name, (additional_error ? additional_error : "")); + error_occurred = 1; } - - - /* checks for dependences among options */ - return error_occurred; + + /* checks for dependences among options */ + + return error_occurred; } @@ -384,7 +422,7 @@ static char *package_name = 0; */ static int update_arg(void *field, char **orig_field, - unsigned int *field_given, unsigned int *prev_given, + unsigned int *field_given, unsigned int *prev_given, char *value, const char *possible_values[], const char *default_value, cmdline_parser_arg_type arg_type, @@ -393,196 +431,236 @@ int update_arg(void *field, char **orig_field, const char *long_opt, char short_opt, const char *additional_error) { - char *stop_char = 0; - const char *val = value; - int found; - FIX_UNUSED (field); + char *stop_char = 0; + const char *val = value; + int found; + FIX_UNUSED(field); - stop_char = 0; - found = 0; + stop_char = 0; + found = 0; - if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given))) + if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given))) { - if (short_opt != '-') - fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n", - package_name, long_opt, short_opt, - (additional_error ? additional_error : "")); - else - fprintf (stderr, "%s: `--%s' option given more than once%s\n", - package_name, long_opt, - (additional_error ? additional_error : "")); - return 1; /* failure */ + if (short_opt != '-') + fprintf(stderr, "%s: `--%s' (`-%c') option given more than once%s\n", + package_name, long_opt, short_opt, + (additional_error ? additional_error : "")); + else + fprintf(stderr, "%s: `--%s' option given more than once%s\n", + package_name, long_opt, + (additional_error ? additional_error : "")); + + return 1; /* failure */ } - FIX_UNUSED (default_value); - - if (field_given && *field_given && ! override) - return 0; - if (prev_given) - (*prev_given)++; - if (field_given) - (*field_given)++; - if (possible_values) - val = possible_values[found]; + FIX_UNUSED(default_value); - switch(arg_type) { - case ARG_FLAG: - *((int *)field) = !*((int *)field); - break; - case ARG_INT: - if (val) *((int *)field) = strtol (val, &stop_char, 0); - break; - default: - break; - }; - - /* check numeric conversion */ - switch(arg_type) { - case ARG_INT: - if (val && !(stop_char && *stop_char == '\0')) { - fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val); - return 1; /* failure */ + if (field_given && *field_given && ! override) + { + return 0; } - break; - default: - ; - }; - /* store the original value */ - switch(arg_type) { - case ARG_NO: - case ARG_FLAG: - break; - default: - if (value && orig_field) { - if (no_free) { - *orig_field = value; - } else { - if (*orig_field) - free (*orig_field); /* free previous string */ - *orig_field = gengetopt_strdup (value); - } + if (prev_given) + { + (*prev_given)++; } - }; - return 0; /* OK */ + if (field_given) + { + (*field_given)++; + } + + if (possible_values) + { + val = possible_values[found]; + } + + switch (arg_type) + { + case ARG_FLAG: + *((int *)field) = !*((int *)field); + break; + + case ARG_INT: + if (val) { *((int *)field) = strtol(val, &stop_char, 0); } + + break; + + default: + break; + }; + + /* check numeric conversion */ + switch (arg_type) + { + case ARG_INT: + if (val && !(stop_char && *stop_char == '\0')) + { + fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val); + return 1; /* failure */ + } + + break; + + default: + ; + }; + + /* store the original value */ + switch (arg_type) + { + case ARG_NO: + case ARG_FLAG: + break; + + default: + if (value && orig_field) + { + if (no_free) + { + *orig_field = value; + } + else + { + if (*orig_field) + { + free(*orig_field); /* free previous string */ + } + + *orig_field = gengetopt_strdup(value); + } + } + }; + + return 0; /* OK */ } int -cmdline_parser_internal ( - int argc, char **argv, struct gengetopt_args_info *args_info, - struct cmdline_parser_params *params, const char *additional_error) +cmdline_parser_internal( + int argc, char **argv, struct gengetopt_args_info *args_info, + struct cmdline_parser_params *params, const char *additional_error) { - int c; /* Character of the parsed option. */ + int c; /* Character of the parsed option. */ - int error_occurred = 0; - struct gengetopt_args_info local_args_info; - - int override; - int initialize; - int check_required; - int check_ambiguity; - - package_name = argv[0]; - - override = params->override; - initialize = params->initialize; - check_required = params->check_required; - check_ambiguity = params->check_ambiguity; + int error_occurred = 0; + struct gengetopt_args_info local_args_info; - if (initialize) - cmdline_parser_init (args_info); + int override; + int initialize; + int check_required; + int check_ambiguity; - cmdline_parser_init (&local_args_info); + package_name = argv[0]; - optarg = 0; - optind = 0; - opterr = params->print_errors; - optopt = '?'; + override = params->override; + initialize = params->initialize; + check_required = params->check_required; + check_ambiguity = params->check_ambiguity; - while (1) + if (initialize) { - int option_index = 0; + cmdline_parser_init(args_info); + } - static struct option long_options[] = { - { "help", 0, NULL, 'h' }, - { "version", 0, NULL, 'V' }, - { "nodeid", 1, NULL, 0 }, - { "stdserial", 0, NULL, 'S' }, - { 0, 0, 0, 0 } - }; + cmdline_parser_init(&local_args_info); - c = getopt_long (argc, argv, "hVS", long_options, &option_index); + optarg = 0; + optind = 0; + opterr = params->print_errors; + optopt = '?'; - if (c == -1) break; /* Exit from `while (1)' loop. */ + while (1) + { + int option_index = 0; - switch (c) + static struct option long_options[] = { - case 'h': /* Print help and exit. */ - cmdline_parser_print_help (); - cmdline_parser_free (&local_args_info); - exit (EXIT_SUCCESS); + { "help", 0, NULL, 'h' }, + { "version", 0, NULL, 'V' }, + { "nodeid", 1, NULL, 0 }, + { "stdserial", 0, NULL, 'S' }, + { 0, 0, 0, 0 } + }; - case 'V': /* Print version and exit. */ - cmdline_parser_print_version (); - cmdline_parser_free (&local_args_info); - exit (EXIT_SUCCESS); + c = getopt_long(argc, argv, "hVS", long_options, &option_index); - case 'S': /* Use stdin/stdout for serial. */ - - - if (update_arg((void *)&(args_info->stdserial_flag), 0, &(args_info->stdserial_given), - &(local_args_info.stdserial_given), optarg, 0, 0, ARG_FLAG, - check_ambiguity, override, 1, 0, "stdserial", 'S', - additional_error)) + if (c == -1) { break; } /* Exit from `while (1)' loop. */ + + switch (c) + { + case 'h': /* Print help and exit. */ + cmdline_parser_print_help(); + cmdline_parser_free(&local_args_info); + exit(EXIT_SUCCESS); + + case 'V': /* Print version and exit. */ + cmdline_parser_print_version(); + cmdline_parser_free(&local_args_info); + exit(EXIT_SUCCESS); + + case 'S': /* Use stdin/stdout for serial. */ + + + if (update_arg((void *) & (args_info->stdserial_flag), 0, &(args_info->stdserial_given), + &(local_args_info.stdserial_given), optarg, 0, 0, ARG_FLAG, + check_ambiguity, override, 1, 0, "stdserial", 'S', + additional_error)) + { + goto failure; + } + + break; + + case 0: /* Long option with no short option */ + + /* Node ID. */ + if (strcmp(long_options[option_index].name, "nodeid") == 0) + { + + + if (update_arg((void *) & (args_info->nodeid_arg), + &(args_info->nodeid_orig), &(args_info->nodeid_given), + &(local_args_info.nodeid_given), optarg, 0, 0, ARG_INT, + check_ambiguity, override, 0, 0, + "nodeid", '-', + additional_error)) + { + goto failure; + } + + } + + break; + + case '?': /* Invalid option. */ + /* `getopt_long' already printed an error message. */ goto failure; - - break; - case 0: /* Long option with no short option */ - /* Node ID. */ - if (strcmp (long_options[option_index].name, "nodeid") == 0) - { - - - if (update_arg( (void *)&(args_info->nodeid_arg), - &(args_info->nodeid_orig), &(args_info->nodeid_given), - &(local_args_info.nodeid_given), optarg, 0, 0, ARG_INT, - check_ambiguity, override, 0, 0, - "nodeid", '-', - additional_error)) - goto failure; - - } - - break; - case '?': /* Invalid option. */ - /* `getopt_long' already printed an error message. */ - goto failure; - - default: /* bug: option not considered. */ - fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); - abort (); + default: /* bug: option not considered. */ + fprintf(stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); + abort(); } /* switch */ } /* while */ - if (check_required) + if (check_required) { - error_occurred += cmdline_parser_required2 (args_info, argv[0], additional_error); + error_occurred += cmdline_parser_required2(args_info, argv[0], additional_error); } - cmdline_parser_release (&local_args_info); + cmdline_parser_release(&local_args_info); - if ( error_occurred ) - return (EXIT_FAILURE); + if (error_occurred) + { + return (EXIT_FAILURE); + } - return 0; + return 0; failure: - - cmdline_parser_release (&local_args_info); - return (EXIT_FAILURE); + + cmdline_parser_release(&local_args_info); + return (EXIT_FAILURE); } diff --git a/examples/platform/posix/cmdline.h b/examples/platform/posix/cmdline.h index 39a123fa0..e5017188e 100644 --- a/examples/platform/posix/cmdline.h +++ b/examples/platform/posix/cmdline.h @@ -60,29 +60,29 @@ extern "C" { /** @brief Where the command line options are stored */ struct gengetopt_args_info { - const char *help_help; /**< @brief Print help and exit help description. */ - const char *version_help; /**< @brief Print version and exit help description. */ - int nodeid_arg; /**< @brief Node ID. */ - char * nodeid_orig; /**< @brief Node ID original value given at command line. */ - const char *nodeid_help; /**< @brief Node ID help description. */ - int stdserial_flag; /**< @brief Use stdin/stdout for serial (default=on). */ - const char *stdserial_help; /**< @brief Use stdin/stdout for serial help description. */ - - unsigned int help_given ; /**< @brief Whether help was given. */ - unsigned int version_given ; /**< @brief Whether version was given. */ - unsigned int nodeid_given ; /**< @brief Whether nodeid was given. */ - unsigned int stdserial_given ; /**< @brief Whether stdserial was given. */ + const char *help_help; /**< @brief Print help and exit help description. */ + const char *version_help; /**< @brief Print version and exit help description. */ + int nodeid_arg; /**< @brief Node ID. */ + char *nodeid_orig; /**< @brief Node ID original value given at command line. */ + const char *nodeid_help; /**< @brief Node ID help description. */ + int stdserial_flag; /**< @brief Use stdin/stdout for serial (default=on). */ + const char *stdserial_help; /**< @brief Use stdin/stdout for serial help description. */ + + unsigned int help_given ; /**< @brief Whether help was given. */ + unsigned int version_given ; /**< @brief Whether version was given. */ + unsigned int nodeid_given ; /**< @brief Whether nodeid was given. */ + unsigned int stdserial_given ; /**< @brief Whether stdserial was given. */ } ; /** @brief The additional parameters to pass to parser functions */ struct cmdline_parser_params { - int override; /**< @brief whether to override possibly already present options (default 0) */ - int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */ - int check_required; /**< @brief whether to check that all required options were provided (default 1) */ - int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */ - int print_errors; /**< @brief whether getopt_long should print an error message for a bad option (default 1) */ + int override; /**< @brief whether to override possibly already present options (default 0) */ + int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */ + int check_required; /**< @brief whether to check that all required options were provided (default 1) */ + int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */ + int print_errors; /**< @brief whether getopt_long should print an error message for a bad option (default 1) */ } ; /** @brief the purpose string of the program */ @@ -101,8 +101,8 @@ extern const char *gengetopt_args_info_help[]; * @param args_info the structure where option information will be stored * @return 0 if everything went fine, NON 0 if an error took place */ -int cmdline_parser (int argc, char **argv, - struct gengetopt_args_info *args_info); +int cmdline_parser(int argc, char **argv, + struct gengetopt_args_info *args_info); /** * The command line parser (version with additional parameters - deprecated) @@ -115,9 +115,9 @@ int cmdline_parser (int argc, char **argv, * @return 0 if everything went fine, NON 0 if an error took place * @deprecated use cmdline_parser_ext() instead */ -int cmdline_parser2 (int argc, char **argv, - struct gengetopt_args_info *args_info, - int override, int initialize, int check_required); +int cmdline_parser2(int argc, char **argv, + struct gengetopt_args_info *args_info, + int override, int initialize, int check_required); /** * The command line parser (version with additional parameters) @@ -127,9 +127,9 @@ int cmdline_parser2 (int argc, char **argv, * @param params additional parameters for the parser * @return 0 if everything went fine, NON 0 if an error took place */ -int cmdline_parser_ext (int argc, char **argv, - struct gengetopt_args_info *args_info, - struct cmdline_parser_params *params); +int cmdline_parser_ext(int argc, char **argv, + struct gengetopt_args_info *args_info, + struct cmdline_parser_params *params); /** * Save the contents of the option struct into an already open FILE stream. @@ -138,7 +138,7 @@ int cmdline_parser_ext (int argc, char **argv, * @return 0 if everything went fine, NON 0 if an error took place */ int cmdline_parser_dump(FILE *outfile, - struct gengetopt_args_info *args_info); + struct gengetopt_args_info *args_info); /** * Save the contents of the option struct into a (text) file. @@ -148,7 +148,7 @@ int cmdline_parser_dump(FILE *outfile, * @return 0 if everything went fine, NON 0 if an error took place */ int cmdline_parser_file_save(const char *filename, - struct gengetopt_args_info *args_info); + struct gengetopt_args_info *args_info); /** * Print the help @@ -160,7 +160,7 @@ void cmdline_parser_print_help(void); void cmdline_parser_print_version(void); /** - * Initializes all the fields a cmdline_parser_params structure + * Initializes all the fields a cmdline_parser_params structure * to their default values * @param params the structure to initialize */ @@ -178,13 +178,13 @@ struct cmdline_parser_params *cmdline_parser_params_create(void); * (also set default values for options that have a default) * @param args_info the structure to initialize */ -void cmdline_parser_init (struct gengetopt_args_info *args_info); +void cmdline_parser_init(struct gengetopt_args_info *args_info); /** * Deallocates the string fields of the gengetopt_args_info structure * (but does not deallocate the structure itself) * @param args_info the structure to deallocate */ -void cmdline_parser_free (struct gengetopt_args_info *args_info); +void cmdline_parser_free(struct gengetopt_args_info *args_info); /** * Checks that all the required options were specified @@ -193,8 +193,8 @@ void cmdline_parser_free (struct gengetopt_args_info *args_info); * possible errors * @return */ -int cmdline_parser_required (struct gengetopt_args_info *args_info, - const char *prog_name); +int cmdline_parser_required(struct gengetopt_args_info *args_info, + const char *prog_name); #ifdef __cplusplus diff --git a/examples/platform/posix/serial.c b/examples/platform/posix/serial.c index 9355162a1..af5f48b63 100644 --- a/examples/platform/posix/serial.c +++ b/examples/platform/posix/serial.c @@ -137,7 +137,7 @@ ThreadError otPlatSerialEnable(void) // turn off character processing termios.c_cflag &= ~(CSIZE | PARENB); - termios.c_cflag |= CS8|HUPCL|CREAD|CLOCAL; + termios.c_cflag |= CS8 | HUPCL | CREAD | CLOCAL; // return 1 byte at a time termios.c_cc[VMIN] = 1; @@ -162,7 +162,7 @@ ThreadError otPlatSerialEnable(void) // turn off character processing termios.c_cflag &= ~(CSIZE | PARENB); - termios.c_cflag |= CS8|HUPCL|CREAD|CLOCAL; + termios.c_cflag |= CS8 | HUPCL | CREAD | CLOCAL; // configure baud rate VerifyOrExit(cfsetospeed(&termios, B115200) == 0, perror("cfsetospeed"); error = kThreadError_Error);