stdio.h 5.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef __STDIO
  2. #define __STDIO
  3. #ifndef KERNEL_NEW
  4. #include <default.h>
  5. #endif
  6. /* Begin Auto-Generated Part */
  7. #define EOF (-1)
  8. #define NULL ((void*)0)
  9. #define TMP_MAX 152587890625
  10. #ifndef __HAVE_size_t
  11. #define __HAVE_size_t
  12. typedef unsigned long size_t;
  13. #endif
  14. #ifndef __HAVE_va_list
  15. #define __HAVE_va_list
  16. typedef void*va_list;
  17. #endif
  18. typedef struct{char*fpos;void*base;unsigned short handle;short flags;short unget;unsigned long alloc;unsigned short buffincrement;}FILE;
  19. enum FileFlags{_F_READ=0x0001,_F_WRIT=0x0002,_F_RDWR=0x0003,_F_ERR=0x0010,_F_EOF=0x0020,_F_BIN=0x0040};
  20. typedef unsigned long fpos_t;
  21. enum SeekModes{SEEK_SET,SEEK_CUR,SEEK_END};
  22. typedef CALLBACK void(*vcbprintf_Callback_t)(char c,void**param);
  23. typedef CALLBACK short(*vcbscanf_get_Callback_t)(void*param);
  24. typedef CALLBACK short(*vcbscanf_unget_Callback_t)(void*param);
  25. extern void cbprintf(vcbprintf_Callback_t,void**,const char*,...)__ATTR_TIOS__;
  26. extern short cbscanf(vcbscanf_get_Callback_t asm("a0"),vcbscanf_unget_Callback_t asm("a1"),void* asm("a2"),const char* asm("a3"),...)__ATTR_LIB_ASM__;
  27. #define clearerr(f) ((void)(((f)->flags)&=~(_F_EOF|_F_ERR)))
  28. extern void clrscr(void)__ATTR_LIB_ASM__;
  29. extern short fclose(FILE*)__ATTR_LIB_C__;
  30. #define feof(f) (((f)->flags)&_F_EOF)
  31. #define ferror(f) (((f)->flags)&_F_ERR)
  32. #define fflush(f) ((f)->unget=0)
  33. extern short fgetc(FILE*)__ATTR_LIB_C__;
  34. extern short fgetchar(void)__ATTR_LIB_ASM__;
  35. #define fgetpos(f,p) (((long)((*(p)=ftell(f))))==EOF)
  36. extern char *fgets(char*,short,FILE*)__ATTR_LIB_C__;
  37. extern FILE *fopen(const char*,const char*)__ATTR_LIB_C__;
  38. extern short fprintf(FILE*,const char*,...)__ATTR_TIOS__;
  39. extern short fputc(short,FILE*)__ATTR_TIOS_CALLBACK__;
  40. extern short fputchar(short)__ATTR_TIOS_CALLBACK__;
  41. extern short fputs(const char*,FILE*)__ATTR_LIB_ASM__;
  42. extern unsigned short fread(void*,short,short,FILE*)__ATTR_LIB_C__;
  43. #define freopen(n,m,f) (fclose(f),(f)=fopen((n),(m)),(f))
  44. #define fscanf(__file__,__format__...) cbscanf((vcbscanf_get_Callback_t)__fscanf_get,(vcbscanf_unget_Callback_t)__fscanf_unget,(void*)(__file__),__format__)
  45. extern short fseek(FILE*,long,short)__ATTR_LIB_C__;
  46. extern void fsetbufsize(short,FILE*)__ATTR_LIB_C__;
  47. #define fsetpos(f,p) fseek((f),*(p),SEEK_SET)
  48. extern long ftell(const FILE*)__ATTR_LIB_C__;
  49. extern unsigned short fwrite(const void*,short,short,FILE*)__ATTR_LIB_C__;
  50. #define getc fgetc
  51. #define getchar fgetchar
  52. extern char *gets(char* asm("a2"))__ATTR_LIB_ASM__;
  53. extern char *getsn(char* asm("a2"),long asm("d3"))__ATTR_LIB_ASM__;
  54. #define printf_xy(x,y,f...) ({char __s[200];_rom_call_attr(short,(char*,const char*,...),__attribute__((__format__(__printf__,2,3))),53)(__s ,##f);_rom_call(void,(short,short,const char*,short),1A9)(x,y,__s,4);})
  55. extern void printf(const char*,...)__ATTR_TIOS__;
  56. #define putc fputc
  57. #define putchar fputchar
  58. extern void puts(const char*)__ATTR_LIB_ASM__;
  59. #define remove unlink
  60. extern short rename(const char*,const char*)__ATTR_LIB_C__;
  61. #define rewind(f) ((void)({FILE*__file1__=(f);fseek(__file1__,0,SEEK_SET);__file1__->flags&=~_F_ERR;}))
  62. #define scanf(__format__...) ({long __maxbuflen=(_rom_call(unsigned long,(void),9C))()-2;(__maxbuflen>0)?({char*__inputbuf=(_rom_call(void*,(long),A2))(__maxbuflen);getsn(__inputbuf,__maxbuflen);short __result=sscanf(__inputbuf,__format__);(_rom_call(void,(void*),A3))(__inputbuf);__result;}):0;})
  63. #define sprintf _rom_call_attr(short,(char*,const char*,...),__attribute__((__format__(__printf__,2,3))),53)
  64. #define sscanf(__buffer__,__format__...) ({__sscanf_string __param__={(__buffer__),0};cbscanf((vcbscanf_get_Callback_t)__sscanf_get,(vcbscanf_unget_Callback_t)__sscanf_unget,&__param__,__format__);})
  65. #define strerror _rom_call(char*,(short),27D)
  66. extern void strputchar(char,void**)__ATTR_TIOS_CALLBACK__;
  67. extern char *tmpnam(char*)__ATTR_LIB_C__;
  68. #define ungetc(c,f) ((f)->unget=((c)|0x8000))
  69. extern short unlink(const char*)__ATTR_LIB_C__;
  70. #define vcbprintf ({register long __a=32+(long)(_rom_call_addr(53));(__vcbprintf__type__)(__a+*(short*)__a);})
  71. extern short vcbscanf(vcbscanf_get_Callback_t asm("a0"),vcbscanf_unget_Callback_t asm("a1"),void* asm("a2"),const char* asm("a3"),va_list asm("a4"))__ATTR_LIB_ASM__;
  72. #define vfprintf(s,f,a) vcbprintf((vcbprintf_Callback_t)fputc,(void**)(s),(f),(a))
  73. #define vfscanf(__file__,__format__,__arglist__) vcbscanf((vcbscanf_get_Callback_t)__fscanf_get,(vcbscanf_unget_Callback_t)__fscanf_unget,(void*)(__file__),(__format__),(__arglist__))
  74. #define vprintf(f,a) vcbprintf((vcbprintf_Callback_t)fputchar,NULL,(f),(a))
  75. #define vscanf(__format__,__arglist__) ({long __maxbuflen=(_rom_call(unsigned long,(void),9C))()-2;(__maxbuflen>0)?({char*__inputbuf=(_rom_call(void*,(long),A2))(__maxbuflen);getsn(__inputbuf,__maxbuflen);short __result=vsscanf(__inputbuf,(__format__),(__arglist__));(_rom_call(void,(void*),A3))(__inputbuf);__result;}):0;})
  76. #define vsprintf(b,f,a) ((void)({void*__p=(b);vcbprintf((vcbprintf_Callback_t)strputchar,&__p,(f),(a));*(char*)__p=0;}))
  77. #define vsscanf(__buffer__,__format__,__arglist__) ({__sscanf_string __param__={(__buffer__),0};vcbscanf((vcbscanf_get_Callback_t)__sscanf_get,(vcbscanf_unget_Callback_t)__sscanf_unget,&__param__,(__format__),(__arglist__));})
  78. /* End Auto-Generated Part */
  79. #define __FERROR(f) ({(f)->flags|=_F_ERR; return EOF;})
  80. typedef void(*__vcbprintf__type__)(vcbprintf_Callback_t,void**,const char*,void*)__ATTR_TIOS__;
  81. CALLBACK short __fscanf_get(FILE *param);
  82. CALLBACK void __fscanf_unget(short c, FILE *param);
  83. typedef struct {const char *buffer; unsigned short pos;} __sscanf_string;
  84. CALLBACK short __sscanf_get(__sscanf_string *param);
  85. CALLBACK void __sscanf_unget(short c, __sscanf_string *param);
  86. #endif