src/utils_cmd_putval.[ch]: Allow identifiers to include spaces.
[collectd.git] / src / exec.c
index a80de1e..88026b6 100644 (file)
@@ -490,19 +490,22 @@ static int fork_child (program_list_t *pl, int *fd_in, int *fd_out, int *fd_err)
 
 static int parse_line (char *buffer) /* {{{ */
 {
-  char *fields[256];
-  int fields_num;
-
-  fields[0] = "PUTVAL";
-  fields_num = strsplit (buffer, fields + 1, STATIC_ARRAY_SIZE(fields) - 1);
-
-  if (strcasecmp (fields[1], "putval") == 0)
-    return (handle_putval (stdout, fields + 1, fields_num));
+  if (strncasecmp ("PUTVAL", buffer, strlen ("PUTVAL")) == 0)
+    return (handle_putval (stdout, buffer));
+#if !COLLECT_DEBUG
+#error "TODO: PUTNOTIF"
   else if (strcasecmp (fields[1], "putnotif") == 0)
     return (handle_putnotif (stdout, fields + 1, fields_num));
-
-  /* compatibility code */
-  return (handle_putval (stdout, fields, fields_num + 1));
+#endif
+  else
+  {
+    /* For backwards compatibility */
+    char tmp[1220];
+    /* Let's annoy the user a bit.. */
+    INFO ("exec plugin: Prepending `PUTVAL' to this line: %s", buffer);
+    ssnprintf (tmp, sizeof (tmp), "PUTVAL %s", buffer);
+    return (handle_putval (stdout, tmp));
+  }
 } /* int parse_line }}} */
 
 static void *exec_read_one (void *arg) /* {{{ */