mirror of
https://github.com/json-c/json-c.git
synced 2026-03-22 14:39:07 +08:00
Rename _set_last_err() to _json_c_set_last_err().
This commit is contained in:
@@ -756,13 +756,13 @@ int json_c_set_serialization_double_format(const char *double_format, int global
|
||||
}
|
||||
tls_serialization_float_format = double_format ? strdup(double_format) : NULL;
|
||||
#else
|
||||
_set_last_err("json_c_set_option: not compiled with __thread support\n");
|
||||
_json_c_set_last_err("json_c_set_option: not compiled with __thread support\n");
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
_set_last_err("json_c_set_option: invalid global_or_thread value: %d\n", global_or_thread);
|
||||
_json_c_set_last_err("json_c_set_option: invalid global_or_thread value: %d\n", global_or_thread);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -48,7 +48,7 @@ struct json_object
|
||||
void *_userdata;
|
||||
};
|
||||
|
||||
void _set_last_err(const char *err_fmt, ...);
|
||||
void _json_c_set_last_err(const char *err_fmt, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
18
json_util.c
18
json_util.c
@@ -72,7 +72,7 @@ const char *json_util_get_last_err()
|
||||
return _last_err;
|
||||
}
|
||||
|
||||
void _set_last_err(const char *err_fmt, ...)
|
||||
void _json_c_set_last_err(const char *err_fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, err_fmt);
|
||||
@@ -89,14 +89,14 @@ struct json_object* json_object_from_fd(int fd)
|
||||
int ret;
|
||||
|
||||
if(!(pb = printbuf_new())) {
|
||||
_set_last_err("json_object_from_file: printbuf_new failed\n");
|
||||
_json_c_set_last_err("json_object_from_file: printbuf_new failed\n");
|
||||
return NULL;
|
||||
}
|
||||
while((ret = read(fd, buf, JSON_FILE_BUF_SIZE)) > 0) {
|
||||
printbuf_memappend(pb, buf, ret);
|
||||
}
|
||||
if(ret < 0) {
|
||||
_set_last_err("json_object_from_fd: error reading fd %d: %s\n", fd, strerror(errno));
|
||||
_json_c_set_last_err("json_object_from_fd: error reading fd %d: %s\n", fd, strerror(errno));
|
||||
printbuf_free(pb);
|
||||
return NULL;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ struct json_object* json_object_from_file(const char *filename)
|
||||
int fd;
|
||||
|
||||
if((fd = open(filename, O_RDONLY)) < 0) {
|
||||
_set_last_err("json_object_from_file: error opening file %s: %s\n",
|
||||
_json_c_set_last_err("json_object_from_file: error opening file %s: %s\n",
|
||||
filename, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
@@ -128,12 +128,12 @@ int json_object_to_file_ext(const char *filename, struct json_object *obj, int f
|
||||
int saved_errno;
|
||||
|
||||
if (!obj) {
|
||||
_set_last_err("json_object_to_file: object is null\n");
|
||||
_json_c_set_last_err("json_object_to_file: object is null\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, 0644)) < 0) {
|
||||
_set_last_err("json_object_to_file: error opening file %s: %s\n",
|
||||
_json_c_set_last_err("json_object_to_file: error opening file %s: %s\n",
|
||||
filename, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
@@ -147,7 +147,7 @@ int json_object_to_file_ext(const char *filename, struct json_object *obj, int f
|
||||
int json_object_to_fd(int fd, struct json_object *obj, int flags)
|
||||
{
|
||||
if (!obj) {
|
||||
_set_last_err("json_object_to_fd: object is null\n");
|
||||
_json_c_set_last_err("json_object_to_fd: object is null\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ static int _json_object_to_fd(int fd, struct json_object *obj, int flags, const
|
||||
wpos = 0;
|
||||
while(wpos < wsize) {
|
||||
if((ret = write(fd, json_str + wpos, wsize-wpos)) < 0) {
|
||||
_set_last_err("json_object_to_file: error writing file %s: %s\n",
|
||||
_json_c_set_last_err("json_object_to_file: error writing file %s: %s\n",
|
||||
filename, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
@@ -235,7 +235,7 @@ const char *json_type_to_name(enum json_type o_type)
|
||||
int o_type_int = (int)o_type;
|
||||
if (o_type_int < 0 || o_type_int >= (int)NELEM(json_type_name))
|
||||
{
|
||||
_set_last_err("json_type_to_name: type %d is out of range [0,%d]\n", o_type, NELEM(json_type_name));
|
||||
_json_c_set_last_err("json_type_to_name: type %d is out of range [0,%d]\n", o_type, NELEM(json_type_name));
|
||||
return NULL;
|
||||
}
|
||||
return json_type_name[o_type];
|
||||
|
||||
@@ -77,8 +77,8 @@ extern int json_object_to_file_ext(const char *filename, struct json_object *obj
|
||||
extern int json_object_to_fd(int fd, struct json_object *obj, int flags);
|
||||
|
||||
/**
|
||||
* Return the last error from json_object_to_file{,_ext},
|
||||
* json_object_to_fd() or
|
||||
* Return the last error from various json-c functions, including:
|
||||
* json_object_to_file{,_ext}, json_object_to_fd() or
|
||||
* json_object_from_{file,fd}, or NULL if there is none.
|
||||
*/
|
||||
const char *json_util_get_last_err(void);
|
||||
|
||||
Reference in New Issue
Block a user