1use crate::path::*;
2use crate::utf8::*;
3
4use libc::*;
5
6use allegro_util::c_bool;
7
8allegro_util::opaque!(ALLEGRO_FILE);
9
10#[repr(C)]
11#[derive(Copy, Clone, Debug)]
12pub struct ALLEGRO_FILE_INTERFACE
13{
14 pub fi_fopen:
15 Option<unsafe extern "C" fn(path: *const c_char, mode: *const c_char) -> *mut c_void>,
16 pub fi_fclose: Option<unsafe extern "C" fn(handle: *mut ALLEGRO_FILE) -> c_bool>,
17 pub fi_fread: Option<
18 unsafe extern "C" fn(f: *mut ALLEGRO_FILE, ptr: *mut c_void, size: c_ulong) -> c_ulong,
19 >,
20 pub fi_fwrite: Option<
21 unsafe extern "C" fn(f: *mut ALLEGRO_FILE, ptr: *const c_void, size: c_ulong) -> c_ulong,
22 >,
23 pub fi_fflush: Option<unsafe extern "C" fn(f: *mut ALLEGRO_FILE) -> c_bool>,
24 pub fi_ftell: Option<unsafe extern "C" fn(f: *mut ALLEGRO_FILE) -> i64>,
25 pub fi_fseek:
26 Option<unsafe extern "C" fn(f: *mut ALLEGRO_FILE, offset: i64, whence: c_int) -> c_bool>,
27 pub fi_feof: Option<unsafe extern "C" fn(f: *mut ALLEGRO_FILE) -> c_bool>,
28 pub fi_ferror: Option<unsafe extern "C" fn(f: *mut ALLEGRO_FILE) -> c_int>,
29 pub fi_ferrmsg: Option<unsafe extern "C" fn(f: *mut ALLEGRO_FILE) -> *const c_char>,
30 pub fi_fclearerr: Option<unsafe extern "C" fn(f: *mut ALLEGRO_FILE)>,
31 pub fi_fungetc: Option<unsafe extern "C" fn(f: *mut ALLEGRO_FILE, c: c_int) -> c_int>,
32 pub fi_fsize: Option<unsafe extern "C" fn(f: *mut ALLEGRO_FILE) -> off_t>,
33}
34
35#[derive(Copy, Clone)]
36#[repr(u32)]
37#[derive(Debug)]
38pub enum ALLEGRO_SEEK
39{
40 ALLEGRO_SEEK_SET = 0,
41 ALLEGRO_SEEK_CUR = 1,
42 ALLEGRO_SEEK_END = 2,
43}
44
45unsafe extern "C" {
46 pub fn al_fopen(path: *const c_char, mode: *const c_char) -> *mut ALLEGRO_FILE;
47 pub fn al_fopen_interface(
48 vt: *const ALLEGRO_FILE_INTERFACE, path: *const c_char, mode: *const c_char,
49 ) -> *mut ALLEGRO_FILE;
50 pub fn al_create_file_handle(
51 vt: *const ALLEGRO_FILE_INTERFACE, userdata: *mut c_void,
52 ) -> *mut ALLEGRO_FILE;
53 pub fn al_fclose(f: *mut ALLEGRO_FILE) -> c_bool;
54 pub fn al_fread(f: *mut ALLEGRO_FILE, ptr: *mut c_void, size: c_ulong) -> c_ulong;
55 pub fn al_fwrite(f: *mut ALLEGRO_FILE, ptr: *const c_void, size: c_ulong) -> c_ulong;
56 pub fn al_fflush(f: *mut ALLEGRO_FILE) -> c_bool;
57 pub fn al_ftell(f: *mut ALLEGRO_FILE) -> i64;
58 pub fn al_fseek(f: *mut ALLEGRO_FILE, offset: i64, whence: c_int) -> c_bool;
59 pub fn al_feof(f: *mut ALLEGRO_FILE) -> c_bool;
60 pub fn al_ferror(f: *mut ALLEGRO_FILE) -> c_int;
61 pub fn al_ferrmsg(f: *mut ALLEGRO_FILE) -> *const c_char;
62 pub fn al_fclearerr(f: *mut ALLEGRO_FILE);
63 pub fn al_fungetc(f: *mut ALLEGRO_FILE, c: c_int) -> c_int;
64 pub fn al_fsize(f: *mut ALLEGRO_FILE) -> i64;
65 pub fn al_fgetc(f: *mut ALLEGRO_FILE) -> c_int;
66 pub fn al_fputc(f: *mut ALLEGRO_FILE, c: c_int) -> c_int;
67 pub fn al_fread16le(f: *mut ALLEGRO_FILE) -> i16;
68 pub fn al_fread16be(f: *mut ALLEGRO_FILE) -> i16;
69 pub fn al_fwrite16le(f: *mut ALLEGRO_FILE, w: i16) -> c_ulong;
70 pub fn al_fwrite16be(f: *mut ALLEGRO_FILE, w: i16) -> c_ulong;
71 pub fn al_fread32le(f: *mut ALLEGRO_FILE) -> i32;
72 pub fn al_fread32be(f: *mut ALLEGRO_FILE) -> i32;
73 pub fn al_fwrite32le(f: *mut ALLEGRO_FILE, l: i32) -> c_ulong;
74 pub fn al_fwrite32be(f: *mut ALLEGRO_FILE, l: i32) -> c_ulong;
75 pub fn al_fgets(f: *mut ALLEGRO_FILE, p: *mut c_char, max: c_ulong) -> *mut c_char;
76 pub fn al_fget_ustr(f: *mut ALLEGRO_FILE) -> *mut ALLEGRO_USTR;
77 pub fn al_fputs(f: *mut ALLEGRO_FILE, p: *const c_char) -> c_int;
78 pub fn al_fprintf(f: *mut ALLEGRO_FILE, format: *const c_char, ...) -> c_int;
79 pub fn al_fopen_fd(fd: c_int, mode: *const c_char) -> *mut ALLEGRO_FILE;
80 pub fn al_make_temp_file(
81 tmpl: *const c_char, ret_path: *mut *mut ALLEGRO_PATH,
82 ) -> *mut ALLEGRO_FILE;
83 pub fn al_fopen_slice(
84 fp: *mut ALLEGRO_FILE, initial_size: c_ulong, mode: *const c_char,
85 ) -> *mut ALLEGRO_FILE;
86 pub fn al_get_new_file_interface() -> *const ALLEGRO_FILE_INTERFACE;
87 pub fn al_set_new_file_interface(file_interface: *const ALLEGRO_FILE_INTERFACE);
88 pub fn al_set_standard_file_interface();
89 pub fn al_get_file_userdata(f: *mut ALLEGRO_FILE) -> *mut c_void;
90}