#include <stdlib.h>
#include <stdio.h>
+#include <dirent.h>
#include "system.h"
#define GetSimpleRandom(max) get_random_number(RANDOM_SIMPLE, max)
/* values for Error() */
-#define ERR_INFO 0
-#define ERR_INFO_LINE (1 << 0)
-#define ERR_WARN (1 << 1)
-#define ERR_EXIT (1 << 2)
-#define ERR_HELP (1 << 3)
-#define ERR_SOUND_SERVER (1 << 4)
-#define ERR_NETWORK_SERVER (1 << 5)
-#define ERR_NETWORK_CLIENT (1 << 6)
+#define ERR_UNKNOWN 0
+#define ERR_DEBUG (1 << 0)
+#define ERR_INFO (1 << 1)
+#define ERR_INFO_LINE (1 << 2)
+#define ERR_WARN (1 << 3)
+#define ERR_EXIT (1 << 4)
+#define ERR_HELP (1 << 5)
+#define ERR_SOUND_SERVER (1 << 6)
+#define ERR_NETWORK_SERVER (1 << 7)
+#define ERR_NETWORK_CLIENT (1 << 8)
#define ERR_FROM_SERVER (ERR_SOUND_SERVER | ERR_NETWORK_SERVER)
#define ERR_EXIT_HELP (ERR_EXIT | ERR_HELP)
#define ERR_EXIT_SOUND_SERVER (ERR_EXIT | ERR_SOUND_SERVER)
#define ERR_EXIT_NETWORK_SERVER (ERR_EXIT | ERR_NETWORK_SERVER)
#define ERR_EXIT_NETWORK_CLIENT (ERR_EXIT | ERR_NETWORK_CLIENT)
+#if 0
+#define ERR_ERROR (ERR_UNKNOWN)
+#define ERR_FATAL (ERR_EXIT)
+#define ERR_VERBOSE (ERR_INFO)
+#endif
/* values for getFile...() and putFile...() */
#define BYTE_ORDER_BIG_ENDIAN 0
/* values for general username handling stuff */
#define MAX_USERNAME_LEN 1024
+#if defined(PLATFORM_ANDROID)
+/* values for Android asset handling */
+#define ASSET_TOC_BASENAME ".toc"
+#endif
+
+
+/* structure definitions */
+
+typedef struct
+{
+ char *filename;
+ FILE *file;
+ boolean end_of_file;
+
+#if defined(PLATFORM_ANDROID)
+ boolean file_is_asset;
+ SDL_RWops *asset_file;
+#endif
+} File;
+
+typedef struct
+{
+ boolean is_directory;
+ char *basename;
+ char *filename;
+} DirectoryEntry;
+
+typedef struct
+{
+ char *filename;
+ DIR *dir;
+ DirectoryEntry *dir_entry;
+
+#if defined(PLATFORM_ANDROID)
+ boolean directory_is_asset;
+ SDL_RWops *asset_toc_file;
+ char *current_entry;
+#endif
+} Directory;
+
+
+/* function definitions */
void fprintf_line(FILE *, char *, int);
void printf_line(char *, int);
ListNode *getNodeFromKey(ListNode *, char *);
int getNumNodes(ListNode *);
+File *openFile(char *, char *);
+int closeFile(File *);
+int checkEndOfFile(File *);
+char *getStringFromFile(File *, char *, int);
+
+Directory *openDirectory(char *);
+int closeDirectory(Directory *);
+DirectoryEntry *readDirectory(Directory *);
+void freeDirectoryEntry(DirectoryEntry *);
+
boolean fileExists(char *);
boolean FileIsGraphic(char *);
boolean FileIsSound(char *);
void dumpErrorFile();
void NotifyUserAboutErrorFile();
+#if DEBUG
void debug_print_timestamp(int, char *);
+void print_timestamp_init(char *);
+void print_timestamp_time(char *);
+void print_timestamp_done(char *);
+#endif /* DEBUG */
+
+
#endif /* MISC_H */