58#ifdef HAVE_SYS_IOCTL_H
61#ifdef HAVE_SYS_SELECT_H
62#include <sys/select.h>
67#ifdef FREECIV_HAVE_SYS_TYPES_H
76#ifdef HAVE_SYS_UTSNAME_H
77#include <sys/utsname.h>
79#ifdef FREECIV_HAVE_LIBZ
82#ifdef FREECIV_MSWINDOWS
94#ifdef FREECIV_HAVE_LIBZ
99#include "unicode/ustring.h"
118#ifndef HAVE_WORKING_VSNPRINTF
123#ifndef HAVE_LOCALTIME_R
194 if (
str0 ==
nullptr) {
197 if (
str1 ==
nullptr) {
243 if (
str0 ==
nullptr) {
246 if (
str1 ==
nullptr) {
301 while (*
str !=
'\0' && dest < max) {
336 while (*
str !=
'\0' && dest < max) {
337 if (*
str ==
'\\' && *(
str + 1) ==
'\n') {
366 if (
str[0] ==
'"' &&
str[
len-1] ==
'"') {
384 if (
str0 ==
nullptr) {
387 if (
str1 ==
nullptr) {
394 if (
str0[0] ==
'"') {
402 if (
str1[0] ==
'"') {
439#ifdef HAVE_STRCASESTR
473#if defined(ENABLE_NLS) && defined(HAVE_STRCOLL)
475#elif defined(ENABLE_NLS) && defined(HAVE__STRCOLL)
490#if defined(ENABLE_NLS) && defined(HAVE__STRICOLL)
492#elif defined(ENABLE_NLS) && defined(HAVE_STRICOLL)
494#elif defined(ENABLE_NLS) && defined(HAVE_STRCASECOLL)
509#ifdef FREECIV_MSWINDOWS
523#ifdef FREECIV_MSWINDOWS
534#ifdef FREECIV_HAVE_LIBZ
537#ifdef FREECIV_MSWINDOWS
557#ifdef FREECIV_MSWINDOWS
576#ifdef FREECIV_MSWINDOWS
594#ifdef FREECIV_MSWINDOWS
611#ifdef FREECIV_MSWINDOWS
612 static char buf[256];
615 nullptr,
err, 0,
buf,
sizeof(
buf),
nullptr)) {
617 _(
"error %ld (failed FormatMessage)"),
err);
622 static char buf[256];
630 _(
"error %d (compiled without strerror)"),
err);
644 if (usec >= 1000000) {
645 ts.tv_sec = usec / 1000000;
646 ts.tv_nsec = (usec % 1000000) * 1000;
649 ts.tv_nsec = usec * 1000;
660#ifdef FREECIV_MSWINDOWS
689 if (
search ==
nullptr || replace ==
nullptr) {
701#ifndef FREECIV_NDEBUG
708 "Can't replace '%s' by '%s' in '%s'. Too small "
728 if (
search ==
nullptr || replace ==
nullptr) {
736 while (s !=
nullptr) {
830 return fc_strlcpy(dest + start, src,
n - start) + start;
885#define VSNP_BUF_SIZE (8096*1024)
888#ifdef HAVE_WORKING_VSNPRINTF
897#ifdef HAVE_WORKING_VSNPRINTF
920 fprintf(
stderr,
"Could not allocate %i bytes for vsnprintf() "
1009#ifdef HAVE_GETHOSTNAME
1016#ifdef FREECIV_SOCKET_ZERO_NOT_STDIN
1021#define CONSOLE_BUF_SIZE 100
1026#ifdef FREECIV_MSWINDOWS
1051#ifdef FREECIV_MSWINDOWS
1058 nullptr, 0,
nullptr);
1080#ifdef FREECIV_MSWINDOWS
1198 if (128 <= (
unsigned char) c) {
1201 return isalnum((
int) ((
unsigned char) c)) != 0;
1209 if (128 <= (
unsigned char) c) {
1212 return isalpha((
int) ((
unsigned char) c)) != 0;
1220 if (128 <= (
unsigned char) c) {
1223 return isdigit((
int) ((
unsigned char) c)) != 0;
1231 if (128 <= (
unsigned char) c) {
1234 return isprint((
int) ((
unsigned char) c)) != 0;
1242 if (128 <= (
unsigned char) c) {
1245 return isspace((
int) ((
unsigned char) c)) != 0;
1253 if (128 <= (
unsigned char) c) {
1256 return isupper((
int) ((
unsigned char) c)) != 0;
1264 if (128 <= (
unsigned char) c) {
1267 return (
char)
toupper((
int) ((
unsigned char) c));
1275 if (128 <= (
unsigned char) c) {
1278 return (
char)
tolower((
int) ((
unsigned char) c));
1289 static char buf[2048];
1303#ifdef HAVE_LOCALTIME_R
1319#ifdef HAVE_AT_QUICK_EXIT
1333#ifndef HAVE_WORKING_VSNPRINTF
1337#ifndef HAVE_LOCALTIME_R
1351#ifndef HAVE_WORKING_VSNPRINTF
1359#ifndef HAVE_LOCALTIME_R
char * internal_to_local_string_malloc(const char *text)
char * local_to_internal_string_buffer(const char *text, char *buf, size_t bufsz)
void fc_mutex_allocate(fc_mutex *mutex)
void fc_mutex_init(fc_mutex *mutex)
void fc_mutex_release(fc_mutex *mutex)
void fc_mutex_destroy(fc_mutex *mutex)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define fc_assert_ret_val_msg(condition, val, message,...)
#define fc_realloc(ptr, sz)
void fc_nonblock(int sockfd)
int fc_select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, fc_timeval *timeout)
struct timeval fc_timeval
int fc_snprintf(char *str, size_t n, const char *format,...)
int fc_gethostname(char *buf, size_t len)
size_t fc_strlcpy(char *dest, const char *src, size_t n)
static bool support_initialized
void make_escapes(const char *str, char *buf, size_t buf_len)
int fc_strcasecmp(const char *str0, const char *str1)
void fc_usleep(unsigned long usec)
void fc_support_init(void)
const char * fc_strerror(fc_errno err)
size_t fc_strlcat(char *dest, const char *src, size_t n)
char * fc_strcasestr(const char *haystack, const char *needle)
bool fc_strrep(char *str, size_t len, const char *search, const char *replace)
struct tm * fc_localtime(const time_t *timep, struct tm *result)
int cat_snprintf(char *str, size_t n, const char *format,...)
int fc_vsnprintf(char *str, size_t n, const char *format, va_list ap)
FILE * fc_fopen(const char *filename, const char *opentype)
static void fc_strAPI_free(void)
int fc_break_lines(char *str, size_t desired_len)
static fc_mutex localtime_mutex
static UChar * icu_buffer1
fc_mutex icu_buffer_mutex
fc_errno fc_get_errno(void)
void fc_support_free(void)
void remove_escapes(const char *str, bool full_escapes, char *buf, size_t buf_len)
int fc_strcoll(const char *str0, const char *str1)
int fc_stat(const char *filename, struct stat *buf)
bool is_reg_file_for_access(const char *name, bool write_access)
const char * fc_basename(const char *path)
static void icu_buffers_initial(void)
static char * vsnprintf_buf
static int icu_buffer_uchars
int fc_strncasequotecmp(const char *str0, const char *str1, size_t n)
static fc_mutex vsnprintf_mutex
static void fc_strAPI_init(void)
size_t effectivestrlenquote(const char *str)
static void icu_buffers_increase(void)
int fc_at_quick_exit(void(*func)(void))
int fc_stricoll(const char *str0, const char *str1)
int fc_remove(const char *filename)
int fc_strncasecmp(const char *str0, const char *str1, size_t n)
char * fc_strrep_resize(char *str, size_t *len, const char *search, const char *replace)
static UChar * icu_buffer2
bool are_support_services_available(void)