*
* Copyright (C) 2011 Hugo Villeneuve <hugo@hugovil.com>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This file is released under the GPLv2
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
-#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <argp.h>
/* 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},
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");
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");
{
char *endptr;
- *dest = strtol(arg, &endptr, 0);
+ *dest = (uint16_t) strtol(arg, &endptr, 0);
if (*endptr != '\0') {
log_err("Invalid address");
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;
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;
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");
}