Ejemplo n.º 1
0
int main (int argc, char **argv) {
  char  filename[1024];
  int i,j;
  iferret_t *iferret;
  op_arr_t *op_arr;

  op_arr = op_arr_init(); 
  iferret_log_create();
  iferret = iferret_create();

  // process command line options. 
  process_opt(argc,argv,iferret);

  op_arr = init(iferret->log_prefix, iferret->start_log_num, iferret->num_logs);

//  // iterate over logfiles and process each in sequence
//  for (j=0; j<iferret->num_logs; j++) {
//    i = iferret->start_log_num + j; 
//    sprintf(filename, "%s-%d", iferret->log_prefix, i);
//    //printf ("process: log %d: %d of %d: %s\n", i, j, iferret->num_logs, filename);
//    iferret_log_process(iferret,filename);
//    //iferret_log_spit(filename);
//  }

  op_arr_destroy(op_arr);

  return (0);
}
Ejemplo n.º 2
0
static void process_options( int *parg, int argc, char *argv[] )
{
#define II (*parg)

    for ( II = 1; II < argc && argv[II][0] == '-'; II++ )
        process_opt( &II, argc, argv );

#undef II
}
Ejemplo n.º 3
0
/* process options and do some other initializations, then go through the
   file list and process files one by one
   at the end, exit and return 0 on succes, 1 on failure, 2 on troubles */
