c_stdio.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #ifndef _C_STDIO_H_
  2. #define _C_STDIO_H_
  3. #define __need_size_t
  4. #include "c_stddef.h"
  5. #include "osapi.h"
  6. // #include "driver/uart.h"
  7. // #define __need___va_list
  8. //#include "c_stdarg.h"
  9. //struct __sFILE{
  10. // int _r; /* read space left for getc() */
  11. // int _w; /* write space left for putc() */
  12. //};
  13. // typedef struct __sFILE __FILE;
  14. // typedef __FILE FILE;
  15. extern int c_stdin;
  16. extern int c_stdout;
  17. extern int c_stderr;
  18. // #define _IOFBF 0 /* setvbuf should set fully buffered */
  19. // #define _IOLBF 1 /* setvbuf should set line buffered */
  20. // #define _IONBF 2 /* setvbuf should set unbuffered */
  21. // #ifndef NULL
  22. // #define NULL 0
  23. // #endif
  24. #define EOF (-1)
  25. #ifdef __BUFSIZ__
  26. #define BUFSIZ __BUFSIZ__
  27. #else
  28. #define BUFSIZ 1024
  29. #endif
  30. #ifndef SEEK_SET
  31. #define SEEK_SET 0 /* set file offset to offset */
  32. #endif
  33. #ifndef SEEK_CUR
  34. #define SEEK_CUR 1 /* set file offset to current plus offset */
  35. #endif
  36. #ifndef SEEK_END
  37. #define SEEK_END 2 /* set file offset to EOF plus offset */
  38. #endif
  39. // #define c_malloc os_malloc
  40. // #define c_zalloc os_zalloc
  41. // #define c_free os_free
  42. extern void output_redirect(const char *str);
  43. #define c_puts output_redirect
  44. // #define c_printf os_printf
  45. // int c_printf(const char *c, ...);
  46. #if defined( LUA_NUMBER_INTEGRAL )
  47. #define c_sprintf os_sprintf
  48. #else
  49. #include "c_stdarg.h"
  50. int c_sprintf(char* s,const char *fmt, ...);
  51. #endif
  52. extern void dbg_printf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
  53. #define c_vsprintf ets_vsprintf
  54. #define c_printf(...) do { \
  55. unsigned char __print_buf[BUFSIZ]; \
  56. c_sprintf(__print_buf, __VA_ARGS__); \
  57. c_puts(__print_buf); \
  58. } while(0)
  59. // #define c_getc ets_getc
  60. // #define c_getchar ets_getc
  61. // note: contact esp to ensure the real getchar function..
  62. // FILE *c_fopen(const char *_name, const char *_type);
  63. // FILE *c_freopen(const char *, const char *, FILE *);
  64. // FILE *c_tmpfile(void);
  65. // int c_putchar(int);
  66. // int c_printf(const char *, ...);
  67. // int c_sprintf(char *, const char *, ...);
  68. // int c_getc(FILE *);
  69. // int c_ungetc(int, FILE *);
  70. // int c_fprintf(FILE *, const char *, ...);
  71. // int c_fscanf(FILE *, const char *, ...);
  72. // int c_fclose(FILE *);
  73. // int c_fflush(FILE *);
  74. // int c_setvbuf(FILE *, char *, int, size_t);
  75. // void c_clearerr(FILE *);
  76. // int c_fseek(FILE *, long, int);
  77. // long c_ftell( FILE *);
  78. // int c_fputs(const char *, FILE *);
  79. // char *c_fgets(char *, int, FILE *);
  80. // size_t c_fread(void *, size_t _size, size_t _n, FILE *);
  81. // size_t c_fwrite(const void * , size_t _size, size_t _n, FILE *);
  82. // int c_feof(FILE *);
  83. // int c_ferror(FILE *);
  84. #endif /* _C_STDIO_H_ */