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 /* values for Error() */
32 #define ERR_WARN (1 << 0)
33 #define ERR_EXIT (1 << 1)
34 #define ERR_HELP (1 << 2)
35 #define ERR_SOUND_SERVER (1 << 3)
36 #define ERR_NETWORK_SERVER (1 << 4)
37 #define ERR_NETWORK_CLIENT (1 << 5)
38 #define ERR_FROM_SERVER (ERR_SOUND_SERVER | ERR_NETWORK_SERVER)
39 #define ERR_EXIT_HELP (ERR_EXIT | ERR_HELP)
40 #define ERR_EXIT_SOUND_SERVER (ERR_EXIT | ERR_SOUND_SERVER)
41 #define ERR_EXIT_NETWORK_SERVER (ERR_EXIT | ERR_NETWORK_SERVER)
42 #define ERR_EXIT_NETWORK_CLIENT (ERR_EXIT | ERR_NETWORK_CLIENT)
44 /* values for getFile...() and putFile...() */
45 #define BYTE_ORDER_BIG_ENDIAN 0
46 #define BYTE_ORDER_LITTLE_ENDIAN 1
48 /* values for createDirectory() */
49 #define PERMS_PRIVATE 0
50 #define PERMS_PUBLIC 1
52 /* values for general file handling stuff */
53 #define MAX_FILENAME_LEN 256
54 #define MAX_LINE_LEN 1000
56 void InitCounter(void);
57 unsigned long Counter(void);
58 void Delay(unsigned long);
59 boolean FrameReached(unsigned long *, unsigned long);
60 boolean DelayReached(unsigned long *, unsigned long);
61 void WaitUntilDelayReached(unsigned long *, unsigned long);
62 char *int2str(int, int);
63 unsigned int SimpleRND(unsigned int);
64 unsigned int RND(unsigned int);
65 unsigned int InitRND(long);
66 char *getLoginName(void);
67 char *getRealName(void);
68 char *getHomeDir(void);
69 char *getPath2(char *, char *);
70 char *getPath3(char *, char *, char*);
71 char *getStringCopy(char *);
72 char *getStringToLower(char *);
74 void GetOptions(char **);
76 void SetError(char *, ...);
78 void Error(int, char *, ...);
80 void *checked_malloc(unsigned long);
81 void *checked_calloc(unsigned long);
82 void *checked_realloc(void *, unsigned long);
83 inline void swap_numbers(int *, int *);
84 inline void swap_number_pairs(int *, int *, int *, int *);
86 short getFile16BitInteger(FILE *, int);
87 void putFile16BitInteger(FILE *, short, int);
88 int getFile32BitInteger(FILE *, int);
89 void putFile32BitInteger(FILE *, int, int);
90 boolean getFileChunk(FILE *, char *, int *, int);
91 void putFileChunk(FILE *, char *, int, int);
92 int getFileVersion(FILE *);
93 void putFileVersion(FILE *, int);
94 void ReadUnusedBytesFromFile(FILE *, unsigned long);
95 void WriteUnusedBytesToFile(FILE *, unsigned long);
97 #define getFile16BitBE(f) getFile16BitInteger(f,BYTE_ORDER_BIG_ENDIAN)
98 #define getFile16BitLE(f) getFile16BitInteger(f,BYTE_ORDER_LITTLE_ENDIAN)
99 #define putFile16BitBE(f,x) putFile16BitInteger(f,x,BYTE_ORDER_BIG_ENDIAN)
100 #define putFile16BitLE(f,x) putFile16BitInteger(f,x,BYTE_ORDER_LITTLE_ENDIAN)
101 #define getFile32BitBE(f) getFile32BitInteger(f,BYTE_ORDER_BIG_ENDIAN)
102 #define getFile32BitLE(f) getFile32BitInteger(f,BYTE_ORDER_LITTLE_ENDIAN)
103 #define putFile32BitBE(f,x) putFile32BitInteger(f,x,BYTE_ORDER_BIG_ENDIAN)
104 #define putFile32BitLE(f,x) putFile32BitInteger(f,x,BYTE_ORDER_LITTLE_ENDIAN)
105 #define getFileChunkBE(f,s,x) getFileChunk(f,s,x,BYTE_ORDER_BIG_ENDIAN)
106 #define getFileChunkLE(f,s,x) getFileChunk(f,s,x,BYTE_ORDER_LITTLE_ENDIAN)
107 #define putFileChunkBE(f,s,x) putFileChunk(f,s,x,BYTE_ORDER_BIG_ENDIAN)
108 #define putFileChunkLE(f,s,x) putFileChunk(f,s,x,BYTE_ORDER_LITTLE_ENDIAN)
110 char *getKeyNameFromKey(Key);
111 char *getX11KeyNameFromKey(Key);
112 Key getKeyFromKeyName(char *);
113 Key getKeyFromX11KeyName(char *);
114 char getCharFromKey(Key);
117 ListNode *newListNode(void);
118 void addNodeToList(ListNode **, char *, void *);
119 void deleteNodeFromList(ListNode **, char *, void (*function)(void *));
120 ListNode *getNodeFromKey(ListNode *, char *);
121 int getNumNodes(ListNode *);
124 boolean FileIsGraphic(char *);
125 boolean FileIsSound(char *);
126 boolean FileIsMusic(char *);
127 boolean FileIsArtworkType(char *, int);
129 struct FileInfo *getFileListFromConfigList(struct ConfigInfo *, char **, int);
130 void ReloadCustomArtworkList(struct ArtworkListInfo *);
131 void FreeCustomArtworkList(struct ArtworkListInfo *);
134 #if !defined(PLATFORM_UNIX)
135 void initErrorFile();
136 FILE *openErrorFile();
137 void dumpErrorFile();
140 void debug_print_timestamp(int, char *);