mirror of
https://git.planet-casio.com/Vhex-Kernel-Core/fxlibc.git
synced 2024-12-29 13:03:38 +01:00
stdio: add general file management definitions
This commit is contained in:
parent
518a866750
commit
6e42995388
4 changed files with 60 additions and 6 deletions
14
STATUS
14
STATUS
|
@ -86,7 +86,8 @@ DONE: Function/symbol/macro is defined, builds, links, and is tested
|
||||||
7.18 <stdint.h> => GCC
|
7.18 <stdint.h> => GCC
|
||||||
|
|
||||||
7.19 <stdio.h>
|
7.19 <stdio.h>
|
||||||
! 7.19.1 Introduction: TODO
|
7.19.1 Introduction: TEST
|
||||||
|
TODO: Handle wide-oriented streams? (see notes)
|
||||||
! 7.19.4 Operations on files: TODO
|
! 7.19.4 Operations on files: TODO
|
||||||
! 7.19.5 File access functions: TODO
|
! 7.19.5 File access functions: TODO
|
||||||
! 7.19.6 Formatted input/output functions: TODO
|
! 7.19.6 Formatted input/output functions: TODO
|
||||||
|
@ -182,3 +183,14 @@ What if we wanted to support more locales?
|
||||||
-> Fix the "TODO: locale: ..." messages wherever assumptions on the locale are
|
-> Fix the "TODO: locale: ..." messages wherever assumptions on the locale are
|
||||||
made in the code
|
made in the code
|
||||||
-> Properly implement strcoll() and strxfrm()
|
-> Properly implement strcoll() and strxfrm()
|
||||||
|
|
||||||
|
# Supporting text and binary files (newline translation)
|
||||||
|
|
||||||
|
Because of 7.19.2%1,223 we don't need to support newline translation.
|
||||||
|
|
||||||
|
# Support wide-oriented streams
|
||||||
|
|
||||||
|
This requires all the wide-char functions but also updating fpos_t to be a
|
||||||
|
structure with at least some mbstate_t member (7.19.2§6).
|
||||||
|
|
||||||
|
I really don't want to do that. Use multi-byte functions with UTF-8.
|
||||||
|
|
|
@ -3,8 +3,45 @@
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
/* Type of FILE handlers. */
|
||||||
#include <bits/types/FILE.h>
|
#include <bits/types/FILE.h>
|
||||||
|
|
||||||
|
/* Type of positions within files. */
|
||||||
|
typedef size_t fpos_t;
|
||||||
|
|
||||||
|
/* Buffering modes. */
|
||||||
|
#define _IOFBF 0
|
||||||
|
#define _IOLBF 1
|
||||||
|
#define _IONBF 2
|
||||||
|
|
||||||
|
/* Some buffer size for file buffering. */
|
||||||
|
/* TODO: We might want a larger BUFSIZ than 256 on fx-CG 50. */
|
||||||
|
#define BUFSIZ 256
|
||||||
|
|
||||||
|
/* End-of-file marker. */
|
||||||
|
#define EOF ((int)(-1))
|
||||||
|
|
||||||
|
/* Number of files guaranteed can be opened simultaneously. */
|
||||||
|
/* TODO: FOPEN_MAX is BFile-specific, Vhex might have much larger limits. */
|
||||||
|
#define FOPEN_MAX 4
|
||||||
|
|
||||||
|
/* Recommended length of a filename. */
|
||||||
|
/* TODO: FILENAME_MAX = 128 is quite BFile-centric, Vhex might be different. */
|
||||||
|
#define FILENAME_MAX 128
|
||||||
|
|
||||||
|
/* Length a filename for tmpnam. */
|
||||||
|
#define L_tmpnam FILENAME_MAX
|
||||||
|
|
||||||
|
/* Seeking positions. */
|
||||||
|
#define SEEK_CUR 0
|
||||||
|
#define SEEK_END 1
|
||||||
|
#define SEEK_SET 2
|
||||||
|
|
||||||
|
/* Maximum number of unique filenames that tmpnam can generate. */
|
||||||
|
/* TODO: Set a useful value in TMP_MAX other than 16*16*16 */
|
||||||
|
#define TMP_MAX (16*16*16)
|
||||||
|
|
||||||
/* Standard input, output and error streams. */
|
/* Standard input, output and error streams. */
|
||||||
extern FILE *stdin;
|
extern FILE *stdin;
|
||||||
extern FILE *stdout;
|
extern FILE *stdout;
|
||||||
|
|
|
@ -1,7 +1,17 @@
|
||||||
#ifndef __BITS_TYPES_FILE_H__
|
#ifndef __BITS_TYPES_FILE_H__
|
||||||
# define __BITS_TYPES_FILE_H__
|
# define __BITS_TYPES_FILE_H__
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
/* BFile handler */
|
||||||
|
int fd;
|
||||||
|
/* Current position in file */
|
||||||
|
size_t pos;
|
||||||
|
/* Buffering mode */
|
||||||
|
// TODO
|
||||||
|
/* Opening mode */
|
||||||
|
// TODO
|
||||||
} FILE;
|
} FILE;
|
||||||
|
|
||||||
#endif /*__BITS_TYPES_FILE_H__*/
|
#endif /*__BITS_TYPES_FILE_H__*/
|
||||||
|
|
|
@ -59,11 +59,6 @@ extern ssize_t pread (int __fd, void *__buf, size_t __nbytes, off_t __offset);
|
||||||
*/
|
*/
|
||||||
extern ssize_t pwrite (int __fd, const void *__buf, size_t __n, off_t __offset);
|
extern ssize_t pwrite (int __fd, const void *__buf, size_t __n, off_t __offset);
|
||||||
|
|
||||||
/* Values for the WHENCE argument to lseek. */
|
|
||||||
#define SEEK_SET 0 /* Seek from beginning of file. */
|
|
||||||
#define SEEK_CUR 1 /* Seek from current position. */
|
|
||||||
#define SEEK_END 2 /* Seek from end of file. */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Move FD's file position to OFFSET bytes from the beginning of the file
|
** Move FD's file position to OFFSET bytes from the beginning of the file
|
||||||
** (if WHENCE is SEEK_SET), the current position (if WHENCE is SEEK_CUR),
|
** (if WHENCE is SEEK_SET), the current position (if WHENCE is SEEK_CUR),
|
||||||
|
|
Loading…
Reference in a new issue