29 #define fc__attribute(x) __attribute__(x)
31 #define fc__attribute(x)
36 #if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
37 #define fc__warn_unused_result __attribute__((warn_unused_result))
40 #ifndef fc__warn_unused_result
41 #define fc__warn_unused_result
46 #if defined(__GNUC__) && __GNUC__ >= 7
47 #define fc__fallthrough __attribute__((fallthrough))
49 #define fc__fallthrough
52 #ifdef FREECIV_MSWINDOWS
58 #define fc_malloc(sz) malloc(sz)
59 #define fc_realloc(ptr, sz) realloc(ptr, sz)
61 #define NFCPP_FREE(ptr) \
68 #define NFC_FREE(ptr) \
75 #define NFCN_FREE(ptr) \
83 #define VOIDNFCN_FREE(ptr) \
86 ::operator delete(ptr); \
91 #define NFCNPP_FREE(ptr) \
99 #define FCPP_FREE(ptr) \
105 #define FC_FREE(ptr) \
111 #define fc_strdup(str) real_fc_strdup((str), "strdup", __FC_LINE__, __FILE__)
113 char *
real_fc_strdup(
const char *str,
const char *called_as,
int line,
122 int fc_strcoll(
const char *str0,
const char *str1);
123 int fc_stricoll(
const char *str0,
const char *str1);
125 FILE *
fc_fopen(
const char *filename,
const char *opentype);
127 int fc_stat(
const char *filename,
struct stat *buf);
133 bool fc_strrep(
char *str,
size_t len,
const char *search,
134 const char *replace);
136 size_t fc_strlcpy(
char *dest,
const char *src,
size_t n);
137 size_t fc_strlcat(
char *dest,
const char *src,
size_t n);
140 #define sz_strlcpy(dest, src) \
141 ((void) fc_strlcpy((dest), (src), sizeof(dest)))
142 #define sz_strlcat(dest, src) \
143 ((void) fc_strlcat((dest), (src), sizeof(dest)))
158 void make_escapes(const
char *str,
char *buf,
size_t buf_len);
int fc_gethostname(char *buf, size_t len)
Call gethostname() if supported, else just returns -1.
size_t fc_strlcpy(char *dest, const char *src, size_t n)
fc_strlcpy() provides utf-8 version of (non-standard) function strlcpy() It is intended as more user-...
void make_escapes(const char *str, char *buf, size_t buf_len)
Copies a string and convert the following characters:
char * real_fc_strdup(const char *str, const char *called_as, int line, const char *file) fc__warn_unused_result
Function used by fc_strdup macro, strdup() replacement No need to check return value.
int fc_strcasecmp(const char *str0, const char *str1)
Compare strings like strcmp(), but ignoring case.
void fc_usleep(unsigned long usec)
Suspend execution for the specified number of microseconds.
int fc_snprintf(char *str, size_t n, const char *format,...) fc__attribute((__format__(__printf__
size_t fc_strlcat(char *dest, const char *src, size_t n)
fc_strlcat() provides utf-8 version of (non-standard) function strlcat() It is intended as more user-...
bool fc_strrep(char *str, size_t len, const char *search, const char *replace)
Replace 'search' by 'replace' within 'str'.
const char * fc_strerror(fc_errno err)
Return a string which describes a given error (errno-style.) The string is converted as necessary fro...
QString remove_escapes(const QString &str, bool full_escapes)
Copies a string.
int fc_break_lines(char *str, size_t desired_len)
Replace the spaces by line breaks when the line lenght is over the desired one.
int int cat_snprintf(char *str, size_t n, const char *format,...) fc__attribute((__format__(__printf__
int fc_strcoll(const char *str0, const char *str1)
Wrapper function for strcoll().
#define fc__warn_unused_result
int fc_stat(const char *filename, struct stat *buf)
Wrapper function for stat() with filename conversion to local encoding on Windows.
int fc_vsnprintf(char *str, size_t n, const char *format, va_list ap) fc__attribute((nonnull(1
int fc_at_quick_exit(void(*func)())
Set quick_exit() callback if possible.
int fc_strncasequotecmp(const char *str0, const char *str1, size_t n)
Compare strings like strncasecmp() but ignoring surrounding quotes in either string.
FILE * fc_fopen(const char *filename, const char *opentype)
Wrapper function for fopen() with filename conversion to local encoding on Windows.
size_t effectivestrlenquote(const char *str)
Count length of string without possible surrounding quotes.
int fc_stricoll(const char *str0, const char *str1)
Wrapper function for stricoll().
int fc_remove(const char *filename)
Wrapper function for remove() with filename conversion to local encoding on Windows.
int fc_strncasecmp(const char *str0, const char *str1, size_t n)
Compare strings like strncmp(), but ignoring case.
fc_errno fc_get_errno()
Returns last error code.