1
0

stdio.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * stdio.h
  3. *
  4. * Copyright (C) 2017 Aleksandar Andrejevic <theflash@sdf.lonestar.org>
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as
  8. * published by the Free Software Foundation, either version 3 of the
  9. * License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef _STDIO_H_
  20. #define _STDIO_H_
  21. #include <mlcrt.h>
  22. #include <stdlib.h>
  23. #include <stdarg.h>
  24. #define EOF -1
  25. struct __CRT_PRIVATE(file);
  26. typedef struct __CRT_PRIVATE(file) FILE;
  27. extern FILE *__CRT_PUBLIC(stdin);
  28. extern FILE *__CRT_PUBLIC(stdout);
  29. extern FILE *__CRT_PUBLIC(stderr);
  30. int __CRT_PUBLIC(fgetc)(FILE *stream);
  31. int __CRT_PUBLIC(fputc)(int c, FILE *stream);
  32. char *__CRT_PUBLIC(fgets)(char *s, int size, FILE *stream);
  33. int __CRT_PUBLIC(fputs)(const char *s, FILE *stream);
  34. int __CRT_PUBLIC(ungetc)(int c, FILE *stream);
  35. char *__CRT_PUBLIC(gets)(char *s);
  36. int __CRT_PUBLIC(puts)(const char *s);
  37. static inline int __CRT_PUBLIC(getc)(FILE *stream)
  38. {
  39. return __CRT_PUBLIC(fgetc)(stream);
  40. }
  41. static inline int __CRT_PUBLIC(getchar)(void)
  42. {
  43. return __CRT_PUBLIC(fgetc)(__CRT_PUBLIC(stdin));
  44. }
  45. static inline int __CRT_PUBLIC(putc)(int c, FILE *stream)
  46. {
  47. return __CRT_PUBLIC(fputc)(c, stream);
  48. }
  49. static inline int __CRT_PUBLIC(putchar)(int c)
  50. {
  51. return __CRT_PUBLIC(fputc)(c, __CRT_PUBLIC(stdout));
  52. }
  53. int __CRT_PUBLIC(fgetc_unlocked)(FILE *stream);
  54. int __CRT_PUBLIC(fputc_unlocked)(int c, FILE *stream);
  55. char *__CRT_PUBLIC(fgets_unlocked)(char *s, int size, FILE *stream);
  56. int __CRT_PUBLIC(fputs_unlocked)(const char *s, FILE *stream);
  57. static inline int __CRT_PUBLIC(getc_unlocked)(FILE *stream)
  58. {
  59. return __CRT_PUBLIC(fgetc_unlocked)(stream);
  60. }
  61. static inline int __CRT_PUBLIC(getchar_unlocked)(void)
  62. {
  63. return __CRT_PUBLIC(fgetc_unlocked)(__CRT_PUBLIC(stdin));
  64. }
  65. static inline int __CRT_PUBLIC(putc_unlocked)(int c, FILE *stream)
  66. {
  67. return __CRT_PUBLIC(fputc_unlocked)(c, stream);
  68. }
  69. static inline int __CRT_PUBLIC(putchar_unlocked)(int c)
  70. {
  71. return __CRT_PUBLIC(fputc)(c, __CRT_PUBLIC(stdout));
  72. }
  73. FILE *__CRT_PUBLIC(fopen)(const char *pathname, const char *mode);
  74. FILE *__CRT_PUBLIC(fdopen)(int fd, const char *mode);
  75. FILE *__CRT_PUBLIC(fmemopen)(void *buf, size_t size, const char *mode);
  76. int __CRT_PUBLIC(fclose)(FILE *stream);
  77. #define BUFSIZ 4096
  78. #define _IOFBF 0
  79. #define _IOLBF 1
  80. #define _IONBF 2
  81. int __CRT_PUBLIC(setvbuf)(FILE *stream, char *buf, int mode, size_t size);
  82. void __CRT_PUBLIC(setbuf)(FILE *stream, char *buf);
  83. void __CRT_PUBLIC(setbuffer)(FILE *stream, char *buf, size_t size);
  84. void __CRT_PUBLIC(setlinebuf)(FILE *stream);
  85. int __CRT_PUBLIC(printf)(const char *format, ...);
  86. int __CRT_PUBLIC(fprintf)(FILE *stream, const char *format, ...);
  87. int __CRT_PUBLIC(dprintf)(int fd, const char *format, ...);
  88. int __CRT_PUBLIC(sprintf)(char *str, const char *format, ...);
  89. int __CRT_PUBLIC(snprintf)(char *str, size_t size, const char *format, ...);
  90. int __CRT_PUBLIC(vprintf)(const char *format, va_list ap);
  91. int __CRT_PUBLIC(vfprintf)(FILE *stream, const char *format, va_list ap);
  92. int __CRT_PUBLIC(vdprintf)(int fd, const char *format, va_list ap);
  93. int __CRT_PUBLIC(vsprintf)(char *str, const char *format, va_list ap);
  94. int __CRT_PUBLIC(vsnprintf)(char *str, size_t size, const char *format, va_list ap);
  95. #endif