[Lapetus-cvs] lapetus/sys bup.c, NONE, 1.1 cd.c, NONE, 1.1 close.c, NONE, 1.1 file.h, NONE, 1.1 fst
Status: Inactive
Brought to you by:
cyberwarriorx
From: Theo B. <cyb...@us...> - 2009-06-03 01:17:57
|
Update of /cvsroot/lapetus/lapetus/sys In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv29538 Added Files: bup.c cd.c close.c file.h fstat.c lseek.c open.c read.c stderr.c stdin.c stdout.c sys.c write.c Log Message: -Added some earlier stdio stuff --- NEW FILE: lseek.c --- /* Copyright 2008 Theo Berkau This file is part of Lapetus. Lapetus is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Lapetus is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Lapetus; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <reent.h> ////////////////////////////////////////////////////////////////////////////// /* _off_t _lseek_r _PARAMS ((struct _reent *, int, _off_t, int)) { } */ ////////////////////////////////////////////////////////////////////////////// --- NEW FILE: sys.c --- /* Copyright 2008 Theo Berkau This file is part of Lapetus. Lapetus is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Lapetus is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Lapetus; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <stdio.h> #include <reent.h> #include "lapetus.h" #include "file.h" const devoptab_t *devoptab_list[] = { &dotab_stdin, &dotab_stdout, &dotab_stderr, &dotab_cd, &dotab_bup, NULL }; ////////////////////////////////////////////////////////////////////////////// /* void *_sbrk_r _PARAMS ((struct _reent *, ptrdiff_t)) { } */ ////////////////////////////////////////////////////////////////////////////// /* int _stat_r _PARAMS ((struct _reent *, const char *, struct stat *)) { } */ ////////////////////////////////////////////////////////////////////////////// /* _CLOCK_T_ _times_r _PARAMS ((struct _reent *, struct tms *)) { } */ ////////////////////////////////////////////////////////////////////////////// --- NEW FILE: file.h --- /* Copyright 2008 Theo Berkau This file is part of Lapetus. Lapetus is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Lapetus is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Lapetus; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef FILE_H #define FILE_H typedef struct { const char *name; int (*open) (struct _reent *r, const char *path, int flags, int mode ); int (*close) (struct _reent *r, int fd ); _ssize_t (*write) (struct _reent *r, int fd, const char *ptr, int len); _ssize_t (*read) (struct _reent *r, int fd, char *ptr, int len); } devoptab_t; extern const devoptab_t dotab_stdin; extern const devoptab_t dotab_stdout; extern const devoptab_t dotab_stderr; extern const devoptab_t dotab_cd; extern const devoptab_t dotab_bup; extern const devoptab_t *devoptab_list[]; #endif --- NEW FILE: stdin.c --- /* Copyright 2008 Theo Berkau This file is part of Lapetus. Lapetus is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Lapetus is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Lapetus; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <reent.h> #include "../lapetus.h" #include "file.h" ////////////////////////////////////////////////////////////////////////////// int stdin_open(struct _reent *r, const char *path, int flags, int mode) { return 0; } ////////////////////////////////////////////////////////////////////////////// int stdin_close(struct _reent *r, int fd) { return 0; } ////////////////////////////////////////////////////////////////////////////// _ssize_t stdin_write(struct _reent *r, int fd, const char *ptr, int len) { return -1; // Doesn't support writing } ////////////////////////////////////////////////////////////////////////////// _ssize_t stdin_read(struct _reent *r, int fd, char *ptr, int len) { if (per[0].id == PER_KEYBOARD) { return len; // fix me } return -1; } ////////////////////////////////////////////////////////////////////////////// const devoptab_t dotab_stdin = { "stdin", stdin_open, stdin_close, stdin_write, stdin_read }; ////////////////////////////////////////////////////////////////////////////// --- NEW FILE: close.c --- /* Copyright 2008 Theo Berkau This file is part of Lapetus. Lapetus is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Lapetus is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Lapetus; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <reent.h> #include "file.h" ////////////////////////////////////////////////////////////////////////////// int _close_r _PARAMS ((struct _reent *r, int fd)) { int device = fd >> 16; return devoptab_list[device]->close(r, fd & 0xFFFF); } ////////////////////////////////////////////////////////////////////////////// --- NEW FILE: open.c --- /* Copyright 2008 Theo Berkau This file is part of Lapetus. Lapetus is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Lapetus is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Lapetus; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <reent.h> #include <stdio.h> #include <string.h> #include "file.h" ////////////////////////////////////////////////////////////////////////////// int _open_r _PARAMS ((struct _reent *r, const char *file, int flags, int mode)) { int i; int device=-1; int fd; for (i = 0; devoptab_list[i] != NULL; i++) { if (strncmp(devoptab_list[i]->name, file, strlen(devoptab_list[i]->name)) == 0) device = i; } if (device < 0 || (fd = devoptab_list[device]->open(r, file, flags, mode)) == -1) return -1; return ((device << 16) | (fd & 0xFFFF)); } ////////////////////////////////////////////////////////////////////////////// --- NEW FILE: stdout.c --- /* Copyright 2008 Theo Berkau This file is part of Lapetus. Lapetus is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Lapetus is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Lapetus; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <reent.h> #include "file.h" ////////////////////////////////////////////////////////////////////////////// int stdout_open(struct _reent *r, const char *path, int flags, int mode) { return 0; // fix me } ////////////////////////////////////////////////////////////////////////////// int stdout_close(struct _reent *r, int fd) { return 0; // fix me } ////////////////////////////////////////////////////////////////////////////// _ssize_t stdout_write(struct _reent *r, int fd, const char *ptr, int len) { return len; // fix me } ////////////////////////////////////////////////////////////////////////////// _ssize_t stdout_read(struct _reent *r, int fd, char *ptr, int len) { return len; // fix me } ////////////////////////////////////////////////////////////////////////////// const devoptab_t dotab_stdout = { "stdout", stdout_open, stdout_close, stdout_write, stdout_read }; --- NEW FILE: stderr.c --- /* Copyright 2008 Theo Berkau This file is part of Lapetus. Lapetus is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Lapetus is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Lapetus; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <reent.h> #include "file.h" ////////////////////////////////////////////////////////////////////////////// int stderr_open(struct _reent *r, const char *path, int flags, int mode) { return 0; // fix me } ////////////////////////////////////////////////////////////////////////////// int stderr_close(struct _reent *r, int fd) { return 0; // fix me } ////////////////////////////////////////////////////////////////////////////// _ssize_t stderr_write(struct _reent *r, int fd, const char *ptr, int len) { return len; // fix me } ////////////////////////////////////////////////////////////////////////////// _ssize_t stderr_read(struct _reent *r, int fd, char *ptr, int len) { return len; // fix me } ////////////////////////////////////////////////////////////////////////////// const devoptab_t dotab_stderr = { "stderr", stderr_open, stderr_close, stderr_write, stderr_read }; --- NEW FILE: fstat.c --- /* Copyright 2008 Theo Berkau This file is part of Lapetus. Lapetus is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Lapetus is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Lapetus; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <reent.h> ////////////////////////////////////////////////////////////////////////////// /* int _fstat_r _PARAMS ((struct _reent *, int, struct stat *)) { } */ ////////////////////////////////////////////////////////////////////////////// --- NEW FILE: write.c --- /* Copyright 2008 Theo Berkau This file is part of Lapetus. Lapetus is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Lapetus is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Lapetus; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <reent.h> #include "file.h" ////////////////////////////////////////////////////////////////////////////// _ssize_t _write_r _PARAMS ((struct _reent *r, int fd, const void *ptr, size_t len)) { int device = fd >> 16; return devoptab_list[device]->write(r, fd & 0xFFFF, ptr, len); } ////////////////////////////////////////////////////////////////////////////// --- NEW FILE: bup.c --- /* Copyright 2008 Theo Berkau This file is part of Lapetus. Lapetus is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Lapetus is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Lapetus; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <reent.h> #include "file.h" ////////////////////////////////////////////////////////////////////////////// int bup_open(struct _reent *r, const char *path, int flags, int mode) { return 0; // fix me } ////////////////////////////////////////////////////////////////////////////// int bup_close(struct _reent *r, int fd) { return 0; // fix me } ////////////////////////////////////////////////////////////////////////////// _ssize_t bup_write(struct _reent *r, int fd, const char *ptr, int len) { return len; // fix me } ////////////////////////////////////////////////////////////////////////////// _ssize_t bup_read(struct _reent *r, int fd, char *ptr, int len) { return len; // fix me } ////////////////////////////////////////////////////////////////////////////// const devoptab_t dotab_bup = { "bup", bup_open, bup_close, bup_write, bup_read }; --- NEW FILE: read.c --- /* Copyright 2008 Theo Berkau This file is part of Lapetus. Lapetus is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Lapetus is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Lapetus; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <reent.h> #include "file.h" ////////////////////////////////////////////////////////////////////////////// _ssize_t _read_r _PARAMS ((struct _reent *r, int fd, void *ptr, size_t len)) { int device = fd >> 16; return devoptab_list[device]->read(r, fd & 0xFFFF, ptr, len); } ////////////////////////////////////////////////////////////////////////////// --- NEW FILE: cd.c --- /* Copyright 2008 Theo Berkau This file is part of Lapetus. Lapetus is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Lapetus is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Lapetus; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <reent.h> #include "../lapetus.h" #include "file.h" ////////////////////////////////////////////////////////////////////////////// int cdfs_open(struct _reent *r, const char *path, int flags, int mode) { // Make sure CDFS has been initialized // Anyways, file has finally been found, return the fid return 0; } ////////////////////////////////////////////////////////////////////////////// int cdfs_close(struct _reent *r, int fd) { return 0; } ////////////////////////////////////////////////////////////////////////////// _ssize_t cdfs_write(struct _reent *r, int fd, const char *ptr, int len) { return len; // fix me } ////////////////////////////////////////////////////////////////////////////// _ssize_t cdfs_read(struct _reent *r, int fd, char *ptr, int len) { return len; // fix me } ////////////////////////////////////////////////////////////////////////////// const devoptab_t dotab_cd = { "cd", cdfs_open, cdfs_close, cdfs_write, cdfs_read }; ////////////////////////////////////////////////////////////////////////////// |