2
0

stdio.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. #ifndef _SFSTDIO_H
  2. #define _SFSTDIO_H 1
  3. /********************************************************************************
  4. * This product contains certain software code or other information *
  5. * ("AT&T Software") proprietary to AT&T Corp. ("AT&T"). *
  6. * The AT&T Software is provided to you "AS IS". YOU ASSUME TOTAL *
  7. * RESPONSIBILITY AND RISK FOR USE OF THE AT&T SOFTWARE. *
  8. * AT&T DOES NOT MAKE, AND EXPRESSLY DISCLAIMS, ANY EXPRESS OR *
  9. * IMPLIED WARRANTIES OF ANY KIND WHATSOEVER, INCLUDING, *
  10. * WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY OR *
  11. * FITNESS FOR A PARTICULAR PURPOSE, WARRANTIES OF TITLE OR *
  12. * NON-INFRINGEMENT OF ANY INTELLECTUAL PROPERTY RIGHTS, *
  13. * ANY WARRANTIES ARISING BY USAGE OF TRADE, COURSE OF DEALING OR *
  14. * COURSE OF PERFORMANCE, OR ANY WARRANTY THAT THE AT&T SOFTWARE *
  15. * IS "ERROR FREE" OR WILL MEET YOUR REQUIREMENTS. *
  16. * *
  17. * All rights reserved. AT&T is a registered trademark of AT&T Corp. *
  18. ********************************************************************************/
  19. /*This is modifyed SFIO include file.
  20. To use it on Solaris platforms just copy it to sfio include directory.
  21. Konstantin Kuznetsov. 29 mar 2006 */
  22. #define BUFSIZ SF_BUFSIZE
  23. #define _FILEDEFED
  24. /* need for solaris 9*/
  25. #undef FILE
  26. #define FILE Sfio_t
  27. #include <sfio_t.h>
  28. #include <stdarg.h>
  29. #define _IOFBF 0
  30. #define _IONBF 1
  31. #define _IOLBF 2
  32. #define L_ctermid 32
  33. #define L_cuserid 32
  34. #define P_tmpdir "/tmp/"
  35. #define L_tmpnam (sizeof(P_tmpdir)+32)
  36. #undef fpos_t
  37. #define fpos_t Sfoff_t
  38. #undef off_t
  39. #define off_t Sfoff_t
  40. _BEGIN_EXTERNS_
  41. #if _BLD_sfio && defined(__EXPORT__)
  42. #define extern __EXPORT__
  43. #endif
  44. #if !_BLD_sfio && defined(__IMPORT__) && defined(__EXPORT__)
  45. #define extern __IMPORT__
  46. #endif
  47. extern char* ctermid _ARG_((char*));
  48. extern char* cuserid _ARG_((char*));
  49. extern char* tmpnam _ARG_((char*));
  50. extern char* tempnam _ARG_((const char*, const char*));
  51. #ifndef remove
  52. extern int remove _ARG_((const char*));
  53. #endif
  54. extern void perror _ARG_((const char*));
  55. extern Sfio_t* _stdfdopen _ARG_((int, const char*));
  56. extern Sfio_t* _stdfopen _ARG_((const char*, const char*));
  57. extern Sfio_t* _stdfreopen _ARG_((const char*, const char*, Sfio_t*));
  58. extern Sfio_t* _stdpopen _ARG_((const char*, const char*));
  59. extern Sfio_t* _stdtmpfile _ARG_((void));
  60. extern int _stdprintf _ARG_((const char*, ...));
  61. extern int _stdfprintf _ARG_((Sfio_t* f, const char*, ...));
  62. extern int _stdsprintf _ARG_((char*, const char*, ...));
  63. extern int _stdscanf _ARG_((const char*, ...));
  64. extern int _stdfscanf _ARG_((Sfio_t* f, const char*, ...));
  65. extern int _stdsetvbuf _ARG_((Sfio_t*, char*, int, size_t));
  66. extern int _stdfputc _ARG_((int, Sfio_t*));
  67. extern int _stdfgetc _ARG_((Sfio_t*));
  68. extern int _stdputw _ARG_((int, Sfio_t*));
  69. extern int _stdgetw _ARG_((Sfio_t*));
  70. extern ssize_t _stdfwrite _ARG_((const Void_t*, size_t, size_t, Sfio_t*));
  71. extern ssize_t _stdfread _ARG_((Void_t*, size_t, size_t, Sfio_t*));
  72. extern char* _stdgets _ARG_((Sfio_t*, char*, int n, int isgets));
  73. extern int _stdfflush _ARG_((FILE *));
  74. #undef extern
  75. _END_EXTERNS_
  76. #define _STDSIZE(s) (sizeof(s) != sizeof(char*) ? sizeof(s) : BUFSIZ)
  77. #define printf _stdprintf
  78. #define fprintf _stdfprintf
  79. #define sprintf _stdsprintf
  80. #define snprintf sfsprintf
  81. #define vsnprintf sfvsprintf
  82. #define scanf _stdscanf
  83. #define fscanf _stdfscanf
  84. #define sscanf sfsscanf
  85. #define fdopen _stdfdopen
  86. #define fopen _stdfopen
  87. #define popen _stdpopen
  88. #define freopen _stdfreopen
  89. #define tmpfile _stdtmpfile
  90. #define setvbuf _stdsetvbuf
  91. #define putw _stdputw
  92. #define fputc _stdfputc
  93. #define fputc_unlocked _stdfputc
  94. #define fwrite _stdfwrite
  95. #define fwrite_unlocked _stdfwrite
  96. #define getw _stdgetw
  97. #define fgetc _stdfgetc
  98. #define fgetc_unlocked _stdfgetc
  99. #define fread _stdfread
  100. #define fread_unlocked _stdfread
  101. #define _std_fclose(f) sfclose(f)
  102. #define _std_pclose(f) sfclose(f)
  103. #define _std_flockfile(f) sfmutex((f), SFMTX_LOCK)
  104. #define _std_ftrylockfile(f) sfmutex((f), SFMTX_TRYLOCK)
  105. #define _std_funlockfile(f) sfmutex((f), SFMTX_UNLOCK)
  106. #define _std_putc(c,f) sfputc((f),(c))
  107. #define _std_putchar(c) sfputc(sfstdout,(c))
  108. #define _std_fputs(s,f) sfputr((f),(s),-1)
  109. #define _std_puts(s) sfputr(sfstdout,(s),'\n')
  110. #define _std_vprintf(fmt,a) sfvprintf(sfstdout,(fmt),(a))
  111. #define _std_vfprintf(f,fmt,a) sfvprintf((f),(fmt),(a))
  112. #define _std_doprnt(fmt,a,f) sfvprintf((f),(fmt),(a))
  113. #define _std_vsprintf(s,fmt,a) sfvsprintf((s),_STDSIZE(s),(fmt),(a) )
  114. #define _std_getc(f) sfgetc(f)
  115. #define _std_getchar() sfgetc(sfstdin)
  116. #define _std_ungetc(c,f) sfungetc((f),(c))
  117. #define _std_fgets(s,n,f) _stdgets((f),(s),(n),0)
  118. #define _std_gets(s) _stdgets(sfstdin,(s),_STDSIZE(s),1)
  119. #define _std_vscanf(fmt,a) sfvscanf(sfstdin,(fmt),(a))
  120. #define _std_vfscanf(f,fmt,a) sfvscanf((f),(fmt),(a))
  121. #define _std_doscan(f,fmt,a) sfvscanf((f),(fmt),(a))
  122. #define _std_vsscanf(s,fmt,a) sfvsscanf(s,(fmt),(a))
  123. #define _std_fpurge(f) sfpurge(f)
  124. #define _std_fflush(f) _stdfflush(f)
  125. #define _std_rewind(f) (sfseek((f), (Sfoff_t)0, SEEK_SET|SF_SHARE), sfclrerr(f) )
  126. #define _std_fseek(f,o,t) (sfseek((f), (Sfoff_t)(o), (t)|SF_SHARE) < 0 ? -1 : 0 )
  127. #define _std_ftell(f) ((long)sfseek((f), (Sfoff_t)0, SEEK_CUR) )
  128. #define _std_fgetpos(f,p) ((*(p) = _std_ftell(f)) >= 0 ? 0 : -1 )
  129. #define _std_fsetpos(f,p) (sfseek((f), *(p), SEEK_SET|SF_SHARE) != *(p) ? -1 : 0 )
  130. #define _std_fseeko(f,o,t) (sfseek((f), (Sfoff_t)(o), (t)|SF_SHARE) < 0 ? -1 : 0 )
  131. #define _std_ftello(f) ((off_t)sfseek((f), (Sfoff_t)0, SEEK_CUR) )
  132. #define _std_setbuf(f,b) (sfsetbuf((f),(b),(b) ? BUFSIZ : 0) )
  133. #define _std_setbuffer(f,b,n) (sfsetbuf((f),(b),(n)) ? 0 : -1)
  134. #define _std_setlinebuf(f) sfset((f),SF_LINE,1)
  135. #define _std_fileno(f) sffileno(f)
  136. #define _std_feof(f) sfeof(f)
  137. #define _std_ferror(f) sferror(f)
  138. #define _std_clearerr(f) (sfclrlock(f), sfclrerr(f) )
  139. #if defined(__INLINE__) && !_BLD_sfio
  140. __INLINE__ int fclose(FILE* f) { return _std_fclose(f); }
  141. __INLINE__ int pclose(FILE* f) { return _std_pclose(f); }
  142. __INLINE__ void flockfile(FILE* f) { (void) _std_flockfile(f); }
  143. __INLINE__ int ftrylockfile(FILE* f) { return _std_ftrylockfile(f); }
  144. __INLINE__ void funlockfile(FILE* f) { (void) _std_funlockfile(f); }
  145. __INLINE__ int putc(int c, FILE* f) { return _std_putc(c,f); }
  146. __INLINE__ int putc_unlocked(int c, FILE* f) { return _std_putc(c,f); }
  147. __INLINE__ int putchar(int c) { return _std_putchar(c); }
  148. __INLINE__ int putchar_unlocked(int c) { return _std_putchar(c); }
  149. __INLINE__ int fputs(const char* s, FILE* f) { return _std_fputs(s,f); }
  150. __INLINE__ int fputs_unlocked(const char* s, FILE* f) { return _std_fputs(s,f); }
  151. __INLINE__ int puts(const char* s) { return _std_puts(s); }
  152. __INLINE__ int puts_unlocked(const char* s) { return _std_puts(s); }
  153. __INLINE__ int vprintf(const char* fmt, va_list a) { return _std_vprintf(fmt,a); }
  154. __INLINE__ int vfprintf(Sfio_t* f, const char* fmt, va_list a)
  155. { return _std_vfprintf(f,fmt,a);}
  156. __INLINE__ int _doprnt(const char* fmt, va_list a, FILE* f)
  157. { return _std_doprnt(fmt,a,f); }
  158. __INLINE__ int vsprintf(char* s, const char* fmt, va_list a)
  159. { return _std_vsprintf(s,fmt,a);}
  160. __INLINE__ int getc(FILE* f) { return _std_getc(f); }
  161. __INLINE__ int getc_unlocked(FILE* f) { return _std_getc(f); }
  162. __INLINE__ int getchar(void) { return _std_getchar(); }
  163. __INLINE__ int getchar_unlocked(void) { return _std_getchar(); }
  164. __INLINE__ int ungetc(int c, FILE* f) { return _std_ungetc(c,f); }
  165. __INLINE__ char* fgets(char* s, int n, FILE* f) { return _std_fgets(s,n,f); }
  166. __INLINE__ char* fgets_unlocked(char* s, int n, FILE* f){ return _std_fgets(s,n,f); }
  167. __INLINE__ char* gets_unlocked(char* s) { return _std_gets(s); }
  168. __INLINE__ int vscanf(const char* fmt, va_list a) { return _std_vscanf(fmt,a); }
  169. __INLINE__ int vfscanf(Sfio_t* f, const char* fmt, va_list a)
  170. { return _std_vfscanf(f,fmt,a); }
  171. __INLINE__ int _doscan(Sfio_t* f, const char* fmt, va_list a)
  172. { return _std_doscan(f,fmt,a); }
  173. __INLINE__ int vsscanf(char* s, const char* fmt, va_list a)
  174. { return _std_vsscanf(s,fmt,a); }
  175. __INLINE__ int fpurge(FILE* f) { return _std_fpurge(f); }
  176. __INLINE__ int fflush(FILE* f) { return _std_fflush(f); }
  177. __INLINE__ int fflush_unlocked(FILE* f) { return _std_fflush(f); }
  178. __INLINE__ void rewind(FILE* f) { (void) _std_rewind(f); }
  179. __INLINE__ int fseek(FILE* f, long o, int t) { return _std_fseek(f,o,t); }
  180. __INLINE__ long ftell(FILE* f) { return _std_ftell(f); }
  181. __INLINE__ int fsetpos(FILE* f, fpos_t* pos) { return _std_fsetpos(f,pos); }
  182. __INLINE__ int fgetpos(FILE* f, fpos_t* pos) { return _std_fgetpos(f,pos); }
  183. __INLINE__ int fseeko(FILE* f, off_t o, int t) { return _std_fseeko(f,o,t); }
  184. __INLINE__ off_t ftello(FILE* f) { return _std_ftello(f); }
  185. __INLINE__ void setbuf(FILE* f, char* b) { (void) _std_setbuf(f,b); }
  186. __INLINE__ int setbuffer(FILE* f, char* b, int n) { return _std_setbuffer(f,b,n); }
  187. __INLINE__ int setlinebuf(FILE* f) { return _std_setlinebuf(f); }
  188. __INLINE__ int fileno(FILE* f) { return _std_fileno(f); }
  189. __INLINE__ int feof(FILE* f) { return _std_feof(f); }
  190. __INLINE__ int feof_unlocked(FILE* f) { return _std_feof(f); }
  191. __INLINE__ int ferror(FILE* f) { return _std_ferror(f); }
  192. __INLINE__ int ferror_unlocked(FILE* f) { return _std_ferror(f); }
  193. __INLINE__ void clearerr(FILE* f) { (void) _std_clearerr(f); }
  194. __INLINE__ void clearerr_unlocked(FILE* f) { (void) _std_clearerr(f); }
  195. __INLINE__ char * gets(char* f) { return _std_gets(f);}
  196. #else
  197. #define fclose(f) ( _std_fclose(f) )
  198. #define pclose(f) ( _std_pclose(f) )
  199. #define flockfile(f) ( _std_flockfile(f) )
  200. #define ftrylockfile(f) ( _std_ftrylockfile(f) )
  201. #define funlockfile(f) ( _std_funlockfile(f) )
  202. #define putc(c,f) ( _std_putc(c,f) )
  203. #define putc_unlocked(c,f) ( _std_putc(c,f) )
  204. #define putchar(c) ( _std_putchar(c) )
  205. #define putchar_unlocked(c) ( _std_putchar(c) )
  206. #define fputs(s,f) ( _std_fputs(s,f) )
  207. #define fputs_unlocked(s,f) ( _std_fputs(s,f) )
  208. #define puts(s) ( _std_puts(s) )
  209. #define puts_unlocked (s) ( _std_puts(s) )
  210. #define vprintf(fmt,a) ( _std_vprintf(fmt,a) )
  211. #define vfprintf(f,fmt,a) ( _std_vfprintf(f,fmt,a) )
  212. #define _doprnt(fmt,a,f) ( _std_doprnt(fmt,a,f) )
  213. #define vsprintf(s,fmt,a) ( _std_vsprintf(s,fmt,a) )
  214. #define getc(f) ( _std_getc(f) )
  215. #define getc_unlocked(f) ( _std_getc(f) )
  216. #define getchar() ( _std_getchar() )
  217. #define getchar_unlocked() ( _std_getchar() )
  218. #define ungetc(c,f) ( _std_ungetc(c,f) )
  219. #define fgets(s,n,f) ( _std_fgets(s,n,f) )
  220. #define fgets_unlocked(s,n,f) ( _std_fgets(s,n,f) )
  221. #define gets(s) ( _std_gets(s) )
  222. #define gets_unlocked(s) ( _std_gets(s) )
  223. #define vscanf(fmt,a) ( _std_vscanf(fmt,a) )
  224. #define vfscanf(f,fmt,a) ( _std_vfscanf(f,fmt,a) )
  225. #define vsscanf(s,fmt,a) ( _std_vsscanf(s,fmt,a) )
  226. #define fpurge(f) ( _std_fpurge(f) )
  227. #define fflush(f) ( _std_fflush(f) )
  228. #define fflush_unlocked(f) ( _std_fflush(f) )
  229. #define rewind(f) ( (void)_std_rewind(f) )
  230. #define fseek(f,o,t) ( _std_fseek(f,o,t) )
  231. #define ftell(f) ( _std_ftell(f) )
  232. #define fgetpos(f,pos) ( _std_fgetpos(f,pos) )
  233. #define fsetpos(f,pos) ( _std_fsetpos(f,pos) )
  234. #define fseeko(f,o,t) ( _std_fseeko(f,o,t) )
  235. #define ftello(f) ( _std_ftello(f) )
  236. #define setbuf(f,b) ( (void)_std_setbuf(f,b) )
  237. #define setbuffer(f,b,n) ( _std_setbuffer(f,b,n) )
  238. #define setlinebuf(f) ( _std_setlinebuf(f) )
  239. #define fileno(f) ( _std_fileno(f) )
  240. #define feof(f) ( _std_feof(f) )
  241. #define feof_unlocked(f) ( _std_feof(f) )
  242. #define ferror(f) ( _std_ferror(f) )
  243. #define ferror_unlocked(f) ( _std_ferror(f) )
  244. #define clearerr(f) ( (void)_std_clearerr(f) )
  245. #define clearerr_unlocked(f) ( (void)_std_clearerr(f) )
  246. #endif
  247. /* standard streams */
  248. #ifdef SF_FILE_STRUCT
  249. #define sfstdin (&_Sfstdin)
  250. #define sfstdout (&_Sfstdout)
  251. #define sfstderr (&_Sfstderr)
  252. #endif
  253. #define stdin sfstdin
  254. #define stdout sfstdout
  255. #define stderr sfstderr
  256. #endif /* _SFSTDIO_H */