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)
24 size_t length = strlen(source);
25 if(length < JSON_ERROR_SOURCE_LENGTH)
26 strcpy(error->source, source);
28 size_t extra = length - JSON_ERROR_SOURCE_LENGTH + 4;
29 strcpy(error->source, "...");
30 strcpy(error->source + 3, source + extra);
34 void jsonp_error_set(json_error_t *error, int line, int column,
35 size_t position, const char *msg, ...)
40 jsonp_error_vset(error, line, column, position, msg, ap);
44 void jsonp_error_vset(json_error_t *error, int line, int column,
45 size_t position, const char *msg, va_list ap)
50 if(error->text[0] != '\0') {
51 /* error already set */
56 error->column = column;
57 error->position = position;
59 vsnprintf(error->text, JSON_ERROR_TEXT_LENGTH, msg, ap);