source: trunk/src/odincrt/file.cpp

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

Updates

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