stats: fix collector updates of symlinks
[vpp.git] / src / vlib / cli.c
index 2187d28..c43371e 100644 (file)
@@ -159,6 +159,64 @@ done:
   return match;
 }
 
+uword
+unformat_vlib_cli_line (unformat_input_t *i, va_list *va)
+{
+  unformat_input_t *result = va_arg (*va, unformat_input_t *);
+  u8 *line = 0;
+  uword c;
+  int skip;
+
+next_line:
+  skip = 0;
+
+  /* skip leading whitespace if any */
+  unformat_skip_white_space (i);
+
+  if (unformat_is_eof (i))
+    return 0;
+
+  while ((c = unformat_get_input (i)) != UNFORMAT_END_OF_INPUT)
+    {
+      if (c == '\\')
+       {
+         c = unformat_get_input (i);
+
+         if (c == '\n')
+           {
+             if (!skip)
+               vec_add1 (line, '\n');
+             skip = 0;
+             continue;
+           }
+
+         if (!skip)
+           vec_add1 (line, '\\');
+
+         if (c == UNFORMAT_END_OF_INPUT)
+           break;
+
+         if (!skip)
+           vec_add1 (line, c);
+         continue;
+       }
+
+      if (c == '#')
+       skip = 1;
+      else if (c == '\n')
+       break;
+
+      if (!skip)
+       vec_add1 (line, c);
+    }
+
+  if (line == 0)
+    goto next_line;
+
+  unformat_init_vector (result, line);
+  return 1;
+}
+
 /* Looks for string based sub-input formatted { SUB-INPUT }. */
 uword
 unformat_vlib_cli_sub_input (unformat_input_t * i, va_list * args)
@@ -617,7 +675,7 @@ vlib_cli_dispatch_sub_commands (vlib_main_t * vm,
                      vec_add1 (c_error->what, 0);
                      ed->err = elog_string (vlib_get_elog_main (),
                                             (char *) c_error->what);
-                     _vec_len (c_error->what) -= 1;
+                     vec_dec_len (c_error->what, 1);
                    }
                  else
                    ed->err = elog_string (vlib_get_elog_main (), "OK");
@@ -1097,7 +1155,7 @@ restart_cmd_fn (vlib_main_t * vm, unformat_input_t * input,
   /* *INDENT-ON* */
 
   /* Exec ourself */
-  execve (vgm->name, (char **) vm->argv, environ);
+  execve (vgm->name, (char **) vgm->argv, environ);
 
   return 0;
 }
@@ -1179,7 +1237,7 @@ vlib_cli_normalize_path (char *input, char **result)
 
   /* Remove any extra space at end. */
   if (l > 0 && s[l - 1] == ' ')
-    _vec_len (s) -= 1;
+    vec_dec_len (s, 1);
 
   *result = s;
   return index_of_last_space;