]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/json.c
zebra, lib: fix the ZEBRA_INTERFACE_VRF_UPDATE zapi message
[mirror_frr.git] / lib / json.c
index ccbecb726ad420d31923f29dd2813bd7c193cf63..4ea20ba178ad5e57b7a44fe0a391c489d086440a 100644 (file)
  * 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 GNU Zebra; see the file COPYING.  If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
+ * 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>
  * is the *last* keyword on the line no matter
  * what.
  */
-int
-use_json (const int argc, struct cmd_token *argv[])
+bool use_json(const int argc, struct cmd_token *argv[])
 {
-  if (argc == 0)
-    return 0;
+       if (argc == 0)
+               return false;
 
-  if (argv[argc-1]->arg && strcmp(argv[argc-1]->arg, "json") == 0)
-    return 1;
+       if (argv[argc - 1]->arg && strmatch(argv[argc - 1]->text, "json"))
+               return true;
 
-  return 0;
+       return false;
 }
 
-void
-json_object_string_add(struct json_object* obj, const char *key,
-                       const char *s)
+void json_object_string_add(struct json_object *obj, const char *key,
+                           const char *s)
 {
-  json_object_object_add(obj, key, json_object_new_string(s));
+       json_object_object_add(obj, key, json_object_new_string(s));
 }
 
-void
-json_object_int_add(struct json_object* obj, const char *key, int32_t i)
-{
-  json_object_object_add(obj, key, json_object_new_int(i));
-}
-
-void
-json_object_long_add(struct json_object* obj, const char *key, int64_t i)
+void json_object_int_add(struct json_object *obj, const char *key, int64_t i)
 {
 #if defined(HAVE_JSON_C_JSON_H)
-  json_object_object_add(obj, key, json_object_new_int64(i));
+       json_object_object_add(obj, key, json_object_new_int64(i));
 #else
-  json_object_object_add(obj, key, json_object_new_int((int)i));
+       json_object_object_add(obj, key, json_object_new_int((int)i));
 #endif
 }
 
-void
-json_object_boolean_false_add(struct json_object* obj, const char *key)
+void json_object_boolean_false_add(struct json_object *obj, const char *key)
 {
-  json_object_object_add(obj, key, json_object_new_boolean(0));
+       json_object_object_add(obj, key, json_object_new_boolean(0));
 }
 
-void
-json_object_boolean_true_add(struct json_object* obj, const char *key)
+void json_object_boolean_true_add(struct json_object *obj, const char *key)
 {
-  json_object_object_add(obj, key, json_object_new_boolean(1));
+       json_object_object_add(obj, key, json_object_new_boolean(1));
 }
 
-struct json_object*
-json_object_lock(struct json_object *obj)
+struct json_object *json_object_lock(struct json_object *obj)
 {
-  return json_object_get(obj);
+       return json_object_get(obj);
 }
 
-void
-json_object_free(struct json_object *obj)
+void json_object_free(struct json_object *obj)
 {
-  json_object_put(obj);
+       json_object_put(obj);
 }
 
 #if !defined(HAVE_JSON_C_JSON_H)
-int
-json_object_object_get_ex(struct json_object *obj,
-                         const char *key,
-                         struct json_object **value)
+int json_object_object_get_ex(struct json_object *obj, const char *key,
+                             struct json_object **value)
 {
-  *value = json_object_object_get(obj, key);
+       *value = json_object_object_get(obj, key);
 
-  if (*value)
-    return 1;
+       if (*value)
+               return 1;
 
-  return 0;
+       return 0;
 }
 #endif