int
main(int argc, char *argv[])
{
  char **pp_file, **flist; /* filename list pointer */
  long int err; /* nonzero if process_file() ever returned nonzero */
  EncaAnalyser an;

  /* Process command line arguments. */
  pp_file = flist = process_opt(argc, argv);

  /* Initialization. */
  if (options.verbosity_level > 2)
    fprintf(stderr, "Initializing language %s\n", options.language);
  an = enca_analyser_alloc(options.language);
  if (!an) {
    fprintf(stderr, "%s: Language `%s' is unknown or not supported.\n"
                    "Run `%s --list languages' to get list "
                    "of supported languages.\n"
                    "Run `%s -L none' to test only language independent, "
                    "multibyte encodings.\n",
                    program_name, options.language,
                    program_name,
                    program_name);
    exit(EXIT_TROUBLE);
  }

  enca_set_threshold(an, 1.38);
  enca_set_multibyte(an, 1);
  enca_set_ambiguity(an, 1);
  enca_set_garbage_test(an, 1);

  /* Any files specified on command line? */
  if (pp_file == NULL) {
    /* No => read stdin. */
    err = process_file(an, NULL);
  }
  else {
    /* Process file list, cumultate the worst error in err. */
    err = 0;
    while (*pp_file != NULL) {
      err |= process_file(an, *pp_file);
      enca_free(*pp_file);
      pp_file++;
    }
  }

  process_file(NULL, NULL);
  enca_analyser_free(an);
  enca_free(options.language);
  enca_free(options.target_enc_str);
  enca_free(flist);

  if (err & EXIT_TROUBLE)
    err = EXIT_TROUBLE;

  return err;
}
Ejemplo n.º 4
0
int search_options(APPROX_PARAMS *ap, MODEL_PARAMS *mp, SENTENCE *sent, OPTION **prev_b_options, int prev_cand_num, OPTION **new_b_options) {
    OPTION_LIST *ol = increase_list(NULL, NULL);
    int i;
    for (i = 0; i < prev_cand_num; i++) {
        increase_list_asc(ol, prev_b_options[i]);
    }

    int new_cand_num = 0;
    // to set static variable
    process_opt(ap, mp, sent, new_b_options, &new_cand_num, NULL, ol);
    while(ol->prev != NULL) {
        OPTION *opt = ol->prev->elem;
        ol = reduce_list(ol);                
        process_opt(ap, mp, sent, new_b_options, &new_cand_num, opt, ol);
    }
    free(ol);
    return new_cand_num;
}
Ejemplo n.º 5
0
int ibdiag_process_opts(int argc, char *const argv[], void *cxt,
			const char *exclude_common_str,
			const struct ibdiag_opt custom_opts[],
			int (*custom_handler) (void *cxt, int val,
					       char *optarg),
			const char *usage_args, const char *usage_examples[])
{
	char str_opts[1024];
	const struct ibdiag_opt *o;

	prog_name = argv[0];
	prog_args = usage_args;
	prog_examples = usage_examples;

	if (long_opts)
		free(long_opts);

	long_opts = make_long_opts(exclude_common_str, custom_opts, opts_map);
	if (!long_opts)
		return -1;

	read_ibdiag_config(IBDIAG_CONFIG_GENERAL);

	make_str_opts(long_opts, str_opts, sizeof(str_opts));

	while (1) {
		int ch = getopt_long(argc, argv, str_opts, long_opts, NULL);
		if (ch == -1)
			break;
		o = opts_map[ch];
		if (!o)
			ibdiag_show_usage();
		if (custom_handler) {
			if (custom_handler(cxt, ch, optarg) &&
			    process_opt(ch, optarg))
				ibdiag_show_usage();
		} else if (process_opt(ch, optarg))
			ibdiag_show_usage();
	}

	return 0;
}
Ejemplo n.º 6
0
int main(int argc, char **argv) {
  const char *cmd;
  struct cmd_func_pair {
    const char *cmd;
    cmd_exec_func_t func;
  } *pair_ptr, exec_funcs[] =
  {
    { "help", exec_help },
    { "create", exec_create },
    { "enroll", exec_enroll },
    { "request", exec_request },
    { "sign", exec_sign },
    { "revoke", exec_revoke },
    { "gencrl", exec_gencrl },
    { "cmpsvr", exec_cmpsvr },
    { "cmpcli", exec_cmpcli },
    { "info", exec_info },
    { "addpubkey", exec_addpubkey },
    { NULL, NULL }
  };
  int retval, status;
  int argv_cmd_index;
  if (argc < 2) {
    fprintf(stderr, "usage: %s [opts] command [params]\n", argv[0]);
    fprintf(stderr, "%s help gives more help\n", argv[0]);
    exit(1);
  }
  status = cryptInit();
  if (!cryptStatusOK(status)) {
    fprintf(stderr, "cryptlib error %d while initializing cryptlib\n", status);
  }
  argv_cmd_index = 1;
  while (argv[argv_cmd_index][0] == '-') {
    process_opt(argv[argv_cmd_index]); argv_cmd_index++;
  }
  cmd = argv[argv_cmd_index];
  for (pair_ptr = exec_funcs; pair_ptr->cmd; pair_ptr++) {
    if (strcmp(cmd, pair_ptr->cmd) == 0) {
      retval = pair_ptr->func(argc - argv_cmd_index - 1, argv + argv_cmd_index + 1);
      break;
    }
  }
  if (pair_ptr->cmd == 0) {
    fprintf(stderr, "unknown command %s\n", cmd);
    fprintf(stderr, "%s help gives more help\n", argv[0]);
    retval = 1;
  }
  status = cryptEnd();
  if (!cryptStatusOK(status)) {
    fprintf(stderr, "cryptlib error %d while deinitializing cryptlib\n", status);
  }
  return retval;
}
Ejemplo n.º 7
0
static int process_gopt(struct fuse_opt_context *ctx, const char *arg, int iso)
{
    unsigned sep;
    const struct fuse_opt *opt = find_opt(ctx->opt, arg, &sep);
    if (opt) {
        for (; opt; opt = find_opt(opt + 1, arg, &sep)) {
            int res;
            if (sep && opt->templ[sep] == ' ' && !arg[sep])
                res = process_opt_sep_arg(ctx, opt, sep, arg, iso);
            else
                res = process_opt(ctx, opt, sep, arg, iso);
            if (res == -1)
                return -1;
        }
        return 0;
    } else
        return call_proc(ctx, arg, FUSE_OPT_KEY_OPT, iso);
}
Ejemplo n.º 8
0
static int process_opt_sep_arg(struct fuse_opt_context *ctx,
			       const struct fuse_opt *opt, unsigned sep,
			       const char *arg, int iso)
{
	int res;
	char *newarg;
	char *param;

	if (next_arg(ctx, arg) == -1)
		return -1;

	param = ctx->argv[ctx->argctr];
	newarg = malloc(sep + strlen(param) + 1);
	if (!newarg)
		return alloc_failed();

	memcpy(newarg, arg, sep);
	strcpy(newarg + sep, param);
	res = process_opt(ctx, opt, sep, newarg, iso);
	free(newarg);

	return res;
}
Ejemplo n.º 9
0
Archivo: erlc.c Proyecto: Dasudian/otp
int wmain(int argc, wchar_t **wcargv)
{
    char** argv;
#else
int main(int argc, char** argv)
{
#endif
    int eargv_size;
    int eargc_base;		/* How many arguments in the base of eargv. */
    char* emulator;
    char *env;

#ifdef __WIN32__
    int i;
    int len;
    /* Convert argv to utf8 */
    argv = malloc((argc+1) * sizeof(char*));
    for (i=0; i<argc; i++) {
	len = WideCharToMultiByte(CP_UTF8, 0, wcargv[i], -1, NULL, 0, NULL, NULL);
	argv[i] = malloc(len*sizeof(char));
	WideCharToMultiByte(CP_UTF8, 0, wcargv[i], -1, argv[i], len, NULL, NULL);
    }
    argv[argc] = NULL;
#endif

    env = get_env("ERLC_EMULATOR");
    emulator = env ? env : get_default_emulator(argv[0]);

    if (strlen(emulator) >= MAXPATHLEN)
        error("Value of environment variable ERLC_EMULATOR is too large");

    /*
     * Allocate the argv vector to be used for arguments to Erlang.
     * Arrange for starting to pushing information in the middle of
     * the array, to allow easy adding of emulator options (like -pa)
     * before '-s erlcompile compile_cmdline...'.
     *
     * Oh, by the way, we will push the compiler command in the
     * base of the eargv vector, and move it up later.
     */

    eargv_size = argc*6+100;
    eargv_base = (char **) emalloc(eargv_size*sizeof(char*));
    eargv = eargv_base;
    eargc = 0;
    push_words(emulator);
    eargc_base = eargc;
    eargv = eargv + eargv_size/2;
    eargc = 0;

    free_env_val(env);

    /*
     * Push initial arguments.
     */

    PUSH("+sbtu");
    PUSH("+A0");
    PUSH("-noinput");
    PUSH2("-mode", "minimal");
    PUSH2("-boot", "start_clean");
    PUSH3("-s", "erl_compile", "compile_cmdline");
    PUSH("-extra");

    /*
     * Push standard arguments to Erlang.
     */

    /*
     * Parse all command line switches.
     */

    while (argc > 1) {

	/*
	 * Options starting with '+' are passed on to Erlang.
	 */

	switch (argv[1][0]) {
	case '+':
	    PUSH(argv[1]);
	    break;
	case '-':
	    switch (argv[1][1]) {
	    case 'd':
		if (argv[1][2] == '\0') {
		    debug = 1;
		} else {
		    PUSH(argv[1]);
		}
		break;
	    case 'p':
		{
		    int c = argv[1][2];
		    
		    if (c != 'a' && c != 'z') {
			PUSH(argv[1]);
#ifdef __WIN32__
		    } else if (strcmp(argv[1], "-pause") == 0) {
			pause_after_execution = 1;
#endif
		    } else {
			char option[4];

			UNSHIFT(process_opt(&argc, &argv, 1));
			option[0] = '-';
			option[1] = 'p';
			option[2] = c;
			option[3] = '\0';
			UNSHIFT(strsave(option));
		    }
		}
		break;
	    case 's':
		if (strcmp(argv[1], "-smp") == 0) {
		    UNSHIFT(argv[1]);
		} else {
		    PUSH(argv[1]);
		}
		break;
	    default:
		PUSH(argv[1]);
		break;
	    }
	    break;
	default:
	    PUSH(argv[1]);
	    break;
	}
	argc--, argv++;
    }

    /*
     * Move up the commands for invoking the emulator and adjust eargv
     * accordingly.
     */

    while (--eargc_base >= 0) {
	UNSHIFT(eargv_base[eargc_base]);
    }
    
    /*
     * Invoke Erlang with the collected options.
     */

    PUSH(NULL);
    return run_erlang(eargv[0], eargv);
}