diff options
Diffstat (limited to 'libio/strfile.h')
-rw-r--r-- | libio/strfile.h | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/libio/strfile.h b/libio/strfile.h index 75caac2..e51ac34 100644 --- a/libio/strfile.h +++ b/libio/strfile.h @@ -24,7 +24,9 @@ This exception applies to code released by its copyright holders in files containing the exception. */ -#include <stdio.h> +#ifndef STRFILE_H_ +#define STRFILE_H_ + #include "libioP.h" typedef void *(*_IO_alloc_type) (size_t); @@ -80,3 +82,32 @@ typedef struct } _IO_wstrnfile; extern const struct _IO_jump_t _IO_wstrn_jumps attribute_hidden; + +/* Initialize an _IO_strfile SF to read from narrow string STRING, and + return the corresponding FILE object. It is not necessary to fclose + the FILE when it is no longer needed. */ +static inline FILE * +_IO_strfile_read (_IO_strfile *sf, const char *string) +{ + sf->_sbf._f._lock = NULL; + _IO_no_init (&sf->_sbf._f, _IO_USER_LOCK, -1, NULL, NULL); + _IO_JUMPS (&sf->_sbf) = &_IO_str_jumps; + _IO_str_init_static_internal (sf, (char*)string, 0, NULL); + return &sf->_sbf._f; +} + +/* Initialize an _IO_strfile SF and _IO_wide_data WD to read from wide + string STRING, and return the corresponding FILE object. It is not + necessary to fclose the FILE when it is no longer needed. */ +static inline FILE * +_IO_strfile_readw (_IO_strfile *sf, struct _IO_wide_data *wd, + const wchar_t *string) +{ + sf->_sbf._f._lock = NULL; + _IO_no_init (&sf->_sbf._f, _IO_USER_LOCK, 0, wd, &_IO_wstr_jumps); + _IO_fwide (&sf->_sbf._f, 1); + _IO_wstr_init_static (&sf->_sbf._f, (wchar_t *)string, 0, NULL); + return &sf->_sbf._f; +} + +#endif /* strfile.h. */ |