From: Pierre-Marc Fournier Date: Mon, 28 Sep 2009 23:52:58 +0000 (-0400) Subject: ust.c: remove regex handling because it should be done in libust X-Git-Tag: v1.9.1~886 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=ee648b8f2e4387488bfeed55a949f8e2b2df88fd;p=lttng-ust.git ust.c: remove regex handling because it should be done in libust --- diff --git a/ust/ust.c b/ust/ust.c index 3f87c734..789dfe0f 100644 --- a/ust/ust.c +++ b/ust/ust.c @@ -21,7 +21,6 @@ #include #include #include -#include #include "ustcomm.h" #include "ustcmd.h" @@ -43,8 +42,6 @@ struct ust_opts { enum command cmd; pid_t *pids; char *regex; - regex_t preg; - int regex_state; }; char *progname = NULL; @@ -71,7 +68,6 @@ int parse_opts_long(int argc, char **argv, struct ust_opts *opts) opts->pids = NULL; opts->regex = NULL; - opts->regex_state = -1; while (1) { int option_index = 0; @@ -162,56 +158,9 @@ int parse_opts_long(int argc, char **argv, struct ust_opts *opts) opts->pids[pididx] = -1; } - if (opts->cmd == ENABLE_MARKER || opts->cmd == DISABLE_MARKER) { - opts->regex_state = regcomp(&opts->preg, opts->regex, 0); - if (opts->regex_state) { - ERR("invalid regular expression\n"); - } - } - return 0; } -static void regex_change_m_state(struct ust_opts *opts, pid_t pid) -{ - struct marker_status *cmsf = NULL; - unsigned int i = 0; - int e = (opts->cmd == ENABLE_MARKER); - - if (opts->regex_state != 0) { - return; - } - - if (ustcmd_get_cmsf(&cmsf, pid)) { - fprintf(stderr, "error while trying to get markers for PID " - "%u\n", (unsigned int) pid); - return; - } - while (cmsf[i].channel != NULL) { - char *mc; - asprintf(&mc, "%s/%s", cmsf[i].channel, cmsf[i].marker); - if (regexec(&opts->preg, mc, 0, NULL, 0) == 0) { - /* We got a match! */ - if (ustcmd_set_marker_state(mc, - e ? USTCMD_MS_ON : USTCMD_MS_OFF, pid)) { - fprintf(stderr, - "error while trying to %sable marker" - "\"%s\" for PID %u\n", - e ? "en" : "dis", mc, - (unsigned int) pid); - } else { - printf("sucessfully %sabled marker " - "\"%s\" for PID %u\n", - e ? "en" : "dis", mc, - (unsigned int) pid); - } - } - free(mc); - ++i; - } - ustcmd_free_cmsf(cmsf); -} - int main(int argc, char *argv[]) { pid_t *pidit; @@ -322,9 +271,13 @@ int main(int argc, char *argv[]) break; case ENABLE_MARKER: + if(opts.regex) + ustcmd_set_marker_state(opts.regex, 1, *pidit); + break; case DISABLE_MARKER: - regex_change_m_state(&opts, *pidit); - break; + if(opts.regex) + ustcmd_set_marker_state(opts.regex, 0, *pidit); + break; default: ERR("unknown command\n");