1 #ifndef __al_included_allegro5_file_h 2 #define __al_included_allegro5_file_h 3 4 #include "allegro5/base.h" 5 #include "allegro5/path.h" 6 #include "allegro5/utf8.h" 7 8 #ifdef __cplusplus 9 extern "C" { 10 #endif 11 12 13 /* Type: ALLEGRO_FILE 14 */ 15 typedef struct ALLEGRO_FILE ALLEGRO_FILE; 16 17 18 /* Type: ALLEGRO_FILE_INTERFACE 19 */ 20 typedef struct ALLEGRO_FILE_INTERFACE 21 { 22 AL_METHOD(void *, fi_fopen, (const char *path, const char *mode)); 23 AL_METHOD(bool, fi_fclose, (ALLEGRO_FILE *handle)); 24 AL_METHOD(size_t, fi_fread, (ALLEGRO_FILE *f, void *ptr, size_t size)); 25 AL_METHOD(size_t, fi_fwrite, (ALLEGRO_FILE *f, const void *ptr, size_t size)); 26 AL_METHOD(bool, fi_fflush, (ALLEGRO_FILE *f)); 27 AL_METHOD(int64_t, fi_ftell, (ALLEGRO_FILE *f)); 28 AL_METHOD(bool, fi_fseek, (ALLEGRO_FILE *f, int64_t offset, int whence)); 29 AL_METHOD(bool, fi_feof, (ALLEGRO_FILE *f)); 30 AL_METHOD(int, fi_ferror, (ALLEGRO_FILE *f)); 31 AL_METHOD(const char *, fi_ferrmsg, (ALLEGRO_FILE *f)); 32 AL_METHOD(void, fi_fclearerr, (ALLEGRO_FILE *f)); 33 AL_METHOD(int, fi_fungetc, (ALLEGRO_FILE *f, int c)); 34 AL_METHOD(off_t, fi_fsize, (ALLEGRO_FILE *f)); 35 } ALLEGRO_FILE_INTERFACE; 36 37 38 /* Enum: ALLEGRO_SEEK 39 */ 40 typedef enum ALLEGRO_SEEK 41 { 42 ALLEGRO_SEEK_SET = 0, 43 ALLEGRO_SEEK_CUR, 44 ALLEGRO_SEEK_END 45 } ALLEGRO_SEEK; 46 47 48 /* The basic operations. */ 49 AL_FUNC(ALLEGRO_FILE*, al_fopen, (const char *path, const char *mode)); 50 AL_FUNC(ALLEGRO_FILE*, al_fopen_interface, (const ALLEGRO_FILE_INTERFACE *vt, const char *path, const char *mode)); 51 AL_FUNC(ALLEGRO_FILE*, al_create_file_handle, (const ALLEGRO_FILE_INTERFACE *vt, void *userdata)); 52 AL_FUNC(bool, al_fclose, (ALLEGRO_FILE *f)); 53 AL_FUNC(size_t, al_fread, (ALLEGRO_FILE *f, void *ptr, size_t size)); 54 AL_FUNC(size_t, al_fwrite, (ALLEGRO_FILE *f, const void *ptr, size_t size)); 55 AL_FUNC(bool, al_fflush, (ALLEGRO_FILE *f)); 56 AL_FUNC(int64_t, al_ftell, (ALLEGRO_FILE *f)); 57 AL_FUNC(bool, al_fseek, (ALLEGRO_FILE *f, int64_t offset, int whence)); 58 AL_FUNC(bool, al_feof, (ALLEGRO_FILE *f)); 59 AL_FUNC(int, al_ferror, (ALLEGRO_FILE *f)); 60 AL_FUNC(const char *, al_ferrmsg, (ALLEGRO_FILE *f)); 61 AL_FUNC(void, al_fclearerr, (ALLEGRO_FILE *f)); 62 AL_FUNC(int, al_fungetc, (ALLEGRO_FILE *f, int c)); 63 AL_FUNC(int64_t, al_fsize, (ALLEGRO_FILE *f)); 64 65 /* Convenience functions. */ 66 AL_FUNC(int, al_fgetc, (ALLEGRO_FILE *f)); 67 AL_FUNC(int, al_fputc, (ALLEGRO_FILE *f, int c)); 68 AL_FUNC(int16_t, al_fread16le, (ALLEGRO_FILE *f)); 69 AL_FUNC(int16_t, al_fread16be, (ALLEGRO_FILE *f)); 70 AL_FUNC(size_t, al_fwrite16le, (ALLEGRO_FILE *f, int16_t w)); 71 AL_FUNC(size_t, al_fwrite16be, (ALLEGRO_FILE *f, int16_t w)); 72 AL_FUNC(int32_t, al_fread32le, (ALLEGRO_FILE *f)); 73 AL_FUNC(int32_t, al_fread32be, (ALLEGRO_FILE *f)); 74 AL_FUNC(size_t, al_fwrite32le, (ALLEGRO_FILE *f, int32_t l)); 75 AL_FUNC(size_t, al_fwrite32be, (ALLEGRO_FILE *f, int32_t l)); 76 AL_FUNC(char*, al_fgets, (ALLEGRO_FILE *f, char * const p, size_t max)); 77 AL_FUNC(ALLEGRO_USTR *, al_fget_ustr, (ALLEGRO_FILE *f)); 78 AL_FUNC(int, al_fputs, (ALLEGRO_FILE *f, const char *p)); 79 AL_FUNC(int, al_fprintf, (ALLEGRO_FILE *f, const char *format, ...)); 80 AL_FUNC(int, al_vfprintf, (ALLEGRO_FILE *f, const char* format, va_list args)); 81 82 /* Specific to stdio backend. */ 83 AL_FUNC(ALLEGRO_FILE*, al_fopen_fd, (int fd, const char *mode)); 84 AL_FUNC(ALLEGRO_FILE*, al_make_temp_file, (const char *tmpl, 85 ALLEGRO_PATH **ret_path)); 86 87 /* Specific to slices. */ 88 AL_FUNC(ALLEGRO_FILE*, al_fopen_slice, (ALLEGRO_FILE *fp, 89 size_t initial_size, const char *mode)); 90 91 /* Thread-local state. */ 92 AL_FUNC(const ALLEGRO_FILE_INTERFACE *, al_get_new_file_interface, (void)); 93 AL_FUNC(void, al_set_new_file_interface, (const ALLEGRO_FILE_INTERFACE * 94 file_interface)); 95 AL_FUNC(void, al_set_standard_file_interface, (void)); 96 97 /* ALLEGRO_FILE field accessors */ 98 AL_FUNC(void *, al_get_file_userdata, (ALLEGRO_FILE *f)); 99 100 101 #ifdef __cplusplus 102 } 103 #endif 104 105 #endif 106 107 /* vim: set sts=3 sw=3 et: */ 108