ust.c: remove regex handling because it should be done in libust
authorPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Mon, 28 Sep 2009 23:52:58 +0000 (19:52 -0400)
committerPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Mon, 28 Sep 2009 23:57:51 +0000 (19:57 -0400)
ust/ust.c

index 3f87c73454ac0b6460177a07d491467a265987d9..789dfe0feeb7c8d44da14ebc97ae23cef75969c3 100644 (file)
--- a/ust/ust.c
+++ b/ust/ust.c
@@ -21,7 +21,6 @@
 #include <getopt.h>
 #include <stdlib.h>
 #include <fcntl.h>
-#include <regex.h>
 
 #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");
This page took 0.026577 seconds and 4 git commands to generate.