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) {
125 size_t n = (location->
number == -1)
135 log_error(
"ERROR:plocation_write_elem:array not found for sub location:"
154 switch (location->
kind) {
162 log_error(
"Unknown packet part location kind.");
210 switch (location->
kind) {
216 log_error(
"Unknown packet part location kind.");
261 const struct plocation *location,
int value)
278 const struct plocation *location,
int value)
349 if (order->
dir == -1) {
429 const struct plocation *location,
int *dest)
442 const struct plocation *location,
int *dest)
491 const struct plocation *location,
int *dest)
504 const struct plocation *location,
int *dest)
527 log_packet(
"Corrupt cm_parameter.max_growth");
534 log_packet(
"Corrupt cm_parameter.require_happy");
541 log_packet(
"Corrupt cm_parameter.allow_disorder");
548 log_packet(
"Corrupt cm_parameter.allow_specialists");
556 log_packet(
"Corrupt cm_parameter.happy_factor");
578 log_packet(
"Corrupt cm_parameter.minimal_surplus");
607 while (
loc->sub_location) {
618 loc->sub_location->name =
"activity";
625 loc->sub_location->name =
"target";
632 loc->sub_location->name =
"sub_target";
639 loc->sub_location->name =
"action";
646 loc->sub_location->name =
"dir";
696 for (
i = 0;
i < length;
i++) {
744 log_warn(
"Received unimplemeted data type uint8_vec8.");
762 log_warn(
"Received unimplemeted data type uint16_vec8.");
779 bool survives, present, quiet;
794 log_error(
"ERROR: Unable to get part of requirement from location: %s",
801 log_error(
"ERROR: Unable to get part of requirement from location: %s",
808 log_error(
"ERROR: Unable to get part of requirement from location: %s",
815 log_error(
"ERROR: Unable to get part of requirement from location: %s",
822 log_error(
"ERROR: Unable to get part of requirement from location: %s",
829 log_error(
"ERROR: Unable to get part of requirement from location: %s",
859 log_error(
"ERROR: Unable to get action probability from location: %s",
868 log_error(
"ERROR: Unable to get part of action probability "
876 log_error(
"ERROR: Unable to get part of action probability "
920 const struct plocation *location,
int value)
937 const struct plocation *location,
int value)
954 const struct plocation *location,
bool value)
971 const struct plocation *location,
bool value)
989 float value,
int float_factor)
1007 float value,
int float_factor)
1031 log_error(
"Tried to send unimplemeted data type uint8_vec8.");
1044 const struct plocation *location,
int *values,
1051 log_error(
"Tried to send unimplemeted data type uint16_vec8.");
1081 ((
unsigned char *)value)[
i]);
1148 bool survives, present, quiet;
1230 const struct plocation *location,
bool *dest)
1232 if (
pc->json_mode) {
1243 const struct plocation *location,
bool *dest)
1245 if (
pc->json_mode) {
1270 float *dest,
int float_factor)
1272 if (
pc->json_mode) {
1292 float *dest,
int float_factor)
1294 if (
pc->json_mode) {
1313 const struct plocation *location,
int *dest)
1315 if (
pc->json_mode) {
1339 const struct plocation *location,
int *dest)
1341 if (
pc->json_mode) {
1366 void *dest,
size_t dest_size)
1368 if (
pc->json_mode) {
1373 for (
i = 0;
i < dest_size;
i++) {
1382 ((
unsigned char *)dest)[
i] = val;
1426 if (
pc->json_mode) {
1443 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)
int dio_put_uint8_vec8_json(struct json_data_out *dout, const struct plocation *location, int *values, int stop_value)
bool dio_get_uint16_json(struct connection *pc, struct data_in *din, const struct plocation *location, int *dest)
bool dio_get_estring_json(struct connection *pc, struct data_in *din, const struct plocation *location, char *dest, size_t max_dest_size)
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)
bool dio_get_worklist_json(struct connection *pc, struct data_in *din, struct plocation *location, struct worklist *pwl)
int dio_put_uint16_vec8_json(struct json_data_out *dout, const struct plocation *location, int *values, int stop_value)
bool dio_get_sint16_json(struct connection *pc, struct data_in *din, const struct plocation *location, int *dest)
bool dio_get_sint32_json(struct connection *pc, struct data_in *din, const struct plocation *location, int *dest)
bool dio_get_sint8_json(struct connection *pc, struct data_in *din, const struct plocation *location, int *dest)
int dio_put_uint16_json(struct json_data_out *dout, const struct plocation *location, int value)
bool dio_get_bool32_json(struct connection *pc, struct data_in *din, const struct plocation *location, bool *dest)
int dio_put_memory_json(struct json_data_out *dout, struct plocation *location, const void *value, size_t size)
bool dio_get_uint32_json(struct connection *pc, struct data_in *din, const struct plocation *location, int *dest)
bool dio_get_string_json(struct connection *pc, struct data_in *din, const struct plocation *location, char *dest, size_t max_dest_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)
bool dio_get_requirement_json(struct connection *pc, struct data_in *din, const struct plocation *location, struct requirement *preq)
int dio_put_bool8_json(struct json_data_out *dout, const struct plocation *location, bool value)
bool dio_get_uint8_vec8_json(struct connection *pc, struct data_in *din, 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)
bool dio_get_sfloat_json(struct connection *pc, struct data_in *din, const struct plocation *location, float *dest, int float_factor)
bool dio_get_uint8_json(struct connection *pc, struct data_in *din, const struct plocation *location, int *dest)
int dio_put_sint32_json(struct json_data_out *dout, const struct plocation *location, int value)
bool dio_get_memory_json(struct connection *pc, struct data_in *din, struct plocation *location, void *dest, size_t dest_size)
bool dio_get_unit_order_json(struct connection *pc, struct data_in *din, struct plocation *location, struct unit_order *order)
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_ufloat_json(struct connection *pc, struct data_in *din, const struct plocation *location, float *dest, int float_factor)
int dio_put_bool32_json(struct json_data_out *dout, const struct plocation *location, bool value)
bool dio_get_action_probability_json(struct connection *pc, struct data_in *din, const struct plocation *location, struct act_prob *prob)
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_bool8_json(struct connection *pc, struct data_in *din, const struct plocation *location, bool *dest)
int dio_put_string_json(struct json_data_out *dout, const struct plocation *location, const char *value)
int dio_put_cm_parameter_json(struct json_data_out *dout, struct plocation *location, const struct cm_parameter *order)
bool dio_get_uint16_vec8_json(struct connection *pc, struct data_in *din, const struct plocation *location, int **values, int stop_value)
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_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)