stdio.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 <bits/FILE.h>
  9. #include <limits.h>
  10. #include <stdarg.h>
  11. #include <sys/cdefs.h>
  12. #include <sys/types.h>
  13. #define FILENAME_MAX 1024
  14. __BEGIN_DECLS
  15. #ifndef EOF
  16. # define EOF (-1)
  17. #endif
  18. #define SEEK_SET 0
  19. #define SEEK_CUR 1
  20. #define SEEK_END 2
  21. #define _IOFBF 0
  22. #define _IOLBF 1
  23. #define _IONBF 2
  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*, const fpos_t*);
  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();
  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(const char* pathname);
  48. FILE* fdopen(int fd, const char* mode);
  49. FILE* fopen(const char* pathname, const char* mode);
  50. FILE* freopen(const char* pathname, const char* mode, FILE*);
  51. void flockfile(FILE* filehandle);
  52. void funlockfile(FILE* filehandle);
  53. int fclose(FILE*);
  54. void rewind(FILE*);
  55. void clearerr(FILE*);
  56. int ferror(FILE*);
  57. int feof(FILE*);
  58. int fflush(FILE*);
  59. size_t fread(void* ptr, size_t size, size_t nmemb, FILE*);
  60. size_t fread_unlocked(void* ptr, size_t size, size_t nmemb, FILE*);
  61. size_t fwrite(const void* ptr, size_t size, size_t nmemb, FILE*);
  62. int vprintf(const char* fmt, va_list) __attribute__((format(printf, 1, 0)));
  63. int vfprintf(FILE*, const char* fmt, va_list) __attribute__((format(printf, 2, 0)));
  64. int vasprintf(char** strp, const char* fmt, va_list) __attribute__((format(printf, 2, 0)));
  65. int vsprintf(char* buffer, const char* fmt, va_list) __attribute__((format(printf, 2, 0)));
  66. int vsnprintf(char* buffer, size_t, const char* fmt, va_list) __attribute__((format(printf, 3, 0)));
  67. int fprintf(FILE*, const char* fmt, ...) __attribute__((format(printf, 2, 3)));
  68. int printf(const char* fmt, ...) __attribute__((format(printf, 1, 2)));
  69. void dbgputch(char);
  70. void dbgputstr(const char*, size_t);
  71. int sprintf(char* buffer, const char* fmt, ...) __attribute__((format(printf, 2, 3)));
  72. int asprintf(char** strp, const char* fmt, ...) __attribute__((format(printf, 2, 3)));
  73. int snprintf(char* buffer, size_t, const char* fmt, ...) __attribute__((format(printf, 3, 4)));
  74. int putchar(int ch);
  75. int putc(int ch, FILE*);
  76. int puts(const char*);
  77. int fputs(const char*, FILE*);
  78. void perror(const char*);
  79. int scanf(const char* fmt, ...) __attribute__((format(scanf, 1, 2)));
  80. int sscanf(const char* str, const char* fmt, ...) __attribute__((format(scanf, 2, 3)));
  81. int fscanf(FILE*, const char* fmt, ...) __attribute__((format(scanf, 2, 3)));
  82. int vscanf(const char*, va_list) __attribute__((format(scanf, 1, 0)));
  83. int vfscanf(FILE*, const char*, va_list) __attribute__((format(scanf, 2, 0)));
  84. int vsscanf(const char*, const char*, 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(const char* oldpath, const char* newpath);
  89. FILE* tmpfile();
  90. char* tmpnam(char*);
  91. FILE* popen(const char* command, const char* type);
  92. int pclose(FILE*);
  93. __END_DECLS