-
-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
153 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include <_cheader.h> | ||
#include <sys/types.h> | ||
|
||
_Begin_C_Header | ||
|
||
struct utimbuf { | ||
time_t actime; | ||
time_t modtime; | ||
}; | ||
|
||
extern int utime(const char *filename, const struct utimbuf *times); | ||
|
||
_End_C_Header |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
#include <unistd.h> | ||
|
||
int getpgrp() { | ||
/* XXX */ | ||
return getgid(); | ||
return getpgid(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#include <stdlib.h> | ||
#include <ctype.h> | ||
#include <limits.h> | ||
#include <wchar.h> | ||
#include <errno.h> | ||
|
||
static int is_valid(int base, wchar_t c) { | ||
if (c < '0') return 0; | ||
if (base <= 10) { | ||
return c < ('0' + base); | ||
} | ||
|
||
if (c >= 'a' && c < 'a' + (base - 10)) return 1; | ||
if (c >= 'A' && c < 'A' + (base - 10)) return 1; | ||
if (c >= '0' && c <= '9') return 1; | ||
return 0; | ||
} | ||
|
||
static int convert_digit(wchar_t c) { | ||
if (c >= '0' && c <= '9') { | ||
return c - '0'; | ||
} | ||
if (c >= 'a' && c <= 'z') { | ||
return c - 'a' + 0xa; | ||
} | ||
if (c >= 'A' && c <= 'Z') { | ||
return c - 'A' + 0xa; | ||
} | ||
return 0; | ||
} | ||
|
||
#define strtox(max, type) \ | ||
if (base < 0 || base == 1 || base > 36) { \ | ||
errno = EINVAL; \ | ||
return max; \ | ||
} \ | ||
while (*nptr && isspace(*nptr)) nptr++; \ | ||
int sign = 1; \ | ||
if (*nptr == '-') { \ | ||
sign = -1; \ | ||
nptr++; \ | ||
} else if (*nptr == '+') { \ | ||
nptr++; \ | ||
} \ | ||
if (base == 16) { \ | ||
if (*nptr == '0') { \ | ||
nptr++; \ | ||
if (*nptr == 'x') { \ | ||
nptr++; \ | ||
} \ | ||
} \ | ||
} \ | ||
if (base == 0) { \ | ||
if (*nptr == '0') { \ | ||
base = 8; \ | ||
nptr++; \ | ||
if (*nptr == 'x') { \ | ||
base = 16; \ | ||
nptr++; \ | ||
} \ | ||
} else { \ | ||
base = 10; \ | ||
} \ | ||
} \ | ||
type val = 0; \ | ||
while (is_valid(base, *nptr)) { \ | ||
val *= base; \ | ||
val += convert_digit(*nptr); \ | ||
nptr++; \ | ||
} \ | ||
if (endptr) { \ | ||
*endptr = (wchar_t *)nptr; \ | ||
} \ | ||
if (sign == -1) { \ | ||
return -val; \ | ||
} else { \ | ||
return val; \ | ||
} | ||
|
||
unsigned long int wcstoul(const wchar_t *nptr, wchar_t **endptr, int base) { | ||
strtox(ULONG_MAX, unsigned long int); | ||
} | ||
|
||
unsigned long long int wcstoull(const char *nptr, wchar_t **endptr, int base) { | ||
strtox(ULLONG_MAX, unsigned long int); | ||
} | ||
|
||
long int wcstol(const wchar_t *nptr, wchar_t **endptr, int base) { | ||
strtox(LONG_MAX, unsigned long int); | ||
} | ||
|
||
long long int wcstoll(const wchar_t *nptr, wchar_t **endptr, int base) { | ||
strtox(LLONG_MAX, unsigned long long int); | ||
} | ||
|