Jansson now builds correctly with Visual C++ Express 2010.
#include <string.h>
#include <assert.h>
-#include <jansson.h>
+#include "jansson.h"
#include "jansson_private.h"
#include "strbuffer.h"
#include "utf.h"
size = snprintf(buffer, MAX_INTEGER_STR_LENGTH,
"%" JSON_INTEGER_FORMAT,
json_integer_value(json));
- if(size >= MAX_INTEGER_STR_LENGTH)
+ if(size < 0 || size >= MAX_INTEGER_STR_LENGTH)
return -1;
return dump(buffer, size, data);
error->position = position;
vsnprintf(error->text, JSON_ERROR_TEXT_LENGTH, msg, ap);
+ error->text[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
}
#include <stdlib.h>
#include <string.h>
-#include <jansson_config.h> /* for JSON_INLINE */
+#include "jansson_config.h" /* for JSON_INLINE */
#include "jansson_private.h" /* for container_of() */
#include "hashtable.h"
--- /dev/null
+LIBRARY "jansson"
+
+EXPORTS
+ json_delete
+ json_true
+ json_false
+ json_null
+ json_string
+ json_string_nocheck
+ json_string_value
+ json_string_set
+ json_string_set_nocheck
+ json_integer
+ json_integer_value
+ json_integer_set
+ json_real
+ json_real_value
+ json_real_set
+ json_number_value
+ json_array
+ json_array_size
+ json_array_get
+ json_array_set_new
+ json_array_append_new
+ json_array_insert_new
+ json_array_remove
+ json_array_clear
+ json_array_extend
+ json_object
+ json_object_size
+ json_object_get
+ json_object_set_new
+ json_object_set_new_nocheck
+ json_object_del
+ json_object_clear
+ json_object_update
+ json_object_update_existing
+ json_object_update_missing
+ json_object_iter
+ json_object_iter_at
+ json_object_iter_next
+ json_object_iter_key
+ json_object_iter_value
+ json_object_iter_set_new
+ json_object_key_to_iter
+ json_dumps
+ json_dumpf
+ json_dump_file
+ json_dump_callback
+ json_loads
+ json_loadb
+ json_loadf
+ json_load_file
+ json_load_callback
+ json_equal
+ json_copy
+ json_deep_copy
+ json_pack
+ json_pack_ex
+ json_vpack_ex
+ json_unpack
+ json_unpack_ex
+ json_vunpack_ex
+ json_set_alloc_funcs
+
#include <stdlib.h> /* for size_t */
#include <stdarg.h>
-#include <jansson_config.h>
+#include "jansson_config.h"
#ifdef __cplusplus
extern "C" {
#ifdef __cplusplus
#define JSON_INLINE inline
#else
-#define JSON_INLINE
+#define JSON_INLINE __inline
#endif
/* If your compiler supports the `long long` type and the strtoll()
void jsonp_free(void *ptr);
char *jsonp_strdup(const char *str);
+/* Windows compatibility */
+#ifdef _WIN32
+#define snprintf _snprintf
+#define vsnprintf _vsnprintf
+#endif
+
#endif
#include <string.h>
#include <assert.h>
-#include <jansson.h>
+#include "jansson.h"
#include "jansson_private.h"
#include "strbuffer.h"
#include "utf.h"
va_start(ap, msg);
vsnprintf(msg_text, JSON_ERROR_TEXT_LENGTH, msg, ap);
+ msg_text[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
va_end(ap);
if(lex)
if(lex->saved_text.length <= 20) {
snprintf(msg_with_context, JSON_ERROR_TEXT_LENGTH,
"%s near '%s'", msg_text, saved_text);
+ msg_with_context[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
result = msg_with_context;
}
}
else {
snprintf(msg_with_context, JSON_ERROR_TEXT_LENGTH,
"%s near end of file", msg_text);
+ msg_with_context[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
result = msg_with_context;
}
}
}
#if JSON_INTEGER_IS_LONG_LONG
+#ifdef _WIN32
+#define json_strtoint _strtoi64
+#else
#define json_strtoint strtoll
+#endif
#else
#define json_strtoint strtol
#endif
#include <stdlib.h>
#include <string.h>
-#include <jansson.h>
+#include "jansson.h"
#include "jansson_private.h"
/* memory function pointers */
*/
#include <string.h>
-#include <jansson.h>
+#include "jansson.h"
#include "jansson_private.h"
#include "utf.h"
if(!(s->flags & JSON_VALIDATE_ONLY)) {
int *target = va_arg(*ap, int*);
if(root)
- *target = json_integer_value(root);
+ *target = (int)json_integer_value(root);
}
return 0;
#include <stdlib.h>
#include <string.h>
-#include <jansson.h>
+#include "jansson.h"
#include "hashtable.h"
#include "jansson_private.h"
#include "utf.h"
double json_number_value(const json_t *json)
{
if(json_is_integer(json))
- return json_integer_value(json);
+ return (double)json_integer_value(json);
else if(json_is_real(json))
return json_real_value(json);
else
#!/bin/sh
-
+#
# This test checks that libjansson.so exports the correct symbols.
-
-# The list of symbols that the shared object should export
-sort >$test_log/exports <<EOF
-json_delete
-json_true
-json_false
-json_null
-json_string
-json_string_nocheck
-json_string_value
-json_string_set
-json_string_set_nocheck
-json_integer
-json_integer_value
-json_integer_set
-json_real
-json_real_value
-json_real_set
-json_number_value
-json_array
-json_array_size
-json_array_get
-json_array_set_new
-json_array_append_new
-json_array_insert_new
-json_array_remove
-json_array_clear
-json_array_extend
-json_object
-json_object_size
-json_object_get
-json_object_set_new
-json_object_set_new_nocheck
-json_object_del
-json_object_clear
-json_object_update
-json_object_update_existing
-json_object_update_missing
-json_object_iter
-json_object_iter_at
-json_object_iter_next
-json_object_iter_key
-json_object_iter_value
-json_object_iter_set_new
-json_object_key_to_iter
-json_dumps
-json_dumpf
-json_dump_file
-json_dump_callback
-json_loads
-json_loadb
-json_loadf
-json_load_file
-json_load_callback
-json_equal
-json_copy
-json_deep_copy
-json_pack
-json_pack_ex
-json_vpack_ex
-json_unpack
-json_unpack_ex
-json_vunpack_ex
-json_set_alloc_funcs
-EOF
-
-# The list of functions are not exported in the library because they
-# are macros or static inline functions. This is only the make the
-# list complete, there are not used by the test.
-sort >$test_log/macros_or_inline <<EOF
-json_typeof
-json_incref
-json_decref
-json_is_object
-json_is_object
-json_is_array
-json_is_string
-json_is_integer
-json_is_real
-json_is_true
-json_is_false
-json_is_null
-json_is_number
-json_is_boolean
-json_array_set
-json_array_append
-json_array_insert
-json_object_set
-json_object_set_nocheck
-EOF
+#
SOFILE="../src/.libs/libjansson.so"
+# The list of symbols, which the shared object should export, is read
+# from the def file, which is used in Windows builds
+grep 'json_' $top_srcdir/src/jansson.def \
+ | sed -e 's/ //g' \
+ | sort \
+ >$test_log/exports
+
nm -D $SOFILE >/dev/null >$test_log/symbols 2>/dev/null \
|| exit 77 # Skip if "nm -D" doesn't seem to work