libdragon
Loading...
Searching...
No Matches
system.h
Go to the documentation of this file.
1
6#ifndef __LIBDRAGON_SYSTEM_H
7#define __LIBDRAGON_SYSTEM_H
8
42#define MAX_FILESYSTEMS 10
44#define MAX_OPEN_HANDLES 4096
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
50#include <dir.h>
51#include <sys/stat.h>
52
63typedef struct
64{
77 void *(*open)( char *name, int flags );
88 int (*fstat)( void *file, struct stat *st );
102 int (*lseek)( void *file, int ptr, int dir );
116 int (*read)( void *file, uint8_t *ptr, int len );
129 int (*write)( void *file, uint8_t *ptr, int len );
138 int (*close)( void *file );
148 int (*unlink)( char *name );
162 int (*findfirst)( char *path, dir_t *dir );
173 int (*findnext)( dir_t *dir );
175
183typedef struct
184{
195 int (*stdin_read)( char *data, unsigned int len );
206 int (*stdout_write)( char *data, unsigned int len );
217 int (*stderr_write)( char *data, unsigned int len );
218} stdio_t;
219
244int attach_filesystem( const char * const prefix, filesystem_t *filesystem );
245
259int detach_filesystem( const char * const prefix );
260
261
270int hook_stdio_calls( stdio_t *stdio_calls );
271
280int unhook_stdio_calls( stdio_t *stdio_calls );
281
282
291int hook_time_call( time_t (*time_fn)( void ) );
292
301int unhook_time_call( time_t (*time_fn)( void ) );
302
303#ifdef __cplusplus
304}
305#endif
306
309#endif
Directory handling.
int hook_time_call(time_t(*time_fn)(void))
Hook into gettimeofday with a current time callback.
Definition system.c:1306
int hook_stdio_calls(stdio_t *stdio_calls)
Hook into stdio for STDIN, STDOUT and STDERR callbacks.
Definition system.c:1272
int unhook_stdio_calls(stdio_t *stdio_calls)
Unhook from stdio.
Definition system.c:1292
int unhook_time_call(time_t(*time_fn)(void))
Unhook from gettimeofday current time callback.
Definition system.c:1318
int detach_filesystem(const char *const prefix)
Unregister a filesystem from newlib.
Definition system.c:350
int attach_filesystem(const char *const prefix, filesystem_t *filesystem)
Register a filesystem with newlib.
Definition system.c:289
Directory entry structure.
Definition dir.h:34
Filesystem hook structure.
Definition system.h:64
Standard I/O hook structure.
Definition system.h:184
int read(int fileno, char *ptr, int len)
Read data from a file.
Definition system.c:927
int lseek(int file, int ptr, int dir)
Seek to a location in a file.
Definition system.c:825
int fstat(int fileno, struct stat *st)
Return stats on an open file handle.
Definition system.c:673
int stat(const char *file, struct stat *st)
Return file stats based on a file name.
Definition system.c:1041
int close(int fildes)
Close a file.
Definition system.c:577
int unlink(char *name)
Remove a file based on filename.
Definition system.c:1098
int write(int file, char *ptr, int len)
Write data to a file.
Definition system.c:1149