Index: apps/app_externalivr.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_externalivr.c,v retrieving revision 1.8 diff -u -r1.8 app_externalivr.c --- apps/app_externalivr.c 7 Sep 2005 15:32:01 -0000 1.8 +++ apps/app_externalivr.c 8 Sep 2005 01:56:09 -0000 @@ -24,6 +24,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision: 1.8 $") +#include "asterisk/compat.h" #include "asterisk/lock.h" #include "asterisk/file.h" #include "asterisk/logger.h" @@ -259,17 +260,17 @@ LOCAL_USER_ADD(u); - if (pipe(child_stdin)) { + if (AST_PIPE(child_stdin)) { ast_chan_log(LOG_WARNING, chan, "Could not create pipe for child input: %s\n", strerror(errno)); goto exit; } - if (pipe(child_stdout)) { + if (AST_PIPE(child_stdout)) { ast_chan_log(LOG_WARNING, chan, "Could not create pipe for child output: %s\n", strerror(errno)); goto exit; } - if (pipe(child_stderr)) { + if (AST_PIPE(child_stderr)) { ast_chan_log(LOG_WARNING, chan, "Could not create pipe for child errors: %s\n", strerror(errno)); goto exit; } Index: apps/app_festival.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_festival.c,v retrieving revision 1.32 diff -u -r1.32 app_festival.c --- apps/app_festival.c 6 Jun 2005 22:39:31 -0000 1.32 +++ apps/app_festival.c 8 Sep 2005 01:56:09 -0000 @@ -32,6 +32,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision: 1.32 $") +#include "asterisk/compat.h" #include "asterisk/file.h" #include "asterisk/logger.h" #include "asterisk/channel.h" @@ -154,7 +155,7 @@ char frdata[2048]; } myf; - if (pipe(fds)) { + if (AST_PIPE(fds)) { ast_log(LOG_WARNING, "Unable to create pipe\n"); return -1; } Index: apps/app_ices.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_ices.c,v retrieving revision 1.7 diff -u -r1.7 app_ices.c --- apps/app_ices.c 6 Jun 2005 22:39:31 -0000 1.7 +++ apps/app_ices.c 8 Sep 2005 01:56:09 -0000 @@ -24,6 +24,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision: 1.7 $") +#include "asterisk/compat.h" #include "asterisk/lock.h" #include "asterisk/file.h" #include "asterisk/logger.h" @@ -95,7 +96,7 @@ ast_log(LOG_WARNING, "ICES requires an argument (configfile.xml)\n"); return -1; } - if (pipe(fds)) { + if (AST_PIPE(fds)) { ast_log(LOG_WARNING, "Unable to create pipe\n"); return -1; } Index: apps/app_intercom.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_intercom.c,v retrieving revision 1.22 diff -u -r1.22 app_intercom.c --- apps/app_intercom.c 6 Jun 2005 22:39:31 -0000 1.22 +++ apps/app_intercom.c 8 Sep 2005 01:56:09 -0000 @@ -21,7 +21,7 @@ #if defined(__linux__) #include -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) || defined(__CYGWIN__) #include #else #include Index: apps/app_mp3.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_mp3.c,v retrieving revision 1.26 diff -u -r1.26 app_mp3.c --- apps/app_mp3.c 15 Jul 2005 23:00:46 -0000 1.26 +++ apps/app_mp3.c 8 Sep 2005 01:56:09 -0000 @@ -23,6 +23,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision: 1.26 $") +#include "asterisk/compat.h" #include "asterisk/lock.h" #include "asterisk/file.h" #include "asterisk/logger.h" @@ -120,7 +121,7 @@ ast_log(LOG_WARNING, "MP3 Playback requires an argument (filename)\n"); return -1; } - if (pipe(fds)) { + if (AST_PIPE(fds)) { ast_log(LOG_WARNING, "Unable to create pipe\n"); return -1; } Index: apps/app_sms.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_sms.c,v retrieving revision 1.26 diff -u -r1.26 app_sms.c --- apps/app_sms.c 7 Sep 2005 18:57:01 -0000 1.26 +++ apps/app_sms.c 8 Sep 2005 01:56:10 -0000 @@ -22,6 +22,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision: 1.26 $") +#include "asterisk/compat.h" #include "asterisk/lock.h" #include "asterisk/file.h" #include "asterisk/logger.h" @@ -427,7 +428,7 @@ static void packdate (unsigned char *o, time_t w) { struct tm *t = localtime (&w); -#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__) +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__) || defined(__CYGWIN__) int z = -t->tm_gmtoff / 60 / 15; #else int z = timezone / 60 / 15; Index: include/asterisk/compat.h =================================================================== RCS file: /usr/cvsroot/asterisk/include/asterisk/compat.h,v retrieving revision 1.2 diff -u -r1.2 compat.h --- include/asterisk/compat.h 8 Sep 2005 02:26:35 -0000 1.2 +++ include/asterisk/compat.h 8 Sep 2005 01:56:10 -0000 @@ -14,6 +14,19 @@ #ifndef _COMPAT_H #define _COMPAT_H +/*! + \brief Emulates pipe on platforms where it is not well supported + \fd An fd just as you would use in pipe + + This macro behaves just like pipe but will behave better cross platform +*/ +#define AST_PIPE(fd) \ +#ifdef __CYGWIN__ + socketpair(AF_LOCAL, SOCK_STREAM, 0, fd) +#else + pipe(fd) +#endif + #ifdef SOLARIS #define __BEGIN_DECLS #define __END_DECLS @@ -63,6 +76,10 @@ #define _WIN32_WINNT 0x0500 #include #include +#include +#ifndef NAME_MAX +#define NAME_MAX FILENAME_MAX +#endif #endif /* __CYGWIN__ */ #define HAVE_VASPRINTF Index: res/res_agi.c =================================================================== RCS file: /usr/cvsroot/asterisk/res/res_agi.c,v retrieving revision 1.49 diff -u -r1.49 res_agi.c --- res/res_agi.c 23 Aug 2005 01:30:22 -0000 1.49 +++ res/res_agi.c 8 Sep 2005 01:56:11 -0000 @@ -32,6 +32,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision: 1.49 $") +#include "asterisk/compat.h" #include "asterisk/file.h" #include "asterisk/logger.h" #include "asterisk/channel.h" @@ -203,7 +204,11 @@ return 0; } +#ifndef __CYGWIN__ static int launch_script(char *script, char *argv[], int *fds, int *efd, int *opid) +#else +static int launch_script(char *script, char *argv[], int *fds, int *efd, int *opid, void *winp) +#endif { char tmp[256]; int pid; @@ -221,18 +226,18 @@ snprintf(tmp, sizeof(tmp), "%s/%s", (char *)ast_config_AST_AGI_DIR, script); script = tmp; } - if (pipe(toast)) { + if (AST_PIPE(toast)) { ast_log(LOG_WARNING, "Unable to create toast pipe: %s\n",strerror(errno)); return -1; } - if (pipe(fromast)) { + if (AST_PIPE(fromast)) { ast_log(LOG_WARNING, "unable to create fromast pipe: %s\n", strerror(errno)); close(toast[0]); close(toast[1]); return -1; } if (efd) { - if (pipe(audio)) { + if (AST_PIPE(audio)) { ast_log(LOG_WARNING, "unable to create audio pipe: %s\n", strerror(errno)); close(fromast[0]); close(fromast[1]); @@ -1993,6 +1998,9 @@ int pid; char *stringp; AGI agi; +#ifdef __CYGWIN__ + void *winp = NULL; +#endif if (!data || ast_strlen_zero(data)) { ast_log(LOG_WARNING, "AGI requires an argument (script)\n"); @@ -2016,7 +2024,11 @@ } } #endif +#ifdef __CYGWIN__ + res = launch_script(argv[0], argv, fds, enhanced ? &efd : NULL, &pid, winp); +#else res = launch_script(argv[0], argv, fds, enhanced ? &efd : NULL, &pid); +#endif if (!res) { agi.fd = fds[1]; agi.ctrl = fds[0]; @@ -2025,6 +2037,10 @@ close(fds[1]); if (efd > -1) close(efd); +#ifdef __CYGWIN__ + if (winp) + wincons_clean(winp); +#endif } LOCAL_USER_REMOVE(u); return res; Index: res/res_features.c =================================================================== RCS file: /usr/cvsroot/asterisk/res/res_features.c,v retrieving revision 1.71 diff -u -r1.71 res_features.c --- res/res_features.c 7 Sep 2005 21:36:30 -0000 1.71 +++ res/res_features.c 8 Sep 2005 01:56:12 -0000 @@ -1628,6 +1628,9 @@ ast_mutex_unlock(&parking_lock); rfds = nrfds; efds = nefds; +#ifdef __CYGWIN__ + if (max <0) ms = 25; +#endif tv = ast_samp2tv(ms, 1000); /* Wait for something to happen */ ast_select(max + 1, &rfds, NULL, &efds, (ms > -1) ? &tv : NULL); @@ -2120,6 +2123,10 @@ ast_cli_unregister(&showfeatures); ast_cli_unregister(&showparked); ast_unregister_application(parkcall); +#ifdef __CYGWIN__ + pthread_cancel(parking_thread); + pthread_join(parking_thread, NULL); +#endif return ast_unregister_application(parkedcall); } Index: res/res_musiconhold.c =================================================================== RCS file: /usr/cvsroot/asterisk/res/res_musiconhold.c,v retrieving revision 1.70 diff -u -r1.70 res_musiconhold.c --- res/res_musiconhold.c 1 Sep 2005 19:34:49 -0000 1.70 +++ res/res_musiconhold.c 8 Sep 2005 01:56:13 -0000 @@ -37,6 +37,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision: 1.70 $") +#include "asterisk/compat.h" #include "asterisk/lock.h" #include "asterisk/file.h" #include "asterisk/logger.h" @@ -392,7 +393,7 @@ if (dir) { closedir(dir); } - if (pipe(fds)) { + if (AST_PIPE(fds)) { ast_log(LOG_WARNING, "Pipe failed\n"); return -1; } @@ -602,7 +603,7 @@ if (!moh) return NULL; memset(moh, 0, sizeof(struct mohdata)); - if (pipe(moh->pipe)) { + if (AST_PIPE(moh->pipe)) { ast_log(LOG_WARNING, "Failed to create pipe: %s\n", strerror(errno)); free(moh); return NULL;