rename export to json.

this may or may not have been a good idea, but for now, that is what I
choose.
This commit is contained in:
Enno Rehling 2014-03-14 22:30:07 -07:00
parent 7256b4c04f
commit fc1a56d46a
7 changed files with 28 additions and 23 deletions

View File

@ -64,7 +64,7 @@ set (SERVER_SRC
eressea.pkg.c
settings.pkg.c
eressea.c
export.c
json.c
archetype.c
creation.c
creport.c
@ -127,7 +127,7 @@ set(SERVER_TEST_SRC
test_eressea.c
tests.c
tests_test.c
bindings_test.c
json_test.c
economy_test.c
market_test.c
laws_test.c

View File

@ -2,7 +2,7 @@
#include <platform.h>
#include "export.h"
#include "json.h"
#include <kernel/types.h>
#include <kernel/config.h>
@ -35,7 +35,7 @@ int eressea_export_json(const char * filename, unsigned int flags) {
stream out = { 0 };
int err;
fstream_init(&out, F);
err = export_json(&out, flags);
err = json_export(&out, flags);
fstream_done(&out);
return err;
}

View File

@ -1,12 +0,0 @@
#pragma once
#ifndef ERESSEA_EXPORT_H
#define ERESSEA_EXPORT_H
#define EXPORT_REGIONS 1<<0
#define EXPORT_FACTIONS 1<<1
#define EXPORT_UNITS 1<<2
struct stream;
int export_json(struct stream * out, unsigned int flags);
#endif

View File

@ -2,7 +2,7 @@
#include <util/base36.h>
#include <platform.h>
#include "export.h"
#include "json.h"
#include <kernel/types.h>
#include <kernel/region.h>
@ -13,7 +13,11 @@
#include <assert.h>
int export_json(stream * out, unsigned int flags) {
int json_import(struct stream * out) {
return 0;
}
int json_export(stream * out, unsigned int flags) {
cJSON *json, *root = cJSON_CreateObject();
assert(out && out->api);
if (flags & EXPORT_REGIONS) {

13
src/json.h Normal file
View File

@ -0,0 +1,13 @@
#pragma once
#ifndef ERESSEA_JSON_H
#define ERESSEA_JSON_H
#define EXPORT_REGIONS 1<<0
#define EXPORT_FACTIONS 1<<1
#define EXPORT_UNITS 1<<2
struct stream;
int json_export(struct stream * out, unsigned int flags);
int json_import(struct stream * out);
#endif

View File

@ -2,7 +2,7 @@
#include <CuTest.h>
#include <stream.h>
#include <memstream.h>
#include "export.h"
#include "json.h"
#include "bind_eressea.h"
static void test_export(CuTest * tc) {
@ -11,7 +11,7 @@ static void test_export(CuTest * tc) {
int err;
mstream_init(&out);
err = export_json(&out, EXPORT_REGIONS);
err = json_export(&out, EXPORT_REGIONS);
CuAssertIntEquals(tc, 0, err);
out.api->rewind(out.handle);
out.api->read(out.handle, buf, sizeof(buf));
@ -19,7 +19,7 @@ static void test_export(CuTest * tc) {
mstream_done(&out);
}
CuSuite *get_bindings_suite(void) {
CuSuite *get_json_suite(void) {
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_export);
return suite;

View File

@ -3,7 +3,7 @@
#include <util/log.h>
CuSuite *get_tests_suite(void);
CuSuite *get_bindings_suite(void);
CuSuite *get_json_suite(void);
CuSuite *get_economy_suite(void);
CuSuite *get_laws_suite(void);
CuSuite *get_market_suite(void);
@ -35,7 +35,7 @@ int RunAllTests(void)
/* self-test */
CuSuiteAddSuite(suite, get_tests_suite());
CuSuiteAddSuite(suite, get_bindings_suite());
CuSuiteAddSuite(suite, get_json_suite());
/* util */
CuSuiteAddSuite(suite, get_base36_suite());
CuSuiteAddSuite(suite, get_bsdstring_suite());