2 * Interface for configuring and controlling the state of tracing events.
4 * Copyright (C) 2011 LluĂs Vilanova <vilanova@ac.upc.edu>
6 * This work is licensed under the terms of the GNU GPL, version 2. See
7 * the COPYING file in the top-level directory.
10 #include "trace/control.h"
13 void trace_backend_init_events(const char *fname)
21 FILE *fp = fopen(fname, "r");
23 fprintf(stderr, "error: could not open trace events file '%s': %s\n",
24 fname, strerror(errno));
28 while (fgets(line_buf, sizeof(line_buf), fp)) {
29 size_t len = strlen(line_buf);
30 if (len > 1) { /* skip empty lines */
31 line_buf[len - 1] = '\0';
32 if ('#' == line_buf[0]) { /* skip commented lines */
35 if ('-' == line_buf[0]) {
36 ret = trace_event_set_state(line_buf+1, false);
38 ret = trace_event_set_state(line_buf, true);
42 "error: trace event '%s' does not exist\n", line_buf);
47 if (fclose(fp) != 0) {
48 fprintf(stderr, "error: closing file '%s': %s\n",
49 fname, strerror(errno));