-struct flush_info_s
-{
- char **plugins;
- int plugins_num;
- int timeout;
-};
-typedef struct flush_info_s flush_info_t;
-
-static int parse_option_plugin (flush_info_t *fi, const char *option)
-{
- char **temp;
-
- temp = (char **) realloc (fi->plugins,
- (fi->plugins_num + 1) * sizeof (char *));
- if (temp == NULL)
- {
- ERROR ("utils_cmd_flush: parse_option_plugin: realloc failed.");
- return (-1);
- }
- fi->plugins = temp;
-
- fi->plugins[fi->plugins_num] = strdup (option + strlen ("plugin="));
- if (fi->plugins[fi->plugins_num] == NULL)
- {
- /* fi->plugins is freed in handle_flush in this case */
- ERROR ("utils_cmd_flush: parse_option_plugin: strdup failed.");
- return (-1);
+#define print_to_socket(fh, ...) \
+ if (fprintf (fh, __VA_ARGS__) < 0) { \
+ char errbuf[1024]; \
+ WARNING ("handle_flush: failed to write to socket #%i: %s", \
+ fileno (fh), sstrerror (errno, errbuf, sizeof (errbuf))); \
+ return -1; \