stdio.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #define _STDIO_H // Make GMP believe we exist.
  8. #include <Kernel/API/POSIX/stdio.h>
  9. #include <bits/FILE.h>
  10. #include <limits.h>
  11. #include <stdarg.h>
  12. #include <sys/cdefs.h>
  13. #include <sys/types.h>
  14. #define FILENAME_MAX 1024
  15. #define FOPEN_MAX 1024
  16. __BEGIN_DECLS
  17. #ifndef EOF
  18. # define EOF (-1)
  19. #endif
  20. #define _IOFBF 0
  21. #define _IOLBF 1
  22. #define _IONBF 2
  23. #define L_ctermid 9
  24. #define L_tmpnam 256
  25. #define P_tmpdir "/tmp"
  26. extern FILE* stdin;
  27. extern FILE* stdout;
  28. extern FILE* stderr;
  29. typedef off_t fpos_t;
  30. int fseek(FILE*, long offset, int whence);
  31. int fseeko(FILE*, off_t offset, int whence);
  32. int fgetpos(FILE*, fpos_t*);
  33. int fsetpos(FILE*, fpos_t const*);
  34. long ftell(FILE*);
  35. off_t ftello(FILE*);
  36. char* fgets(char* buffer, int size, FILE*);
  37. int fputc(int ch, FILE*);
  38. int fileno(FILE*);
  39. int fgetc(FILE*);
  40. int fgetc_unlocked(FILE*);
  41. int getc(FILE*);
  42. int getc_unlocked(FILE* stream);
  43. int getchar(void);
  44. ssize_t getdelim(char**, size_t*, int, FILE*);
  45. ssize_t getline(char**, size_t*, FILE*);
  46. int ungetc(int c, FILE*);
  47. int remove(char const* pathname);
  48. FILE* fdopen(int fd, char const* mode);
  49. FILE* fopen(char const* pathname, char const* mode);
  50. FILE* freopen(char const* pathname, char const* mode, FILE*);
  51. FILE* fmemopen(void* buf, size_t size, char const* mode);
  52. void flockfile(FILE* filehandle);
  53. void funlockfile(FILE* filehandle);
  54. int fclose(FILE*);
  55. void rewind(FILE*);
  56. void clearerr(FILE*);
  57. int ferror(FILE*);
  58. int feof(FILE*);
  59. int fflush(FILE*);
  60. size_t fread(void* ptr, size_t size, size_t nmemb, FILE*);
  61. size_t fread_unlocked(void* ptr, size_t size, size_t nmemb, FILE*);
  62. size_t fwrite(void const* ptr, size_t size, size_t nmemb, FILE*);
  63. int vprintf(char const* fmt, va_list) __attribute__((format(printf, 1, 0)));
  64. int vfprintf(FILE*, char const* fmt, va_list) __attribute__((format(printf, 2, 0)));
  65. int vasprintf(char** strp, char const* fmt, va_list) __attribute__((format(printf, 2, 0)));
  66. int vsprintf(char* buffer, char const* fmt, va_list) __attribute__((format(printf, 2, 0)));
  67. int vsnprintf(char* buffer, size_t, char const* fmt, va_list) __attribute__((format(printf, 3, 0)));
  68. int fprintf(FILE*, char const* fmt, ...) __attribute__((format(printf, 2, 3)));
  69. int printf(char const* fmt, ...) __attribute__((format(printf, 1, 2)));
  70. void dbgputstr(char const*, size_t);
  71. int sprintf(char* buffer, char const* fmt, ...) __attribute__((format(printf, 2, 3)));
  72. int asprintf(char** strp, char const* fmt, ...) __attribute__((format(printf, 2, 3)));
  73. int snprintf(char* buffer, size_t, char const* fmt, ...) __attribute__((format(printf, 3, 4)));
  74. int putchar(int ch);
  75. int putc(int ch, FILE*);
  76. int puts(char const*);
  77. int fputs(char const*, FILE*);
  78. void perror(char const*);
  79. int scanf(char const* fmt, ...) __attribute__((format(scanf, 1, 2)));
  80. int sscanf(char const* str, char const* fmt, ...) __attribute__((format(scanf, 2, 3)));
  81. int fscanf(FILE*, char const* fmt, ...) __attribute__((format(scanf, 2, 3)));
  82. int vscanf(char const*, va_list) __attribute__((format(scanf, 1, 0)));
  83. int vfscanf(FILE*, char const*, va_list) __attribute__((format(scanf, 2, 0)));
  84. int vsscanf(char const*, char const*, va_list) __attribute__((format(scanf, 2, 0)));
  85. int setvbuf(FILE*, char* buf, int mode, size_t);
  86. void setbuf(FILE*, char* buf);
  87. void setlinebuf(FILE*);
  88. int rename(char const* oldpath, char const* newpath);
  89. int renameat(int olddirfd, char const* oldpath, int newdirfd, char const* newpath);
  90. FILE* tmpfile(void);
  91. char* tmpnam(char*);
  92. FILE* popen(char const* command, char const* type);
  93. int pclose(FILE*);
  94. char* ctermid(char* s);
  95. __END_DECLS