1 #ifndef STDIO_H 2 #define STDIO_H 3 4 // CHDK stdio 5 6 // Note: used in modules and platform independent code. 7 // Do not add platform dependent stuff in here (#ifdef/#endif compile options or camera dependent values) 8 9 //========================================================== 10 11 #define SEEK_SET 0 12 #define SEEK_CUR 1 13 #define SEEK_END 2 14 15 // reverse engineered file struct. Appears to be valid for both vxworks and dryos 16 // don't use this directly unless you absolutely need to 17 // don't EVER try to create one yourself, as this isn't the full structure. 18 typedef struct FILE_S { 19 int fd; // used by Read/Write 20 unsigned len; // +4 verfied in Fseek_FileStream 21 int unk0; // +8 22 unsigned pos; // +0xC verified in Fseek_FileStream 23 // unk1; // +0x10 24 // unk2; // +0x14 25 // io_buf; // +0x18 32k uncached allocated in Fopen_FileStream 26 // unk3; // +0x20 related to StartFileAccess_Sem 27 // ...name 28 } FILE; 29 30 extern FILE *fopen(const char *filename, const char *mode); 31 extern long fclose(FILE *f); 32 extern long fread(void *buf, long elsize, long count, FILE *f); 33 extern long fwrite(const void *buf, long elsize, long count, FILE *f); 34 extern long fseek(FILE *file, long offset, long whence); 35 extern long fflush(FILE *file); 36 extern long feof(FILE *file); 37 extern long ftell(FILE *file); 38 extern char *fgets(char *buf, int n, FILE *f); 39 40 #define ftell(f) (f ? (long)f->pos : -1) 41 42 //--------------------------------------------------------------- 43 44 #endif