1 /***********************************************************
2 * Artsoft Retro-Game Library *
3 *----------------------------------------------------------*
4 * (c) 1994-2002 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
23 /* values for InitCounter() and Counter() */
24 #define INIT_COUNTER 0
25 #define READ_COUNTER 1
27 /* values for InitRND() */
28 #define NEW_RANDOMIZE -1
30 #define InitRND(seed) init_random_number(0, seed)
31 #define InitSimpleRND(seed) init_random_number(1, seed)
32 #define RND(max) get_random_number(0, max)
33 #define SimpleRND(max) get_random_number(1, max)
35 /* values for Error() */
37 #define ERR_RETURN_LINE (1 << 0)
38 #define ERR_WARN (1 << 1)
39 #define ERR_EXIT (1 << 2)
40 #define ERR_HELP (1 << 3)
41 #define ERR_SOUND_SERVER (1 << 4)
42 #define ERR_NETWORK_SERVER (1 << 5)
43 #define ERR_NETWORK_CLIENT (1 << 6)
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 cursor bitmap creation */
55 #define BIT_ORDER_MSB 0
56 #define BIT_ORDER_LSB 1
58 /* values for createDirectory() */
59 #define PERMS_PRIVATE 0
60 #define PERMS_PUBLIC 1
62 /* values for general file handling stuff */
63 #define MAX_FILENAME_LEN 256
64 #define MAX_LINE_LEN 1024
66 /* values for general username handling stuff */
67 #define MAX_USERNAME_LEN 1024
70 void fprintf_line(FILE *, char *, int);
71 void printf_line(char *, int);
72 char *int2str(int, int);
73 char *i_to_a(unsigned int);
74 int log_2(unsigned int);
76 void InitCounter(void);
77 unsigned long Counter(void);
78 void Delay(unsigned long);
79 boolean FrameReached(unsigned long *, unsigned long);
80 boolean DelayReached(unsigned long *, unsigned long);
81 void WaitUntilDelayReached(unsigned long *, unsigned long);
84 unsigned int SimpleRND(unsigned int);
85 unsigned int InitSimpleRND(long);
86 unsigned int RND(unsigned int);
87 unsigned int InitRND(long);
90 unsigned int init_random_number(int, long);
91 unsigned int get_random_number(int, int);
93 char *getLoginName(void);
94 char *getRealName(void);
95 char *getHomeDir(void);
97 char *getPath2(char *, char *);
98 char *getPath3(char *, char *, char*);
99 char *getStringCat2(char *, char *);
100 char *getStringCopy(char *);
101 char *getStringToLower(char *);
102 void setString(char **, char *);
104 void GetOptions(char **, void (*print_usage_function)(void));
106 void SetError(char *, ...);
107 char *GetError(void);
108 void Error(int, char *, ...);
110 void *checked_malloc(unsigned long);
111 void *checked_calloc(unsigned long);
112 void *checked_realloc(void *, unsigned long);
113 void checked_free(void *);
115 inline void swap_numbers(int *, int *);
116 inline void swap_number_pairs(int *, int *, int *, int *);
118 int getFile16BitInteger(FILE *, int);
119 void putFile16BitInteger(FILE *, int, int);
120 int getFile32BitInteger(FILE *, int);
121 void putFile32BitInteger(FILE *, int, int);
122 boolean getFileChunk(FILE *, char *, int *, int);
123 void putFileChunk(FILE *, char *, int, int);
124 int getFileVersion(FILE *);
125 void putFileVersion(FILE *, int);
126 void ReadUnusedBytesFromFile(FILE *, unsigned long);
127 void WriteUnusedBytesToFile(FILE *, unsigned long);
129 #define getFile8Bit(f) fgetc(f)
130 #define putFile8Bit(f,x) fputc(x, f)
131 #define getFile16BitBE(f) getFile16BitInteger(f,BYTE_ORDER_BIG_ENDIAN)
132 #define getFile16BitLE(f) getFile16BitInteger(f,BYTE_ORDER_LITTLE_ENDIAN)
133 #define putFile16BitBE(f,x) putFile16BitInteger(f,x,BYTE_ORDER_BIG_ENDIAN)
134 #define putFile16BitLE(f,x) putFile16BitInteger(f,x,BYTE_ORDER_LITTLE_ENDIAN)
135 #define getFile32BitBE(f) getFile32BitInteger(f,BYTE_ORDER_BIG_ENDIAN)
136 #define getFile32BitLE(f) getFile32BitInteger(f,BYTE_ORDER_LITTLE_ENDIAN)
137 #define putFile32BitBE(f,x) putFile32BitInteger(f,x,BYTE_ORDER_BIG_ENDIAN)
138 #define putFile32BitLE(f,x) putFile32BitInteger(f,x,BYTE_ORDER_LITTLE_ENDIAN)
139 #define getFileChunkBE(f,s,x) getFileChunk(f,s,x,BYTE_ORDER_BIG_ENDIAN)
140 #define getFileChunkLE(f,s,x) getFileChunk(f,s,x,BYTE_ORDER_LITTLE_ENDIAN)
141 #define putFileChunkBE(f,s,x) putFileChunk(f,s,x,BYTE_ORDER_BIG_ENDIAN)
142 #define putFileChunkLE(f,s,x) putFileChunk(f,s,x,BYTE_ORDER_LITTLE_ENDIAN)
144 char *getKeyNameFromKey(Key);
145 char *getX11KeyNameFromKey(Key);
146 Key getKeyFromKeyName(char *);
147 Key getKeyFromX11KeyName(char *);
148 char getCharFromKey(Key);
150 int get_integer_from_string(char *);
151 boolean get_boolean_from_string(char *);
153 ListNode *newListNode(void);
154 void addNodeToList(ListNode **, char *, void *);
155 void deleteNodeFromList(ListNode **, char *, void (*function)(void *));
156 ListNode *getNodeFromKey(ListNode *, char *);
157 int getNumNodes(ListNode *);
159 boolean fileExists(char *);
160 boolean FileIsGraphic(char *);
161 boolean FileIsSound(char *);
162 boolean FileIsMusic(char *);
163 boolean FileIsArtworkType(char *, int);
165 int get_parameter_value(char *, char *, int);
166 int get_auto_parameter_value(char *, char *);
168 struct FileInfo *getFileListFromConfigList(struct ConfigInfo *,
169 struct ConfigInfo *, char **, int);
170 void LoadArtworkConfig(struct ArtworkListInfo *);
171 void ReloadCustomArtworkList(struct ArtworkListInfo *);
172 void FreeCustomArtworkLists(struct ArtworkListInfo *);
174 #if !defined(PLATFORM_UNIX)
175 void initErrorFile();
176 FILE *openErrorFile();
177 void dumpErrorFile();
180 void debug_print_timestamp(int, char *);