fix link errors on compilers with strict "extern" enforcement
[rofl0r-openbor.git] / source / utils.h
blobdca32c1299094a91a761e9d2df4841b3eb8badb4
1 /*
2 * OpenBOR - http://www.LavaLit.com
3 * -----------------------------------------------------------------------
4 * Licensed under the BSD license, see LICENSE in OpenBOR root for details.
6 * Copyright (c) 2004 - 2011 OpenBOR Team
7 */
9 #ifndef UTILS_H
10 #define UTILS_H
12 #include "debug.h"
14 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
16 // *** INCLUDES ***
17 #include "types.h"
18 #include "stringptr.h"
20 // *** TYPE DECLARATIONS ***
21 #define SCRIPT_LOG 0
22 #define OPENBOR_LOG 1
24 // *** VARIABLE DECLARATIONS ***
25 extern char debug_msg[2048];
26 extern unsigned long debug_time;
28 // *** FUNCTIONS DECLARATIONS ***
29 #define LOGHANDLE stderr
30 #define writeToLogFile(fmt...) fprintf(LOGHANDLE, fmt)
31 #define SCRIPTLOGHANDLE stderr
32 #define writeToScriptLog(fmt...) fprintf(SCRIPTLOGHANDLE, fmt)
34 int fileExists(char *fnam);
35 int dirExists(char *dname, int create);
36 int is_dir(char* fn);
37 stringptr *readFromLogFile(int which);
38 void freeAndNull(void** data);
39 void lc(char *buf, size_t size);
40 size_t getNewLineStart(char *buf);
41 void debugBuf(unsigned char *buf, size_t size, int columns);
42 void debug_printf(char *, ...);
44 typedef enum {
45 ST_SAVE = 0,
46 ST_HISCORE,
47 ST_SCRIPT,
48 ST_INP,
49 ST_CFG,
50 ST_MAX
51 } savefile_type;
53 void getSaveFileName(char name[256], unsigned int type);
54 void screenshot(s_screen * vscreen, unsigned char *pal, int ingame);
55 void getBasePath(char *newName, char *name, int type);
56 unsigned readlsb32(const unsigned char *src);
57 int searchList(const char *list[], const char *value, int length);
58 char *commaprint(u64 n);
59 void char_to_lower(char *dst, char *src, size_t maxlen);
60 void int_min_max(int* candidate, int min, int max);
61 void short_min_max(short* candidate, short min, short max);
63 #ifndef MAX
64 #define MAX(a, b) ((a) > (b) ? (a) : (b))
65 #endif
67 #ifndef MIN
68 #define MIN(a, b) ((a) < (b) ? (a) : (b))
69 #endif
72 #endif