source: trunk/src/odincrt/file.cpp@ 10367

Last change on this file since 10367 was 10185, checked in by sandervl, 22 years ago

Updates

File size: 4.1 KB
Line 
1/* $Id: file.cpp,v 1.5 2003-07-28 11:30:17 sandervl Exp $ */
2/*
3 * Project Odin Software License can be found in LICENSE.TXT
4 * strncpy replacement (one in RTL lib is buggy; doesn't stop at 0 terminator)
5 *
6 * Copyright 1999 Sander van Leeuwen
7 * Copyright 1999 Patrick Haller
8 *
9 */
10#define ORIGINAL_VAC_FUNCTIONS
11#include <stdio.h>
12#include <os2sel.h>
13#include <wchar.h>
14
15int _LNK_CONV CRTWRAP(fclose)( FILE *fp )
16{
17 unsigned short sel = RestoreOS2FS();
18 int rc;
19
20 rc = fclose(fp);
21 SetFS(sel);
22 return rc;
23}
24
25int _LNK_CONV CRTWRAP(feof)( FILE *fp )
26{
27 unsigned short sel = RestoreOS2FS();
28 int rc;
29
30 rc = feof(fp);
31 SetFS(sel);
32 return rc;
33}
34int _LNK_CONV CRTWRAP(ferror)( FILE *fp )
35{
36 unsigned short sel = RestoreOS2FS();
37 int rc;
38
39 rc = ferror(fp);
40 SetFS(sel);
41 return rc;
42}
43
44int _LNK_CONV CRTWRAP(fflush)( FILE *fp )
45{
46 unsigned short sel = RestoreOS2FS();
47 int rc;
48
49 rc = fflush(fp);
50 SetFS(sel);
51 return rc;
52}
53
54int _LNK_CONV CRTWRAP(fgetc)( FILE *fp )
55{
56 unsigned short sel = RestoreOS2FS();
57 int rc;
58
59 rc = fgetc(fp);
60 SetFS(sel);
61 return rc;
62}
63
64int _LNK_CONV CRTWRAP(fgetpos)( FILE *fp, fpos_t *pos)
65{
66 unsigned short sel = RestoreOS2FS();
67 int rc;
68
69 rc = fgetpos(fp,pos);
70 SetFS(sel);
71 return rc;
72}
73
74char *_LNK_CONV CRTWRAP(fgets)( char *buf, int size, FILE *fp )
75{
76 unsigned short sel = RestoreOS2FS();
77 char * rc;
78
79 rc = fgets(buf, size, fp);
80 SetFS(sel);
81 return rc;
82}
83
84FILE * _LNK_CONV CRTWRAP(fopen)( const char *name, const char *type)
85{
86 unsigned short sel = RestoreOS2FS();
87 FILE * rc;
88
89 rc = fopen(name, type);
90 SetFS(sel);
91 return rc;
92}
93
94int _LNK_CONV CRTWRAP(fputc)( int c, FILE *fp )
95{
96 unsigned short sel = RestoreOS2FS();
97 int rc;
98
99 rc = fputc(c, fp);
100 SetFS(sel);
101 return rc;
102}
103
104int _LNK_CONV CRTWRAP(fputs)( const char *string, FILE *fp )
105{
106 unsigned short sel = RestoreOS2FS();
107 int rc;
108
109 rc = fputs(string, fp);
110 SetFS(sel);
111 return rc;
112}
113
114size_t _LNK_CONV CRTWRAP(fread)( void *buf, size_t size, size_t elsize, FILE *fp )
115{
116 unsigned short sel = RestoreOS2FS();
117 size_t rc;
118
119 rc = fread(buf, size, elsize, fp);
120 SetFS(sel);
121 return rc;
122}
123
124FILE * _LNK_CONV CRTWRAP(freopen)( const char *name, const char *type, FILE *fp )
125{
126 unsigned short sel = RestoreOS2FS();
127 FILE * rc;
128
129 rc = freopen(name, type, fp);
130 SetFS(sel);
131 return rc;
132}
133
134int _LNK_CONV CRTWRAP(fseek)( FILE *fp, long int pos, int type)
135{
136 unsigned short sel = RestoreOS2FS();
137 int rc;
138
139 rc = fseek(fp, pos, type);
140 SetFS(sel);
141 return rc;
142}
143
144int _LNK_CONV CRTWRAP(fsetpos)( FILE *fp, const fpos_t *pos)
145{
146 unsigned short sel = RestoreOS2FS();
147 int rc;
148
149 rc = fsetpos(fp, pos);
150 SetFS(sel);
151 return rc;
152}
153
154long int _LNK_CONV CRTWRAP(ftell)( FILE *fp )
155{
156 unsigned short sel = RestoreOS2FS();
157 long rc;
158
159 rc = ftell(fp);
160 SetFS(sel);
161 return rc;
162}
163
164size_t _LNK_CONV CRTWRAP(fwrite)( const void *buf, size_t size, size_t elsize, FILE *fp )
165{
166 unsigned short sel = RestoreOS2FS();
167 size_t rc;
168
169 rc = fwrite(buf, size, elsize, fp);
170 SetFS(sel);
171 return rc;
172}
173
174int _LNK_CONV CRTWRAP(vfprintf)( FILE *fp, const char *string, __va_list list )
175{
176 unsigned short sel = RestoreOS2FS();
177 int rc;
178
179 rc = vfprintf(fp, string, list);
180 SetFS(sel);
181 return rc;
182}
183
184wint_t _LNK_CONV CRTWRAP(fgetwc)(FILE *fp)
185{
186 unsigned short sel = RestoreOS2FS();
187 wint_t rc;
188
189 rc = fgetwc(fp);
190 SetFS(sel);
191 return rc;
192}
193
194wchar_t * _LNK_CONV CRTWRAP(fgetws)(wchar_t *buf, int size, FILE *fp)
195{
196 unsigned short sel = RestoreOS2FS();
197 wchar_t * rc;
198
199 rc = fgetws(buf, size, fp);
200 SetFS(sel);
201 return rc;
202}
203
204wint_t _LNK_CONV CRTWRAP(fputwc)(wchar_t character, FILE *fp)
205{
206 unsigned short sel = RestoreOS2FS();
207 wint_t rc;
208
209 rc = fputwc(character, fp);
210 SetFS(sel);
211 return rc;
212}
213
214int _LNK_CONV CRTWRAP(fputws)(const wchar_t *string, FILE *fp)
215{
216 unsigned short sel = RestoreOS2FS();
217 int rc;
218
219 rc = fputws(string, fp);
220 SetFS(sel);
221 return rc;
222}
223
224FILE * _LNK_CONV CRTWRAP(fdopen)( int a, const char *bla)
225{
226 unsigned short sel = RestoreOS2FS();
227 FILE *rc;
228
229 rc = _fdopen(a, bla);
230 SetFS(sel);
231 return rc;
232}
233
234
235char * _LNK_CONV CRTWRAP(tmpnam)( char * a)
236{
237 unsigned short sel = RestoreOS2FS();
238 char *rc;
239
240 rc = tmpnam(a);
241 SetFS(sel);
242 return rc;
243}
Note: See TracBrowser for help on using the repository browser.