2 #include "jansson_private.h"
4 void jsonp_error_init(json_error_t *error, const char *source)
13 jsonp_error_set_source(error, source);
15 error->source[0] = '\0';
19 void jsonp_error_set_source(json_error_t *error, const char *source)
26 length = strlen(source);
27 if(length < JSON_ERROR_SOURCE_LENGTH)
28 strcpy(error->source, source);
30 size_t extra = length - JSON_ERROR_SOURCE_LENGTH + 4;
31 strcpy(error->source, "...");
32 strcpy(error->source + 3, source + extra);
36 void jsonp_error_set(json_error_t *error, int line, int column,
37 size_t position, const char *msg, ...)
42 jsonp_error_vset(error, line, column, position, msg, ap);
46 void jsonp_error_vset(json_error_t *error, int line, int column,
47 size_t position, const char *msg, va_list ap)
52 if(error->text[0] != '\0') {
53 /* error already set */
58 error->column = column;
59 error->position = position;
61 vsnprintf(error->text, JSON_ERROR_TEXT_LENGTH, msg, ap);