]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - client/jansson/error.c
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 strncpy(error
->source
, source
, JSON_ERROR_SOURCE_LENGTH
);
30 size_t extra
= length
- JSON_ERROR_SOURCE_LENGTH
+ 4;
31 memcpy(error
->source
, "...", 3);
32 strncpy(error
->source
+ 3, source
+ extra
, length
- extra
+ 1);
36 void jsonp_error_set(json_error_t
*error
, int line
, int column
,
37 size_t position
, enum json_error_code code
,
43 jsonp_error_vset(error
, line
, column
, position
, code
, msg
, ap
);
47 void jsonp_error_vset(json_error_t
*error
, int line
, int column
,
48 size_t position
, enum json_error_code code
,
49 const char *msg
, va_list ap
)
54 if(error
->text
[0] != '\0') {
55 /* error already set */
60 error
->column
= column
;
61 error
->position
= (int)position
;
63 vsnprintf(error
->text
, JSON_ERROR_TEXT_LENGTH
- 1, msg
, ap
);
64 error
->text
[JSON_ERROR_TEXT_LENGTH
- 2] = '\0';
65 error
->text
[JSON_ERROR_TEXT_LENGTH
- 1] = code
;