libdragon
system.h
Go to the documentation of this file.
1
6#ifndef __LIBDRAGON_SYSTEM_H
7#define __LIBDRAGON_SYSTEM_H
8
15#define MAX_FILESYSTEMS 10
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21#include <dir.h>
22#include <sys/stat.h>
23
34typedef struct
35{
48 void *(*open)( char *name, int flags );
59 int (*fstat)( void *file, struct stat *st );
73 int (*lseek)( void *file, int ptr, int dir );
87 int (*read)( void *file, uint8_t *ptr, int len );
100 int (*write)( void *file, uint8_t *ptr, int len );
109 int (*close)( void *file );
119 int (*unlink)( char *name );
132 int (*findfirst)( char *path, dir_t *dir );
142 int (*findnext)( dir_t *dir );
144
152typedef struct
153{
164 int (*stdin_read)( char *data, unsigned int len );
175 int (*stdout_write)( char *data, unsigned int len );
186 int (*stderr_write)( char *data, unsigned int len );
187} stdio_t;
188
189int attach_filesystem( const char * const prefix, filesystem_t *filesystem );
190int detach_filesystem( const char * const prefix );
191
192int hook_stdio_calls( stdio_t *stdio_calls );
193int unhook_stdio_calls( stdio_t *stdio_calls );
194
195int hook_time_call( time_t (*time_fn)( void ) );
196int unhook_time_call( time_t (*time_fn)( void ) );
197
198#ifdef __cplusplus
199}
200#endif
201
204#endif
Directory handling.
int read(int fileno, char *ptr, int len)
Read data from a file.
Definition: system.c:999
int lseek(int file, int ptr, int dir)
Seek to a location in a file.
Definition: system.c:897
int hook_time_call(time_t(*time_fn)(void))
Hook into gettimeofday with a current time callback.
Definition: system.c:1402
int hook_stdio_calls(stdio_t *stdio_calls)
Hook into stdio for STDIN, STDOUT and STDERR callbacks.
Definition: system.c:1352
int fstat(int fileno, struct stat *st)
Return stats on an open file handle.
Definition: system.c:745
int stat(const char *file, struct stat *st)
Return file stats based on a file name.
Definition: system.c:1113
int unhook_stdio_calls(stdio_t *stdio_calls)
Unhook from stdio.
Definition: system.c:1380
int unhook_time_call(time_t(*time_fn)(void))
Unhook from gettimeofday current time callback.
Definition: system.c:1422
int detach_filesystem(const char *const prefix)
Unregister a filesystem from newlib.
Definition: system.c:422
int close(int fildes)
Close a file.
Definition: system.c:649
int attach_filesystem(const char *const prefix, filesystem_t *filesystem)
Register a filesystem with newlib.
Definition: system.c:348
int unlink(char *name)
Remove a file based on filename.
Definition: system.c:1170
int write(int file, char *ptr, int len)
Write data to a file.
Definition: system.c:1221
Directory entry structure.
Definition: dir.h:32
Filesystem hook structure.
Definition: system.h:35
Standard I/O hook structure.
Definition: system.h:153