2007-05-02 01:07:00 +00:00
|
|
|
/*
|
2008-03-19 02:26:52 +00:00
|
|
|
* $Id: stdio.h 148 2008-03-18 08:26:52Z baconevi $
|
2008-03-18 04:27:02 +00:00
|
|
|
*
|
|
|
|
* {License}
|
2007-05-02 01:07:00 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ASE_UTL_STDIO_H_
|
|
|
|
#define _ASE_UTL_STDIO_H_
|
|
|
|
|
|
|
|
#include <ase/cmn/types.h>
|
|
|
|
#include <ase/cmn/macros.h>
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <wchar.h>
|
|
|
|
|
|
|
|
#if defined(_WIN32)
|
|
|
|
#include <tchar.h>
|
|
|
|
|
|
|
|
#define ase_printf _tprintf
|
|
|
|
#define ase_vprintf _vtprintf
|
|
|
|
#define ase_fprintf _ftprintf
|
|
|
|
#define ase_vfprintf _vftprintf
|
|
|
|
|
2008-01-16 00:36:07 +00:00
|
|
|
#define ase_fgets(x,y,s) _fgetts(x,y,s)
|
|
|
|
#define ase_fgetc(x) _fgettc(x)
|
|
|
|
#define ase_fputs(x,s) _fputts(x,s)
|
|
|
|
#define ase_fputc(x,s) _fputtc(x,s)
|
2007-05-02 01:07:00 +00:00
|
|
|
#elif defined(ASE_CHAR_IS_MCHAR)
|
2008-01-16 00:36:07 +00:00
|
|
|
#define ase_fgets(x,y,s) fgets(x,y,s)
|
|
|
|
#define ase_fgetc(x) fgetc(x)
|
|
|
|
#define ase_fputs(x,s) fputs(x,s)
|
|
|
|
#define ase_fputc(x,s) fputc(x,s)
|
2007-05-02 01:07:00 +00:00
|
|
|
#else
|
2008-01-16 00:36:07 +00:00
|
|
|
#define ase_fgets(x,y,s) fgetws(x,y,s)
|
|
|
|
#define ase_fgetc(x) fgetwc(x)
|
|
|
|
#define ase_fputs(x,s) fputws(x,s)
|
|
|
|
#define ase_fputc(x,s) fputwc(x,s)
|
2007-05-02 01:07:00 +00:00
|
|
|
#endif
|
|
|
|
|
2008-01-16 00:36:07 +00:00
|
|
|
#define ase_feof(s) feof(s)
|
|
|
|
#define ase_ferror(s) ferror(s)
|
|
|
|
#define ase_clearerr(s) clearerr(s)
|
2008-02-02 00:52:07 +00:00
|
|
|
#define ase_fflush(s) fflush(s)
|
2008-03-09 23:59:34 +00:00
|
|
|
#define ase_fclose(s) fclose(s)
|
2008-01-16 00:36:07 +00:00
|
|
|
|
2008-03-19 02:02:12 +00:00
|
|
|
#define ASE_FILE FILE
|
2008-02-09 03:04:38 +00:00
|
|
|
#define ASE_STDIN stdin
|
|
|
|
#define ASE_STDOUT stdout
|
|
|
|
#define ASE_STDERR stderr
|
|
|
|
|
2008-03-19 02:26:52 +00:00
|
|
|
typedef int (*ase_getdelim_t) (const ase_char_t* ptr,ase_size_t len, void* arg);
|
|
|
|
|
2007-05-02 01:07:00 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int ase_vsprintf (ase_char_t* buf, size_t size, const ase_char_t* fmt, va_list ap);
|
|
|
|
int ase_sprintf (ase_char_t* buf, size_t size, const ase_char_t* fmt, ...);
|
|
|
|
|
2007-06-18 00:31:00 +00:00
|
|
|
#if !defined(_WIN32)
|
2008-03-19 02:02:12 +00:00
|
|
|
int ase_vfprintf (ASE_FILE *stream, const ase_char_t* fmt, va_list ap);
|
2007-05-02 01:07:00 +00:00
|
|
|
int ase_vprintf (const ase_char_t* fmt, va_list ap);
|
2008-03-19 02:02:12 +00:00
|
|
|
int ase_fprintf (ASE_FILE* file, const ase_char_t* fmt, ...);
|
2007-05-02 01:07:00 +00:00
|
|
|
int ase_printf (const ase_char_t* fmt, ...);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int ase_dprintf (const ase_char_t* fmt, ...);
|
2008-03-19 02:02:12 +00:00
|
|
|
ASE_FILE* ase_fopen (const ase_char_t* path, const ase_char_t* mode);
|
|
|
|
ASE_FILE* ase_popen (const ase_char_t* cmd, const ase_char_t* mode);
|
2007-05-02 01:07:00 +00:00
|
|
|
|
2008-03-13 06:25:11 +00:00
|
|
|
/**
|
|
|
|
* returns -2 on error, -1 on eof, length of data read on success
|
|
|
|
*/
|
2008-03-19 02:02:12 +00:00
|
|
|
ase_ssize_t ase_getline (ase_char_t **buf, ase_size_t *n, ASE_FILE *fp);
|
|
|
|
/**
|
|
|
|
* returns -3 on line breaker error, -2 on error, -1 on eof,
|
|
|
|
* length of data read on success
|
|
|
|
*/
|
2008-03-13 05:55:39 +00:00
|
|
|
ase_ssize_t ase_getdelim (
|
2008-03-19 02:02:12 +00:00
|
|
|
ase_char_t **buf, ase_size_t *n,
|
2008-03-19 02:26:52 +00:00
|
|
|
ase_getdelim_t fn, void* fnarg, ASE_FILE *fp);
|
2008-03-13 05:55:39 +00:00
|
|
|
|
2007-05-02 01:07:00 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|