18#ifdef FREECIV_JSON_CONNECTION
31#ifdef FREECIV_HAVE_SYS_TYPES_H
34#ifdef HAVE_SYS_SOCKET_H
35#include <sys/socket.h>
37#ifdef HAVE_NETINET_IN_H
38#include <netinet/in.h>
40#ifdef HAVE_ARPA_INET_H
117 if (location->
number == -1) {
123 size_t n = (location->
number == -1)
144 switch (location->
kind) {
152 log_error(
"Unknown packet part location kind.");
200 switch (location->
kind) {
206 log_error(
"Unknown packet part location kind.");
251 const struct plocation *location,
int value)
268 const struct plocation *location,
int value)
339 if (order->
dir == -1) {
414 const struct plocation *location,
int *dest)
427 const struct plocation *location,
int *dest)
466 const struct plocation *location,
int *dest)
479 const struct plocation *location,
int *dest)
502 log_packet(
"Corrupt cm_parameter.max_growth");
509 log_packet(
"Corrupt cm_parameter.require_happy");
516 log_packet(
"Corrupt cm_parameter.allow_disorder");
523 log_packet(
"Corrupt cm_parameter.allow_specialists");
531 log_packet(
"Corrupt cm_parameter.happy_factor");
553 log_packet(
"Corrupt cm_parameter.minimal_surplus");
582 while (
loc->sub_location) {
593 loc->sub_location->name =
"activity";
600 loc->sub_location->name =
"target";
607 loc->sub_location->name =
"sub_target";
614 loc->sub_location->name =
"action";
621 loc->sub_location->name =
"dir";
671 for (
i = 0;
i < length;
i++) {
715 const struct plocation *location,
int *dest)
742 log_warn(
"Received unimplemeted data type uint8_vec8.");
760 log_warn(
"Received unimplemeted data type uint16_vec8.");
777 bool survives, present, quiet;
792 log_error(
"ERROR: Unable to get part of requirement from location: %s",
799 log_error(
"ERROR: Unable to get part of requirement from location: %s",
806 log_error(
"ERROR: Unable to get part of requirement from location: %s",
813 log_error(
"ERROR: Unable to get part of requirement from location: %s",
820 log_error(
"ERROR: Unable to get part of requirement from location: %s",
827 log_error(
"ERROR: Unable to get part of requirement from location: %s",
857 log_error(
"ERROR: Unable to get action probability from location: %s",
866 log_error(
"ERROR: Unable to get part of action probability "
874 log_error(
"ERROR: Unable to get part of action probability "
935 const struct plocation *location,
int value)
952 const struct plocation *location,
int value)
969 const struct plocation *location,
bool value)
986 const struct plocation *location,
bool value)
1004 float value,
int float_factor)
1022 float value,
int float_factor)
1064 log_error(
"Tried to send unimplemeted data type uint8_vec8.");
1077 const struct plocation *location,
int *values,
1084 log_error(
"Tried to send unimplemeted data type uint16_vec8.");
1114 ((
unsigned char *)value)[
i]);
1181 bool survives, present, quiet;
1258 const struct plocation *location,
bool *dest)
1260 if (
pc->json_mode) {
1271 const struct plocation *location,
bool *dest)
1273 if (
pc->json_mode) {
1293 float *dest,
int float_factor)
1295 if (
pc->json_mode) {
1315 float *dest,
int float_factor)
1317 if (
pc->json_mode) {
1336 const struct plocation *location,
int *dest)
1338 if (
pc->json_mode) {
1357 const struct plocation *location,
int *dest)
1359 if (
pc->json_mode) {
1379 void *dest,
size_t dest_size)
1381 if (
pc->json_mode) {
1386 for (
i = 0;
i < dest_size;
i++) {
1395 ((
unsigned char *)dest)[
i] = val;
1439 if (
pc->json_mode) {
1456 if (
pc->json_mode) {
void cm_init_parameter(struct cm_parameter *dest)
int dio_put_unit_order_json(struct json_data_out *dout, struct plocation *location, const struct unit_order *order)
bool dio_get_uint8_vec8_json(struct connection *pc, struct data_in *din, const struct plocation *location, int **values, int stop_value) fc__attribute((nonnull(4)))
bool dio_get_uint8_json(struct connection *pc, struct data_in *din, const struct plocation *location, int *dest) fc__attribute((nonnull(4)))
int dio_put_uint8_vec8_json(struct json_data_out *dout, const struct plocation *location, int *values, int stop_value)
bool dio_get_cm_parameter_json(struct connection *pc, struct data_in *din, struct plocation *location, struct cm_parameter *param) fc__attribute((nonnull(4)))
bool dio_get_requirement_json(struct connection *pc, struct data_in *din, const struct plocation *location, struct requirement *preq) fc__attribute((nonnull(4)))
int dio_put_worklist_json(struct json_data_out *dout, struct plocation *location, const struct worklist *pwl)
int dio_put_uint32_json(struct json_data_out *dout, const struct plocation *location, int value)
int dio_put_object_json(struct json_data_out *dout, const struct plocation *location)
bool dio_get_estring_json(struct connection *pc, struct data_in *din, const struct plocation *location, char *dest, size_t max_dest_size) fc__attribute((nonnull(4)))
int dio_put_uint16_vec8_json(struct json_data_out *dout, const struct plocation *location, int *values, int stop_value)
bool dio_get_uint32_json(struct connection *pc, struct data_in *din, const struct plocation *location, int *dest) fc__attribute((nonnull(4)))
bool dio_get_memory_json(struct connection *pc, struct data_in *din, struct plocation *location, void *dest, size_t dest_size) fc__attribute((nonnull(4)))
bool dio_get_uint16_vec8_json(struct connection *pc, struct data_in *din, const struct plocation *location, int **values, int stop_value) fc__attribute((nonnull(4)))
int dio_put_uint16_json(struct json_data_out *dout, const struct plocation *location, int value)
bool dio_get_sint8_json(struct connection *pc, struct data_in *din, const struct plocation *location, int *dest) fc__attribute((nonnull(4)))
int dio_put_memory_json(struct json_data_out *dout, struct plocation *location, const void *value, size_t size)
bool dio_get_sint32_json(struct connection *pc, struct data_in *din, const struct plocation *location, int *dest) fc__attribute((nonnull(4)))
int dio_put_arraylen_json(struct json_data_out *dout, const struct plocation *location, int size)
int dio_put_uint8_json(struct json_data_out *dout, const struct plocation *location, int value)
int dio_put_farray_json(struct json_data_out *dout, const struct plocation *location, int size)
int dio_put_bool8_json(struct json_data_out *dout, const struct plocation *location, bool value)
int dio_put_sint32_json(struct json_data_out *dout, const struct plocation *location, int value)
int dio_put_estring_json(struct json_data_out *dout, const struct plocation *location, const char *value)
int dio_put_action_probability_json(struct json_data_out *dout, const struct plocation *location, const struct act_prob *prob)
bool dio_get_arraylen_json(struct connection *pc, struct data_in *din, const struct plocation *location, int *dest) fc__attribute((nonnull(4)))
bool dio_get_worklist_json(struct connection *pc, struct data_in *din, struct plocation *location, struct worklist *pwl) fc__attribute((nonnull(4)))
bool dio_get_sfloat_json(struct connection *pc, struct data_in *din, const struct plocation *location, float *dest, int float_factor) fc__attribute((nonnull(4)))
int dio_put_bool32_json(struct json_data_out *dout, const struct plocation *location, bool value)
bool dio_get_bool32_json(struct connection *pc, struct data_in *din, const struct plocation *location, bool *dest) fc__attribute((nonnull(4)))
bool dio_get_ufloat_json(struct connection *pc, struct data_in *din, const struct plocation *location, float *dest, int float_factor) fc__attribute((nonnull(4)))
bool dio_get_bool8_json(struct connection *pc, struct data_in *din, const struct plocation *location, bool *dest) fc__attribute((nonnull(4)))
bool dio_get_unit_order_json(struct connection *pc, struct data_in *din, struct plocation *location, struct unit_order *order) fc__attribute((nonnull(4)))
int dio_put_sfloat_json(struct json_data_out *dout, const struct plocation *location, float value, int float_factor)
int dio_put_requirement_json(struct json_data_out *dout, const struct plocation *location, const struct requirement *preq)
int dio_put_sint8_json(struct json_data_out *dout, const struct plocation *location, int value)
int dio_put_sint16_json(struct json_data_out *dout, const struct plocation *location, int value)
int dio_put_ufloat_json(struct json_data_out *dout, const struct plocation *location, float value, int float_factor)
bool dio_get_sint16_json(struct connection *pc, struct data_in *din, const struct plocation *location, int *dest) fc__attribute((nonnull(4)))
int dio_put_string_json(struct json_data_out *dout, const struct plocation *location, const char *value)
bool dio_get_action_probability_json(struct connection *pc, struct data_in *din, const struct plocation *location, struct act_prob *prob) fc__attribute((nonnull(4)))
bool dio_get_uint16_json(struct connection *pc, struct data_in *din, const struct plocation *location, int *dest) fc__attribute((nonnull(4)))
int dio_put_cm_parameter_json(struct json_data_out *dout, struct plocation *location, const struct cm_parameter *order)
bool dio_get_string_json(struct connection *pc, struct data_in *din, const struct plocation *location, char *dest, size_t max_dest_size) fc__attribute((nonnull(4)))
bool dio_get_requirement_raw(struct data_in *din, struct requirement *preq)
bool dio_get_sint8_raw(struct data_in *din, int *dest)
int dio_put_uint8_vec8_raw(struct raw_data_out *dout, int *values, int stop_value)
int dio_put_cm_parameter_raw(struct raw_data_out *dout, const struct cm_parameter *param)
int dio_put_action_probability_raw(struct raw_data_out *dout, const struct act_prob *aprob)
int dio_put_uint8_raw(struct raw_data_out *dout, int value)
struct plocation * plocation_field_new(char *name)
bool dio_get_worklist_raw(struct data_in *din, struct worklist *pwl)
bool dio_get_action_probability_raw(struct data_in *din, struct act_prob *aprob)
int dio_put_uint32_raw(struct raw_data_out *dout, int value)
bool dataio_get_conv_callback(char *dst, size_t ndst, const char *src, size_t nsrc)
bool dio_get_sfloat_raw(struct data_in *din, float *dest, int float_factor)
bool dio_get_uint32_raw(struct data_in *din, int *dest)
int dio_put_string_raw(struct raw_data_out *dout, const char *value)
bool dio_get_sint16_raw(struct data_in *din, int *dest)
bool dio_get_unit_order_raw(struct data_in *din, struct unit_order *order)
bool dio_get_sint32_raw(struct data_in *din, int *dest)
int dio_put_bool8_raw(struct raw_data_out *dout, bool value)
bool dio_get_cm_parameter_raw(struct data_in *din, struct cm_parameter *param)
int dio_put_sint8_raw(struct raw_data_out *dout, int value)
int dio_put_requirement_raw(struct raw_data_out *dout, const struct requirement *preq)
bool dio_get_uint8_vec8_raw(struct data_in *din, int **values, int stop_value)
bool dio_get_uint16_raw(struct data_in *din, int *dest)
int dio_put_sint32_raw(struct raw_data_out *dout, int value)
bool dio_get_memory_raw(struct data_in *din, void *dest, size_t dest_size)
int dio_put_memory_raw(struct raw_data_out *dout, const void *value, size_t size)
bool dio_get_bool32_raw(struct data_in *din, bool *dest)
bool dio_get_ufloat_raw(struct data_in *din, float *dest, int float_factor)
int dio_put_bool32_raw(struct raw_data_out *dout, bool value)
bool dio_get_uint8_raw(struct data_in *din, int *dest)
int dio_put_uint16_raw(struct raw_data_out *dout, int value)
bool dio_get_uint16_vec8_raw(struct data_in *din, int **values, int stop_value)
struct plocation * plocation_elem_new(int number)
bool dio_get_bool8_raw(struct data_in *din, bool *dest)
int dio_put_unit_order_raw(struct raw_data_out *dout, const struct unit_order *order)
int dio_put_ufloat_raw(struct raw_data_out *dout, float value, int float_factor)
int dio_put_uint16_vec8_raw(struct raw_data_out *dout, int *values, int stop_value)
int dio_put_sfloat_raw(struct raw_data_out *dout, float value, int float_factor)
int dio_put_sint16_raw(struct raw_data_out *dout, int value)
bool dio_get_string_raw(struct data_in *din, char *dest, size_t max_dest_size)
const char * plocation_name(const struct plocation *loc)
int dio_put_worklist_raw(struct raw_data_out *dout, const struct worklist *pwl)
#define dio_put_arraylen_raw
#define dio_get_arraylen_raw
#define dio_get_estring_raw
#define dio_put_estring_raw
#define log_warn(message,...)
#define log_error(message,...)
void req_get_values(const struct requirement *req, int *type, int *range, bool *survives, bool *present, bool *quiet, int *value)
struct requirement req_from_values(int type, int range, bool survives, bool present, bool quiet, int value)
struct universal universal_by_number(const enum universals_n kind, const int value)
int universal_number(const struct universal *source)
int minimal_surplus[O_LAST]
struct plocation * sub_location
enum unit_activity activity
void worklist_init(struct worklist *pwl)
bool worklist_append(struct worklist *pwl, const struct universal *prod)
int worklist_length(const struct worklist *pwl)