]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/vty.c
Merge pull request #12780 from opensourcerouting/spdx-license-id
[mirror_frr.git] / lib / vty.c
index d53e07fe4276b5e40467a3e7a436ec9ce5b052b3..76dfe9734e684edbd011417e07dc4c999d61692b 100644 (file)
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -1,22 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Virtual terminal [aka TeletYpe] interface routine.
  * Copyright (C) 1997, 98 Kunihiro Ishiguro
- *
- * This file is part of GNU Zebra.
- *
- * GNU Zebra is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * GNU Zebra is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <zebra.h>
@@ -284,7 +269,8 @@ done:
        return len;
 }
 
-int vty_json(struct vty *vty, struct json_object *json)
+static int vty_json_helper(struct vty *vty, struct json_object *json,
+                          uint32_t options)
 {
        const char *text;
 
@@ -292,13 +278,25 @@ int vty_json(struct vty *vty, struct json_object *json)
                return CMD_SUCCESS;
 
        text = json_object_to_json_string_ext(
-               json, JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_NOSLASHESCAPE);
+               json, options);
        vty_out(vty, "%s\n", text);
        json_object_free(json);
 
        return CMD_SUCCESS;
 }
 
+int vty_json(struct vty *vty, struct json_object *json)
+{
+       return vty_json_helper(vty, json,
+                              JSON_C_TO_STRING_PRETTY |
+                                      JSON_C_TO_STRING_NOSLASHESCAPE);
+}
+
+int vty_json_no_pretty(struct vty *vty, struct json_object *json)
+{
+       return vty_json_helper(vty, json, JSON_C_TO_STRING_NOSLASHESCAPE);
+}
+
 /* Output current time to the vty. */
 void vty_time_print(struct vty *vty, int cr)
 {