svn commit: r275552 - in head/cddl: contrib/opensolaris/lib/libnvpair lib/libnvpair
Xin LI
delphij at FreeBSD.org
Sat Dec 6 01:01:53 UTC 2014
Author: delphij
Date: Sat Dec 6 01:01:51 2014
New Revision: 275552
URL: https://svnweb.freebsd.org/changeset/base/275552
Log:
MFV r260710 + 275532:
Add a new method, nvlist_print_json to allow libnvpair to emit JSON.
MFC after: 1 month
Added:
head/cddl/contrib/opensolaris/lib/libnvpair/nvpair_json.c
- copied, changed from r260710, vendor/illumos/dist/lib/libnvpair/nvpair_json.c
Modified:
head/cddl/contrib/opensolaris/lib/libnvpair/libnvpair.h
head/cddl/lib/libnvpair/Makefile
Directory Properties:
head/cddl/contrib/opensolaris/ (props changed)
Modified: head/cddl/contrib/opensolaris/lib/libnvpair/libnvpair.h
==============================================================================
--- head/cddl/contrib/opensolaris/lib/libnvpair/libnvpair.h Sat Dec 6 00:50:57 2014 (r275551)
+++ head/cddl/contrib/opensolaris/lib/libnvpair/libnvpair.h Sat Dec 6 01:01:51 2014 (r275552)
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, Joyent, Inc. All rights reserved.
*/
#ifndef _LIBNVPAIR_H
@@ -46,6 +47,7 @@ extern int nvpair_value_match_regex(nvpa
char **);
extern void nvlist_print(FILE *, nvlist_t *);
+extern int nvlist_print_json(FILE *, nvlist_t *);
extern void dump_nvlist(nvlist_t *, int);
/*
Copied and modified: head/cddl/contrib/opensolaris/lib/libnvpair/nvpair_json.c (from r260710, vendor/illumos/dist/lib/libnvpair/nvpair_json.c)
==============================================================================
--- vendor/illumos/dist/lib/libnvpair/nvpair_json.c Thu Jan 16 13:12:06 2014 (r260710, copy source)
+++ head/cddl/contrib/opensolaris/lib/libnvpair/nvpair_json.c Sat Dec 6 01:01:51 2014 (r275552)
@@ -9,7 +9,7 @@
* http://www.illumos.org/license/CDDL.
*/
/*
- * Copyright (c) 2013, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2014, Joyent, Inc.
*/
#include <stdio.h>
@@ -20,9 +20,11 @@
#include "libnvpair.h"
-#define FPRINTF(fp, ...) \
- if (fprintf(fp, __VA_ARGS__) < 0) \
- return (-1) \
+#define FPRINTF(fp, ...) \
+ do { \
+ if (fprintf(fp, __VA_ARGS__) < 0) \
+ return (-1); \
+ } while (0)
/*
* When formatting a string for JSON output we must escape certain characters,
@@ -300,7 +302,7 @@ nvlist_print_json(FILE *fp, nvlist_t *nv
for (i = 0; i < valsz; i++) {
if (i > 0)
FPRINTF(fp, ",");
- FPRINTF(fp, "%hd", val[i]);
+ FPRINTF(fp, "%hhd", val[i]);
}
FPRINTF(fp, "]");
break;
@@ -328,7 +330,7 @@ nvlist_print_json(FILE *fp, nvlist_t *nv
for (i = 0; i < valsz; i++) {
if (i > 0)
FPRINTF(fp, ",");
- FPRINTF(fp, "%hhd", val[i]);
+ FPRINTF(fp, "%hd", val[i]);
}
FPRINTF(fp, "]");
break;
Modified: head/cddl/lib/libnvpair/Makefile
==============================================================================
--- head/cddl/lib/libnvpair/Makefile Sat Dec 6 00:50:57 2014 (r275551)
+++ head/cddl/lib/libnvpair/Makefile Sat Dec 6 01:01:51 2014 (r275552)
@@ -9,6 +9,7 @@ SRCS= libnvpair.c \
nvpair_alloc_system.c \
nvpair_alloc_fixed.c \
nvpair.c \
+ nvpair_json.c \
fnvpair.c
WARNS?= 0
More information about the svn-src-head
mailing list