stdio.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright (c) mlibc & plct lab
  3. *
  4. * SPDX-License-Identifier: MIT
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2023/06/16 bernard the first verison
  9. */
  10. #ifndef MLIBC_STDIO_H__
  11. #define MLIBC_STDIO_H__
  12. #include <sys/types.h>
  13. #include <stdarg.h>
  14. #include <stddef.h>
  15. #define _FILE_IND_EOF (1 << 0)
  16. #define _FILE_IND_ERROR (1 << 1)
  17. #define _IOFBF 0
  18. #define _IOLBF 1
  19. #define _IONBF 2
  20. #define BUFSIZ 128 /* buffer size */
  21. #define EOF (-1) /* end-of-file descriptor */
  22. #ifndef SEEK_SET
  23. #define SEEK_SET 0 /* set file offset to offset */
  24. #endif
  25. #ifndef SEEK_CUR
  26. #define SEEK_CUR 1 /* set file offset to current plus offset */
  27. #endif
  28. #ifndef SEEK_END
  29. #define SEEK_END 2 /* set file offset to EOF plus offset */
  30. #endif
  31. #define CHAR_BIT 8
  32. #define UCHAR_MAX 255
  33. struct __MLIBC_IO_FILE;
  34. typedef struct __MLIBC_IO_FILE FILE;
  35. extern FILE* stdin;
  36. extern FILE* stdout;
  37. extern FILE* stderr;
  38. /* File open and close */
  39. int fclose(FILE *);
  40. FILE *fdopen(int, const char *);
  41. FILE *fopen(const char *, const char *);
  42. FILE *freopen(const char *, const char *, FILE *);
  43. /* Formatted I/O status */
  44. int printf(const char *, ...);
  45. void perror(const char *);
  46. int scanf(const char *, ...);
  47. int snprintf(char *, size_t, const char *, ...);
  48. int sprintf(char *, const char *, ...);
  49. int sscanf(const char *, const char *, ...);
  50. int vfprintf(FILE *, const char *, va_list);
  51. int vfscanf(FILE *, const char *, va_list);
  52. int vprintf(const char *, va_list);
  53. int vscanf(const char *, va_list);
  54. int vsnprintf(char *, size_t, const char *, va_list);
  55. int vsprintf(char *, const char *, va_list);
  56. int vsscanf(const char *, const char *, va_list);
  57. /* File read and write operations */
  58. int feof(FILE *);
  59. int ferror(FILE *);
  60. int fflush(FILE *);
  61. int fgetc(FILE *);
  62. char *fgets(char *, int, FILE *);
  63. int fileno(FILE *);
  64. void flockfile(FILE *);
  65. int fprintf(FILE *, const char *, ...);
  66. int fputc(int, FILE *);
  67. int fputs(const char *, FILE *);
  68. size_t fread(void *, size_t, size_t, FILE *);
  69. size_t fwrite(const void *, size_t, size_t, FILE *);
  70. int ftrylockfile(FILE *);
  71. void funlockfile(FILE *);
  72. int getc(FILE *);
  73. int getc_unlocked(FILE *);
  74. int getchar(void);
  75. int getchar_unlocked(void);
  76. char *gets(char *);
  77. int putc(int, FILE *);
  78. int putc_unlocked(int, FILE *);
  79. int putchar(int);
  80. int putchar_unlocked(int);
  81. int puts(const char *);
  82. int ungetc(int, FILE *);
  83. int libc_stdio_set_console(const char* device_name, int mode);
  84. int libc_stdio_get_console(void);
  85. extern char **__environ;
  86. void __env_rm_add(char *old, char *new);
  87. int __putenv(char *s, size_t l, char *r);
  88. int putenv(char *s);
  89. char *getenv(const char *name);
  90. int setenv(const char *var, const char *value, int overwrite);
  91. int unsetenv(const char *name);
  92. int rename(const char *oldpath, const char *newpath);
  93. #endif /*MLIBC_STDIO_H__*/