libc.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //Libc fudge, mainly for windows.
  2. #ifndef BB_LIB_C_H
  3. #define BB_LIB_C_H
  4. #include <stdio.h>
  5. #include <string.h>
  6. #include <stdlib.h>
  7. #include <time.h>
  8. #include <limits.h>
  9. #include <sys/stat.h>
  10. #include <sys/types.h>
  11. #if _WIN32
  12. #include <windows.h>
  13. #include <wchar.h>
  14. #define PATH_MAX 260
  15. #if _MSC_VER
  16. typedef int mode_t;
  17. #endif
  18. struct dirent{
  19. char *d_name;
  20. };
  21. struct DIR;
  22. typedef struct tm tm_t;
  23. typedef struct _stat stat_t;
  24. const wchar_t *widen_utf8( const char *p );
  25. const char *narrow_utf8( const wchar_t *w );
  26. FILE *fopen_utf8( const char *path,char const *mode );
  27. int fputs_utf8( const char *str,FILE *stream );
  28. int remove_utf8( const char *path );
  29. int rename_utf8( const char *oldpath,const char *newpath );
  30. int puts_utf8( const char *str );
  31. int setenv_utf8( const char *name,const char *value,int overwrite );
  32. char *getenv_utf8( const char *name );
  33. int system_utf8( const char *cmd );
  34. char *realpath_utf8( const char *path,char *resolved_path );
  35. int mkdir_utf8( const char *path,int mode );
  36. int gettimeofday_utf8( timeval *tv );
  37. char *getcwd_utf8( char *buf,int size );
  38. int chdir_utf8( const char *path );
  39. int rmdir_utf8( const char *path );
  40. int stat_utf8( const char *path,stat_t *buf );
  41. DIR *opendir_utf8( const char *path );
  42. dirent *readdir_utf8( DIR *dir );
  43. void closedir_utf8( DIR *dir );
  44. #else
  45. #include <unistd.h>
  46. #include <dirent.h>
  47. #include <sys/time.h>
  48. typedef struct tm tm_t;
  49. typedef struct stat stat_t;
  50. #define fopen_utf8 fopen
  51. #define fputs_utf8 fputs
  52. #define remove_utf8 remove
  53. #define rename_utf8 rename
  54. #define puts_utf8 puts
  55. #define setenv_utf8 setenv
  56. #define getenv_utf8 getenv
  57. #define system_utf8 system
  58. #define realpath_utf8 realpath
  59. #define mkdir_utf8 mkdir
  60. #define gettimeofday_utf8 gettimeofday
  61. #define getcwd_utf8 getcwd
  62. #define chdir_utf8 chdir
  63. #define rmdir_utf8 rmdir
  64. #define stat_utf8 stat
  65. #define opendir_utf8 opendir
  66. #define readdir_utf8 readdir
  67. #define closedir_utf8 closedir
  68. #endif
  69. #endif
  70. /*
  71. #include <stdio.h>
  72. #include <string.h>
  73. #include <stdlib.h>
  74. #include <sys/types.h>
  75. #include <sys/stat.h>
  76. #include <time.h>
  77. #include <limits.h>
  78. #if _MSC_VER
  79. #include <direct.h>
  80. #include <winsock2.h> //for struct timeval?!?
  81. #include "dirent_msvc.h"
  82. typedef int mode_t;
  83. #else
  84. #include <unistd.h>
  85. #include <dirent.h>
  86. #include <sys/time.h>
  87. #endif
  88. #if _WIN32
  89. #define PATH_MAX 260
  90. #define realpath(X,Y) _fullpath( (Y),(X),PATH_MAX )
  91. #else
  92. #include <limits.h>
  93. #endif
  94. typedef struct tm tm_t;
  95. typedef struct stat stat_t;
  96. int system_( const char *command );
  97. void setenv_( const char *name,const char *value,int overwrite );
  98. int mkdir_( const char *path,int mode );
  99. int gettimeofday_( timeval *tv );
  100. #endif
  101. */