File: compat.h

package info (click to toggle)
crossfire 1.75.0-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,168 kB
  • sloc: ansic: 83,169; sh: 4,659; perl: 1,736; lex: 1,443; makefile: 1,199; python: 43
file content (48 lines) | stat: -rw-r--r-- 995 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
 * @file
 * Compatibility implementations of useful nonstandard types and functions.
 */

#ifndef _COMPAT_H
#define _COMPAT_H

// Maintain backward compatibility with original macros.
#define TRUE true
#define FALSE false
#define FMT64   PRId64
#define FMT64U  PRIu64


#ifndef MIN
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#endif
#ifndef MAX
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#endif

#define safe_strncpy strlcpy
#define strcasestr_local strcasestr
#define strdup_local strdup

#define CALLOC(x, y) calloc(x, y)
#define object_decrease_nrof_by_one(xyz) object_decrease_nrof(xyz, 1)

void safe_strcat(char *dest, const char *orig, size_t *curlen, size_t maxlen);

#ifndef HAVE_STRCASESTR
char *strcasestr(const char *s, const char *find);
#endif

#ifndef HAVE_STRDUP
char *strdup(const char *str);
#endif

#ifndef HAVE_STRLCPY
size_t strlcpy(char *dst, const char *src, size_t size);
#endif

#ifndef HAVE_TEMPNAM
char *tempnam(const char *tmpdir, const char *prefix);
#endif

#endif