aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPetri Lehtinen <petri@digip.org>2009-07-28 10:57:17 +0300
committerPetri Lehtinen <petri@digip.org>2009-07-28 10:58:13 +0300
commitf41e3809844319feae0033ce84d3acc2c5340e8d (patch)
tree1bfe87f8365bd6783c5926b920002af20164d0e0 /src
parentb348519e96f3414c6264748c2c63bc2a1c64642a (diff)
downloadjansson-f41e3809844319feae0033ce84d3acc2c5340e8d.zip
jansson-f41e3809844319feae0033ce84d3acc2c5340e8d.tar.gz
jansson-f41e3809844319feae0033ce84d3acc2c5340e8d.tar.bz2
Rename json_{load,dump} to json_{load,dump}_file
Diffstat (limited to 'src')
-rw-r--r--src/dump.c28
-rw-r--r--src/jansson.h4
-rw-r--r--src/load.c38
3 files changed, 35 insertions, 35 deletions
diff --git a/src/dump.c b/src/dump.c
index e5af458..9645e9f 100644
--- a/src/dump.c
+++ b/src/dump.c
@@ -225,20 +225,6 @@ static int do_dump(const json_t *json, uint32_t flags, int depth,
}
-int json_dump(const json_t *json, const char *path, uint32_t flags)
-{
- int result;
-
- FILE *output = fopen(path, "w");
- if(!output)
- return -1;
-
- result = json_dumpf(json, output, flags);
-
- fclose(output);
- return result;
-}
-
char *json_dumps(const json_t *json, uint32_t flags)
{
strbuffer_t strbuff;
@@ -265,3 +251,17 @@ int json_dumpf(const json_t *json, FILE *output, uint32_t flags)
return -1;
return dump_to_file("\n", 1, (void *)output);
}
+
+int json_dump_file(const json_t *json, const char *path, uint32_t flags)
+{
+ int result;
+
+ FILE *output = fopen(path, "w");
+ if(!output)
+ return -1;
+
+ result = json_dumpf(json, output, flags);
+
+ fclose(output);
+ return result;
+}
diff --git a/src/jansson.h b/src/jansson.h
index e90491a..9b79892 100644
--- a/src/jansson.h
+++ b/src/jansson.h
@@ -93,14 +93,14 @@ typedef struct {
int line;
} json_error_t;
-json_t *json_load(const char *path, json_error_t *error);
json_t *json_loads(const char *input, json_error_t *error);
json_t *json_loadf(FILE *input, json_error_t *error);
+json_t *json_load_file(const char *path, json_error_t *error);
#define JSON_INDENT(n) (n & 0xFF)
-int json_dump(const json_t *json, const char *path, uint32_t flags);
char *json_dumps(const json_t *json, uint32_t flags);
int json_dumpf(const json_t *json, FILE *output, uint32_t flags);
+int json_dump_file(const json_t *json, const char *path, uint32_t flags);
#endif
diff --git a/src/load.c b/src/load.c
index 975d7e9..d28721e 100644
--- a/src/load.c
+++ b/src/load.c
@@ -734,25 +734,6 @@ json_t *parse_json(lex_t *lex, json_error_t *error)
return parse_value(lex, error);
}
-json_t *json_load(const char *path, json_error_t *error)
-{
- json_t *result;
- FILE *fp;
-
- fp = fopen(path, "r");
- if(!fp)
- {
- error_set(error, NULL, "unable to open %s: %s",
- path, strerror(errno));
- return NULL;
- }
-
- result = json_loadf(fp, error);
-
- fclose(fp);
- return result;
-}
-
typedef struct
{
const char *data;
@@ -821,3 +802,22 @@ json_t *json_loadf(FILE *input, json_error_t *error)
lex_close(&lex);
return result;
}
+
+json_t *json_load_file(const char *path, json_error_t *error)
+{
+ json_t *result;
+ FILE *fp;
+
+ fp = fopen(path, "r");
+ if(!fp)
+ {
+ error_set(error, NULL, "unable to open %s: %s",
+ path, strerror(errno));
+ return NULL;
+ }
+
+ result = json_loadf(fp, error);
+
+ fclose(fp);
+ return result;
+}