/* * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License (not later!) * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, see * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include #include #include #include #include #include #include #include #include #include "event-parse.h" #include "event-utils.h" #define LOCAL_PLUGIN_DIR ".traceevent/plugins" static struct registered_plugin_options { struct registered_plugin_options *next; struct pevent_plugin_option *options; } *registered_options; static struct trace_plugin_options { struct trace_plugin_options *next; char *plugin; char *option; char *value; } *trace_plugin_options; struct plugin_list { struct plugin_list *next; char *name; void *handle; }; static void lower_case(char *str) { if (!str) return; for (; *str; str++) *str = tolower(*str); } static int update_option_value(struct pevent_plugin_option *op, const char *val) { char *op_val; if (!val) { /* toggle, only if option is boolean */ if (op->value) /* Warn? */ return 0; op->set ^= 1; return 0; } /* * If the option has a value then it takes a string * otherwise the option is a boolean. */ if (op->value) { op->value = val; return 0; } /* Option is boolean, must be either "1", "0", "true" or "false" */ op_val = strdup(val); if (!op_val) return -1; lower_case(op_val); if (strcmp(val, "1") == 0 || strcmp(val, "true") == 0) op->set = 1; else if (strcmp(val, "0") == 0 || strcmp(val, "false") == 0) op->set = 0; free(op_val); return 0; } /** * traceevent_plugin_list_options - get list of plugin options * * Returns an array of char strings that list the currently registered * plugin options in the format of :