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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
|
// -*- C++ -*-
//=============================================================================
/**
* @file OS_NS_stdio.h
*
* $Id$
*
* @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
* @author Jesper S. M|ller<stophph@diku.dk>
* @author and a cast of thousands...
*
* Originally in OS.h.
*/
//=============================================================================
#ifndef ACE_OS_NS_STDIO_H
# define ACE_OS_NS_STDIO_H
# include /**/ "ace/pre.h"
# include "ace/config-all.h"
# if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
# endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/os_include/os_stdio.h"
#include "ace/os_include/os_fcntl.h"
#include /**/ "ace/ACE_export.h"
/* OPENVMS needs unistd for cuserid() */
#if defined (CYGWIN32) || defined (ACE_OPENVMS)
# include "ace/os_include/os_unistd.h"
#endif /* CYGWIN32 || ACE_OPENVMS */
#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
# include "io.h"
#endif
#if defined (ACE_EXPORT_MACRO)
# undef ACE_EXPORT_MACRO
#endif
#define ACE_EXPORT_MACRO ACE_Export
/*
* We inline and undef some functions that may be implemented
* as macros on some platforms. This way macro definitions will
* be usable later as there is no way to save the macro definition
* using the pre-processor.
*
*/
inline void ace_clearerr_helper (FILE *stream)
{
#if defined (clearerr)
clearerr (stream);
#undef clearerr
#else
ACE_STD_NAMESPACE::clearerr (stream);
#endif /* defined (clearerr) */
}
inline int ace_fgetc_helper (FILE *fp)
{
#if defined (fgetc)
return fgetc (fp);
#undef fgetc
#else
return ACE_STD_NAMESPACE::fgetc (fp);
#endif /* defined (fgetc) */
}
inline int ace_fputc_helper (int ch, FILE *fp)
{
#if defined (fputc)
return fputc (ch, fp);
#undef fputc
#else
return ACE_STD_NAMESPACE::fputc (ch, fp);
#endif /* defined (fputc) */
}
inline int ace_getc_helper (FILE *fp)
{
#if defined (getc)
return getc (fp);
#undef getc
#else
return ACE_STD_NAMESPACE::getc (fp);
#endif /* defined (getc) */
}
inline int ace_putc_helper (int ch, FILE *fp)
{
#if defined (putc)
return putc (ch, fp);
#undef putc
#else
return ACE_STD_NAMESPACE::putc (ch, fp);
#endif /* defined (putc) */
}
inline int ace_ungetc_helper (int ch, FILE *fp)
{
#if defined (ungetc)
return ungetc (ch, fp);
#undef ungetc
#else
return ACE_STD_NAMESPACE::ungetc (ch, fp);
#endif /* defined (ungetc) */
}
#if !defined ACE_FILENO_EQUIVALENT
inline ACE_HANDLE ace_fileno_helper (FILE *fp)
{
# if defined (fileno)
return (ACE_HANDLE)fileno (fp);
# undef fileno
# else
return (ACE_HANDLE)ACE_STD_NAMESPACE::fileno (fp);
# endif /* defined (fileno) */
}
#endif /* !ACE_FILENO_EQUIVALENT */
#if !defined (ACE_LACKS_CUSERID) && !defined(ACE_HAS_ALT_CUSERID) \
&& !defined(ACE_WIN32) && !defined (ACE_VXWORKS)
/// Helper for the ACE_OS::cuserid() function
/**
* On some platforms cuserid is a macro. Defining ACE_OS::cuserid()
* becomes really hard, as there is no way to save the macro
* definition using the pre-processor.
* This inline function achieves the same effect, without namespace
* pollution or performance penalties.
*
* @todo We maybe should move a lot of the code in ACE_OS::cuserid here so
* it is treated the same as the above ace_difftime and ace_timezone.
* But since there is a good deal more code in ACE_OS::cuserid, we
* probably need to move some of it off into some sort of emulation
* function.
*/
inline char *ace_cuserid(char *user)
{
return cuserid(user);
}
#endif /* !ACE_LACKS_CUSERID && !ACE_HAS_ALT_CUSERID && ... */
# if defined (ACE_LACKS_FILELOCKS)
# if ! defined (ACE_VXWORKS) && ! defined (ACE_HAS_RTEMS) && !defined (INTEGRITY)
// VxWorks defines struct flock in sys/fcntlcom.h. But it doesn't
// appear to support flock (). RTEMS defines struct flock but
// currently does not support locking.
struct flock
{
short l_type;
short l_whence;
ACE_OFF_T l_start;
ACE_OFF_T l_len; /* len == 0 means until end of file */
long l_sysid;
pid_t l_pid;
long l_pad[4]; /* reserve area */
};
# endif /* ! VXWORKS */
# endif /* ACE_LACKS_FILELOCKS */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
namespace ACE_OS {
/**
* @class ace_flock_t
*
* @brief OS file locking structure.
*/
class ACE_Export ace_flock_t
{
public:
/// Dump state of the object.
void dump (void) const;
# if defined (ACE_WIN32)
ACE_OVERLAPPED overlapped_;
# else
struct flock lock_;
# endif /* ACE_WIN32 */
/// Name of this filelock.
const ACE_TCHAR *lockname_;
/// Handle to the underlying file.
ACE_HANDLE handle_;
};
# if defined (ACE_USES_WCHAR)
// If fp points to the Unicode format file, the file pointer will be moved right next
// to the Unicode header (2 types). Otherwise, file pointer will be at the beginning.
extern ACE_Export
void checkUnicodeFormat (FILE* fp);
# endif // ACE_USES_WCHAR
ACE_NAMESPACE_INLINE_FUNCTION
void clearerr (FILE* fp);
//@{ @name Wrappers to obtain the current user id
// Legacy as per SUSV3
# if !defined (ACE_LACKS_CUSERID)
# if defined(cuserid)
# undef cuserid
# endif /* cuserid */
ACE_NAMESPACE_INLINE_FUNCTION
char *cuserid (char *user,
size_t maxlen = ACE_MAX_USERID);
# if defined (ACE_HAS_WCHAR)
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t *cuserid (wchar_t *user,
size_t maxlen = ACE_MAX_USERID);
# endif /* ACE_HAS_WCHAR */
# endif /* ACE_LACKS_CUSERID */
//@}
extern ACE_Export
int asprintf (char **bufp, const char* format, ...)
ACE_GCC_FORMAT_ATTRIBUTE (printf, 2, 3);
# if defined (ACE_HAS_WCHAR)
extern ACE_Export
int asprintf (wchar_t **bufp, const wchar_t* format, ...);
#endif /* ACE_HAS_WCHAR */
ACE_NAMESPACE_INLINE_FUNCTION
int fclose (FILE *fp);
ACE_NAMESPACE_INLINE_FUNCTION
FILE *fdopen (ACE_HANDLE handle, const ACE_TCHAR *mode);
ACE_NAMESPACE_INLINE_FUNCTION
int fflush (FILE *fp);
ACE_NAMESPACE_INLINE_FUNCTION
int fgetc (FILE* fp);
ACE_NAMESPACE_INLINE_FUNCTION
int getc (FILE* fp);
ACE_NAMESPACE_INLINE_FUNCTION
int fgetpos (FILE* fp, fpos_t* pos);
ACE_NAMESPACE_INLINE_FUNCTION
char *fgets (char *buf, int size, FILE *fp);
# if defined (ACE_HAS_WCHAR) && !defined(ACE_LACKS_FGETWS)
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t *fgets (wchar_t *buf, int size, FILE *fp);
# endif /* ACE_HAS_WCHAR && !ACE_LACKS_FGETWS */
//@{ @name A set of wrappers for file locks.
# if defined (ACE_WIN32)
ACE_NAMESPACE_INLINE_FUNCTION
void flock_adjust_params (ace_flock_t *lock,
short whence,
ACE_OFF_T &start,
ACE_OFF_T &len);
# endif /* ACE_WIN32 */
ACE_NAMESPACE_INLINE_FUNCTION
int flock_init (ace_flock_t *lock,
int flags = 0,
const ACE_TCHAR *name = 0,
mode_t perms = 0);
ACE_NAMESPACE_INLINE_FUNCTION
int flock_destroy (ace_flock_t *lock,
int unlink_file = 1);
ACE_NAMESPACE_INLINE_FUNCTION
int flock_rdlock (ace_flock_t *lock,
short whence = 0,
ACE_OFF_T start = 0,
ACE_OFF_T len = 0);
ACE_NAMESPACE_INLINE_FUNCTION
int flock_tryrdlock (ace_flock_t *lock,
short whence = 0,
ACE_OFF_T start = 0,
ACE_OFF_T len = 0);
ACE_NAMESPACE_INLINE_FUNCTION
int flock_trywrlock (ace_flock_t *lock,
short whence = 0,
ACE_OFF_T start = 0,
ACE_OFF_T len = 0);
ACE_NAMESPACE_INLINE_FUNCTION
int flock_unlock (ace_flock_t *lock,
short whence = 0,
ACE_OFF_T start = 0,
ACE_OFF_T len = 0);
ACE_NAMESPACE_INLINE_FUNCTION
int flock_wrlock (ace_flock_t *lock,
short whence = 0,
ACE_OFF_T start = 0,
ACE_OFF_T len = 0);
//@}
ACE_NAMESPACE_INLINE_FUNCTION
ACE_HANDLE fileno (FILE *stream);
#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
extern ACE_Export
#else
ACE_NAMESPACE_INLINE_FUNCTION
#endif /* ACE_WIN32 */
FILE *fopen (const char *filename, const char *mode);
#if defined (ACE_HAS_WCHAR)
#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
extern ACE_Export
#else
ACE_NAMESPACE_INLINE_FUNCTION
#endif /* ACE_WIN32 */
FILE *fopen (const char *filename, const wchar_t *mode);
# if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
extern ACE_Export
# else
ACE_NAMESPACE_INLINE_FUNCTION
# endif /* ACE_WIN32 */
FILE *fopen (const wchar_t *filename, const wchar_t *mode);
# if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
extern ACE_Export
# else
ACE_NAMESPACE_INLINE_FUNCTION
# endif /* ACE_WIN32 */
FILE *fopen (const wchar_t *filename, const char *mode);
#endif /* ACE_HAS_WCHAR */
#if defined (ACE_WIN32)
/// Default Win32 Security Attributes definition.
ACE_NAMESPACE_INLINE_FUNCTION
LPSECURITY_ATTRIBUTES default_win32_security_attributes (LPSECURITY_ATTRIBUTES);
ACE_NAMESPACE_INLINE_FUNCTION
LPSECURITY_ATTRIBUTES default_win32_security_attributes_r (LPSECURITY_ATTRIBUTES,
LPSECURITY_ATTRIBUTES,
SECURITY_DESCRIPTOR*);
// = Win32 OS version determination function.
/// Return the win32 OSVERSIONINFO structure.
ACE_NAMESPACE_INLINE_FUNCTION
const ACE_TEXT_OSVERSIONINFO &get_win32_versioninfo (void);
// = A pair of functions for modifying ACE's Win32 resource usage.
/// Return the handle of the module containing ACE's resources. By
/// default, for a DLL build of ACE this is a handle to the ACE DLL
/// itself, and for a static build it is a handle to the executable.
ACE_NAMESPACE_INLINE_FUNCTION
HINSTANCE get_win32_resource_module (void);
/// Allow an application to modify which module contains ACE's
/// resources. This is mainly useful for a static build of ACE where
/// the required resources reside somewhere other than the executable.
ACE_NAMESPACE_INLINE_FUNCTION
void set_win32_resource_module (HINSTANCE);
extern ACE_Export ACE_TEXT_OSVERSIONINFO win32_versioninfo_;
extern ACE_Export HINSTANCE win32_resource_module_;
#endif /* ACE_WIN32 */
extern ACE_Export
int fprintf (FILE *fp, const char *format, ...)
ACE_GCC_FORMAT_ATTRIBUTE (printf, 2, 3);
# if defined (ACE_HAS_WCHAR)
extern ACE_Export
int fprintf (FILE *fp, const wchar_t *format, ...);
# endif /* ACE_HAS_WCHAR */
ACE_NAMESPACE_INLINE_FUNCTION
int ungetc (int c,
FILE *fp);
ACE_NAMESPACE_INLINE_FUNCTION
int fputc (int c,
FILE *fp);
ACE_NAMESPACE_INLINE_FUNCTION
int putc (int c,
FILE *fp);
ACE_NAMESPACE_INLINE_FUNCTION
int fputs (const char *s,
FILE *stream);
# if defined (ACE_HAS_WCHAR) && !defined(ACE_LACKS_FPUTWS)
ACE_NAMESPACE_INLINE_FUNCTION
int fputs (const wchar_t *s,
FILE *stream);
# endif /* ACE_HAS_WCHAR && !ACE_LACKS_FPUTWS */
ACE_NAMESPACE_INLINE_FUNCTION
size_t fread (void *ptr,
size_t size,
size_t nelems,
FILE *fp);
ACE_NAMESPACE_INLINE_FUNCTION
FILE *freopen (const ACE_TCHAR *filename,
const ACE_TCHAR *mode,
FILE* stream);
ACE_NAMESPACE_INLINE_FUNCTION
int fseek (FILE *fp,
long offset,
int ptrname);
ACE_NAMESPACE_INLINE_FUNCTION
int fsetpos (FILE* fp, fpos_t* pos);
ACE_NAMESPACE_INLINE_FUNCTION
long ftell (FILE* fp);
ACE_NAMESPACE_INLINE_FUNCTION
size_t fwrite (const void *ptr,
size_t size,
size_t nitems,
FILE *fp);
ACE_NAMESPACE_INLINE_FUNCTION
void perror (const char *s);
#if defined (ACE_HAS_WCHAR)
ACE_NAMESPACE_INLINE_FUNCTION
void perror (const wchar_t *s);
#endif /* ACE_HAS_WCHAR */
extern ACE_Export
int printf (const char *format, ...)
ACE_GCC_FORMAT_ATTRIBUTE (printf, 1, 2);
#if defined (ACE_HAS_WCHAR)
extern ACE_Export
int printf (const wchar_t *format, ...);
#endif
ACE_NAMESPACE_INLINE_FUNCTION
int puts (const char *s);
#if defined (ACE_HAS_WCHAR)
ACE_NAMESPACE_INLINE_FUNCTION
int puts (const wchar_t *s);
#endif /* ACE_HAS_WCHAR */
ACE_NAMESPACE_INLINE_FUNCTION
int rename (const char *old_name,
const char *new_name,
int flags = -1);
#if defined (ACE_HAS_WCHAR)
ACE_NAMESPACE_INLINE_FUNCTION
int rename (const wchar_t *old_name,
const wchar_t *new_name,
int flags = -1);
#endif /* ACE_HAS_WCHAR */
ACE_NAMESPACE_INLINE_FUNCTION
void rewind (FILE *fp);
extern ACE_Export
int snprintf (char *buf, size_t maxlen, const char *format, ...)
ACE_GCC_FORMAT_ATTRIBUTE (printf, 3, 4);
# if defined (ACE_HAS_WCHAR)
extern ACE_Export
int snprintf (wchar_t *buf, size_t maxlen, const wchar_t *format, ...);
# endif /* ACE_HAS_WCHAR */
extern ACE_Export
int sprintf (char *buf, const char *format, ...)
ACE_GCC_FORMAT_ATTRIBUTE (printf, 2, 3);
# if defined (ACE_HAS_WCHAR)
extern ACE_Export
int sprintf (wchar_t *buf, const wchar_t *format, ...);
# endif /* ACE_HAS_WCHAR */
ACE_NAMESPACE_INLINE_FUNCTION
char *tempnam (const char *dir = 0,
const char *pfx = 0);
#if defined (ACE_HAS_WCHAR)
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t *tempnam (const wchar_t *dir,
const wchar_t *pfx = 0);
#endif /* ACE_HAS_WCHAR */
ACE_NAMESPACE_INLINE_FUNCTION
int vasprintf (char **bufp, const char *format, va_list argptr)
ACE_GCC_FORMAT_ATTRIBUTE (printf, 2, 0);
ACE_NAMESPACE_INLINE_FUNCTION
int vprintf (const char *format, va_list argptr)
ACE_GCC_FORMAT_ATTRIBUTE (printf, 1, 0);
ACE_NAMESPACE_INLINE_FUNCTION
int vfprintf (FILE *fp, const char *format, va_list argptr)
ACE_GCC_FORMAT_ATTRIBUTE (printf, 2, 0);
ACE_NAMESPACE_INLINE_FUNCTION
int vsprintf (char *buffer, const char *format, va_list argptr)
ACE_GCC_FORMAT_ATTRIBUTE (printf, 2, 0);
ACE_NAMESPACE_INLINE_FUNCTION
int vsnprintf (char *buffer, size_t maxlen, const char *format, va_list argptr)
ACE_GCC_FORMAT_ATTRIBUTE (printf, 3, 0);
# if defined (ACE_HAS_WCHAR)
ACE_NAMESPACE_INLINE_FUNCTION
int vasprintf (wchar_t **bufp, const wchar_t *format, va_list argptr);
ACE_NAMESPACE_INLINE_FUNCTION
int vprintf (const wchar_t *format, va_list argptr);
ACE_NAMESPACE_INLINE_FUNCTION
int vfprintf (FILE *fp, const wchar_t *format, va_list argptr);
ACE_NAMESPACE_INLINE_FUNCTION
int vsprintf (wchar_t *buffer, const wchar_t *format, va_list argptr);
ACE_NAMESPACE_INLINE_FUNCTION
int vsnprintf (wchar_t *buffer, size_t maxlen, const wchar_t *format, va_list argptr);
# endif /* ACE_HAS_WCHAR */
#if !defined (ACE_HAS_VASPRINTF)
extern ACE_Export
int vasprintf_emulation (char **bufp, const char *format, va_list argptr);
#endif /* !ACE_HAS_VASPRINTF */
#if defined (ACE_HAS_WCHAR)
#if !defined (ACE_HAS_VASWPRINTF)
extern ACE_Export
int vaswprintf_emulation (wchar_t **bufp, const wchar_t *format, va_list argptr);
#endif /* !ACE_HAS_VASWPRINTF */
#endif /* ACE_HAS_WCHAR */
} /* namespace ACE_OS */
ACE_END_VERSIONED_NAMESPACE_DECL
# if defined (ACE_HAS_INLINED_OSCALLS)
# if defined (ACE_INLINE)
# undef ACE_INLINE
# endif /* ACE_INLINE */
# define ACE_INLINE inline
# include "ace/OS_NS_stdio.inl"
# endif /* ACE_HAS_INLINED_OSCALLS */
# include /**/ "ace/post.h"
#endif /* ACE_OS_NS_STDIO_H */
|