socsvn commit: r270543 - soc2014/zkorchev/freebsd_head/lib/libsol

zkorchev at FreeBSD.org zkorchev at FreeBSD.org
Mon Jul 7 10:32:02 UTC 2014


Author: zkorchev
Date: Mon Jul  7 10:32:00 2014
New Revision: 270543
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=270543

Log:
  added a function that creates map key from an integer

Modified:
  soc2014/zkorchev/freebsd_head/lib/libsol/sol.c
  soc2014/zkorchev/freebsd_head/lib/libsol/sol.h

Modified: soc2014/zkorchev/freebsd_head/lib/libsol/sol.c
==============================================================================
--- soc2014/zkorchev/freebsd_head/lib/libsol/sol.c	Mon Jul  7 09:37:22 2014	(r270542)
+++ soc2014/zkorchev/freebsd_head/lib/libsol/sol.c	Mon Jul  7 10:32:00 2014	(r270543)
@@ -111,6 +111,17 @@
 	return 0;
 }
 
+int sol_map_keyi(struct sol_stream *restrict stream, intmax_t number)
+{
+	char buffer[20 + 1]; // INT64_MIN and INT64_MAX fit in 20 bytes
+	size_t len;
+
+	len = sprintf(buffer, "%" PRIi64, number);
+	yajl_gen_string(stream->ctx.g, (const unsigned char *)buffer, len);
+
+	return 0;
+}
+
 int sol_string(struct sol_stream *restrict stream, const char *data, size_t length)
 {
 	yajl_gen_string(stream->ctx.g, (const unsigned char *)data, length);

Modified: soc2014/zkorchev/freebsd_head/lib/libsol/sol.h
==============================================================================
--- soc2014/zkorchev/freebsd_head/lib/libsol/sol.h	Mon Jul  7 09:37:22 2014	(r270542)
+++ soc2014/zkorchev/freebsd_head/lib/libsol/sol.h	Mon Jul  7 10:32:00 2014	(r270543)
@@ -47,6 +47,7 @@
 int sol_map_start(struct sol_stream *restrict stream);
 int sol_map_end(struct sol_stream *restrict stream);
 int sol_map_key(struct sol_stream *restrict stream, const char *key, size_t length);
+int sol_map_keyi(struct sol_stream *restrict stream, intmax_t number);
 
 int sol_boolean(struct sol_stream *restrict stream, unsigned char value);
 int sol_integer(struct sol_stream *restrict stream, int64_t value);


More information about the svn-soc-all mailing list