diff options
| author | Jiri Olsa <Jiri Olsa jolsa@redhat.com> | 2011-10-18 10:00:38 +0200 |
|---|---|---|
| committer | Jiri Olsa <Jiri Olsa jolsa@redhat.com> | 2011-11-24 21:20:27 +0100 |
| commit | 2d6cc3704e7affeb56c798b39a942daca95385dc (patch) | |
| tree | dd339c0bbc9305fa4352deff86da4d14f3a96c9d /src/config.c | |
| parent | e2052e8c5f9fa4dc50bdcf33ff96c6bcc71ca59e (diff) | |
| download | latrace-2d6cc3704e7affeb56c798b39a942daca95385dc.tar.gz latrace-2d6cc3704e7affeb56c798b39a942daca95385dc.tar.xz latrace-2d6cc3704e7affeb56c798b39a942daca95385dc.zip | |
error simulation: application part
Diffstat (limited to 'src/config.c')
| -rw-r--r-- | src/config.c | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/src/config.c b/src/config.c index 9fea08b..b04ec2c 100644 --- a/src/config.c +++ b/src/config.c @@ -87,6 +87,8 @@ static void usage() printf(" -R, --ctl-config controled config\n"); printf(" -q, --disable disable auditing\n"); printf("\n"); + printf(" -e, --error error set error simulation\n"); + printf("\n"); printf(" -v, --verbose verbose output\n"); printf(" -V, --version display version\n"); printf(" -h, --help display help\n"); @@ -392,7 +394,7 @@ int lt_config_ln_add(struct lt_list_head *head, char *name) return 0; } -int lt_config_ln_fill(struct lt_list_head *head, char *buf, int size) +int lt_config_ln_fill_buf(struct lt_list_head *head, char *buf, int size) { struct lt_config_ln *ln, *n; int first = 1; @@ -422,6 +424,30 @@ int lt_config_ln_fill(struct lt_list_head *head, char *buf, int size) return 0; } +char **lt_config_ln_fill_array(struct lt_list_head *head) +{ + struct lt_config_ln *ln, *n; + char **array = NULL; + int i = 0; + + lt_list_for_each_entry_safe(ln, n, head, list) { + + /* starting from zero index and keeping NULL + * at the end of the args array*/ + array = realloc(array, sizeof(*array) * (i + 2)); + if (!array) + return NULL; + + array[i++] = ln->name; + array[i] = NULL; + + lt_list_del(&ln->list); + free(ln); + } + + return array; +} + int lt_config(struct lt_config_app *cfg, int argc, char **argv) { memset(cfg, 0, sizeof(*cfg)); @@ -439,6 +465,7 @@ int lt_config(struct lt_config_app *cfg, int argc, char **argv) cfg->csort = LT_CSORT_CALL; cfg->fstat = stdout; cfg->output_tty_fd = -1; + lt_init_list_head(&cfg->error_apps); lt_init_list_head(&cfg->process_funcs); @@ -480,12 +507,13 @@ int lt_config(struct lt_config_app *cfg, int argc, char **argv) {"no-follow-exec", no_argument, 0, 'E'}, {"disable", no_argument, 0, 'q'}, {"ctl-config", no_argument, 0, 'R'}, + {"error", required_argument, 0, 'e'}, {"version", no_argument, 0, 'V'}, {"help", no_argument, 0, 'h'}, {0, 0, 0, 0} }; - c = getopt_long(argc, argv, "+s:n:l:t:f:vhi:BdISb:cC:y:YL:po:a:N:ADVTFERq", + c = getopt_long(argc, argv, "+s:n:l:t:f:vhi:BdISb:cC:y:YL:po:a:N:ADVTFERe:q", long_options, &option_index); if (c == -1) @@ -643,6 +671,16 @@ int lt_config(struct lt_config_app *cfg, int argc, char **argv) lt_sh(cfg, ctl_config) = 1; break; + #ifndef CONFIG_ARCH_HAVE_ERROR_SIM + case 'e': + printf("Error simulation support not compiled in"); + #else + case 'e': + if (lt_error_set(cfg, optarg)) + usage(); + #endif /* CONFIG_ARCH_HAVE_ERROR_SIM */ + break; + case 'V': version(); break; @@ -667,7 +705,7 @@ int lt_config(struct lt_config_app *cfg, int argc, char **argv) cfg->arg_num = i_arg; } - if (!cfg->prog) { + if ((!cfg->prog) && (!lt_sh(cfg, error_sim))) { printf("failed: no program specified\n"); usage(); } |
