65 int inet_aton(
register const char *cp,
struct in_addr *addr)
67 register uint32_t val;
71 register u_int *pp = parts;
85 if (c ==
'x' || c ==
'X')
91 if (isascii(c) && isdigit(c)) {
92 val = (val * base) + (c -
'0');
94 }
else if (base == 16 && isascii(c) && isxdigit(c)) {
96 (c + 10 - (islower(c) ?
'a' :
'A'));
118 if (c !=
'\0' && (!isascii(c) || !isspace(c)))
136 val |= parts[0] << 24;
142 val |= (parts[0] << 24) | (parts[1] << 16);
148 val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
152 addr->s_addr = htonl(val);
156 unsigned __int64 strtoull(
const char *p,
char **pend,
int base) {
157 unsigned __int64 number = 0;
161 while ((
'\b' == *p) || (
'\t' == *p))
188 if (*p ==
'0' && (p[1] ==
'x' || p[1] ==
'X'))
193 if (*p ==
'0' && (p[1] ==
'b' || p[1] ==
'B'))
201 if (
'0' <= c && c <=
'9')
203 else if (
'a' <= c && c <=
'z')
205 else if (
'A' <= c && c <=
'Z')
211 if ((ULLONG_MAX - c) / base < number)
213 number = number * base + c;
232 if (rusage == (
struct rusage *)NULL) {
236 memset(rusage, 0,
sizeof(
struct rusage));
237 if (GetProcessTimes(GetCurrentProcess(),
238 &starttime, &exittime, &kerneltime,
245 memcpy(&li, &kerneltime,
sizeof(FILETIME));
247 rusage->ru_stime.tv_sec = (long)(li.QuadPart / 1000000L);
248 rusage->ru_stime.tv_usec = li.QuadPart % 1000000L;
249 memcpy(&li, &usertime,
sizeof(FILETIME));
251 rusage->ru_utime.tv_sec = (long)(li.QuadPart / 1000000L);
252 rusage->ru_utime.tv_usec = li.QuadPart % 1000000L;
256 int sleep(
int seconds) {
261 int kill(
int pid,
int sig) {
262 if (TerminateProcess((HANDLE)pid, 0))
267 int spawn_memcached(
int argc,
char **argv) {
271 for (
int ii = 0; ii < argc; ++ii) {
272 if (strcmp(
"-d", argv[ii]) != 0) {
273 offset += snprintf(buffer + offset,
sizeof(buffer) - offset,
278 STARTUPINFO sinfo = { .cb =
sizeof(sinfo) };
279 PROCESS_INFORMATION pinfo;
281 if (CreateProcess(argv[0], buffer, NULL, NULL, FALSE,
282 CREATE_NEW_PROCESS_GROUP | CREATE_NO_WINDOW,
283 NULL, NULL, &sinfo, &pinfo)) {
296 void (*
ret)(int) = signal(sig, act->sa_handler);
298 oact->sa_handler =
ret;
300 if (
ret == SIG_ERR) {
307 void initialize_sockets(
void)
310 if (WSAStartup(MAKEWORD(2,0), &wsaData) != 0) {
311 fprintf(stderr,
"Socket Initialization Error. Program aborted\n");