+ /* Parse the options which may still be contained in the buffer. Valid
+ * options are "host", "plugin", "plugin_instance", "type" and
+ * "type_instance"; each option takes a regular expression as argument which
+ * is used to filter the returned identifiers. */
+ while (*buffer != 0)
+ {
+ char *opt_key;
+ char *opt_value;
+ regex_t *re;
+ _Bool *have_re;
+
+ opt_key = NULL;
+ opt_value = NULL;
+ status = parse_option (&buffer, &opt_key, &opt_value);
+ if (status != 0)
+ {
+ print_to_socket (fh, "-1 Parsing options failed.\n");
+ FREE_EVERYTHING_AND_RETURN (-1);
+ }
+
+ if (strcasecmp ("host", opt_key) == 0)
+ {
+ re = &re_host;
+ have_re = &have_re_host;
+ }
+ else if (strcasecmp ("plugin", opt_key) == 0)
+ {
+ re = &re_plugin;
+ have_re = &have_re_plugin;
+ }
+ else if (strcasecmp ("plugin_instance", opt_key) == 0)
+ {
+ re = &re_plugin_instance;
+ have_re = &have_re_plugin_instance;
+ }
+ else if (strcasecmp ("type", opt_key) == 0)
+ {
+ re = &re_type;
+ have_re = &have_re_type;
+ }
+ else if (strcasecmp ("type_instance", opt_key) == 0)
+ {
+ re = &re_type_instance;
+ have_re = &have_re_type_instance;
+ }
+ else
+ {
+ print_to_socket (fh, "-1 Unknown option: %s\n", opt_key);
+ FREE_EVERYTHING_AND_RETURN (-1);
+ }
+
+ /* Free a previous regular expression */
+ if (*have_re)
+ {
+ NOTICE ("listval command: More than one match for part \"%s\". "
+ "Only the last regular expression will be used to search "
+ "for matching value lists!",
+ opt_key);
+ regfree (re);
+ *have_re = 0;
+ }
+
+ /* Compile the regular expression. */
+ status = regcomp (re, opt_value, REG_EXTENDED | REG_NOSUB);
+ if (status != 0)
+ {
+ char errbuf[1024];
+ regerror (status, re, errbuf, sizeof (errbuf));
+ errbuf[sizeof (errbuf) - 1] = 0;
+ print_to_socket (fh, "-1 Compiling %s regex failed: %s\n",
+ opt_key, errbuf);
+ FREE_EVERYTHING_AND_RETURN (-1);
+ }
+ *have_re = 1;
+ } /* while (*buffer != 0) */
+
+ /* Get a list of values from the cache. */