Exemplo n.º 1
0
void
parse_force(const char *value, bool set)
{
	const char *comma;
	size_t l;
	const struct forceinfo *fip;

	if (strcmp(value, "help") == 0) {
		printf(_(
"%s forcing options - control behaviour when problems found:\n"
"  warn but continue:  --force-<thing>,<thing>,...\n"
"  stop with error:    --refuse-<thing>,<thing>,... | --no-force-<thing>,...\n"
" Forcing things:\n"), dpkg_get_progname());

		for (fip = forceinfos; fip->name; fip++)
			if ((enum force_flags)fip->flag == FORCE_ALL ||
			    (fip->flag & force_mask) == fip->flag)
				print_forceinfo(fip);

		printf(_(
"\n"
"WARNING - use of options marked [!] can seriously damage your installation.\n"
"Forcing options marked [*] are enabled by default.\n"));
		m_output(stdout, _("<standard output>"));

		printf(_(
"\n"
"Currently enabled options:\n"
" %s\n"), get_force_string());

		exit(0);
	}

	for (;;) {
		comma = strchrnul(value, ',');
		l = (size_t)(comma - value);
		for (fip = forceinfos; fip->name; fip++)
			if (strncmp(fip->name, value, l) == 0 &&
			    strlen(fip->name) == l)
				break;

		if (!fip->name) {
			badusage(_("unknown force/refuse option '%.*s'"),
			         (int)min(l, 250), value);
		} else if (fip->flag) {
			if (set)
				set_force(fip->flag);
			else
				reset_force(fip->flag);
		} else {
			warning(_("obsolete force/refuse option '%s'"),
			        fip->name);
		}

		if (*comma == '\0')
			break;
		value = ++comma;
	}
}
Exemplo n.º 2
0
void
set_force_default(int mask)
{
	const char *force_env;
	const struct forceinfo *fip;

	force_mask = mask;

	/* If we get passed force options from the environment, do not
	 * initialize from the built-in defaults. */
	force_env = getenv("DPKG_FORCE");
	if (force_env != NULL) {
		if (force_env[0] != '\0')
			parse_force(force_env, 1);
		return;
	}

	for (fip = forceinfos; fip->name; fip++)
		if (fip->type == FORCETYPE_ENABLED)
			set_force(fip->flag);
}
Exemplo n.º 3
0
BOOL LASwriteOpener::parse(int argc, char* argv[])
{
  int i;
  for (i = 1; i < argc; i++)
  {
    if (argv[i][0] == '\0')
    {
      continue;
    }
    else if (strcmp(argv[i],"-h") == 0 || strcmp(argv[i],"-help") == 0)
    {
      usage();
      return TRUE;
    }
    else if (strcmp(argv[i],"-o") == 0)
    {
      if ((i+1) >= argc)
      {
        fprintf(stderr,"ERROR: '%s' needs 1 argument: file_name\n", argv[i]);
        return FALSE;
      }
      set_file_name(argv[i+1]);
      *argv[i]='\0'; *argv[i+1]='\0'; i+=1;
    }
    else if (strcmp(argv[i],"-odir") == 0)
    {
      if ((i+1) >= argc)
      {
        fprintf(stderr,"ERROR: '%s' needs 1 argument: directory\n", argv[i]);
        return FALSE;
      }
      set_directory(argv[i+1]);
      *argv[i]='\0'; *argv[i+1]='\0'; i+=1;
    }
    else if (strcmp(argv[i],"-odix") == 0)
    {
      if ((i+1) >= argc)
      {
        fprintf(stderr,"ERROR: '%s' needs 1 argument: appendix\n", argv[i]);
        return FALSE;
      }
      set_appendix(argv[i+1]);
      *argv[i]='\0'; *argv[i+1]='\0'; i+=1;
    }
    else if (strcmp(argv[i],"-ocut") == 0)
    {
      if ((i+1) >= argc)
      {
        fprintf(stderr,"ERROR: '%s' needs 1 argument: number of characters to cut\n", argv[i]);
        return FALSE;
      }
      set_cut(atoi(argv[i+1]));
      *argv[i]='\0'; *argv[i+1]='\0'; i+=1;
    }
    else if (strcmp(argv[i],"-oforce") == 0)
    {
      set_force(TRUE);
      *argv[i]='\0';
    }
    else if (strcmp(argv[i],"-olas") == 0)
    {
      specified = TRUE;
      format = LAS_TOOLS_FORMAT_LAS;
      *argv[i]='\0';
    }
    else if (strcmp(argv[i],"-olaz") == 0)
    {
      specified = TRUE;
      format = LAS_TOOLS_FORMAT_LAZ;
      *argv[i]='\0';
    }
    else if (strcmp(argv[i],"-otxt") == 0)
    {
      specified = TRUE;
      format = LAS_TOOLS_FORMAT_TXT;
      *argv[i]='\0';
    }
    else if (strcmp(argv[i],"-obin") == 0)
    {
      specified = TRUE;
      format = LAS_TOOLS_FORMAT_BIN;
      *argv[i]='\0';
    }
    else if (strcmp(argv[i],"-oqi") == 0)
    {
      specified = TRUE;
      format = LAS_TOOLS_FORMAT_QFIT;
      *argv[i]='\0';
    }
    else if (strcmp(argv[i],"-owrl") == 0)
    {
      specified = TRUE;
      format = LAS_TOOLS_FORMAT_VRML;
      *argv[i]='\0';
    }
    else if (strcmp(argv[i],"-stdout") == 0)
    {
      use_stdout = TRUE;
      use_nil = FALSE;
      *argv[i]='\0';
    }
    else if (strcmp(argv[i],"-nil") == 0)
    {
      use_nil = TRUE;
      use_stdout = FALSE;
      *argv[i]='\0';
    }
    else if (strcmp(argv[i],"-buffered") == 0)
    {
      buffered = TRUE;
      *argv[i]='\0';
    }
    else if (strcmp(argv[i],"-v1") == 0)
    {
      use_v1 = TRUE;
      use_chunking = FALSE;
      *argv[i]='\0';
    }
    else if (strcmp(argv[i],"-v2") == 0)
    {
      use_v1 = FALSE;
      use_chunking = TRUE;
      *argv[i]='\0';
    }
    else if (strcmp(argv[i],"-no_chunk") == 0)
    {
      use_chunking = FALSE;
      *argv[i]='\0';
    }
    else if (strcmp(argv[i],"-chunk") == 0)
    {
      use_chunking = TRUE;
      *argv[i]='\0';
    }
    else if (strcmp(argv[i],"-chunk_size") == 0)
    {
      if ((i+1) >= argc)
      {
        fprintf(stderr,"ERROR: '%s' needs 1 argument: number_points\n", argv[i]);
        return FALSE;
      }
      set_chunk_size(atoi(argv[i+1]));
      *argv[i]='\0'; *argv[i+1]='\0'; i+=1;
    }
    else if (strcmp(argv[i],"-oparse") == 0)
    {
      if ((i+1) >= argc)
      {
        fprintf(stderr,"ERROR: '%s' needs 1 argument: string\n", argv[i]);
        return FALSE;
      }
      set_parse_string(argv[i+1]);
      *argv[i]='\0'; *argv[i+1]='\0'; i+=1;
    }
    else if (strcmp(argv[i],"-osep") == 0)
    {
      if ((i+1) >= argc)
      {
        fprintf(stderr,"ERROR: '%s' needs 1 argument: separator\n", argv[i]);
        return FALSE;
      }
      set_separator(argv[i+1]);
      *argv[i]='\0'; *argv[i+1]='\0'; i+=1;
    }
    else if (strcmp(argv[i],"-oscale_rgb") == 0)
    {
      if ((i+1) >= argc)
      {
        fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]);
        return FALSE;
      }
      set_scale_rgb((F32)atof(argv[i+1]));
      *argv[i]='\0'; *argv[i+1]='\0'; i+=1;
    }
    else if (strcmp(argv[i],"-opts") == 0)
    {
      opts = TRUE;
      *argv[i]='\0';
    }
    else if (strcmp(argv[i],"-optx") == 0)
    {
      optx = TRUE;
      *argv[i]='\0';
    }
  }
  return TRUE;
}