35#ifdef FREECIV_HAVE_SYS_TYPES_H
38#ifdef HAVE_SYS_SOCKET_H
39#include <sys/socket.h>
41#ifdef HAVE_NETINET_IN_H
42#include <netinet/in.h>
44#ifdef HAVE_ARPA_INET_H
67static bool get_conv(
char *dst,
size_t ndst,
const char *src,
76#if defined(FREECIV_TESTMATIC) && !defined(FIELD_RANGE_ASSERT)
77#define FIELD_RANGE_ASSERT
80#ifdef FIELD_RANGE_ASSERT
85#define FIELD_RANGE_TEST(_test_, _action_, _format_, ...) \
87 log_error(_format_, ## __VA_ARGS__); \
88 fc_assert(!(_test_)); \
92#define FIELD_RANGE_TEST(_test_, _action_, _format_, ...) \
94 log_error(_format_, ## __VA_ARGS__); \
175 dout->dest_size = dest_size;
205 din->src_size = src_size;
223 return din->src_size -
din->current;
272 "Trying to put %d into 8 bits; "
273 "it will result %d at receiving side.",
294 "Trying to put %d into 16 bits; "
295 "it will result %d at receiving side.",
316 "Trying to put %d into 32 bits; "
317 "it will result %d at receiving side.",
389 value = (value !=
FALSE);,
390 "Trying to put a non-boolean: %d", (
int) value);
401 value = (value !=
FALSE);,
402 "Trying to put a non-boolean: %d",
417 "Trying to put %f with factor %d in 32 bits; "
418 "it will result %f at receiving side, having error of %f units.",
419 value, float_factor, (
float) v / float_factor,
420 fabsf((
float) v / float_factor - value) * float_factor);
431 int32_t v = value * float_factor;
434 "Trying to put %f with factor %d in 32 bits; "
435 "it will result %f at receiving side, having error of %f units.",
436 value, float_factor, (
float) v / float_factor,
437 fabsf((
float) v / float_factor - value) * float_factor);
452 for (count = 0; values[count] !=
stop_value; count++) {
461 for (
i = 0;
i < count;
i++) {
479 for (count = 0; values[count] !=
stop_value; count++) {
488 for (
i = 0;
i < count;
i++) {
585 for (
i = 0;
i < length;
i++) {
605 log_packet(
"Packet too short to read 1 byte");
626 log_packet(
"Packet too short to read 2 bytes");
647 log_packet(
"Packet too short to read 4 bytes");
804 if (
tmp > 0x7fffffff) {
824 din->current += dest_size;
834 size_t offset, remaining;
847 for (offset = 0; offset < remaining && c[offset] !=
'\0'; offset++) {
851 if (offset >= remaining) {
861 din->current += offset + 1;
943 for (
i = 0;
i < length;
i++) {
977 vec =
fc_calloc(count + 1,
sizeof(*vec));
1002 vec =
fc_calloc(count + 1,
sizeof(*vec));
1055 bool survives, present, quiet;
1082 bool survives, present, quiet;
1135 return "No location";
1138 switch (
loc->kind) {
1146 return "Illegal location";
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_type_raw(struct raw_data_out *dout, enum data_type type, int value)
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)
static bool enough_space(struct raw_data_out *dout, size_t size)
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)
void dio_output_init(struct raw_data_out *dout, void *destination, size_t dest_size)
void dio_set_get_conv_callback(DIO_GET_CONV_FUN fun)
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)
size_t dio_input_remaining(struct data_in *din)
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)
void dio_input_rewind(struct data_in *din)
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)
static bool get_conv(char *dst, size_t ndst, const char *src, size_t nsrc)
bool dio_get_type_raw(struct data_in *din, enum data_type type, int *dest)
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)
static bool enough_data(struct data_in *din, size_t size)
static DIO_GET_CONV_FUN get_conv_callback
int dio_put_uint16_raw(struct raw_data_out *dout, int value)
bool dio_input_skip(struct data_in *din, size_t size)
bool dio_get_uint16_vec8_raw(struct data_in *din, int **values, int stop_value)
size_t data_type_size(enum data_type type)
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)
size_t dio_output_used(struct raw_data_out *dout)
int dio_put_uint16_vec8_raw(struct raw_data_out *dout, int *values, int stop_value)
void dio_input_init(struct data_in *din, const void *src, size_t src_size)
int dio_put_sfloat_raw(struct raw_data_out *dout, float value, int float_factor)
#define FIELD_RANGE_TEST(_test_, _action_, _format_,...)
static DIO_PUT_CONV_FUN put_conv_callback
void dio_set_put_conv_callback(DIO_PUT_CONV_FUN fun)
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)
void dio_output_rewind(struct raw_data_out *dout)
int dio_put_worklist_raw(struct raw_data_out *dout, const struct worklist *pwl)
char *(* DIO_PUT_CONV_FUN)(const char *src, size_t *length)
bool(* DIO_GET_CONV_FUN)(char *dst, size_t ndst, const char *src, size_t nsrc)
#define fc_assert_msg(condition, message,...)
#define fc_assert(condition)
#define FC_STATIC_ASSERT(cond, tag)
#define fc_calloc(n, esz)
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)
#define ADD_TO_POINTER(p, n)
int minimal_surplus[O_LAST]
enum unit_activity activity
int fc_snprintf(char *str, size_t n, const char *format,...)
void worklist_init(struct worklist *pwl)
bool worklist_append(struct worklist *pwl, const struct universal *prod)
int worklist_length(const struct worklist *pwl)