Exemple #1
0
void disallow_plus(int arg)
{
	if(optsign == '+') {
		fprintf(stderr, "Unknown option '%c%c'\n", optsign, arg);
		exit_with_usage(-1);
	}
}
Exemple #2
0
int main(int argc, char **argv) {
  signal(SIGINT, signal_callback_handler);

  /* Default settings */
  server_port = 8000;
  void (*request_handler)(int) = NULL;

  int i;
  for (i = 1; i < argc; i++) {
    if (strcmp("--files", argv[i]) == 0) {
      request_handler = handle_files_request;
      free(server_files_directory);
      server_files_directory = argv[++i];
      if (!server_files_directory) {
        fprintf(stderr, "Expected argument after --files\n");
        exit_with_usage();
      }
    } else if (strcmp("--proxy", argv[i]) == 0) {
      request_handler = handle_proxy_request;

      char *proxy_target = argv[++i];
      if (!proxy_target) {
        fprintf(stderr, "Expected argument after --proxy\n");
        exit_with_usage();
      }

      char *colon_pointer = strchr(proxy_target, ':');
      if (colon_pointer != NULL) {
        *colon_pointer = '\0';
        server_proxy_hostname = proxy_target;
        server_proxy_port = atoi(colon_pointer + 1);
      } else {
        server_proxy_hostname = proxy_target;
        server_proxy_port = 80;
      }
    } else if (strcmp("--port", argv[i]) == 0) {
      char *server_port_string = argv[++i];
      if (!server_port_string) {
        fprintf(stderr, "Expected argument after --port\n");
        exit_with_usage();
      }
      server_port = atoi(server_port_string);
    } else if (strcmp("--help", argv[i]) == 0) {
      exit_with_usage();
    } else {
      fprintf(stderr, "Unrecognized option: %s\n", argv[i]);
      exit_with_usage();
    }
  }

  if (server_files_directory == NULL && server_proxy_hostname == NULL) {
    fprintf(stderr, "Please specify either \"--files [DIRECTORY]\" or \n"
                    "                      \"--proxy [HOSTNAME:PORT]\"\n");
    exit_with_usage();
  }

  serve_forever(&server_fd, request_handler);

  return EXIT_SUCCESS;
}
Exemple #3
0
static void
check_options( int argc, char **argv, GOptionContext *context )
{
	GError *error = NULL;

	if( argc == 1 ){
		g_set_prgname( argv[0] );
		gchar *help = g_option_context_get_help( context, FALSE, NULL );
		g_print( "\n%s", help );
		g_free( help );
		exit( EXIT_SUCCESS );
	}

	if( !g_option_context_parse( context, &argc, &argv, &error )){
		g_printerr( _( "Syntax error: %s\n" ), error->message );
		g_error_free (error);
		exit_with_usage();
	}

	g_option_context_free( context );

	if( version ){
		na_core_utils_print_version();
		exit( EXIT_SUCCESS );
	}

	gint errors = 0;

	if( !uri || !strlen( uri )){
		g_printerr( _( "Error: uri is mandatory.\n" ));
		errors += 1;
	}

	if( errors ){
		exit_with_usage();
	}
}
Exemple #4
0
void parse_entarg(void)
{
	size_t i, pos;
	size_t arglen;

	arglen = strlen(optarg);
	for(i = 0; i < arglen; i++) {
		pos = optarg[i] - 'a' + 1;
		if(pos < 1 || pos > et_LAST || Options.etypes[pos] == -1) {
			fprintf(stderr,
					"Unknown entity type code '%c' in option '%ce %s'\n",
					optarg[i], optsign, optarg);
			exit_with_usage(-1);
		}
		if(optsign == '-') Options.etypes[pos] = 0;
		else if(optsign == '+') Options.etypes[pos] = 1;
	}
}
Exemple #5
0
int main(int argc, char *argv[])
{
	unsigned int seed;
	double density;
	unsigned int bitsnumber;
	char *filename;

	/* Check for help */
	if (argc == 2)
	{
		if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))
			exit_with_usage(stdout);
		else 
			exit_with_usage(stderr);
	}
	
	if (argc != 5 )
		exit_with_usage(stderr);

	char *check;
	seed = strtoul (argv[1], &check, 10);
	if (*check != '\0')
	{
		fprintf(stderr, "Seed error\n\n");
		exit_with_usage(stderr);
	}
		
	density = strtod (argv[2], &check);
	if (*check != '\0')
	{
		fprintf(stderr, "Density error\n\n");
		exit_with_usage(stderr);
	}
		
	bitsnumber = strtoul (argv[3], &check, 10);
	if (*check != '\0')
	{
		fprintf(stderr, "Bitsnumber error\n\n");
		exit_with_usage(stderr);
	}
	
	filename = argv[4];
	
	return make_randbitmap(seed, density, bitsnumber, filename);
}
Exemple #6
0
int
main (int argc, const char *argv[])
{
	int busnum = 0, devnum = 0;
	int cmd = COMMAND_SET_NONE;
	int port = 1;
	int value = 0;
	int request, feature, index;
	int result = 0;
	int listing = 0;
	int verbose = 0;
	int hub = -1;
	libusb_device_handle *uh = NULL;
	int i;

	if (argc == 1)
		listing = 1;

	for (i = 1; i < argc; i++)
		if (argv[i][0] == '-')
			switch (argv[i][1])
		{
			case 'h':
				if (++i >= argc || busnum > 0 || devnum > 0)
					exit_with_usage (argv[0]);
				hub = atoi (argv[i]);
				break;

			case 'b':
				if (++i >= argc || hub >= 0)
					exit_with_usage (argv[0]);
				busnum = atoi (argv[i]);
				break;

			case 'd':
				if (++i >= argc || hub >= 0)
					exit_with_usage (argv[0]);
				devnum = atoi (argv[i]);
				break;

			case 'P':
				if (++i >= argc)
					exit_with_usage (argv[0]);
				port = atoi (argv[i]);
				break;

			case 'l':
				if (cmd != COMMAND_SET_NONE)
					exit_with_usage (argv[0]);
				if (++i < argc)
					value = atoi (argv[i]);
				else
					value = HUB_LED_GREEN;
				cmd = COMMAND_SET_LED;
				break;

			case 'p':
				if (cmd != COMMAND_SET_NONE)
					exit_with_usage (argv[0]);
				if (++i < argc)
					value = atoi (argv[i]);
				else
					value= 0;
				cmd = COMMAND_SET_POWER;
				break;

			case 'v':
				verbose = 1;
				if (argc == 2)
					listing = 1;
				break;

			default:
				exit_with_usage (argv[0]);
		}
		else
			exit_with_usage (argv[0]);

	if ((busnum > 0 && devnum <= 0) || (busnum <= 0 && devnum > 0))
		/* BUS is specified, but DEV is'nt, or ... */
		exit_with_usage (argv[0]);

	/* Default is the hub #0 */
	if (hub < 0 && busnum == 0)
		hub = 0;

	/* Default is POWER */
	if (cmd == COMMAND_SET_NONE)
		cmd = COMMAND_SET_POWER;

	libusb_init ( &ctx );
	libusb_set_debug( ctx, 3 );

	if (usb_find_hubs (listing, verbose, busnum, devnum, hub) <= 0)
	{
		fprintf (stderr, "No hubs found.\n");
		libusb_exit( ctx );
		exit (1);
	}

	if (listing){
		libusb_exit( ctx );
		exit (0);
	}

	if (hub < 0)
		hub = get_hub (busnum, devnum);

	if (hub >= 0 && hub < number_of_hubs_with_feature){
		if ( libusb_open (hubs[hub].dev, &uh ) || uh == NULL)
		{
			fprintf (stderr, "Device not found.\n");
			result = 1;
		}
		else
		{
			if (cmd == COMMAND_SET_POWER){
				if (value){
					request = LIBUSB_REQUEST_SET_FEATURE;
					feature = USB_PORT_FEAT_POWER;
					index = port;
				}else{
					request = LIBUSB_REQUEST_CLEAR_FEATURE;
					feature = USB_PORT_FEAT_POWER;
					index = port;
				}
			}else{
				request = LIBUSB_REQUEST_SET_FEATURE;
				feature = USB_PORT_FEAT_INDICATOR;
				index = (value << 8) | port;
			}

			if (verbose)
				printf ("Send control message (REQUEST=%d, FEATURE=%d, INDEX=%d)\n",
				request, feature, index);
/*
			if(libusb_detach_kernel_driver( uh, 0 ))
				perror("libusb_detach_kernel_driver");
			if(libusb_claim_interface( uh, 0 ))
				perror("libusb_claim_interface");
*/
			if (libusb_control_transfer (uh, USB_RT_PORT, request, feature, index,
				NULL, 0, CTRL_TIMEOUT) < 0)
			{
				perror ("failed to control.\n");
				result = 1;
			}

			if (verbose)
				hub_port_status (uh, hubs[hub].nport, hubs[hub].usb3);
/*
			libusb_release_interface( uh,0 );
			libusb_attach_kernel_driver( uh, 0); 
*/

			libusb_close (uh);
		}
	}
	libusb_exit( ctx );
	exit (result);
}
Exemple #7
0
int main(int argc, char **argv)
{

  signal(SIGINT, signal_callback_handler);

  /* Default settings */
  server_port = 8000;
  server_files_directory = malloc(1024);
  getcwd(server_files_directory, 1024);
  server_proxy_hostname = "inst.eecs.berkeley.edu";
  server_proxy_port = 80;

  void (*request_handler)(int) = handle_files_request;

  int i;
  for (i = 1; i < argc; i++)
  {
    if (strcmp("--files", argv[i]) == 0) {
      request_handler = handle_files_request;
      free(server_files_directory);
      server_files_directory = argv[++i];
      if (!server_files_directory) {
        fprintf(stderr, "Expected argument after --files\n");
        exit_with_usage();
      }
    } else if (strcmp("--proxy", argv[i]) == 0) {
      request_handler = handle_proxy_request;

      char *proxy_target = argv[++i];
      if (!proxy_target) {
        fprintf(stderr, "Expected argument after --proxy\n");
        exit_with_usage();
      }

      char *colon_pointer = strchr(proxy_target, ':');
      if (colon_pointer != NULL) {
        *colon_pointer = '\0';
        server_proxy_hostname = proxy_target;
        server_proxy_port = atoi(colon_pointer + 1);
      } else {
        server_proxy_hostname = proxy_target;
        server_proxy_port = 80;
      }
    } else if (strcmp("--port", argv[i]) == 0) {
      char *server_port_string = argv[++i];
      if (!server_port_string) {
        fprintf(stderr, "Expected argument after --port\n");
        exit_with_usage();
      }
      server_port = atoi(server_port_string);
    } else if (strcmp("--help", argv[i]) == 0) {
      exit_with_usage();
    } else {
      fprintf(stderr, "Unrecognized option: %s\n", argv[i]);
      exit_with_usage();
    }
  }

  serve_forever(&server_fd, request_handler);

  return EXIT_SUCCESS;

}
int
main( int argc, char** argv )
{
	int status = EXIT_SUCCESS;
	GOptionContext *context;
	GError *error = NULL;
	gchar *help;
	gint errors;
	NAObjectItem *item;
	NAIExporter *exporter;

#if !GLIB_CHECK_VERSION( 2,36, 0 )
	g_type_init();
#endif

	setlocale( LC_ALL, "" );
	console_init_log_handler();

	context = init_options();

	if( argc == 1 ){
		g_set_prgname( argv[0] );
		help = g_option_context_get_help( context, FALSE, NULL );
		g_print( "\n%s", help );
		g_free( help );
		exit( status );
	}

	if( !g_option_context_parse( context, &argc, &argv, &error )){
		g_printerr( _( "Syntax error: %s\n" ), error->message );
		g_error_free (error);
		exit_with_usage();
	}

	g_option_context_free( context );

	if( version ){
		na_core_utils_print_version();
		exit( status );
	}

	errors = 0;

	if( !id || !strlen( id )){
		g_printerr( _( "Error: a menu or action id is mandatory.\n" ));
		errors += 1;
	}

	item = get_item( id );
	if( !item ){
		errors += 1;
	}

	if( !format || !strlen( format )){
		format = "Desktop1";
	}

	exporter = na_exporter_find_for_format( pivot, format );
	if( !exporter ){
		/* i18n: %s stands for the id of the export format, and is not translatable */
		g_printerr( _( "Error: %s: unknown export format.\n" ), format );
		errors += 1;
	}

	if( errors ){
		exit_with_usage();
	}

	export_item( item, format );

	exit( status );
}
int
main( int argc, char** argv )
{
	int status = EXIT_SUCCESS;
	GOptionContext *context;
	GError *error = NULL;
	NAObjectAction *action;
	GSList *msg = NULL;
	GSList *im;
	gchar *help;
	gint errors;

#if !GLIB_CHECK_VERSION( 2,36, 0 )
	g_type_init();
#endif

	setlocale( LC_ALL, "" );
	console_init_log_handler();

	context = init_options();

	if( argc == 1 ){
		g_set_prgname( argv[0] );
		help = g_option_context_get_help( context, FALSE, NULL );
		g_print( "\n%s", help );
		g_free( help );
		exit( status );
	}

	if( !g_option_context_parse( context, &argc, &argv, &error )){
		g_printerr( _( "Syntax error: %s\n" ), error->message );
		g_error_free (error);
		exit_with_usage();
	}

	if( version ){
		na_core_utils_print_version();
		exit( status );
	}

	errors = 0;

	if( !label || !g_utf8_strlen( label, -1 )){
		g_printerr( _( "Error: an action label is mandatory.\n" ));
		errors += 1;
	}

	if( enabled && disabled ){
		g_printerr( CANNOT_BOTH, "--enabled", "--disabled" );
		errors += 1;
	} else if( !disabled ){
		enabled = TRUE;
	}

	if( target_selection && nocontext ){
		g_printerr( CANNOT_BOTH, "--context", "--nocontext" );
		errors += 1;
	} else if( !nocontext ){
		target_selection = TRUE;
	}

	if( target_location && nolocation ){
		g_printerr( CANNOT_BOTH, "--location", "--nolocation" );
		errors += 1;
	}

	if( target_toolbar && notoolbar ){
		g_printerr( CANNOT_BOTH, "--toolbar", "--notoolbar" );
		errors += 1;
	}

	if( matchcase && nocase ){
		g_printerr( CANNOT_BOTH, "--match-case", "--nocase" );
		errors += 1;
	} else if( !nocase ){
		matchcase = TRUE;
	}

	if( accept_multiple && strlen( selection_count )){
		g_printerr( CANNOT_BOTH, "--accept-multiple", "--selection-count" );
		errors += 1;
	}

	if( onlyshow_array && notshow_array ){
		g_printerr( CANNOT_BOTH, "--only-show-in", "--not-show-in" );
		errors += 1;
	}

	if( output_stdout && output_desktop ){
		g_printerr( _( "Error: only one output option may be specified.\n" ));
		errors += 1;
	}

	if( errors ){
		exit_with_usage();
	}

	action = get_action_from_cmdline();

	if( output_desktop ){
		output_to_desktop( action, &msg );
	} else {
		output_to_stdout( action, &msg );
	}

	if( msg ){
		for( im = msg ; im ; im = im->next ){
			g_printerr( "%s\n", ( gchar * ) im->data );
		}
		na_core_utils_slist_free( msg );
		status = EXIT_FAILURE;
	}

	g_object_unref( action );
	g_option_context_free( context );

	exit( status );
}
int usb_hub_port1_power_ctr(int value)
//main (int argc, const char *argv[])
{
  int busnum = 0, devnum = 0;
  int cmd = COMMAND_SET_NONE;
  int port = 1;
  //int value = 0;
  int request, feature, index;
  int result = 0;
  int listing = 0;
  int verbose = 0;
  int hub = -1;
  usb_dev_handle *uh = NULL;

  int i;




#if 0
  if (argc == 1)
    listing = 1;

  for (i = 1; i < argc; i++)
    if (argv[i][0] == '-')
      switch (argv[i][1])
	{
	case 'h':
	  if (++i >= argc || busnum > 0 || devnum > 0)
	    exit_with_usage (argv[0]);
	  hub = atoi (argv[i]);
	  break;

	case 'b':
	  if (++i >= argc || hub >= 0)
	    exit_with_usage (argv[0]);
	  busnum = atoi (argv[i]);
	  break;

	case 'd':
	  if (++i >= argc || hub >= 0)
	    exit_with_usage (argv[0]);
	  devnum = atoi (argv[i]);
	  break;

	case 'P':
	  if (++i >= argc)
	    exit_with_usage (argv[0]);
	  port = atoi (argv[i]);
	  break;

	case 'l':
	  if (cmd != COMMAND_SET_NONE)
	    exit_with_usage (argv[0]);
	  if (++i < argc)
	    value = atoi (argv[i]);
	  else
	    value = HUB_LED_GREEN;
	  cmd = COMMAND_SET_LED;
	  break;

	case 'p':
	  if (cmd != COMMAND_SET_NONE)
	    exit_with_usage (argv[0]);
	  if (++i < argc)
	    value = atoi (argv[i]);
	  else
	    value= 0;
	  cmd = COMMAND_SET_POWER;
	  break;

	case 'v':
	  verbose = 1;
	  if (argc == 2)
	    listing = 1;
	  break;

	default:
	  exit_with_usage (argv[0]);
	}
    else
      exit_with_usage (argv[0]);



  if ((busnum > 0 && devnum <= 0) || (busnum <= 0 && devnum > 0))
    /* BUS is specified, but DEV is'nt, or ... */
    exit_with_usage (argv[0]);
#else
    listing = 1;
    int return_busnum, return_devnum ;
    int *p_return_busnum = & return_busnum ;
    int *p_return_devnum = & return_devnum ;

#endif


  /* Default is the hub #0 */
  if (hub < 0 && busnum == 0)
    hub = 0;

  /* Default is POWER */
  if (cmd == COMMAND_SET_NONE)
    cmd = COMMAND_SET_POWER;

  usb_init ();
  usb_find_busses ();
  usb_find_devices ();


  if (
  usb_find_hubs (
  p_return_busnum,p_return_devnum     
    ,listing, verbose, busnum, devnum, hub) 
  //usb_find_hubs (listing, verbose, busnum, devnum, hub) 
    <= 0)
    {
  fprintf (stderr, "No hubs found.\n");
  exit (1);
    }
  else
    {
      //printf ("Hub %d:%d\n",return_busnum,return_devnum);
  busnum=return_busnum;
  devnum=return_devnum;
    }

#if 0
  if (listing)
    exit (0);
#endif

  if (hub < 0)
    hub = get_hub (busnum, devnum);

  if (hub >= 0 && hub < number_of_hubs_with_feature)
    uh = usb_open (hubs[hub].dev);

  if (uh == NULL)
    {
      fprintf (stderr, "Device not found.\n");
      result = 1;
    }
  else
    {
      if (cmd == COMMAND_SET_POWER)
	if (value)
	  {
	    request = USB_REQ_SET_FEATURE;
	    feature = USB_PORT_FEAT_POWER;
	    index = port;
	  }
	else
	  {
	    request = USB_REQ_CLEAR_FEATURE;
	    feature = USB_PORT_FEAT_POWER;
	    index = port;
	  }
      else
	{
	  request = USB_REQ_SET_FEATURE;
	  feature = USB_PORT_FEAT_INDICATOR;
	  index = (value << 8) | port;
	}

      if (verbose)
	printf ("Send control message (REQUEST=%d, FEATURE=%d, INDEX=%d)\n",
		request, feature, index);

      if (usb_control_msg (uh, USB_RT_PORT, request, feature, index,
			   NULL, 0, CTRL_TIMEOUT) < 0)
	{
	  perror ("failed to control.\n");
	  result = 1;
	}

      if (verbose)
	hub_port_status (uh, hubs[hub].nport);

      usb_close (uh);
    }

  //exit (result);
  return (result);
}
int
main( int argc, char** argv )
{
	static const gchar *thisfn = "caja_actions_run_main";
	int status = EXIT_SUCCESS;
	GOptionContext *context;
	GError *error = NULL;
	gchar *help;
	gint errors;
	NAObjectAction *action;
	NAObjectProfile *profile;
	GList *targets;

	g_type_init();
	setlocale( LC_ALL, "" );
	console_init_log_handler();

	/* pwi 2011-01-05
	 * run MateConf migration tools before doing anything else
	 * above all before allocating a new NAPivot
	 */
	na_mateconf_migration_run();

	context = init_options();

	if( argc == 1 ){
		g_set_prgname( argv[0] );
		help = g_option_context_get_help( context, FALSE, NULL );
		g_print( "\n%s", help );
		g_free( help );
		exit( status );
	}

	if( !g_option_context_parse( context, &argc, &argv, &error )){
		g_printerr( _( "Syntax error: %s\n" ), error->message );
		g_error_free (error);
		exit_with_usage();
	}

	g_option_context_free( context );

	if( version ){
		na_core_utils_print_version();
		exit( status );
	}

	errors = 0;

	if( !id || !strlen( id )){
		g_printerr( _( "Error: action id is mandatory.\n" ));
		errors += 1;
	}

	action = get_action( id );
	if( !action ){
		errors += 1;
	} else {
		g_debug( "%s: action %s have been found, and is enabled and valid", thisfn, id );
	}

	if( errors ){
		exit_with_usage();
	}

	if( targets_array ){
		targets = targets_from_commandline();

	} else {
		targets = targets_from_selection();
	}

	dump_targets( targets );

	if( g_list_length( targets ) == 0 ){
		g_print( _( "No current selection. Nothing to do. Exiting.\n" ));
		exit( status );
	}

	if( !na_icontext_is_candidate( NA_ICONTEXT( action ), ITEM_TARGET_ANY, targets )){
		g_printerr( _( "Action %s is not a valid candidate. Exiting.\n" ), id );
		exit( status );
	}

	profile = get_profile_for_targets( action, targets );
	if( !profile ){
		g_print( _( "No valid profile is candidate to execution. Exiting.\n" ));
		exit( status );
	}
	g_debug( "%s: profile %p found", thisfn, ( void * ) profile );

	execute_action( action, profile, targets );

	na_selected_info_free_list( targets );
	exit( status );
}
Exemple #12
0
void parseoptions(int argc, char*argv[])
{
	int c;
	double dval;
	char *endptr;

	while((c = dxf2rad_getopt(argc, argv, "HhglcfrvV:s:e:d:a:f:G:")) != EOF) {
		switch(c) {
		case 'e':
			parse_entarg();
			break;
		case 'h':
			disallow_plus(c);
			exit_with_usage(0);
			break;
		case 'H':
			disallow_plus(c);
			show_copyright();
			break;
		case 'f':
			disallow_plus(c);
			Options.skipfrozen++;
			break;
		case 'r':
			disallow_plus(c);
			Options.verbose++;
			break;
		case 'l':
			disallow_plus(c);
			if(Options.exportmode == bycolor) {
				fprintf(stderr, "Can't use both export modes together\n");
				exit_with_usage(-1);
			}
			Options.exportmode = bylayer;
			break;
		case 'c':
			disallow_plus(c);
			if(Options.exportmode == bylayer) {
				fprintf(stderr, "Can't use both export modes together\n");
				exit_with_usage(-1);
			}
			Options.exportmode = bycolor;
			break;
		case 'G':
			disallow_plus(c);
			if(Options.prefix) {
				fprintf(stderr, "Modifier prefix specified more than once\n");
				exit_with_usage(-1);
			}
			Options.prefixlen = strlen(optarg);
			if((Options.prefixlen + 32) >= MAXSTRING) {
				fprintf(stderr, "Modifier prefix too long\n");
				exit_with_usage(-1);
			}
			Options.prefix = malloc(Options.prefixlen+1);
			strncpy(Options.prefix, optarg, Options.prefixlen+1);
			break;
		case 'g':
			if(optsign == '-') Options.geom = 0;
			else Options.geom = 1;
			break;
		case 'v':
			if(optsign == '-') Options.views = 0;
			else Options.views = 1;
			break;
		case 'V':
			disallow_plus(c);
			if(Options.viewprefix) {
				fprintf(stderr, "View prefix specified more than once\n");
				exit_with_usage(-1);
			}
			Options.viewprefixlen = strlen(optarg);
			if((Options.viewprefixlen + 32) > MAXSTRING) {
				fprintf(stderr, "View prefix too long\n");
				exit_with_usage(-1);
			}
			Options.viewprefix = malloc(Options.viewprefixlen+1);
			strncpy(Options.viewprefix, optarg, Options.viewprefixlen+1);
			break;
		case 's':
			disallow_plus(c);
			dval = strtod((const char*)optarg, &endptr);
			if(dval == 0.0) {
				fprintf(stderr, "Invalid or zero scale factor: \"%s\"\n",
						optarg);
				exit_with_usage(-1);
			} else if(dval == DBL_MAX || dval == DBL_MIN) {
				fprintf(stderr, "Invalid scale factor: \"%s\"\n", optarg);
				exit_with_usage(-1);
			} else if(*endptr != '\0') {
				fprintf(stderr, "Invalid scale factor: \"%s\"\n", optarg);
				exit_with_usage(-1);
			}
			Options.scale = dval;
			break;
		case 'd':
			disallow_plus(c);
			dval = strtod((const char*)optarg, &endptr);
			if(dval == 0.0) {
				fprintf(stderr, "Invalid or zero distance tolerance: \"%s\"\n",
						optarg);
				exit_with_usage(-1);
			} else if(dval == DBL_MAX || dval == DBL_MIN) {
				fprintf(stderr, "Invalid distance tolerance: \"%s\"\n", optarg);
				exit_with_usage(-1);
			} else if(*endptr != '\0') {
				fprintf(stderr, "Invalid distance tolerance: \"%s\"\n", optarg);
				exit_with_usage(-1);
			}
			Options.disttol = dval;
			break;
		case 'a':
			disallow_plus(c);
			dval = strtod((const char*)optarg, &endptr);
			if(dval == 0.0) {
				fprintf(stderr, "Invalid or zero angle tolerance: \"%s\"\n",
						optarg);
				exit_with_usage(-1);
			} else if(dval == DBL_MAX || dval == DBL_MIN) {
				fprintf(stderr, "Invalid angle tolerance: \"%s\"\n", optarg);
				exit_with_usage(-1);
			} else if(*endptr != '\0') {
				fprintf(stderr, "Invalid angle tolerance: \"%s\"\n", optarg);
				exit_with_usage(-1);
			}
			Options.angtol = dval * DEG2RAD;
			break;
		}
	}
	if(Options.geom == 0 && Options.views == 0) {
		fprintf(stderr, "No output specified, nothing to do\n");
		exit_with_usage(-1);
	}
	if(Options.exportmode == none) {
		Options.exportmode = bylayer;
	}
	if(Options.prefix == NULL) {
		if(Options.exportmode == bylayer) {
			Options.prefix = "l_";
			Options.prefixlen = 2;
		}
		if(Options.exportmode == bycolor) {
			Options.prefix = "c_";
			Options.prefixlen = 2;
		}
	}
	/* Get file names and add extensions if necessary.  */
	if((argc - optind) > 2) {
		fprintf(stderr, "Too many arguments\n");
		exit_with_usage(-1);
	}
	if((argc - optind) < 1) {
		fprintf(stderr, "Missing input file argument\n");
		exit_with_usage(-1);
	}
	if ((strlen(argv[optind]) + 5) > MAXPATH){
		fprintf(stderr, "Input file path name too long\n");
		exit_with_usage(-1);
	}
	strncpy(Inputfile, argv[optind], MAXPATH);
	if (strcspn(Inputfile,".") == strlen(Inputfile))
		strncat(Inputfile, ".dxf", 5);
	if((argc - optind) < 2
		|| (argv[optind+1][0] == '-' && argv[optind+1][1] == '\0')) {
		if(Options.geom == 1) {
			Options.verbose = 0;
		}
		Outputfile[0] = '\0';
	} else {
		if ((strlen(argv[optind+1]) + 5) > MAXPATH){
			fprintf(stderr, "Output file path name too long\n");
			exit_with_usage(-1);
		}
		strncpy(Outputfile, argv[optind+1], MAXPATH);
		if (strcspn(Outputfile,".") == strlen(Outputfile))
			strncat(Outputfile, ".rad", 4);
	}
	if(Options.viewprefix == NULL) {
		size_t pnlen;
		char *pn;
		pnlen = strlen(Outputfile[0]?Outputfile:Inputfile);
		Options.viewprefix = malloc(pnlen+2);
		strncpy(Options.viewprefix, Outputfile[0]?Outputfile:Inputfile, pnlen+1);
		pn = strrchr(Options.viewprefix, '.');
		if(pn != NULL) *pn = '\0';
		strncat(pn, "_", 2);
		Options.viewprefixlen = strlen(Options.viewprefix);
	}
}