libdragon
Loading...
Searching...
No Matches
system.h
Go to the documentation of this file.
1
8#ifndef __LIBDRAGON_SYSTEM_H
9#define __LIBDRAGON_SYSTEM_H
10
44#define MAX_FILESYSTEMS 10
46#define MAX_OPEN_HANDLES 4096
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
52#include <dir.h>
53#include <sys/stat.h>
54
65typedef struct
66{
79 void *(*open)( char *name, int flags );
90 int (*fstat)( void *file, struct stat *st );
104 int (*lseek)( void *file, int ptr, int dir );
118 int (*read)( void *file, uint8_t *ptr, int len );
131 int (*write)( void *file, uint8_t *ptr, int len );
140 int (*close)( void *file );
150 int (*unlink)( char *name );
164 int (*findfirst)( char *path, dir_t *dir );
175 int (*findnext)( dir_t *dir );
177
185typedef struct
186{
197 int (*stdin_read)( char *data, unsigned int len );
208 int (*stdout_write)( char *data, unsigned int len );
219 int (*stderr_write)( char *data, unsigned int len );
220} stdio_t;
221
246int attach_filesystem( const char * const prefix, filesystem_t *filesystem );
247
261int detach_filesystem( const char * const prefix );
262
263
272int hook_stdio_calls( stdio_t *stdio_calls );
273
282int unhook_stdio_calls( stdio_t *stdio_calls );
283
284
293int hook_time_call( time_t (*time_fn)( void ) );
294
303int unhook_time_call( time_t (*time_fn)( void ) );
304
305#ifdef __cplusplus
306}
307#endif
308
311#endif
Directory handling.
int hook_time_call(time_t(*time_fn)(void))
Hook into gettimeofday with a current time callback.
Definition system.c:1298
int hook_stdio_calls(stdio_t *stdio_calls)
Hook into stdio for STDIN, STDOUT and STDERR callbacks.
Definition system.c:1264
int unhook_stdio_calls(stdio_t *stdio_calls)
Unhook from stdio.
Definition system.c:1284
int unhook_time_call(time_t(*time_fn)(void))
Unhook from gettimeofday current time callback.
Definition system.c:1310
int detach_filesystem(const char *const prefix)
Unregister a filesystem from newlib.
Definition system.c:351
int attach_filesystem(const char *const prefix, filesystem_t *filesystem)
Register a filesystem with newlib.
Definition system.c:290
Directory entry structure.
Definition dir.h:36
Filesystem hook structure.
Definition system.h:66
Standard I/O hook structure.
Definition system.h:186
int read(int fileno, char *ptr, int len)
Read data from a file.
Definition system.c:928
int lseek(int file, int ptr, int dir)
Seek to a location in a file.
Definition system.c:826
int fstat(int fileno, struct stat *st)
Return stats on an open file handle.
Definition system.c:674
int stat(const char *file, struct stat *st)
Return file stats based on a file name.
Definition system.c:1042
int close(int fildes)
Close a file.
Definition system.c:578
int unlink(char *name)
Remove a file based on filename.
Definition system.c:1099
int write(int file, char *ptr, int len)
Write data to a file.
Definition system.c:1150