aboutsummaryrefslogtreecommitdiff
path: root/backends/PalmOS/Src/missing/stdio.h
blob: 558231e2509f594beeb1b2431f00dae907709f0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2001  Ludvig Strigeus
 * Copyright (C) 2001-2006 The ScummVM project
 * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend
 *
 * This program 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.

 * This program 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 this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * $URL$
 * $Id$
 *
 */

#ifndef __STDIO_H__
#define __STDIO_H__

#include "palmversion.h"
#include <stdarg.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef void (*LedProc)(Boolean show);

typedef struct {
	FileRef fileRef;
	UInt32 cacheSize, bufSize, bufPos;
	UInt8 *cache;
	UInt16 mode, err;
} FILE;

extern FILE	gStdioOutput;
typedef UInt32 size_t;

#ifdef stdin
#undef stdin
#undef stdout
#undef stderr
#endif

#ifdef SEEK_SET
#undef SEEK_SET
#undef SEEK_CUR
#undef SEEK_END
#endif

#define stdin		0
#define stdout		(&gStdioOutput)
#define stderr		(&gStdioOutput)

#define clearerr(a)
#define fflush(a)
#define vsnprintf(a,b,c,d)	vsprintf(a,c,d)
#define getc(a)				fgetc(a)

#define	SEEK_SET			vfsOriginBeginning 
#define	SEEK_CUR			vfsOriginCurrent  
#define	SEEK_END			vfsOriginEnd


UInt16		fclose	(FILE *stream);
UInt16		feof	(FILE *stream);
UInt16		ferror	(FILE *stream);
Char *		fgets	(Char *s, UInt32 n, FILE *stream);
Int16		fgetc	(FILE *stream);
FILE *		fopen	(const Char *filename, const Char *type);
UInt32		fread	(void *ptr, UInt32 size, UInt32 nitems, FILE *stream);
UInt32		fwrite	(const void *ptr, UInt32 size, UInt32 nitems, FILE *stream);
Int16		fseek	(FILE *stream, Int32 offset, Int32 whence);
Int32		ftell	(FILE *stream);

Int32	fprintf	(FILE *stream, const Char *formatStr, ...);
Int32	printf	(const Char* formatStr, ...);
Int32	sprintf	(Char* s, const Char* formatStr, ...);
Int32	snprintf(Char* s, UInt32 len, const Char* formatStr, ...);
Int32	vsprintf(Char* s, const Char* formatStr, _Palm_va_list argParam);

void	StdioInit			(UInt16 volRefNum, const Char *output);
void	StdioSetLedProc		(LedProc ledProc);
void	StdioSetCacheSize	(UInt32 s);
void	StdioRelease		();

#ifdef __cplusplus
}
#endif

#endif