-#pragma once
-
-#include <sys/time.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
-
-#ifdef __cplusplus
-}
-#endif
+#include_next <sys/select.h>
\ No newline at end of file
//---------------------------------------------------------------------------------
-ssize_t con_write(struct _reent *r,int fd,const char *ptr, size_t len) {
+ssize_t con_write(struct _reent *r,void *fd,const char *ptr, size_t len) {
//---------------------------------------------------------------------------------
char chr;
};
//---------------------------------------------------------------------------------
-ssize_t debug_write(struct _reent *r, int fd, const char *ptr, size_t len) {
+ssize_t debug_write(struct _reent *r, void *fd, const char *ptr, size_t len) {
//---------------------------------------------------------------------------------
svcOutputDebugString(ptr,len);
return len;
//-----------------------------------------------------------------------------
static int romfs_open(struct _reent *r, void *fileStruct, const char *path, int flags, int mode);
-static int romfs_close(struct _reent *r, int fd);
-static ssize_t romfs_read(struct _reent *r, int fd, char *ptr, size_t len);
-static off_t romfs_seek(struct _reent *r, int fd, off_t pos, int dir);
-static int romfs_fstat(struct _reent *r, int fd, struct stat *st);
+static int romfs_close(struct _reent *r, void *fd);
+static ssize_t romfs_read(struct _reent *r, void *fd, char *ptr, size_t len);
+static off_t romfs_seek(struct _reent *r, void *fd, off_t pos, int dir);
+static int romfs_fstat(struct _reent *r, void *fd, struct stat *st);
static int romfs_stat(struct _reent *r, const char *path, struct stat *st);
static int romfs_chdir(struct _reent *r, const char *path);
static DIR_ITER* romfs_diropen(struct _reent *r, DIR_ITER *dirState, const char *path);
.dirreset_r = romfs_dirreset,
.dirnext_r = romfs_dirnext,
.dirclose_r = romfs_dirclose,
- .deviceData = NULL,
+ .deviceData = 0,
};
//-----------------------------------------------------------------------------
return 0;
}
-int romfs_close(struct _reent *r, int fd)
+int romfs_close(struct _reent *r, void *fd)
{
return 0;
}
-ssize_t romfs_read(struct _reent *r, int fd, char *ptr, size_t len)
+ssize_t romfs_read(struct _reent *r, void *fd, char *ptr, size_t len)
{
romfs_fileobj* file = (romfs_fileobj*)fd;
u64 endPos = file->pos + len;
return -1;
}
-off_t romfs_seek(struct _reent *r, int fd, off_t pos, int dir)
+off_t romfs_seek(struct _reent *r, void *fd, off_t pos, int dir)
{
romfs_fileobj* file = (romfs_fileobj*)fd;
off_t start;
return file->pos;
}
-int romfs_fstat(struct _reent *r, int fd, struct stat *st)
+int romfs_fstat(struct _reent *r, void *fd, struct stat *st)
{
romfs_fileobj* file = (romfs_fileobj*)fd;
memset(st, 0, sizeof(struct stat));
static int sdmc_translate_error(Result error);
static int sdmc_open(struct _reent *r, void *fileStruct, const char *path, int flags, int mode);
-static int sdmc_close(struct _reent *r, int fd);
-static ssize_t sdmc_write(struct _reent *r, int fd, const char *ptr, size_t len);
-static ssize_t sdmc_write_safe(struct _reent *r, int fd, const char *ptr, size_t len);
-static ssize_t sdmc_read(struct _reent *r, int fd, char *ptr, size_t len);
-static off_t sdmc_seek(struct _reent *r, int fd, off_t pos, int dir);
-static int sdmc_fstat(struct _reent *r, int fd, struct stat *st);
+static int sdmc_close(struct _reent *r, void *fd);
+static ssize_t sdmc_write(struct _reent *r, void *fd, const char *ptr, size_t len);
+static ssize_t sdmc_write_safe(struct _reent *r, void *fd, const char *ptr, size_t len);
+static ssize_t sdmc_read(struct _reent *r, void *fd, char *ptr, size_t len);
+static off_t sdmc_seek(struct _reent *r, void *fd, off_t pos, int dir);
+static int sdmc_fstat(struct _reent *r, void *fd, struct stat *st);
static int sdmc_stat(struct _reent *r, const char *file, struct stat *st);
static int sdmc_link(struct _reent *r, const char *existing, const char *newLink);
static int sdmc_unlink(struct _reent *r, const char *name);
static int sdmc_dirnext(struct _reent *r, DIR_ITER *dirState, char *filename, struct stat *filestat);
static int sdmc_dirclose(struct _reent *r, DIR_ITER *dirState);
static int sdmc_statvfs(struct _reent *r, const char *path, struct statvfs *buf);
-static int sdmc_ftruncate(struct _reent *r, int fd, off_t len);
-static int sdmc_fsync(struct _reent *r, int fd);
+static int sdmc_ftruncate(struct _reent *r, void *fd, off_t len);
+static int sdmc_fsync(struct _reent *r, void *fd);
static int sdmc_chmod(struct _reent *r, const char *path, mode_t mode);
-static int sdmc_fchmod(struct _reent *r, int fd, mode_t mode);
+static int sdmc_fchmod(struct _reent *r, void *fd, mode_t mode);
static int sdmc_rmdir(struct _reent *r, const char *name);
/*! @cond INTERNAL */
.statvfs_r = sdmc_statvfs,
.ftruncate_r = sdmc_ftruncate,
.fsync_r = sdmc_fsync,
- .deviceData = NULL,
+ .deviceData = 0,
.chmod_r = sdmc_chmod,
.fchmod_r = sdmc_fchmod,
.rmdir_r = sdmc_rmdir,
*/
static int
sdmc_close(struct _reent *r,
- int fd)
+ void *fd)
{
Result rc;
*/
static ssize_t
sdmc_write(struct _reent *r,
- int fd,
+ void *fd,
const char *ptr,
size_t len)
{
*/
static ssize_t
sdmc_write_safe(struct _reent *r,
- int fd,
+ void *fd,
const char *ptr,
size_t len)
{
*/
static ssize_t
sdmc_read(struct _reent *r,
- int fd,
+ void *fd,
char *ptr,
size_t len)
{
*/
static off_t
sdmc_seek(struct _reent *r,
- int fd,
+ void *fd,
off_t pos,
int whence)
{
*/
static int
sdmc_fstat(struct _reent *r,
- int fd,
+ void *fd,
struct stat *st)
{
Result rc;
if(R_SUCCEEDED(rc = FSUSER_OpenFile(&fd, sdmcArchive, fs_path, FS_OPEN_READ, 0)))
{
sdmc_file_t tmpfd = { .fd = fd };
- rc = sdmc_fstat(r, (int)&tmpfd, st);
+ rc = sdmc_fstat(r, &tmpfd, st);
FSFILE_Close(fd);
return rc;
*/
static int
sdmc_ftruncate(struct _reent *r,
- int fd,
+ void *fd,
off_t len)
{
Result rc;
*/
static int
sdmc_fsync(struct _reent *r,
- int fd)
+ void *fd)
{
Result rc;
*/
static int
sdmc_fchmod(struct _reent *r,
- int fd,
+ void *fd,
mode_t mode)
{
r->_errno = ENOSYS;
#define SYNC_ERROR ENODEV
-int __alloc_handle(size_t size);
-__handle *__get_handle(int fd);
-void __release_handle(int fd);
-
extern Handle SOCU_handle;
extern Handle socMemhandle;
#include <3ds/ipc.h>
static int soc_open(struct _reent *r, void *fileStruct, const char *path, int flags, int mode);
-static int soc_close(struct _reent *r, int fd);
-static ssize_t soc_write(struct _reent *r, int fd, const char *ptr, size_t len);
-static ssize_t soc_read(struct _reent *r, int fd, char *ptr, size_t len);
+static int soc_close(struct _reent *r, void *fd);
+static ssize_t soc_write(struct _reent *r, void *fd, const char *ptr, size_t len);
+static ssize_t soc_read(struct _reent *r, void *fd, char *ptr, size_t len);
static devoptab_t
soc_devoptab =
.statvfs_r = NULL,
.ftruncate_r = NULL,
.fsync_r = NULL,
- .deviceData = NULL,
+ .deviceData = 0,
.chmod_r = NULL,
.fchmod_r = NULL,
};
static int
soc_close(struct _reent *r,
- int fd)
+ void *fd)
{
Handle sockfd = *(Handle*)fd;
static ssize_t
soc_write(struct _reent *r,
- int fd,
+ void *fd,
const char *ptr,
size_t len)
{
static ssize_t
soc_read(struct _reent *r,
- int fd,
+ void *fd,
char *ptr,
size_t len)
{