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.");
252 const struct plocation *location,
int value)
269 const struct plocation *location,
int value)
340 if (order->
dir == -1) {
415 const struct plocation *location,
int *dest)
428 const struct plocation *location,
int *dest)
467 const struct plocation *location,
int *dest)
480 const struct plocation *location,
int *dest)
503 log_packet(
"Corrupt cm_parameter.max_growth");
510 log_packet(
"Corrupt cm_parameter.require_happy");
517 log_packet(
"Corrupt cm_parameter.allow_disorder");
524 log_packet(
"Corrupt cm_parameter.allow_specialists");
532 log_packet(
"Corrupt cm_parameter.happy_factor");
554 log_packet(
"Corrupt cm_parameter.minimal_surplus");
583 while (
loc->sub_location) {
594 loc->sub_location->name =
"activity";
601 loc->sub_location->name =
"target";
608 loc->sub_location->name =
"sub_target";
615 loc->sub_location->name =
"action";
622 loc->sub_location->name =
"dir";
672 for (
i = 0;
i < length;
i++) {
716 const struct plocation *location,
int *dest)
743 log_warn(
"Received unimplemeted data type uint8_vec8.");
761 log_warn(
"Received unimplemeted data type uint16_vec8.");
778 bool survives, present, quiet;
793 log_error(
"ERROR: Unable to get part of requirement from location: %s",
800 log_error(
"ERROR: Unable to get part of requirement from location: %s",
807 log_error(
"ERROR: Unable to get part of requirement from location: %s",
814 log_error(
"ERROR: Unable to get part of requirement from location: %s",
821 log_error(
"ERROR: Unable to get part of requirement from location: %s",
828 log_error(
"ERROR: Unable to get part of requirement from location: %s",
858 log_error(
"ERROR: Unable to get action probability from location: %s",
867 log_error(
"ERROR: Unable to get part of action probability "
875 log_error(
"ERROR: Unable to get part of action probability "
936 const struct plocation *location,
int value)
953 const struct plocation *location,
int value)
970 const struct plocation *location,
bool value)
987 const struct plocation *location,
bool value)
1005 float value,
int float_factor)
1023 float value,
int float_factor)
1065 log_error(
"Tried to send unimplemeted data type uint8_vec8.");
1078 const struct plocation *location,
int *values,
1085 log_error(
"Tried to send unimplemeted data type uint16_vec8.");
1115 ((
unsigned char *)value)[
i]);
1182 bool survives, present, quiet;
1259 const struct plocation *location,
bool *dest)
1261 if (
pc->json_mode) {
1272 const struct plocation *location,
bool *dest)
1274 if (
pc->json_mode) {
1294 float *dest,
int float_factor)
1296 if (
pc->json_mode) {
1316 float *dest,
int float_factor)
1318 if (
pc->json_mode) {
1337 const struct plocation *location,
int *dest)
1339 if (
pc->json_mode) {
1358 const struct plocation *location,
int *dest)
1360 if (
pc->json_mode) {
1380 void *dest,
size_t dest_size)
1382 if (
pc->json_mode) {
1387 for (
i = 0;
i < dest_size;
i++) {
1396 ((
unsigned char *)dest)[
i] = val;
1440 if (
pc->json_mode) {
1457 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)