This commit is contained in:
Tom Stellard 2020-12-30 19:11:58 -08:00
parent 8ff4284ca2
commit 11b7057891
4 changed files with 20 additions and 2 deletions

View File

@ -87,7 +87,7 @@ add_executable(bygfoot src/bet.c src/bet.h src/finance.h src/fixture.h
src/xml_lg_commentary.c src/xml_mmatches.c src/xml_name.c
src/xml_news.c src/xml_strategy.c src/xml_team.c src/youth_academy.c
src/zip/zip.c src/zip/zip.h src/zip/unzip.c src/zip/unzip.h
src/bygfoot.c src/backend_filesystem.c ${JSON_FILES})
src/bygfoot.c src/backend_filesystem.c src/json_serialize.c ${JSON_FILES})
# Some gtk headers use deprecated glib features, so disable this warning
# since we can't do anything about it.

View File

@ -1,6 +1,8 @@
#ifndef BYGFOOT_STRUCT_H
#define BYGFOOT_STRUCT_H
#include <glib.h>
enum BygfootFrontend {
BYGFOOT_FRONTEND_GTK2,

View File

@ -3,6 +3,7 @@
#include <json-c/json_tokener.h>
#include <json-c/json_object.h>
#include "json_interface.h"
#include "json_serialize.h"
#include "user.h"
#include "league_struct.h"
#include "misc.h"
@ -79,7 +80,8 @@ static int bygfoot_json_do_commands(Bygfoot *bygfoot, const json_object *command
json_object* (*func)(Bygfoot *, const json_object *);
} json_funcs[] = {
{ "new_bygfoot", bygfoot_json_call_new_bygfoot },
{ "load_bygfoot", bygfoot_json_call_load_bygfoot },
{ "load_bygfoot", bygfoot_json_call_load_bygfoot },
{ "get_countries", bygfoot_json_call_get_countries },
{ "add_country", bygfoot_json_call_add_country },
{ "add_user", bygfoot_json_call_add_user },
{ "start_bygfoot", bygfoot_json_call_start_bygfoot },
@ -184,6 +186,16 @@ bygfoot_json_call_new_bygfoot(Bygfoot *bygfoot, const json_object *args)
return response;
}
struct json_object *
bygfoot_json_call_get_countries(Bygfoot *bygfoot, const json_object *args)
{
struct json_object *response = json_object_new_object();
GPtrArray *country_list = bygfoot_get_country_list(bygfoot);
json_object_object_add(response, "success",
bygfoot_json_serialize_country_list(country_list));
return response;
}
static json_object *
bygfoot_json_call_add_country(Bygfoot *bygfoot, const json_object *args)
{

View File

@ -1,8 +1,12 @@
#ifndef JSON_INTERFACE_H
#define JSON_INTERFACE_H
#include <json-c/json_object.h>
#include "bygfoot.h"
int bygfoot_json_main(Bygfoot *bygfoot, const CommandLineArgs *cl_args);
struct json_object *bygfoot_json_call_get_countries(Bygfoot *bygfoot, const json_object *args);
#endif