diff -ruN ./win32/Makefile /usr/src/asterisk-1.0.9/win32/Makefile --- ./win32/Makefile 1970-01-01 01:00:00.000000000 +0100 +++ /usr/src/asterisk-1.0.9/win32/Makefile 2005-04-18 21:48:24.000000000 +0200 @@ -0,0 +1,37 @@ +# +# Asterisk -- A telephony toolkit for Windows. +# +# Makefile for Win32 +# +# Copyright (C) 2002-04/2005 +# Patrick DERUEL +# +# +# This program is free software, distributed under the terms of +# the GNU General Public License +# + +WINDRES = windres.exe + +LIB_NAME = libwin32.a +OBJS= inet_ntop.o strtoq.o strndup.o setpriority.o + +all: depend $(OBJS) $(LIB_NAME) + +$(LIB_NAME) : $(OBJS) + ar cr $(LIB_NAME) $(OBJS) + ranlib $(LIB_NAME) + +clean: + rm -f *.o *.res .depend + +ifneq ($(wildcard .depend),) +include .depend +endif + + + +depend: .depend + +.depend: + ../mkdep $(CFLAGS) `ls *.c` diff -ruN ./win32/inet_ntop.c /usr/src/asterisk-1.0.9/win32/inet_ntop.c --- ./win32/inet_ntop.c 1970-01-01 01:00:00.000000000 +0100 +++ /usr/src/asterisk-1.0.9/win32/inet_ntop.c 2005-04-18 16:53:02.000000000 +0200 @@ -0,0 +1,199 @@ +/* This is from the BIND 4.9.4 release, modified to compile by itself */ + +/* Copyright (c) 1996 by Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "inet_ntop.h" + +#define IN6ADDRSZ 16 +#define INT16SZ 2 + +#ifndef AF_INET6 +#define AF_INET6 AF_MAX+1 /* just to let this compile */ +#endif + +/* + * WARNING: Don't even consider trying to compile this on a system where + * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. + */ + +static const char *inet_ntop4(const u_char *src, char *dst, size_t size); +static const char *inet_ntop6(const u_char *src, char *dst, size_t size); + +/* char * + * inet_ntop(af, src, dst, size) + * convert a network format address to presentation format. + * return: + * pointer to presentation format address (`dst'), or NULL (see errno). + * author: + * Paul Vixie, 1996. + */ +const char * +inet_ntop(af, src, dst, size) + int af; + const void *src; + char *dst; + size_t size; +{ + switch (af) { + case AF_INET: + return (inet_ntop4(src, dst, size)); + case AF_INET6: + return (inet_ntop6(src, dst, size)); + default: + errno = EAFNOSUPPORT; + return (NULL); + } + /* NOTREACHED */ +} + +/* const char * + * inet_ntop4(src, dst, size) + * format an IPv4 address, more or less like inet_ntoa() + * return: + * `dst' (as a const) + * notes: + * (1) uses no statics + * (2) takes a u_char* not an in_addr as input + * author: + * Paul Vixie, 1996. + */ +static const char * +inet_ntop4(src, dst, size) + const u_char *src; + char *dst; + size_t size; +{ + static const char fmt[] = "%u.%u.%u.%u"; + char tmp[sizeof "255.255.255.255"]; + + sprintf(tmp, fmt, src[0], src[1], src[2], src[3]); + if ((size_t)strlen(tmp) > size) { + errno = ENOSPC; + return (NULL); + } + strcpy(dst, tmp); + return (dst); +} + +/* const char * + * inet_ntop6(src, dst, size) + * convert IPv6 binary address into presentation (printable) format + * author: + * Paul Vixie, 1996. + */ +static const char * +inet_ntop6(src, dst, size) + const u_char *src; + char *dst; + size_t size; +{ + /* + * Note that int32_t and int16_t need only be "at least" large enough + * to contain a value of the specified size. On some systems, like + * Crays, there is no such thing as an integer variable with 16 bits. + * Keep this in mind if you think this function should have been coded + * to use pointer overlays. All the world's not a VAX. + */ + char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp; + struct { int base, len; } best, cur; + uint32_t words[IN6ADDRSZ / INT16SZ]; + int i; + + /* + * Preprocess: + * Copy the input (bytewise) array into a wordwise array. + * Find the longest run of 0x00's in src[] for :: shorthanding. + */ + memset(words, 0, sizeof words); + for (i = 0; i < IN6ADDRSZ; i++) + words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3)); + best.base = -1; + cur.base = -1; + for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) { + if (words[i] == 0) { + if (cur.base == -1) + cur.base = i, cur.len = 1; + else + cur.len++; + } else { + if (cur.base != -1) { + if (best.base == -1 || cur.len > best.len) + best = cur; + cur.base = -1; + } + } + } + if (cur.base != -1) { + if (best.base == -1 || cur.len > best.len) + best = cur; + } + if (best.base != -1 && best.len < 2) + best.base = -1; + + /* + * Format the result. + */ + tp = tmp; + for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) { + /* Are we inside the best run of 0x00's? */ + if (best.base != -1 && i >= best.base && + i < (best.base + best.len)) { + if (i == best.base) + *tp++ = ':'; + continue; + } + /* Are we following an initial run of 0x00s or any real hex? */ + if (i != 0) + *tp++ = ':'; + /* Is this address an encapsulated IPv4? */ + if (i == 6 && best.base == 0 && + (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) { + if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp))) + return (NULL); + tp += strlen(tp); + break; + } + sprintf(tp, "%x", words[i]); + tp += strlen(tp); + } + /* Was it a trailing run of 0x00's? */ + if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ)) + *tp++ = ':'; + *tp++ = '\0'; + + /* + * Check for overflow, copy, and we're done. + */ + if ((size_t) (tp - tmp) > size) { + errno = ENOSPC; + return (NULL); + } + strcpy(dst, tmp); + return (dst); +} + + diff -ruN ./win32/inet_ntop.h /usr/src/asterisk-1.0.9/win32/inet_ntop.h --- ./win32/inet_ntop.h 1970-01-01 01:00:00.000000000 +0100 +++ /usr/src/asterisk-1.0.9/win32/inet_ntop.h 2005-04-18 16:53:02.000000000 +0200 @@ -0,0 +1,11 @@ +#ifndef HAVE_INET_NTOP +#if defined(__cplusplus) +extern "C" { +#endif + +const char *inet_ntop(int af, const void *src, char *dst, size_t size); + +#if defined(__cplusplus) +} +#endif +#endif /* HAVE_INET_NTOP */ Files ./win32/libwin32.a and /usr/src/asterisk-1.0.9/win32/libwin32.a differ diff -ruN ./win32/resource.h /usr/src/asterisk-1.0.9/win32/resource.h --- ./win32/resource.h 1970-01-01 01:00:00.000000000 +0100 +++ /usr/src/asterisk-1.0.9/win32/resource.h 2005-04-18 16:53:02.000000000 +0200 @@ -0,0 +1,125 @@ +/* Weditres generated include file. Do NOT edit */ +#define DLG_0100 100 +#define _APS_NEXT_SYMED_VALUE 101 +#define IDR_MAINMENU 102 +#define IDD_ABOUT 103 +#define IDI_MYICON 104 +#define _APS_NEXT_RESOURCE_VALUE 105 +#define DLG_0200 200 +#define DLG_0300 300 +#define DLG_0400 400 +#define DLG_0500 500 +#define DLG_0600 600 +#define DLG_0700 700 +#define DLG_0800 800 +#define DLG_0900 900 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define ID_CLI_TEXT 1001 +#define ID_LOADEDMOD_LIST 1002 +#define ID_LOADEDMOD_LOADBTN 1003 +#define ID_MAINSET_VERBOSE 1004 +#define ID_MAINSET_DBGLEV 1005 +#define ID_MAINSET_CONSV 1006 +#define ID_MAINSET_CONSN 1007 +#define ID_MAINSET_CONSW 1008 +#define ID_MAINSET_CONSE 1009 +#define ID_MAINSET_CONSD 1010 +#define ID_MAINSET_LOGV 1011 +#define ID_MAINSET_LOGN 1012 +#define ID_MAINSET_LOGW 1013 +#define ID_MAINSET_LOGE 1014 +#define ID_MAINSET_LOGD 1015 +#define ID_MANAGSET_ENAB 1016 +#define ID_MANAGSET_PORT 1017 +#define ID_MANAGSET_USER 1018 +#define ID_MANAGSET_PWD 1019 +#define ID_MANAGSET_RLOG 1020 +#define ID_MANAGSET_RVERB 1021 +#define ID_MANAGSET_RSYS 1022 +#define ID_MANAGSET_RCALLS 1023 +#define ID_MANAGSET_RCMD 1024 +#define ID_MANAGSET_RAGENTS 1025 +#define ID_MANAGSET_RUSERS 1026 +#define ID_MANAGSET_WLOG 1027 +#define ID_MANAGSET_WVERB 1028 +#define ID_MANAGSET_WSYS 1029 +#define ID_MANAGSET_WCALLS 1030 +#define ID_MANAGSET_WCMD 1031 +#define ID_MANAGSET_WAGENTS 1032 +#define ID_MANAGSET_WUSERS 1033 +#define ID_MANAGSET_LIST 1034 +#define ID_MANAGSET_LADD 1035 +#define ID_MANAGSET_LDEL 1036 +#define ID_MANAGSET_LEDIT 1037 +#define ID_MANAGSET_LVALID 1038 +#define ID_MANAGSET_LCANCEL 1039 +#define ID_VOICEMAIL_SMTP 1040 +#define ID_VOICEMAIL_ATTACH 1041 +#define ID_VOICEMAIL_FORMAT 1042 +#define ID_VOICEMAIL_MAXL 1043 +#define ID_VOICEMAIL_MINL 1044 +#define ID_VOICEMAIL_LMAILBOX 1045 +#define ID_VOICEMAIL_LNAME 1046 +#define ID_VOICEMAIL_LPWD 1047 +#define ID_VOICEMAIL_LEMAIL 1048 +#define ID_VOICEMAIL_LPAGER 1049 +#define ID_VOICEMAIL_LOPTIONS 1050 +#define ID_VOICEMAIL_LIST 1051 +#define ID_VOICEMAIL_LADD 1052 +#define ID_VOICEMAIL_LDEL 1053 +#define ID_VOICEMAIL_LEDIT 1054 +#define ID_VOICEMAIL_LVALID 1055 +#define ID_VOICEMAIL_LCANCEL 1056 +#define ID_PARK_CONTEXT 1057 +#define ID_PARK_TIME 1058 +#define ID_PARK_EXTENSION 1059 +#define ID_PARK_MIN 1060 +#define ID_PARK_MAX 1061 +#define ID_MODULES_AUTO 1062 +#define ID_MODULES_LREMOVE 1063 +#define ID_MODULES_LLOAD 1064 +#define ID_MODULES_LREM_NOLOAD 1065 +#define ID_MODULES_LREM_REMOVE 1066 +#define ID_MODULES_LLOAD_LOAD 1067 +#define ID_MODULES_LLOAD_REMOVE 1068 +#define ID_FLASHOP_WEBHOST 1069 +#define ID_FLASHOP_SECCODE 1070 +#define ID_FLASHOP_REFRESH 1071 +#define ID_FLASHOP_DEBUG 1072 +#define ID_FLASHOP_MAN_NAME 1073 +#define ID_FLASHOP_MAN_PWD 1074 +#define ID_FLASHOP_MD5 1075 +#define ID_FLASHOP_CHECKVOICEMAIL 1076 +#define ID_FLASHOP_CONTEXT 1077 +#define ID_FLASHOP_CROOM_MIN 1078 +#define ID_FLASHOP_CROOM_MAX 1079 +#define ID_MODULES_MODS 1080 +#define ID_VOICEMAIL_MAILFROM 1081 +#define ID_MAINSET_HIGHPRI 1082 +#define ID_MAINSET_CONSEV 1083 +#define ID_MAINSET_LOGEV 1084 +#define ID_PARK_PICKUPEXT 1085 +#define ID_PARK_ADSIPARK 1086 +#define ID_PARK_TRANSFDIGIT 1087 +#define ID_PARK_COURTSYSTONE 1088 +#define ID_FLASHOP_PORT 1089 +#define ID_MANAGSET_BIND 1090 +#define ID_MANAGSET_PERMIT 1091 +#define ID_MANAGSET_DENY 1092 +#define ID_MODULE_LOAD 40001 +#define ID_AST_START 40002 +#define ID_AST_RELOAD 40003 +#define ID_AST_RESTART_NOW 40004 +#define ID_AST_STOP 40005 +#define ID_AST_ABOUT 40006 +#define ID_AST_EXIT 40007 +#define ID_AST_LOADED 40008 +#define ID_SET_MAIN 40009 +#define ID_SET_MODULES 40010 +#define ID_SET_MANAGERS 40011 +#define ID_SET_PARKS 40012 +#define ID_SET_VOICEMAIL 40013 +#define ID_SET_FLASHOP 40014 +#define ID_AST_CLI 40015 +#define ID_AST_RESTART_GRACEFULLY 40016 +#define _APS_NEXT_COMMAND_VALUE 40017 diff -ruN ./win32/setpriority.c /usr/src/asterisk-1.0.9/win32/setpriority.c --- ./win32/setpriority.c 1970-01-01 01:00:00.000000000 +0100 +++ /usr/src/asterisk-1.0.9/win32/setpriority.c 2005-04-18 22:24:28.000000000 +0200 @@ -0,0 +1,51 @@ +/* + * Asterisk -- A telephony toolkit for Linux. + * + * GUI & Console + * + * Copyright (C) 2002-03/2005, Patrick DERUEL + * + * Patrick DERUEL + * + * This program is free software, distributed under the terms of + * the GNU General Public License + */ + +#define _WIN32_WINNT 0x0500 +#include + +void AppendMessage(char *Str) {}; + +void setPriority(int priority) +{ + int dw_th= (int) (priority % 4); + int dw_ps= (int) (priority /4); + + HANDLE hProcess= GetCurrentProcess(); + + if ((dw_ps==1) && (SetPriorityClass(hProcess, ABOVE_NORMAL_PRIORITY_CLASS))) { + AppendMessage("Set PROCESS ABOVE_NORMAL_PRIORITY_CLASS\r\n"); + } + + if ((dw_ps>=2) && (SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS))) { + AppendMessage("Set PROCESS HIGH_PRIORITY_CLASS\r\n"); + } + +// if ((dw_ps>=3) && (SetPriorityClass(hProcess, REALTIME_PRIORITY_CLASS))) { +// AppendMessage("Set PROCESS REALTIME_PRIORITY_CLASS\r\n"); +// } + + HANDLE hThread= GetCurrentThread(); + if ((dw_th==1) && (SetThreadPriority(hThread, THREAD_PRIORITY_ABOVE_NORMAL))) { + AppendMessage("Set THREAD_PRIORITY_ABOVE_NORMAL\r\n"); + } + + if ((dw_th==2) && (SetThreadPriority(hThread, THREAD_PRIORITY_HIGHEST))) { + AppendMessage("Set THREAD_PRIORITY_HIGHEST\r\n"); + } + + if ((dw_th==3) && (SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL))) { + AppendMessage("Set THREAD_PRIORITY_TIME_CRITICAL\r\n"); + } +} + diff -ruN ./win32/strndup.c /usr/src/asterisk-1.0.9/win32/strndup.c --- ./win32/strndup.c 1970-01-01 01:00:00.000000000 +0100 +++ /usr/src/asterisk-1.0.9/win32/strndup.c 2005-04-18 16:53:02.000000000 +0200 @@ -0,0 +1,20 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +char *strndup(const char *data, size_t size) +{ + char *tmp; + if (size < 0) return NULL; + tmp = (char *)malloc(size+1); + strncpy(tmp, data, size); + tmp[size]='\0'; + return tmp; +} diff -ruN ./win32/strtoq.c /usr/src/asterisk-1.0.9/win32/strtoq.c --- ./win32/strtoq.c 1970-01-01 01:00:00.000000000 +0100 +++ /usr/src/asterisk-1.0.9/win32/strtoq.c 2005-04-18 16:53:02.000000000 +0200 @@ -0,0 +1,140 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +//__FBSDID("$FreeBSD: src/sys/libkern/strtoq.c,v 1.5 2003/06/11 05:23:04 obrien Exp $"); + +#include +#//include +//#include +//#include +#include +#include +#include +#define QUAD_MAX 0x7fffffffffffffffLL /* max value for a long long */ +#define QUAD_MIN (-0x7fffffffffffffffLL - 1) /* min for a long long */ + + +/* + * Convert a string to a quad integer. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +quad_t +strtoq(const char *nptr, char **endptr, int base) +{ + const char *s; + u_quad_t acc; + unsigned char c; + u_quad_t qbase, cutoff; + int neg, any, cutlim; + + /* + * Skip white space and pick up leading +/- sign if any. + * If base is 0, allow 0x for hex and 0 for octal, else + * assume decimal; if base is already 16, allow 0x. + */ + s = nptr; + do { + c = *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else { + neg = 0; + if (c == '+') + c = *s++; + } + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + + /* + * Compute the cutoff value between legal numbers and illegal + * numbers. That is the largest legal value, divided by the + * base. An input number that is greater than this value, if + * followed by a legal input character, is too big. One that + * is equal to this value may be valid or not; the limit + * between valid and invalid numbers is then based on the last + * digit. For instance, if the range for quads is + * [-9223372036854775808..9223372036854775807] and the input base + * is 10, cutoff will be set to 922337203685477580 and cutlim to + * either 7 (neg==0) or 8 (neg==1), meaning that if we have + * accumulated a value > 922337203685477580, or equal but the + * next digit is > 7 (or 8), the number is too big, and we will + * return a range error. + * + * Set any if any `digits' consumed; make it negative to indicate + * overflow. + */ + qbase = (unsigned)base; + cutoff = neg ? (u_quad_t)-(QUAD_MIN + QUAD_MAX) + QUAD_MAX : QUAD_MAX; + cutlim = cutoff % qbase; + cutoff /= qbase; + for (acc = 0, any = 0;; c = *s++) { + if (!isascii(c)) + break; + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) + any = -1; + else { + any = 1; + acc *= qbase; + acc += c; + } + } + if (any < 0) { + acc = neg ? QUAD_MIN : QUAD_MAX; + } else if (neg) + acc = -acc; + if (endptr != 0) + *((const char **)endptr) = any ? s - 1 : nptr; + return (acc); +} diff -ruN ./include/asterisk/win32.h /usr/src/asterisk-1.0.9/include/asterisk/win32.h --- ./include/asterisk/win32.h 1970-01-01 01:00:00.000000000 +0100 +++ /usr/src/asterisk-1.0.9/include/asterisk/win32.h 2005-04-18 21:22:32.000000000 +0200 @@ -0,0 +1,25 @@ +/* + * Asterisk -- A telephony toolkit for Linux. + * + * + * Copyright (C) 2002-03/2005, Patrick DERUEL + * + * Patrick DERUEL + * + * This program is free software, distributed under the terms of + * the GNU General Public License + */ + +#ifdef __CYGWIN__ +#ifndef INET_ADDRSTRLEN +#define INET_ADDRSTRLEN 16 +#endif +#ifndef INET6_ADDRSTRLEN +#define INET6_ADDRSTRLEN 46 +#endif +typedef unsigned long long quad_t; +typedef unsigned long long u_quad_t; +const char *inet_ntop(int af, const void *src, char *dst, size_t size); +quad_t strtoq(const char *nptr, char **endptr, int base); +#endif +