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

Last change on this file since 5280 was 3164, checked in by sandervl, 25 years ago

Fixed FS wrapper for _fdopen & others in file.cpp

File size: 3.9 KB
Line 
1/* $Id: file.cpp,v 1.3 2000-03-19 11:04: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#include <stdio.h>
11#include <os2sel.h>
12#include <wchar.h>
13
14int _LNK_CONV os2_fclose( FILE *fp )
15{
16 unsigned short sel = RestoreOS2FS();
17 int rc;
18
19 rc = fclose(fp);
20 SetFS(sel);
21 return rc;
22}
23
24int _LNK_CONV os2_feof( FILE *fp )
25{
26 unsigned short sel = RestoreOS2FS();
27 int rc;
28
29 rc = feof(fp);
30 SetFS(sel);
31 return rc;
32}
33int _LNK_CONV os2_ferror( FILE *fp )
34{
35 unsigned short sel = RestoreOS2FS();
36 int rc;
37
38 rc = ferror(fp);
39 SetFS(sel);
40 return rc;
41}
42
43int _LNK_CONV os2_fflush( FILE *fp )
44{
45 unsigned short sel = RestoreOS2FS();
46 int rc;
47
48 rc = fflush(fp);
49 SetFS(sel);
50 return rc;
51}
52
53int _LNK_CONV os2_fgetc( FILE *fp )
54{
55 unsigned short sel = RestoreOS2FS();
56 int rc;
57
58 rc = fgetc(fp);
59 SetFS(sel);
60 return rc;
61}
62
63int _LNK_CONV os2_fgetpos( FILE *fp, fpos_t *pos)
64{
65 unsigned short sel = RestoreOS2FS();
66 int rc;
67
68 rc = fgetpos(fp,pos);
69 SetFS(sel);
70 return rc;
71}
72
73char *_LNK_CONV os2_fgets( char *buf, int size, FILE *fp )
74{
75 unsigned short sel = RestoreOS2FS();
76 char * rc;
77
78 rc = fgets(buf, size, fp);
79 SetFS(sel);
80 return rc;
81}
82
83FILE * _LNK_CONV os2_fopen( const char *name, const char *type)
84{
85 unsigned short sel = RestoreOS2FS();
86 FILE * rc;
87
88 rc = fopen(name, type);
89 SetFS(sel);
90 return rc;
91}
92
93int _LNK_CONV os2_fputc( int c, FILE *fp )
94{
95 unsigned short sel = RestoreOS2FS();
96 int rc;
97
98 rc = fputc(c, fp);
99 SetFS(sel);
100 return rc;
101}
102
103int _LNK_CONV os2_fputs( const char *string, FILE *fp )
104{
105 unsigned short sel = RestoreOS2FS();
106 int rc;
107
108 rc = fputs(string, fp);
109 SetFS(sel);
110 return rc;
111}
112
113size_t _LNK_CONV os2_fread( void *buf, size_t size, size_t elsize, FILE *fp )
114{
115 unsigned short sel = RestoreOS2FS();
116 size_t rc;
117
118 rc = fread(buf, size, elsize, fp);
119 SetFS(sel);
120 return rc;
121}
122
123FILE * _LNK_CONV os2_freopen( const char *name, const char *type, FILE *fp )
124{
125 unsigned short sel = RestoreOS2FS();
126 FILE * rc;
127
128 rc = freopen(name, type, fp);
129 SetFS(sel);
130 return rc;
131}
132
133int _LNK_CONV os2_fseek( FILE *fp, long int pos, int type)
134{
135 unsigned short sel = RestoreOS2FS();
136 int rc;
137
138 rc = fseek(fp, pos, type);
139 SetFS(sel);
140 return rc;
141}
142
143int _LNK_CONV os2_fsetpos( FILE *fp, const fpos_t *pos)
144{
145 unsigned short sel = RestoreOS2FS();
146 int rc;
147
148 rc = fsetpos(fp, pos);
149 SetFS(sel);
150 return rc;
151}
152
153long int _LNK_CONV os2_ftell( FILE *fp )
154{
155 unsigned short sel = RestoreOS2FS();
156 long rc;
157
158 rc = ftell(fp);
159 SetFS(sel);
160 return rc;
161}
162
163size_t _LNK_CONV os2_fwrite( const void *buf, size_t size, size_t elsize, FILE *fp )
164{
165 unsigned short sel = RestoreOS2FS();
166 size_t rc;
167
168 rc = fwrite(buf, size, elsize, fp);
169 SetFS(sel);
170 return rc;
171}
172
173int _LNK_CONV os2_vfprintf( FILE *fp, const char *string, __va_list list )
174{
175 unsigned short sel = RestoreOS2FS();
176 int rc;
177
178 rc = vfprintf(fp, string, list);
179 SetFS(sel);
180 return rc;
181}
182
183wint_t _LNK_CONV os2_fgetwc(FILE *fp)
184{
185 unsigned short sel = RestoreOS2FS();
186 wint_t rc;
187
188 rc = fgetwc(fp);
189 SetFS(sel);
190 return rc;
191}
192
193wchar_t * _LNK_CONV os2_fgetws(wchar_t *buf, int size, FILE *fp)
194{
195 unsigned short sel = RestoreOS2FS();
196 wchar_t * rc;
197
198 rc = fgetws(buf, size, fp);
199 SetFS(sel);
200 return rc;
201}
202
203wint_t _LNK_CONV os2_fputwc(wchar_t character, FILE *fp)
204{
205 unsigned short sel = RestoreOS2FS();
206 wint_t rc;
207
208 rc = fputwc(character, fp);
209 SetFS(sel);
210 return rc;
211}
212
213int _LNK_CONV os2_fputws(const wchar_t *string, FILE *fp)
214{
215 unsigned short sel = RestoreOS2FS();
216 int rc;
217
218 rc = fputws(string, fp);
219 SetFS(sel);
220 return rc;
221}
222
223FILE * _LNK_CONV os2_fdopen( int a, const char *bla)
224{
225 unsigned short sel = RestoreOS2FS();
226 FILE *rc;
227
228 rc = _fdopen(a, bla);
229 SetFS(sel);
230 return rc;
231}
232
Note: See TracBrowser for help on using the repository browser.