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__); \
177 d_out->dest_size = dest_size;
207 din->src_size = src_size;
225 return din->src_size -
din->current;
274 "Trying to put %d into 8 bits; "
275 "it will result %d at receiving side.",
296 "Trying to put %d into 16 bits; "
297 "it will result %d at receiving side.",
318 "Trying to put %d into 32 bits; "
319 "it will result %d at receiving side.",
392 value = (value !=
FALSE);,
393 "Trying to put a non-boolean: %d", (
int) value);
404 value = (value !=
FALSE);,
405 "Trying to put a non-boolean: %d",
421 "Trying to put %f with factor %d in 32 bits; "
422 "it will result %f at receiving side, having error of %f units.",
423 value, float_factor, (
float) v / float_factor,
424 fabsf((
float) v / float_factor - value) * float_factor);
436 int32_t v = value * float_factor;
439 "Trying to put %f with factor %d in 32 bits; "
440 "it will result %f at receiving side, having error of %f units.",
441 value, float_factor, (
float) v / float_factor,
442 fabsf((
float) v / float_factor - value) * float_factor);
458 for (count = 0; values[count] !=
stop_value; count++) {
467 for (
i = 0;
i < count;
i++) {
486 for (count = 0; values[count] !=
stop_value; count++) {
495 for (
i = 0;
i < count;
i++) {
593 for (
i = 0;
i < length;
i++) {
613 log_packet(
"Packet too short to read 1 byte");
634 log_packet(
"Packet too short to read 2 bytes");
655 log_packet(
"Packet too short to read 4 bytes");
812 if (
tmp > 0x7fffffff) {
832 din->current += dest_size;
842 size_t offset, remaining;
855 for (offset = 0; offset < remaining && c[offset] !=
'\0'; offset++) {
859 if (offset >= remaining) {
869 din->current += offset + 1;
951 for (
i = 0;
i < length;
i++) {
985 vec =
fc_calloc(count + 1,
sizeof(*vec));
1010 vec =
fc_calloc(count + 1,
sizeof(*vec));
1063 bool survives, present, quiet;
1090 bool survives, present, quiet;
1114 out->sub_location =
nullptr;
1128 out->sub_location =
nullptr;
1142 if (
loc ==
nullptr) {
1143 return "No location";
1146 switch (
loc->kind) {
1154 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_uint32_raw(struct raw_data_out *d_out, int value)
int dio_put_uint8_vec8_raw(struct raw_data_out *d_out, int *values, int stop_value)
int dio_put_bool32_raw(struct raw_data_out *d_out, bool value)
struct plocation * plocation_field_new(char *name)
size_t dio_output_used(struct raw_data_out *d_out)
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_cm_parameter_raw(struct raw_data_out *d_out, const struct cm_parameter *param)
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)
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)
int dio_put_ufloat_raw(struct raw_data_out *d_out, float value, int float_factor)
bool dio_get_sint32_raw(struct data_in *din, int *dest)
int dio_put_action_probability_raw(struct raw_data_out *d_out, const struct act_prob *aprob)
static bool enough_space(struct raw_data_out *d_out, size_t size)
int dio_put_uint16_raw(struct raw_data_out *d_out, int value)
int dio_put_worklist_raw(struct raw_data_out *d_out, const struct worklist *pwl)
bool dio_get_cm_parameter_raw(struct data_in *din, struct cm_parameter *param)
int dio_put_memory_raw(struct raw_data_out *d_out, const void *value, size_t size)
void dio_input_rewind(struct data_in *din)
bool dio_get_uint8_vec8_raw(struct data_in *din, int **values, int stop_value)
int dio_put_string_raw(struct raw_data_out *d_out, const char *value)
int dio_put_type_raw(struct raw_data_out *d_out, enum data_type type, int value)
void dio_output_rewind(struct raw_data_out *d_out)
bool dio_get_uint16_raw(struct data_in *din, int *dest)
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)
bool dio_get_bool32_raw(struct data_in *din, bool *dest)
int dio_put_bool8_raw(struct raw_data_out *d_out, bool value)
int dio_put_sfloat_raw(struct raw_data_out *d_out, float value, int float_factor)
void dio_output_init(struct raw_data_out *d_out, void *destination, size_t dest_size)
bool dio_get_ufloat_raw(struct data_in *din, float *dest, int float_factor)
int dio_put_sint16_raw(struct raw_data_out *d_out, int 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
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_sint32_raw(struct raw_data_out *d_out, int value)
int dio_put_sint8_raw(struct raw_data_out *d_out, int value)
void dio_input_init(struct data_in *din, const void *src, size_t src_size)
int dio_put_unit_order_raw(struct raw_data_out *d_out, const struct unit_order *order)
int dio_put_uint16_vec8_raw(struct raw_data_out *d_out, int *values, int stop_value)
#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)
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_requirement_raw(struct raw_data_out *d_out, const struct requirement *preq)
int dio_put_uint8_raw(struct raw_data_out *d_out, int value)
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)