1 /***********************************************************
2 * Artsoft Retro-Game Library *
3 *----------------------------------------------------------*
4 * (c) 1994-2001 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
23 /* functions for version handling */
24 #define VERSION_IDENT(x,y,z) ((x) * 10000 + (y) * 100 + (z))
25 #define VERSION_MAJOR(x) ((x) / 10000)
26 #define VERSION_MINOR(x) (((x) % 10000) / 100)
27 #define VERSION_PATCH(x) ((x) % 100)
29 /* values for InitCounter() and Counter() */
30 #define INIT_COUNTER 0
31 #define READ_COUNTER 1
33 /* values for InitRND() */
34 #define NEW_RANDOMIZE -1
36 /* values for Error() */
38 #define ERR_WARN (1 << 0)
39 #define ERR_EXIT (1 << 1)
40 #define ERR_HELP (1 << 2)
41 #define ERR_SOUND_SERVER (1 << 3)
42 #define ERR_NETWORK_SERVER (1 << 4)
43 #define ERR_NETWORK_CLIENT (1 << 5)
44 #define ERR_FROM_SERVER (ERR_SOUND_SERVER | ERR_NETWORK_SERVER)
45 #define ERR_EXIT_HELP (ERR_EXIT | ERR_HELP)
46 #define ERR_EXIT_SOUND_SERVER (ERR_EXIT | ERR_SOUND_SERVER)
47 #define ERR_EXIT_NETWORK_SERVER (ERR_EXIT | ERR_NETWORK_SERVER)
48 #define ERR_EXIT_NETWORK_CLIENT (ERR_EXIT | ERR_NETWORK_CLIENT)
50 /* values for getFile...() and putFile...() */
51 #define BYTE_ORDER_BIG_ENDIAN 0
52 #define BYTE_ORDER_LITTLE_ENDIAN 1
54 /* values for createDirectory() */
55 #define PERMS_PRIVATE 0
56 #define PERMS_PUBLIC 1
58 /* values for general file handling stuff */
59 #define MAX_FILENAME_LEN 256
60 #define MAX_LINE_LEN 1000
62 void InitCounter(void);
63 unsigned long Counter(void);
64 void Delay(unsigned long);
65 boolean FrameReached(unsigned long *, unsigned long);
66 boolean DelayReached(unsigned long *, unsigned long);
67 void WaitUntilDelayReached(unsigned long *, unsigned long);
68 char *int2str(int, int);
69 unsigned int SimpleRND(unsigned int);
70 unsigned int RND(unsigned int);
71 unsigned int InitRND(long);
72 char *getLoginName(void);
73 char *getRealName(void);
74 char *getHomeDir(void);
75 char *getPath2(char *, char *);
76 char *getPath3(char *, char *, char*);
77 char *getStringCopy(char *);
78 char *getStringToLower(char *);
79 void GetOptions(char **);
80 void Error(int, char *, ...);
81 void *checked_malloc(unsigned long);
82 void *checked_calloc(unsigned long);
83 void *checked_realloc(void *, unsigned long);
84 inline void swap_numbers(int *, int *);
85 inline void swap_number_pairs(int *, int *, int *, int *);
87 short getFile16BitInteger(FILE *, int);
88 void putFile16BitInteger(FILE *, short, int);
89 int getFile32BitInteger(FILE *, int);
90 void putFile32BitInteger(FILE *, int, int);
91 boolean getFileChunk(FILE *, char *, int *, int);
92 void putFileChunk(FILE *, char *, int, int);
93 void ReadUnusedBytesFromFile(FILE *, unsigned long);
94 void WriteUnusedBytesToFile(FILE *, unsigned long);
96 char *getKeyNameFromKey(Key);
97 char *getX11KeyNameFromKey(Key);
98 Key getKeyFromX11KeyName(char *);
99 char getCharFromKey(Key);
101 #if !defined(PLATFORM_UNIX)
102 void initErrorFile();
103 FILE *openErrorFile();
104 void dumpErrorFile();
107 void debug_print_timestamp(int, char *);