X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcommon%2Foptions.c;h=c3d91d17e41e7d23b2396ea5f637b82b0616951e;hb=121bcb38f29409f10de63a68d86620c4beb75c97;hp=4b9b905815d8db2b7103e36f8795803e93ce5539;hpb=3c838204cd78bcf106fdd65476180659ab629fcb;p=emu8051.git diff --git a/src/common/options.c b/src/common/options.c index 4b9b905..c3d91d1 100644 --- a/src/common/options.c +++ b/src/common/options.c @@ -10,7 +10,6 @@ # include "config.h" #endif -#include #include #include #include @@ -43,6 +42,7 @@ static const char args_doc[] = "[FILENAME]"; /* The options we understand. */ static struct argp_option argp_options[] = { {"debug", 'd', "level", 0, "Produce debugging output", 0}, + {"geometry", 'g', "pos", 0, "Set geometry", 0}, {"pram", 'p', "size", 0, "Set program memory size", 0}, {"xram", 'x', "size", 0, "Set external ram size (default is 1024)", 0}, @@ -59,7 +59,7 @@ decode_debug_option(char *arg, struct argp_state *state) char *endptr; int log_level; - log_level = strtol(arg, &endptr, 0); + log_level = (int) strtol(arg, &endptr, 0); if (*endptr != '\0') { log_err("Invalid log level"); @@ -87,13 +87,13 @@ decode_memory_size(char *arg, struct argp_state *state, int memid) else if (memid == EXT_MEM_ID) dest = &options.xram_size; else - exit(1); /* Programming error. */ + exit(EXIT_FAILURE); /* Programming error. */ /* * Sizes versus max memory sizes will be checked when calling * memory_init(). */ - *dest = strtol(arg, &endptr, 0); + *dest = (int) strtol(arg, &endptr, 0); if (*endptr != '\0') { log_err("Invalid memory size"); @@ -106,7 +106,7 @@ decode_address(char *arg, struct argp_state *state, uint16_t *dest) { char *endptr; - *dest = strtol(arg, &endptr, 0); + *dest = (uint16_t) strtol(arg, &endptr, 0); if (*endptr != '\0') { log_err("Invalid address"); @@ -122,6 +122,9 @@ parse_opt(int key, char *arg, struct argp_state *state) case 'd': decode_debug_option(arg, state); break; + case 'g': + options.g = arg; + break; case 'i': decode_memory_size(arg, state, INT_MEM_ID); break; @@ -163,8 +166,11 @@ static struct argp argp = {argp_options, parse_opt, args_doc, str_doc, void parse_command_line_options(int argc, char *argv[]) { + error_t rc; + /* Setting default values. */ options.filename = NULL; + options.g = NULL; options.pram_size = PGM_MEM_DEFAULT_SIZE; options.iram_size = INT_MEM_MAX_SIZE; options.xram_size = EXT_MEM_DEFAULT_SIZE; @@ -172,5 +178,7 @@ parse_command_line_options(int argc, char *argv[]) options.stop_address = 0; /* 0 means stop address is disabled. */ /* Parse our arguments. */ - argp_parse(&argp, argc, argv, 0, 0, NULL); + rc = argp_parse(&argp, argc, argv, 0, 0, NULL); + if (rc != 0) + log_fail("Failure to parse command line arguments"); }