diff --git a/contrib/win32/win32compat/inc/defs.h b/contrib/win32/win32compat/inc/defs.h index a56ea3f..0090baf 100644 --- a/contrib/win32/win32compat/inc/defs.h +++ b/contrib/win32/win32compat/inc/defs.h @@ -28,43 +28,3 @@ /*fd flags*/ #define FD_CLOEXEC 0x1 - - -/* - * open() flags and modes - * all commented out macros are defined in fcntl.h - * they are listed here so as to cross check any conflicts with macros explicitly - * defined below. - */ -/*open access modes. only one of these can be specified*/ -/* #define O_RDONLY 0x0 */ -/* #define O_WRONLY 0x1 */ -/* #define O_RDWR 0x2 */ -/* open file creation and file status flags can be bitwise-or'd*/ -/* #define O_APPEND 0x8 /*file is opened in append mode*/ -#ifndef O_NONBLOCK -#define O_NONBLOCK 0x0004 /*io operations wont block*/ -#endif -/* #define O_CREAT 0x100 /*If the file does not exist it will be created*/ -/* - * If the file exists and is a regular file, and the file is successfully - * opened O_RDWR or O_WRONLY, its length shall be truncated to 0, and the mode - * and owner shall be unchanged - */ -/* #define O_TRUNC 0x200 */ -/* If O_CREAT and O_EXCL are set, open() shall fail if the file exists */ -/* #define O_EXCL 0x400 */ -/* #define O_BINARY 0x8000 //Gives raw data (while O_TEXT normalises line endings */ -// open modes -#ifndef S_IRUSR -#define S_IRUSR 00400 //user has read permission -#endif // ! S_IRUSR -#ifndef S_IWUSR -#define S_IWUSR 00200 //user has write permission -#endif -#ifndef S_IRGRP -#define S_IRGRP 00040 //group has read permission -#endif -#ifndef S_IROTH -#define S_IROTH 00004 //others have read permission -#endif \ No newline at end of file diff --git a/contrib/win32/win32compat/inc/w32posix.h b/contrib/win32/win32compat/inc/w32posix.h index 95d07ca..0e3f851 100644 --- a/contrib/win32/win32compat/inc/w32posix.h +++ b/contrib/win32/win32compat/inc/w32posix.h @@ -58,6 +58,7 @@ int w32_dup2(int oldfd, int newfd); /* misc */ unsigned int w32_alarm(unsigned int seconds); +typedef void(*sighandler_t)(int); #define signal w32_signal #define mysignal w32_signal @@ -89,3 +90,13 @@ unsigned int w32_alarm(unsigned int seconds); #define EPFNOSUPPORT WSAEPFNOSUPPORT #endif + +/* + * these routines are temporarily defined here to allow transition + * from older POSIX wrapper to the newer one. After complete transition + * these should move to a internal header. + */ +int w32_temp_DelChildToWatch(HANDLE processtowatch); +HANDLE w32_fd_to_handle(int fd); +int w32_allocate_fd_for_handle(HANDLE h); + diff --git a/contrib/win32/win32compat/w32fd.c b/contrib/win32/win32compat/w32fd.c index b3b0c2e..20b4f91 100644 --- a/contrib/win32/win32compat/w32fd.c +++ b/contrib/win32/win32compat/w32fd.c @@ -585,4 +585,46 @@ w32_dup2(int oldfd, int newfd) { errno = EOPNOTSUPP; debug("ERROR: dup2 is not implemented yet"); return -1; -} \ No newline at end of file +} + +unsigned int +w32_alarm(unsigned int seconds) { + /*TODO - implement alarm */ + return 0; +} + +sighandler_t w32_signal(int signum, sighandler_t handler) { + /*TODO - implement signal()*/ + return 0; +} + +int +w32_temp_DelChildToWatch(HANDLE processtowatch) { + return 0; +} + +HANDLE +w32_fd_to_handle(int fd) { + return fd_table.w32_ios[fd]->handle; +} + +int w32_allocate_fd_for_handle(HANDLE h) { + int min_index = fd_table_get_min_index(); + struct w32_io* pio; + + if (min_index == -1) { + return -1; + } + + pio = malloc(sizeof(struct w32_io)); + if (pio == NULL) { + errno = ENOMEM; + return -1; + } + memset(pio, 0, sizeof(struct w32_io)); + + pio->type = FILE_FD; + pio->handle = h; + fd_table_set(pio, min_index); + return min_index; +} diff --git a/contrib/win32/win32compat/w32fd.h b/contrib/win32/win32compat/w32fd.h index ea9ab83..e591c7d 100644 --- a/contrib/win32/win32compat/w32fd.h +++ b/contrib/win32/win32compat/w32fd.h @@ -118,3 +118,42 @@ int fileio_isatty(struct w32_io* pio); FILE* fileio_fdopen(struct w32_io* pio, const char *mode); + +/* +* open() flags and modes +* all commented out macros are defined in fcntl.h +* they are listed here so as to cross check any conflicts with macros explicitly +* defined below. +*/ +/*open access modes. only one of these can be specified*/ +/* #define O_RDONLY 0x0 */ +/* #define O_WRONLY 0x1 */ +/* #define O_RDWR 0x2 */ +/* open file creation and file status flags can be bitwise-or'd*/ +/* #define O_APPEND 0x8 /*file is opened in append mode*/ +#ifndef O_NONBLOCK +#define O_NONBLOCK 0x0004 /*io operations wont block*/ +#endif +/* #define O_CREAT 0x100 /*If the file does not exist it will be created*/ +/* +* If the file exists and is a regular file, and the file is successfully +* opened O_RDWR or O_WRONLY, its length shall be truncated to 0, and the mode +* and owner shall be unchanged +*/ +/* #define O_TRUNC 0x200 */ +/* If O_CREAT and O_EXCL are set, open() shall fail if the file exists */ +/* #define O_EXCL 0x400 */ +/* #define O_BINARY 0x8000 //Gives raw data (while O_TEXT normalises line endings */ +// open modes +#ifndef S_IRUSR +#define S_IRUSR 00400 //user has read permission +#endif // ! S_IRUSR +#ifndef S_IWUSR +#define S_IWUSR 00200 //user has write permission +#endif +#ifndef S_IRGRP +#define S_IRGRP 00040 //group has read permission +#endif +#ifndef S_IROTH +#define S_IROTH 00004 //others have read permission +#endif \ No newline at end of file