| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
Ü |
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#ifndef _USUAL_BASE_WIN32_H_ |
| 20 |
#define _USUAL_BASE_WIN32_H_ |
| 21 |
|
| 22 |
#include <winsock2.h> |
| 23 |
#include <windows.h> |
| 24 |
|
| 25 |
#include <io.h> |
| 26 |
#include <process.h> |
| 27 |
|
| 28 |
#ifndef ECONNABORTED |
| 29 |
#define ECONNABORTED WSAECONNABORTED |
| 30 |
#endif |
| 31 |
#ifndef EMSGSIZE |
| 32 |
#define EMSGSIZE WSAEMSGSIZE |
| 33 |
#endif |
| 34 |
#ifndef EINPROGRESS |
| 35 |
#define EINPROGRESS WSAEWOULDBLOCK |
| 36 |
#endif |
| 37 |
#ifndef SHUT_RDWR |
| 38 |
#define SHUT_RDWR SD_BOTH |
| 39 |
#endif |
| 40 |
#ifndef ENOTCONN |
| 41 |
#define ENOTCONN WSAENOTCONN |
| 42 |
#endif |
| 43 |
#ifndef ECONNRESET |
| 44 |
#define ECONNRESET WSAECONNRESET |
| 45 |
#endif |
| 46 |
|
| 47 |
#undef EAGAIN |
| 48 |
#define EAGAIN WSAEWOULDBLOCK |
| 49 |
|
| 50 |
#ifndef EAFNOSUPPORT |
| 51 |
#define EAFNOSUPPORT ENOSYS |
| 52 |
#endif |
| 53 |
|
| 54 |
#ifndef AI_ADDRCONFIG |
| 55 |
#define AI_ADDRCONFIG 0 |
| 56 |
#endif |
| 57 |
|
| 58 |
|
| 59 |
#define hstrerror strerror |
| 60 |
#define getuid() (6667) |
| 61 |
#define setsid() getpid() |
| 62 |
#define setgid(x) (-1) |
| 63 |
#define setuid(x) (-1) |
| 64 |
#define fork() (errno = ENOSYS, -1) |
| 65 |
#define geteuid() getuid() |
| 66 |
static inline int setgroups(int ngroups, const gid_t *gidsets) { errno = EINVAL; return -1; } |
| 67 |
#define chown(f, u, g) (-1) |
| 68 |
|
| 69 |
#define srandom(s) srand(s) |
| 70 |
#define random() rand() |
| 71 |
|
| 72 |
#ifdef _MSC_VER |
| 73 |
|
| 74 |
#define snprintf(fmt, ...) _snprintf(fmt, __VA_ARGS__) |
| 75 |
|
| 76 |
static inline int strcasecmp(const char *a, const char *b) |
| 77 |
{ |
| 78 |
return _stricmp(a, b); |
| 79 |
} |
| 80 |
|
| 81 |
static inline int strncasecmp(const char *a, const char *b, size_t cnt) |
| 82 |
{ |
| 83 |
return _strnicmp(a, b, cnt); |
| 84 |
} |
| 85 |
|
| 86 |
typedef int ssize_t; |
| 87 |
|
| 88 |
#endif |
| 89 |
|
| 90 |
|
| 91 |
#define RLIMIT_NOFILE -1 |
| 92 |
struct rlimit { |
| 93 |
int rlim_cur; |
| 94 |
int rlim_max; |
| 95 |
}; |
| 96 |
static inline int getrlimit(int res, struct rlimit *dst) |
| 97 |
{ |
| 98 |
dst->rlim_cur = dst->rlim_max = -1; |
| 99 |
return 0; |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
struct passwd { |
| 104 |
char *pw_name; |
| 105 |
char *pw_passwd; |
| 106 |
uid_t pw_uid; |
| 107 |
pid_t pw_gid; |
| 108 |
char *pw_gecos; |
| 109 |
char *pw_dir; |
| 110 |
char *pw_shell; |
| 111 |
}; |
| 112 |
static inline struct passwd *getpwnam(const char *u) { return NULL; } |
| 113 |
static inline struct passwd *getpwuid(uid_t uid) { return NULL; } |
| 114 |
|
| 115 |
|
| 116 |
struct group { |
| 117 |
char *gr_name; |
| 118 |
char *gr_passwd; |
| 119 |
gid_t gr_gid; |
| 120 |
char **gr_mem; |
| 121 |
}; |
| 122 |
static inline struct group *getgrnam(const char *g) { return NULL; } |
| 123 |
static inline struct group *getgrgid(gid_t gid) { return NULL; } |
| 124 |
|
| 125 |
|
| 126 |
#ifndef HAVE_INTTYPES_H |
| 127 |
|
| 128 |
#define PRId8 "d" |
| 129 |
#define PRId16 "d" |
| 130 |
#define PRId32 "d" |
| 131 |
#define PRId64 "I64d" |
| 132 |
|
| 133 |
#define PRIi8 "d" |
| 134 |
#define PRIi16 "d" |
| 135 |
#define PRIi32 "d" |
| 136 |
#define PRIi64 "I64d" |
| 137 |
|
| 138 |
#define PRIo8 "o" |
| 139 |
#define PRIo16 "o" |
| 140 |
#define PRIo32 "o" |
| 141 |
#define PRIo64 "I64o" |
| 142 |
|
| 143 |
#define PRIu8 "u" |
| 144 |
#define PRIu16 "u" |
| 145 |
#define PRIu32 "u" |
| 146 |
#define PRIu64 "I64u" |
| 147 |
|
| 148 |
#define PRIx8 "x" |
| 149 |
#define PRIx16 "x" |
| 150 |
#define PRIx32 "x" |
| 151 |
#define PRIx64 "I64x" |
| 152 |
|
| 153 |
#define PRIX8 "X" |
| 154 |
#define PRIX16 "X" |
| 155 |
#define PRIX32 "X" |
| 156 |
#define PRIX64 "I64X" |
| 157 |
|
| 158 |
#endif |
| 159 |
|
| 160 |
#endif |