// SPDX-License-Identifier: LGPL-2.1 /* * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt * */ #include #include #include #include #include #include #include #include #include #include "event-parse.h" #include "event-parse-local.h" #include "event-utils.h" #include "trace-seq.h" #define LOCAL_PLUGIN_DIR ".traceevent/plugins" static struct registered_plugin_options { struct registered_plugin_options *next; struct tep_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 tep_plugin_list { struct tep_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 tep_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; } /** * tep_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 :