rnd-20131212-1-src
[rocksndiamonds.git] / src / libgame / misc.h
index 12c28c3264c8a0b69fd79f77cb1c8c3735419e6a..582a6255f9ee4d2ad67a445e87f3956442409253 100644 (file)
 #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
 
 /* structure definitions */
 
-struct DirectoryEntry
+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;
 
-struct Directory
+typedef struct
 {
   char *filename;
   DIR *dir;
-  struct DirectoryEntry *dir_entry;
+  DirectoryEntry *dir_entry;
 
 #if defined(PLATFORM_ANDROID)
   boolean directory_is_asset;
   SDL_RWops *asset_toc_file;
   char *current_entry;
 #endif
-};
+} Directory;
 
 
 /* function definitions */
@@ -212,10 +231,15 @@ void deleteNodeFromList(ListNode **, char *, void (*function)(void *));
 ListNode *getNodeFromKey(ListNode *, char *);
 int getNumNodes(ListNode *);
 
-struct Directory *openDirectory(char *);
-int closeDirectory(struct Directory *);
-struct DirectoryEntry *readDirectory(struct Directory *);
-void freeDirectoryEntry(struct DirectoryEntry *);
+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 *);
@@ -243,6 +267,13 @@ void closeErrorFile();
 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 */