25 #define _SC_PAGESIZE 0
26 #define _SC_OPEN_MAX 1
30 static __inline
char* getenv (
const char *name)
34 DWORD length = GetEnvironmentVariable( (LPCSTR)name, NULL, 0 );
36 if( 0 == length )
return NULL;
37 buffer = (
char *)malloc(
sizeof(
char) * length);
38 ret = GetEnvironmentVariable((LPCSTR)name, (LPSTR)buffer, length);
39 return (ret > 0) ? buffer: NULL;
43 static __inline
int setenv (
const char *name,
const char *value,
int rewrite)
48 if( 0 == (length = GetEnvironmentVariable( (LPCSTR)name, NULL, length )) ) {
49 if( ERROR_ENVVAR_NOT_FOUND == GetLastError() ) {
55 ret = SetEnvironmentVariable ((LPCSTR)name, (LPCSTR)value);
56 return (0 != ret)? 1: 0;
60 static __inline
unsigned int sleep(
unsigned int seconds) {
63 SleepEx(seconds * 1000, TRUE);
69 static __inline
size_t sysconf(
int option) {
73 if( _SC_OPEN_MAX == option ) {
74 return _getmaxstdio();
77 GetSystemInfo(&sys_info);
78 if (_SC_PAGESIZE == option){
79 return (
size_t)sys_info.dwPageSize;
81 printf(
"This functionality is not supported: line: %d\tfile: %s\n",
95 static __inline
int fcntl (
int fildes,
int cmd, ...) {
100 case F_SETFL: mode = 1; ret = ioctlsocket ((SOCKET)fildes, FIONBIO, (u_long FAR*) &mode);
102 case F_GETFL: ret = 0;
104 default: printf(
"Option not supported: %d %s\n", __LINE__, __FILE__);