dos2unix a bunch of files

For some reason these files would get marked as modified
just after a fresh clone on Linux
This commit is contained in:
Moises Silva 2014-07-22 15:04:28 -04:00
parent 31f98efc5c
commit d6574e8c0f
17 changed files with 7854 additions and 7854 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
The Cepstral SDK for Windows should be placed in c:\dev\cepstral The Cepstral SDK for Windows should be placed in c:\dev\cepstral
ex. C:\dev\cepstral\sdk\include ex. C:\dev\cepstral\sdk\include
This SDK can be obtained from http://cepstral.com/ This SDK can be obtained from http://cepstral.com/
If you want a prebuilt version you may download one from http://files.freeswitch.org/windows/installer/ If you want a prebuilt version you may download one from http://files.freeswitch.org/windows/installer/

View File

@ -537,11 +537,11 @@ int gsmopen_serial_init(private_t * tech_pvt, speed_t controldevice_speed)
NOTICA("SMS=\n%s\n", GSMOPEN_P_LOG, sms->toString().c_str()); NOTICA("SMS=\n%s\n", GSMOPEN_P_LOG, sms->toString().c_str());
#if 0 #if 0
size = MultiByteToWideChar(CP_OEMCP, 0, username, strlen(username)+1, UserName, 0); size = MultiByteToWideChar(CP_OEMCP, 0, username, strlen(username)+1, UserName, 0);
UserName=(wchar_t*)GlobalAlloc(GME­ M_ZEROINIT, size); UserName=(wchar_t*)GlobalAlloc(GME­ M_ZEROINIT, size);
ret = MultiByteToWideChar(CP_OEMCP, 0, username, strlen(username)+1, UserName, size); ret = MultiByteToWideChar(CP_OEMCP, 0, username, strlen(username)+1, UserName, size);
if(ret == 0) if(ret == 0)
getError(GetLastError()); getError(GetLastError());
#endif //0 #endif //0
return (-1); return (-1);
} }

View File

@ -1,17 +1,17 @@
#ifndef LIBCTB_WIN32_GETOPT_H_INCLUDED_ #ifndef LIBCTB_WIN32_GETOPT_H_INCLUDED_
#define LIBCTB_WIN32_GETOPT_H_INCLUDED_ #define LIBCTB_WIN32_GETOPT_H_INCLUDED_
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: win32/getopt.h // Name: win32/getopt.h
// Purpose: // Purpose:
// Author: Joachim Buermann // Author: Joachim Buermann
// Copyright: (c) 2010 Joachim Buermann // Copyright: (c) 2010 Joachim Buermann
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
extern char* optarg; extern char* optarg;
extern int optind; extern int optind;
int getopt(int argc, char* argv[], char* optstring); int getopt(int argc, char* argv[], char* optstring);
#endif #endif

View File

@ -1,414 +1,414 @@
/* /*
* *
* *
* Win32 include file * Win32 include file
* for accessing the 32-bit GPIB DLL (gpib-32.dll) * for accessing the 32-bit GPIB DLL (gpib-32.dll)
* *
* *
* Contains user variables (ibsta, iberr, ibcnt, ibcntl), * Contains user variables (ibsta, iberr, ibcnt, ibcntl),
* function prototypes and useful defined constants for * function prototypes and useful defined constants for
* calling NI-488 and NI-488.2 routines from a Microsoft * calling NI-488 and NI-488.2 routines from a Microsoft
* C/C++ Win32 application. * C/C++ Win32 application.
* *
* *
* Copyright 1998 National Instruments Corporation * Copyright 1998 National Instruments Corporation
* *
*/ */
#ifndef DECL_32_H // ensure we are only included once #ifndef DECL_32_H // ensure we are only included once
#define DECL_32_H #define DECL_32_H
#include "windows.h" #include "windows.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/***************************************************************************/ /***************************************************************************/
/* HANDY CONSTANTS FOR USE BY APPLICATION PROGRAMS ... */ /* HANDY CONSTANTS FOR USE BY APPLICATION PROGRAMS ... */
/***************************************************************************/ /***************************************************************************/
#define UNL 0x3f /* GPIB unlisten command */ #define UNL 0x3f /* GPIB unlisten command */
#define UNT 0x5f /* GPIB untalk command */ #define UNT 0x5f /* GPIB untalk command */
#define GTL 0x01 /* GPIB go to local */ #define GTL 0x01 /* GPIB go to local */
#define SDC 0x04 /* GPIB selected device clear */ #define SDC 0x04 /* GPIB selected device clear */
#define PPC 0x05 /* GPIB parallel poll configure */ #define PPC 0x05 /* GPIB parallel poll configure */
#define GET 0x08 /* GPIB group execute trigger */ #define GET 0x08 /* GPIB group execute trigger */
#define TCT 0x09 /* GPIB take control */ #define TCT 0x09 /* GPIB take control */
#define LLO 0x11 /* GPIB local lock out */ #define LLO 0x11 /* GPIB local lock out */
#define DCL 0x14 /* GPIB device clear */ #define DCL 0x14 /* GPIB device clear */
#define PPU 0.16 /* GPIB parallel poll unconfigure */ #define PPU 0.16 /* GPIB parallel poll unconfigure */
#define SPE 0x18 /* GPIB serial poll enable */ #define SPE 0x18 /* GPIB serial poll enable */
#define SPD 0x19 /* GPIB serial poll disable */ #define SPD 0x19 /* GPIB serial poll disable */
#define PPE 0x60 /* GPIB parallel poll enable */ #define PPE 0x60 /* GPIB parallel poll enable */
#define PPD 0x70 /* GPIB parallel poll disable */ #define PPD 0x70 /* GPIB parallel poll disable */
/* GPIB status bit vector : */ /* GPIB status bit vector : */
/* global variable ibsta and wait mask */ /* global variable ibsta and wait mask */
#define ERR (1<<15) /* Error detected */ #define ERR (1<<15) /* Error detected */
#define TIMO (1<<14) /* Timeout */ #define TIMO (1<<14) /* Timeout */
#define END (1<<13) /* EOI or EOS detected */ #define END (1<<13) /* EOI or EOS detected */
#define SRQI (1<<12) /* SRQ detected by CIC */ #define SRQI (1<<12) /* SRQ detected by CIC */
#define RQS (1<<11) /* Device needs service */ #define RQS (1<<11) /* Device needs service */
#define CMPL (1<<8) /* I/O completed */ #define CMPL (1<<8) /* I/O completed */
#define LOK (1<<7) /* Local lockout state */ #define LOK (1<<7) /* Local lockout state */
#define REM (1<<6) /* Remote state */ #define REM (1<<6) /* Remote state */
#define CIC (1<<5) /* Controller-in-Charge */ #define CIC (1<<5) /* Controller-in-Charge */
#define ATN (1<<4) /* Attention asserted */ #define ATN (1<<4) /* Attention asserted */
#define TACS (1<<3) /* Talker active */ #define TACS (1<<3) /* Talker active */
#define LACS (1<<2) /* Listener active */ #define LACS (1<<2) /* Listener active */
#define DTAS (1<<1) /* Device trigger state */ #define DTAS (1<<1) /* Device trigger state */
#define DCAS (1<<0) /* Device clear state */ #define DCAS (1<<0) /* Device clear state */
/* Error messages returned in global variable iberr */ /* Error messages returned in global variable iberr */
#define EDVR 0 /* System error */ #define EDVR 0 /* System error */
#define ECIC 1 /* Function requires GPIB board to be CIC */ #define ECIC 1 /* Function requires GPIB board to be CIC */
#define ENOL 2 /* Write function detected no Listeners */ #define ENOL 2 /* Write function detected no Listeners */
#define EADR 3 /* Interface board not addressed correctly*/ #define EADR 3 /* Interface board not addressed correctly*/
#define EARG 4 /* Invalid argument to function call */ #define EARG 4 /* Invalid argument to function call */
#define ESAC 5 /* Function requires GPIB board to be SAC */ #define ESAC 5 /* Function requires GPIB board to be SAC */
#define EABO 6 /* I/O operation aborted */ #define EABO 6 /* I/O operation aborted */
#define ENEB 7 /* Non-existent interface board */ #define ENEB 7 /* Non-existent interface board */
#define EDMA 8 /* Error performing DMA */ #define EDMA 8 /* Error performing DMA */
#define EOIP 10 /* I/O operation started before previous */ #define EOIP 10 /* I/O operation started before previous */
/* operation completed */ /* operation completed */
#define ECAP 11 /* No capability for intended operation */ #define ECAP 11 /* No capability for intended operation */
#define EFSO 12 /* File system operation error */ #define EFSO 12 /* File system operation error */
#define EBUS 14 /* Command error during device call */ #define EBUS 14 /* Command error during device call */
#define ESTB 15 /* Serial poll status byte lost */ #define ESTB 15 /* Serial poll status byte lost */
#define ESRQ 16 /* SRQ remains asserted */ #define ESRQ 16 /* SRQ remains asserted */
#define ETAB 20 /* The return buffer is full. */ #define ETAB 20 /* The return buffer is full. */
#define ELCK 21 /* Address or board is locked. */ #define ELCK 21 /* Address or board is locked. */
/* EOS mode bits */ /* EOS mode bits */
#define BIN (1<<12) /* Eight bit compare */ #define BIN (1<<12) /* Eight bit compare */
#define XEOS (1<<11) /* Send END with EOS byte */ #define XEOS (1<<11) /* Send END with EOS byte */
#define REOS (1<<10) /* Terminate read on EOS */ #define REOS (1<<10) /* Terminate read on EOS */
/* Timeout values and meanings */ /* Timeout values and meanings */
#define TNONE 0 /* Infinite timeout (disabled) */ #define TNONE 0 /* Infinite timeout (disabled) */
#define T10us 1 /* Timeout of 10 us (ideal) */ #define T10us 1 /* Timeout of 10 us (ideal) */
#define T30us 2 /* Timeout of 30 us (ideal) */ #define T30us 2 /* Timeout of 30 us (ideal) */
#define T100us 3 /* Timeout of 100 us (ideal) */ #define T100us 3 /* Timeout of 100 us (ideal) */
#define T300us 4 /* Timeout of 300 us (ideal) */ #define T300us 4 /* Timeout of 300 us (ideal) */
#define T1ms 5 /* Timeout of 1 ms (ideal) */ #define T1ms 5 /* Timeout of 1 ms (ideal) */
#define T3ms 6 /* Timeout of 3 ms (ideal) */ #define T3ms 6 /* Timeout of 3 ms (ideal) */
#define T10ms 7 /* Timeout of 10 ms (ideal) */ #define T10ms 7 /* Timeout of 10 ms (ideal) */
#define T30ms 8 /* Timeout of 30 ms (ideal) */ #define T30ms 8 /* Timeout of 30 ms (ideal) */
#define T100ms 9 /* Timeout of 100 ms (ideal) */ #define T100ms 9 /* Timeout of 100 ms (ideal) */
#define T300ms 10 /* Timeout of 300 ms (ideal) */ #define T300ms 10 /* Timeout of 300 ms (ideal) */
#define T1s 11 /* Timeout of 1 s (ideal) */ #define T1s 11 /* Timeout of 1 s (ideal) */
#define T3s 12 /* Timeout of 3 s (ideal) */ #define T3s 12 /* Timeout of 3 s (ideal) */
#define T10s 13 /* Timeout of 10 s (ideal) */ #define T10s 13 /* Timeout of 10 s (ideal) */
#define T30s 14 /* Timeout of 30 s (ideal) */ #define T30s 14 /* Timeout of 30 s (ideal) */
#define T100s 15 /* Timeout of 100 s (ideal) */ #define T100s 15 /* Timeout of 100 s (ideal) */
#define T300s 16 /* Timeout of 300 s (ideal) */ #define T300s 16 /* Timeout of 300 s (ideal) */
#define T1000s 17 /* Timeout of 1000 s (ideal) */ #define T1000s 17 /* Timeout of 1000 s (ideal) */
/* IBLN Constants */ /* IBLN Constants */
#define NO_SAD 0 #define NO_SAD 0
#define ALL_SAD -1 #define ALL_SAD -1
/* The following constants are used for the second parameter of the /* The following constants are used for the second parameter of the
* ibconfig function. They are the "option" selection codes. * ibconfig function. They are the "option" selection codes.
*/ */
#define IbcPAD 0x0001 /* Primary Address */ #define IbcPAD 0x0001 /* Primary Address */
#define IbcSAD 0x0002 /* Secondary Address */ #define IbcSAD 0x0002 /* Secondary Address */
#define IbcTMO 0x0003 /* Timeout Value */ #define IbcTMO 0x0003 /* Timeout Value */
#define IbcEOT 0x0004 /* Send EOI with last data byte? */ #define IbcEOT 0x0004 /* Send EOI with last data byte? */
#define IbcPPC 0x0005 /* Parallel Poll Configure */ #define IbcPPC 0x0005 /* Parallel Poll Configure */
#define IbcREADDR 0x0006 /* Repeat Addressing */ #define IbcREADDR 0x0006 /* Repeat Addressing */
#define IbcAUTOPOLL 0x0007 /* Disable Auto Serial Polling */ #define IbcAUTOPOLL 0x0007 /* Disable Auto Serial Polling */
#define IbcCICPROT 0x0008 /* Use the CIC Protocol? */ #define IbcCICPROT 0x0008 /* Use the CIC Protocol? */
#define IbcIRQ 0x0009 /* Use PIO for I/O */ #define IbcIRQ 0x0009 /* Use PIO for I/O */
#define IbcSC 0x000A /* Board is System Controller? */ #define IbcSC 0x000A /* Board is System Controller? */
#define IbcSRE 0x000B /* Assert SRE on device calls? */ #define IbcSRE 0x000B /* Assert SRE on device calls? */
#define IbcEOSrd 0x000C /* Terminate reads on EOS */ #define IbcEOSrd 0x000C /* Terminate reads on EOS */
#define IbcEOSwrt 0x000D /* Send EOI with EOS character */ #define IbcEOSwrt 0x000D /* Send EOI with EOS character */
#define IbcEOScmp 0x000E /* Use 7 or 8-bit EOS compare */ #define IbcEOScmp 0x000E /* Use 7 or 8-bit EOS compare */
#define IbcEOSchar 0x000F /* The EOS character. */ #define IbcEOSchar 0x000F /* The EOS character. */
#define IbcPP2 0x0010 /* Use Parallel Poll Mode 2. */ #define IbcPP2 0x0010 /* Use Parallel Poll Mode 2. */
#define IbcTIMING 0x0011 /* NORMAL, HIGH, or VERY_HIGH timing. */ #define IbcTIMING 0x0011 /* NORMAL, HIGH, or VERY_HIGH timing. */
#define IbcDMA 0x0012 /* Use DMA for I/O */ #define IbcDMA 0x0012 /* Use DMA for I/O */
#define IbcReadAdjust 0x0013 /* Swap bytes during an ibrd. */ #define IbcReadAdjust 0x0013 /* Swap bytes during an ibrd. */
#define IbcWriteAdjust 0x014 /* Swap bytes during an ibwrt. */ #define IbcWriteAdjust 0x014 /* Swap bytes during an ibwrt. */
#define IbcSendLLO 0x0017 /* Enable/disable the sending of LLO. */ #define IbcSendLLO 0x0017 /* Enable/disable the sending of LLO. */
#define IbcSPollTime 0x0018 /* Set the timeout value for serial polls. */ #define IbcSPollTime 0x0018 /* Set the timeout value for serial polls. */
#define IbcPPollTime 0x0019 /* Set the parallel poll length period. */ #define IbcPPollTime 0x0019 /* Set the parallel poll length period. */
#define IbcEndBitIsNormal 0x001A /* Remove EOS from END bit of IBSTA. */ #define IbcEndBitIsNormal 0x001A /* Remove EOS from END bit of IBSTA. */
#define IbcUnAddr 0x001B /* Enable/disable device unaddressing. */ #define IbcUnAddr 0x001B /* Enable/disable device unaddressing. */
#define IbcSignalNumber 0x001C /* Set UNIX signal number - unsupported */ #define IbcSignalNumber 0x001C /* Set UNIX signal number - unsupported */
#define IbcBlockIfLocked 0x001D /* Enable/disable blocking for locked boards/devices */ #define IbcBlockIfLocked 0x001D /* Enable/disable blocking for locked boards/devices */
#define IbcHSCableLength 0x001F /* Length of cable specified for high speed timing.*/ #define IbcHSCableLength 0x001F /* Length of cable specified for high speed timing.*/
#define IbcIst 0x0020 /* Set the IST bit. */ #define IbcIst 0x0020 /* Set the IST bit. */
#define IbcRsv 0x0021 /* Set the RSV byte. */ #define IbcRsv 0x0021 /* Set the RSV byte. */
/* /*
* Constants that can be used (in addition to the ibconfig constants) * Constants that can be used (in addition to the ibconfig constants)
* when calling the ibask() function. * when calling the ibask() function.
*/ */
#define IbaPAD IbcPAD #define IbaPAD IbcPAD
#define IbaSAD IbcSAD #define IbaSAD IbcSAD
#define IbaTMO IbcTMO #define IbaTMO IbcTMO
#define IbaEOT IbcEOT #define IbaEOT IbcEOT
#define IbaPPC IbcPPC #define IbaPPC IbcPPC
#define IbaREADDR IbcREADDR #define IbaREADDR IbcREADDR
#define IbaAUTOPOLL IbcAUTOPOLL #define IbaAUTOPOLL IbcAUTOPOLL
#define IbaCICPROT IbcCICPROT #define IbaCICPROT IbcCICPROT
#define IbaIRQ IbcIRQ #define IbaIRQ IbcIRQ
#define IbaSC IbcSC #define IbaSC IbcSC
#define IbaSRE IbcSRE #define IbaSRE IbcSRE
#define IbaEOSrd IbcEOSrd #define IbaEOSrd IbcEOSrd
#define IbaEOSwrt IbcEOSwrt #define IbaEOSwrt IbcEOSwrt
#define IbaEOScmp IbcEOScmp #define IbaEOScmp IbcEOScmp
#define IbaEOSchar IbcEOSchar #define IbaEOSchar IbcEOSchar
#define IbaPP2 IbcPP2 #define IbaPP2 IbcPP2
#define IbaTIMING IbcTIMING #define IbaTIMING IbcTIMING
#define IbaDMA IbcDMA #define IbaDMA IbcDMA
#define IbaReadAdjust IbcReadAdjust #define IbaReadAdjust IbcReadAdjust
#define IbaWriteAdjust IbcWriteAdjust #define IbaWriteAdjust IbcWriteAdjust
#define IbaSendLLO IbcSendLLO #define IbaSendLLO IbcSendLLO
#define IbaSPollTime IbcSPollTime #define IbaSPollTime IbcSPollTime
#define IbaPPollTime IbcPPollTime #define IbaPPollTime IbcPPollTime
#define IbaEndBitIsNormal IbcEndBitIsNormal #define IbaEndBitIsNormal IbcEndBitIsNormal
#define IbaUnAddr IbcUnAddr #define IbaUnAddr IbcUnAddr
#define IbaSignalNumber IbcSignalNumber #define IbaSignalNumber IbcSignalNumber
#define IbaBlockIfLocked IbcBlockIfLocked #define IbaBlockIfLocked IbcBlockIfLocked
#define IbaHSCableLength IbcHSCableLength #define IbaHSCableLength IbcHSCableLength
#define IbaIst IbcIst #define IbaIst IbcIst
#define IbaRsv IbcRsv #define IbaRsv IbcRsv
#define IbaBNA 0x0200 /* A device's access board. */ #define IbaBNA 0x0200 /* A device's access board. */
/* Values used by the Send 488.2 command. */ /* Values used by the Send 488.2 command. */
#define NULLend 0x00 /* Do nothing at the end of a transfer.*/ #define NULLend 0x00 /* Do nothing at the end of a transfer.*/
#define NLend 0x01 /* Send NL with EOI after a transfer. */ #define NLend 0x01 /* Send NL with EOI after a transfer. */
#define DABend 0x02 /* Send EOI with the last DAB. */ #define DABend 0x02 /* Send EOI with the last DAB. */
/* Value used by the 488.2 Receive command. /* Value used by the 488.2 Receive command.
*/ */
#define STOPend 0x0100 #define STOPend 0x0100
/* Address type (for 488.2 calls) */ /* Address type (for 488.2 calls) */
typedef short Addr4882_t; /* System dependent: must be 16 bits */ typedef short Addr4882_t; /* System dependent: must be 16 bits */
/* /*
* This macro can be used to easily create an entry in address list * This macro can be used to easily create an entry in address list
* that is required by many of the 488.2 functions. The primary address goes in the * that is required by many of the 488.2 functions. The primary address goes in the
* lower 8-bits and the secondary address goes in the upper 8-bits. * lower 8-bits and the secondary address goes in the upper 8-bits.
*/ */
#define MakeAddr(pad, sad) ((Addr4882_t)(((pad)&0xFF) | ((sad)<<8))) #define MakeAddr(pad, sad) ((Addr4882_t)(((pad)&0xFF) | ((sad)<<8)))
/* /*
* This value is used to terminate an address list. It should be * This value is used to terminate an address list. It should be
* assigned to the last entry. * assigned to the last entry.
*/ */
#ifndef NOADDR #ifndef NOADDR
#define NOADDR (Addr4882_t)((unsigned short)0xFFFF) #define NOADDR (Addr4882_t)((unsigned short)0xFFFF)
#endif #endif
/* /*
* The following two macros are used to "break apart" an address list * The following two macros are used to "break apart" an address list
* entry. They take an unsigned integer and return either the primary * entry. They take an unsigned integer and return either the primary
* or secondary address stored in the integer. * or secondary address stored in the integer.
*/ */
#define GetPAD(val) ((val) & 0xFF) #define GetPAD(val) ((val) & 0xFF)
#define GetSAD(val) (((val) >> 8) & 0xFF) #define GetSAD(val) (((val) >> 8) & 0xFF)
/* iblines constants */ /* iblines constants */
#define ValidEOI (short)0x0080 #define ValidEOI (short)0x0080
#define ValidATN (short)0x0040 #define ValidATN (short)0x0040
#define ValidSRQ (short)0x0020 #define ValidSRQ (short)0x0020
#define ValidREN (short)0x0010 #define ValidREN (short)0x0010
#define ValidIFC (short)0x0008 #define ValidIFC (short)0x0008
#define ValidNRFD (short)0x0004 #define ValidNRFD (short)0x0004
#define ValidNDAC (short)0x0002 #define ValidNDAC (short)0x0002
#define ValidDAV (short)0x0001 #define ValidDAV (short)0x0001
#define BusEOI (short)0x8000 #define BusEOI (short)0x8000
#define BusATN (short)0x4000 #define BusATN (short)0x4000
#define BusSRQ (short)0x2000 #define BusSRQ (short)0x2000
#define BusREN (short)0x1000 #define BusREN (short)0x1000
#define BusIFC (short)0x0800 #define BusIFC (short)0x0800
#define BusNRFD (short)0x0400 #define BusNRFD (short)0x0400
#define BusNDAC (short)0x0200 #define BusNDAC (short)0x0200
#define BusDAV (short)0x0100 #define BusDAV (short)0x0100
/**** /****
**** typedef for ibnotify callback **** **** typedef for ibnotify callback ****
****/ ****/
typedef int (__stdcall * GpibNotifyCallback_t)(int, int, int, long, PVOID); typedef int (__stdcall * GpibNotifyCallback_t)(int, int, int, long, PVOID);
#define IBNOTIFY_REARM_FAILED 0xE00A003F #define IBNOTIFY_REARM_FAILED 0xE00A003F
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* iblockx and ibunlockx definitions --- for use with GPIB-ENET only !! */ /* iblockx and ibunlockx definitions --- for use with GPIB-ENET only !! */
/* */ /* */
/*************************************************************************/ /*************************************************************************/
#define TIMMEDIATE -1 #define TIMMEDIATE -1
#define TINFINITE -2 #define TINFINITE -2
#define MAX_LOCKSHARENAME_LENGTH 64 #define MAX_LOCKSHARENAME_LENGTH 64
#if defined(UNICODE) #if defined(UNICODE)
#define iblockx iblockxW #define iblockx iblockxW
#else #else
#define iblockx iblockxA #define iblockx iblockxA
#endif #endif
extern int __stdcall iblockxA (int ud, int LockWaitTime, PCHAR LockShareName); extern int __stdcall iblockxA (int ud, int LockWaitTime, PCHAR LockShareName);
extern int __stdcall iblockxW (int ud, int LockWaitTime, PWCHAR LockShareName); extern int __stdcall iblockxW (int ud, int LockWaitTime, PWCHAR LockShareName);
extern int __stdcall ibunlockx (int ud); extern int __stdcall ibunlockx (int ud);
/***************************************************************************/ /***************************************************************************/
/* IBSTA, IBERR, IBCNT, IBCNTL and FUNCTION PROTOTYPES */ /* IBSTA, IBERR, IBCNT, IBCNTL and FUNCTION PROTOTYPES */
/* ( only included if not accessing the 32-bit DLL directly ) */ /* ( only included if not accessing the 32-bit DLL directly ) */
/***************************************************************************/ /***************************************************************************/
#if !defined(GPIB_DIRECT_ACCESS) #if !defined(GPIB_DIRECT_ACCESS)
/* /*
* Set up access to the user variables (ibsta, iberr, ibcnt, ibcntl). * Set up access to the user variables (ibsta, iberr, ibcnt, ibcntl).
* These are declared and exported by the 32-bit DLL. Separate copies * These are declared and exported by the 32-bit DLL. Separate copies
* exist for each process that accesses the DLL. They are shared by * exist for each process that accesses the DLL. They are shared by
* multiple threads of a single process. * multiple threads of a single process.
*/ */
extern int ibsta; extern int ibsta;
extern int iberr; extern int iberr;
extern int ibcnt; extern int ibcnt;
extern long ibcntl; extern long ibcntl;
#if defined(UNICODE) #if defined(UNICODE)
#define ibbna ibbnaW #define ibbna ibbnaW
#define ibfind ibfindW #define ibfind ibfindW
#define ibrdf ibrdfW #define ibrdf ibrdfW
#define ibwrtf ibwrtfW #define ibwrtf ibwrtfW
#else #else
#define ibbna ibbnaA #define ibbna ibbnaA
#define ibfind ibfindA #define ibfind ibfindA
#define ibrdf ibrdfA #define ibrdf ibrdfA
#define ibwrtf ibwrtfA #define ibwrtf ibwrtfA
#endif #endif
/* /*
* Extern 32-bit GPIB DLL functions * Extern 32-bit GPIB DLL functions
*/ */
/* NI-488 Function Prototypes */ /* NI-488 Function Prototypes */
extern int __stdcall ibfindA (LPCSTR udname); extern int __stdcall ibfindA (LPCSTR udname);
extern int __stdcall ibbnaA (int ud, LPCSTR udname); extern int __stdcall ibbnaA (int ud, LPCSTR udname);
extern int __stdcall ibrdfA (int ud, LPCSTR filename); extern int __stdcall ibrdfA (int ud, LPCSTR filename);
extern int __stdcall ibwrtfA (int ud, LPCSTR filename); extern int __stdcall ibwrtfA (int ud, LPCSTR filename);
extern int __stdcall ibfindW (LPCWSTR udname); extern int __stdcall ibfindW (LPCWSTR udname);
extern int __stdcall ibbnaW (int ud, LPCWSTR udname); extern int __stdcall ibbnaW (int ud, LPCWSTR udname);
extern int __stdcall ibrdfW (int ud, LPCWSTR filename); extern int __stdcall ibrdfW (int ud, LPCWSTR filename);
extern int __stdcall ibwrtfW (int ud, LPCWSTR filename); extern int __stdcall ibwrtfW (int ud, LPCWSTR filename);
extern int __stdcall ibask (int ud, int option, PINT v); extern int __stdcall ibask (int ud, int option, PINT v);
extern int __stdcall ibcac (int ud, int v); extern int __stdcall ibcac (int ud, int v);
extern int __stdcall ibclr (int ud); extern int __stdcall ibclr (int ud);
extern int __stdcall ibcmd (int ud, PVOID buf, long cnt); extern int __stdcall ibcmd (int ud, PVOID buf, long cnt);
extern int __stdcall ibcmda (int ud, PVOID buf, long cnt); extern int __stdcall ibcmda (int ud, PVOID buf, long cnt);
extern int __stdcall ibconfig (int ud, int option, int v); extern int __stdcall ibconfig (int ud, int option, int v);
extern int __stdcall ibdev (int boardID, int pad, int sad, int tmo, int eot, int eos); extern int __stdcall ibdev (int boardID, int pad, int sad, int tmo, int eot, int eos);
extern int __stdcall ibdiag (int ud, PVOID buf, long cnt); extern int __stdcall ibdiag (int ud, PVOID buf, long cnt);
extern int __stdcall ibdma (int ud, int v); extern int __stdcall ibdma (int ud, int v);
extern int __stdcall ibeos (int ud, int v); extern int __stdcall ibeos (int ud, int v);
extern int __stdcall ibeot (int ud, int v); extern int __stdcall ibeot (int ud, int v);
extern int __stdcall ibgts (int ud, int v); extern int __stdcall ibgts (int ud, int v);
extern int __stdcall ibist (int ud, int v); extern int __stdcall ibist (int ud, int v);
extern int __stdcall iblines (int ud, PSHORT result); extern int __stdcall iblines (int ud, PSHORT result);
extern int __stdcall ibln (int ud, int pad, int sad, PSHORT listen); extern int __stdcall ibln (int ud, int pad, int sad, PSHORT listen);
extern int __stdcall ibloc (int ud); extern int __stdcall ibloc (int ud);
extern int __stdcall ibnotify (int ud, int mask, GpibNotifyCallback_t Callback, PVOID RefData); extern int __stdcall ibnotify (int ud, int mask, GpibNotifyCallback_t Callback, PVOID RefData);
extern int __stdcall ibonl (int ud, int v); extern int __stdcall ibonl (int ud, int v);
extern int __stdcall ibpad (int ud, int v); extern int __stdcall ibpad (int ud, int v);
extern int __stdcall ibpct (int ud); extern int __stdcall ibpct (int ud);
extern int __stdcall ibpoke (int ud, long option, long v); extern int __stdcall ibpoke (int ud, long option, long v);
extern int __stdcall ibppc (int ud, int v); extern int __stdcall ibppc (int ud, int v);
extern int __stdcall ibrd (int ud, PVOID buf, long cnt); extern int __stdcall ibrd (int ud, PVOID buf, long cnt);
extern int __stdcall ibrda (int ud, PVOID buf, long cnt); extern int __stdcall ibrda (int ud, PVOID buf, long cnt);
extern int __stdcall ibrpp (int ud, PCHAR ppr); extern int __stdcall ibrpp (int ud, PCHAR ppr);
extern int __stdcall ibrsc (int ud, int v); extern int __stdcall ibrsc (int ud, int v);
extern int __stdcall ibrsp (int ud, PCHAR spr); extern int __stdcall ibrsp (int ud, PCHAR spr);
extern int __stdcall ibrsv (int ud, int v); extern int __stdcall ibrsv (int ud, int v);
extern int __stdcall ibsad (int ud, int v); extern int __stdcall ibsad (int ud, int v);
extern int __stdcall ibsic (int ud); extern int __stdcall ibsic (int ud);
extern int __stdcall ibsre (int ud, int v); extern int __stdcall ibsre (int ud, int v);
extern int __stdcall ibstop (int ud); extern int __stdcall ibstop (int ud);
extern int __stdcall ibtmo (int ud, int v); extern int __stdcall ibtmo (int ud, int v);
extern int __stdcall ibtrg (int ud); extern int __stdcall ibtrg (int ud);
extern int __stdcall ibwait (int ud, int mask); extern int __stdcall ibwait (int ud, int mask);
extern int __stdcall ibwrt (int ud, PVOID buf, long cnt); extern int __stdcall ibwrt (int ud, PVOID buf, long cnt);
extern int __stdcall ibwrta (int ud, PVOID buf, long cnt); extern int __stdcall ibwrta (int ud, PVOID buf, long cnt);
// GPIB-ENET only functions to support locking across machines // GPIB-ENET only functions to support locking across machines
extern int __stdcall iblock (int ud); extern int __stdcall iblock (int ud);
extern int __stdcall ibunlock (int ud); extern int __stdcall ibunlock (int ud);
/**************************************************************************/ /**************************************************************************/
/* Functions to access Thread-Specific copies of the GPIB global vars */ /* Functions to access Thread-Specific copies of the GPIB global vars */
extern int __stdcall ThreadIbsta (void); extern int __stdcall ThreadIbsta (void);
extern int __stdcall ThreadIberr (void); extern int __stdcall ThreadIberr (void);
extern int __stdcall ThreadIbcnt (void); extern int __stdcall ThreadIbcnt (void);
extern long __stdcall ThreadIbcntl (void); extern long __stdcall ThreadIbcntl (void);
/**************************************************************************/ /**************************************************************************/
/* NI-488.2 Function Prototypes */ /* NI-488.2 Function Prototypes */
extern void __stdcall AllSpoll (int boardID, Addr4882_t * addrlist, PSHORT results); extern void __stdcall AllSpoll (int boardID, Addr4882_t * addrlist, PSHORT results);
extern void __stdcall DevClear (int boardID, Addr4882_t addr); extern void __stdcall DevClear (int boardID, Addr4882_t addr);
extern void __stdcall DevClearList (int boardID, Addr4882_t * addrlist); extern void __stdcall DevClearList (int boardID, Addr4882_t * addrlist);
extern void __stdcall EnableLocal (int boardID, Addr4882_t * addrlist); extern void __stdcall EnableLocal (int boardID, Addr4882_t * addrlist);
extern void __stdcall EnableRemote (int boardID, Addr4882_t * addrlist); extern void __stdcall EnableRemote (int boardID, Addr4882_t * addrlist);
extern void __stdcall FindLstn (int boardID, Addr4882_t * addrlist, Addr4882_t * results, int limit); extern void __stdcall FindLstn (int boardID, Addr4882_t * addrlist, Addr4882_t * results, int limit);
extern void __stdcall FindRQS (int boardID, Addr4882_t * addrlist, PSHORT dev_stat); extern void __stdcall FindRQS (int boardID, Addr4882_t * addrlist, PSHORT dev_stat);
extern void __stdcall PPoll (int boardID, PSHORT result); extern void __stdcall PPoll (int boardID, PSHORT result);
extern void __stdcall PPollConfig (int boardID, Addr4882_t addr, int dataLine, int lineSense); extern void __stdcall PPollConfig (int boardID, Addr4882_t addr, int dataLine, int lineSense);
extern void __stdcall PPollUnconfig (int boardID, Addr4882_t * addrlist); extern void __stdcall PPollUnconfig (int boardID, Addr4882_t * addrlist);
extern void __stdcall PassControl (int boardID, Addr4882_t addr); extern void __stdcall PassControl (int boardID, Addr4882_t addr);
extern void __stdcall RcvRespMsg (int boardID, PVOID buffer, long cnt, int Termination); extern void __stdcall RcvRespMsg (int boardID, PVOID buffer, long cnt, int Termination);
extern void __stdcall ReadStatusByte(int boardID, Addr4882_t addr, PSHORT result); extern void __stdcall ReadStatusByte(int boardID, Addr4882_t addr, PSHORT result);
extern void __stdcall Receive (int boardID, Addr4882_t addr, PVOID buffer, long cnt, int Termination); extern void __stdcall Receive (int boardID, Addr4882_t addr, PVOID buffer, long cnt, int Termination);
extern void __stdcall ReceiveSetup (int boardID, Addr4882_t addr); extern void __stdcall ReceiveSetup (int boardID, Addr4882_t addr);
extern void __stdcall ResetSys (int boardID, Addr4882_t * addrlist); extern void __stdcall ResetSys (int boardID, Addr4882_t * addrlist);
extern void __stdcall Send (int boardID, Addr4882_t addr, PVOID databuf, long datacnt, int eotMode); extern void __stdcall Send (int boardID, Addr4882_t addr, PVOID databuf, long datacnt, int eotMode);
extern void __stdcall SendCmds (int boardID, PVOID buffer, long cnt); extern void __stdcall SendCmds (int boardID, PVOID buffer, long cnt);
extern void __stdcall SendDataBytes (int boardID, PVOID buffer, long cnt, int eot_mode); extern void __stdcall SendDataBytes (int boardID, PVOID buffer, long cnt, int eot_mode);
extern void __stdcall SendIFC (int boardID); extern void __stdcall SendIFC (int boardID);
extern void __stdcall SendLLO (int boardID); extern void __stdcall SendLLO (int boardID);
extern void __stdcall SendList (int boardID, Addr4882_t * addrlist, PVOID databuf, long datacnt, int eotMode); extern void __stdcall SendList (int boardID, Addr4882_t * addrlist, PVOID databuf, long datacnt, int eotMode);
extern void __stdcall SendSetup (int boardID, Addr4882_t * addrlist); extern void __stdcall SendSetup (int boardID, Addr4882_t * addrlist);
extern void __stdcall SetRWLS (int boardID, Addr4882_t * addrlist); extern void __stdcall SetRWLS (int boardID, Addr4882_t * addrlist);
extern void __stdcall TestSRQ (int boardID, PSHORT result); extern void __stdcall TestSRQ (int boardID, PSHORT result);
extern void __stdcall TestSys (int boardID, Addr4882_t * addrlist, PSHORT results); extern void __stdcall TestSys (int boardID, Addr4882_t * addrlist, PSHORT results);
extern void __stdcall Trigger (int boardID, Addr4882_t addr); extern void __stdcall Trigger (int boardID, Addr4882_t addr);
extern void __stdcall TriggerList (int boardID, Addr4882_t * addrlist); extern void __stdcall TriggerList (int boardID, Addr4882_t * addrlist);
extern void __stdcall WaitSRQ (int boardID, PSHORT result); extern void __stdcall WaitSRQ (int boardID, PSHORT result);
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif // DECL_32_H #endif // DECL_32_H

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
#include <stddef.h> #include <stddef.h>
typedef void* iconv_t; typedef void* iconv_t;
iconv_t iconv_open(const char *tocode, const char *fromcode); iconv_t iconv_open(const char *tocode, const char *fromcode);
int iconv_close(iconv_t cd); int iconv_close(iconv_t cd);
size_t iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft); size_t iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);

View File

@ -1,54 +1,54 @@
HRESULT WINAPI ConvertINetString( HRESULT WINAPI ConvertINetString(
LPDWORD lpdwMode, LPDWORD lpdwMode,
DWORD dwSrcEncoding, DWORD dwSrcEncoding,
DWORD dwDstEncoding, DWORD dwDstEncoding,
LPCSTR lpSrcStr, LPCSTR lpSrcStr,
LPINT lpnSrcSize, LPINT lpnSrcSize,
LPBYTE lpDstStr, LPBYTE lpDstStr,
LPINT lpnDstSize LPINT lpnDstSize
); );
HRESULT WINAPI ConvertINetMultiByteToUnicode( HRESULT WINAPI ConvertINetMultiByteToUnicode(
LPDWORD lpdwMode, LPDWORD lpdwMode,
DWORD dwSrcEncoding, DWORD dwSrcEncoding,
LPCSTR lpSrcStr, LPCSTR lpSrcStr,
LPINT lpnMultiCharCount, LPINT lpnMultiCharCount,
LPWSTR lpDstStr, LPWSTR lpDstStr,
LPINT lpnWideCharCount LPINT lpnWideCharCount
); );
HRESULT WINAPI ConvertINetUnicodeToMultiByte( HRESULT WINAPI ConvertINetUnicodeToMultiByte(
LPDWORD lpdwMode, LPDWORD lpdwMode,
DWORD dwEncoding, DWORD dwEncoding,
LPCWSTR lpSrcStr, LPCWSTR lpSrcStr,
LPINT lpnWideCharCount, LPINT lpnWideCharCount,
LPSTR lpDstStr, LPSTR lpDstStr,
LPINT lpnMultiCharCount LPINT lpnMultiCharCount
); );
HRESULT WINAPI IsConvertINetStringAvailable( HRESULT WINAPI IsConvertINetStringAvailable(
DWORD dwSrcEncoding, DWORD dwSrcEncoding,
DWORD dwDstEncoding DWORD dwDstEncoding
); );
HRESULT WINAPI LcidToRfc1766A( HRESULT WINAPI LcidToRfc1766A(
LCID Locale, LCID Locale,
LPSTR pszRfc1766, LPSTR pszRfc1766,
int nChar int nChar
); );
HRESULT WINAPI LcidToRfc1766W( HRESULT WINAPI LcidToRfc1766W(
LCID Locale, LCID Locale,
LPWSTR pszRfc1766, LPWSTR pszRfc1766,
int nChar int nChar
); );
HRESULT WINAPI Rfc1766ToLcidA( HRESULT WINAPI Rfc1766ToLcidA(
LCID *pLocale, LCID *pLocale,
LPSTR pszRfc1766 LPSTR pszRfc1766
); );
HRESULT WINAPI Rfc1766ToLcidW( HRESULT WINAPI Rfc1766ToLcidW(
LCID *pLocale, LCID *pLocale,
LPWSTR pszRfc1766 LPWSTR pszRfc1766
); );

View File

@ -1,3 +1,3 @@
win_iconv is a iconv library using Win32 API to conversion. win_iconv is a iconv library using Win32 API to conversion.
win_iconv is placed in the public domain. win_iconv is placed in the public domain.
Yukihiro Nakadaira <yukihiro.nakadaira@gmail.com> Yukihiro Nakadaira <yukihiro.nakadaira@gmail.com>

File diff suppressed because it is too large Load Diff

View File

@ -1,261 +1,261 @@
#include "win_iconv.c" #include "win_iconv.c"
#include <stdio.h> #include <stdio.h>
const char * const char *
tohex(const char *str, int size) tohex(const char *str, int size)
{ {
static char buf[BUFSIZ]; static char buf[BUFSIZ];
char *pbuf = buf; char *pbuf = buf;
int i; int i;
buf[0] = 0; buf[0] = 0;
for (i = 0; i < size; ++i) for (i = 0; i < size; ++i)
pbuf += sprintf(pbuf, "%02X", str[i] & 0xFF); pbuf += sprintf(pbuf, "%02X", str[i] & 0xFF);
return buf; return buf;
} }
const char * const char *
errstr(int errcode) errstr(int errcode)
{ {
static char buf[BUFSIZ]; static char buf[BUFSIZ];
switch (errcode) switch (errcode)
{ {
case 0: return "NOERROR"; case 0: return "NOERROR";
case EINVAL: return "EINVAL"; case EINVAL: return "EINVAL";
case EILSEQ: return "EILSEQ"; case EILSEQ: return "EILSEQ";
case E2BIG: return "E2BIG"; case E2BIG: return "E2BIG";
} }
sprintf(buf, "%d\n", errcode); sprintf(buf, "%d\n", errcode);
return buf; return buf;
} }
#ifdef USE_LIBICONV_DLL #ifdef USE_LIBICONV_DLL
int use_dll; int use_dll;
int int
setdll(const char *dllpath) setdll(const char *dllpath)
{ {
char buf[BUFSIZ]; char buf[BUFSIZ];
rec_iconv_t cd; rec_iconv_t cd;
sprintf(buf, "WINICONV_LIBICONV_DLL=%s", dllpath); sprintf(buf, "WINICONV_LIBICONV_DLL=%s", dllpath);
putenv(buf); putenv(buf);
if (libiconv_iconv_open(&cd, "ascii", "ascii")) if (libiconv_iconv_open(&cd, "ascii", "ascii"))
{ {
FreeLibrary(cd.hlibiconv); FreeLibrary(cd.hlibiconv);
use_dll = TRUE; use_dll = TRUE;
return TRUE; return TRUE;
} }
use_dll = FALSE; use_dll = FALSE;
return FALSE; return FALSE;
} }
#endif #endif
/* /*
* We can test the codepage that is installed in the system. * We can test the codepage that is installed in the system.
*/ */
int int
check_enc(const char *encname, int codepage) check_enc(const char *encname, int codepage)
{ {
iconv_t cd; iconv_t cd;
int cp; int cp;
cd = iconv_open("utf-8", encname); cd = iconv_open("utf-8", encname);
if (cd == (iconv_t)(-1)) if (cd == (iconv_t)(-1))
{ {
printf("%s(%d) IS NOT SUPPORTED: SKIP THE TEST\n", encname, codepage); printf("%s(%d) IS NOT SUPPORTED: SKIP THE TEST\n", encname, codepage);
return FALSE; return FALSE;
} }
cp = ((rec_iconv_t *)cd)->from.codepage; cp = ((rec_iconv_t *)cd)->from.codepage;
if (cp != codepage) if (cp != codepage)
{ {
printf("%s(%d) ALIAS IS MAPPED TO DIFFERENT CODEPAGE (%d)\n", encname, codepage, cp); printf("%s(%d) ALIAS IS MAPPED TO DIFFERENT CODEPAGE (%d)\n", encname, codepage, cp);
exit(1); exit(1);
} }
iconv_close(cd); iconv_close(cd);
return TRUE; return TRUE;
} }
int use_dll; int use_dll;
void void
test(const char *from, const char *fromstr, int fromsize, const char *to, const char *tostr, int tosize, int errcode, int bufsize, int line) test(const char *from, const char *fromstr, int fromsize, const char *to, const char *tostr, int tosize, int errcode, int bufsize, int line)
{ {
char outbuf[BUFSIZ]; char outbuf[BUFSIZ];
const char *pin; const char *pin;
char *pout; char *pout;
size_t inbytesleft; size_t inbytesleft;
size_t outbytesleft; size_t outbytesleft;
iconv_t cd; iconv_t cd;
size_t r; size_t r;
char dllpath[_MAX_PATH]; char dllpath[_MAX_PATH];
cd = iconv_open(to, from); cd = iconv_open(to, from);
if (cd == (iconv_t)(-1)) if (cd == (iconv_t)(-1))
{ {
printf("%s -> %s: NG: INVALID ENCODING NAME: line=%d\n", from, to, line); printf("%s -> %s: NG: INVALID ENCODING NAME: line=%d\n", from, to, line);
exit(1); exit(1);
} }
#ifdef USE_LIBICONV_DLL #ifdef USE_LIBICONV_DLL
if (((rec_iconv_t *)cd)->hlibiconv != NULL) if (((rec_iconv_t *)cd)->hlibiconv != NULL)
GetModuleFileName(((rec_iconv_t *)cd)->hlibiconv, dllpath, sizeof(dllpath)); GetModuleFileName(((rec_iconv_t *)cd)->hlibiconv, dllpath, sizeof(dllpath));
if (use_dll && ((rec_iconv_t *)cd)->hlibiconv == NULL) if (use_dll && ((rec_iconv_t *)cd)->hlibiconv == NULL)
{ {
printf("%s: %s -> %s: NG: FAILED TO USE DLL: line=%d\n", dllpath, from, to, line); printf("%s: %s -> %s: NG: FAILED TO USE DLL: line=%d\n", dllpath, from, to, line);
exit(1); exit(1);
} }
else if (!use_dll && ((rec_iconv_t *)cd)->hlibiconv != NULL) else if (!use_dll && ((rec_iconv_t *)cd)->hlibiconv != NULL)
{ {
printf("%s: %s -> %s: NG: DLL IS LOADED UNEXPECTEDLY: line=%d\n", dllpath, from, to, line); printf("%s: %s -> %s: NG: DLL IS LOADED UNEXPECTEDLY: line=%d\n", dllpath, from, to, line);
exit(1); exit(1);
} }
#endif #endif
errno = 0; errno = 0;
pin = fromstr; pin = fromstr;
pout = outbuf; pout = outbuf;
inbytesleft = fromsize; inbytesleft = fromsize;
outbytesleft = bufsize; outbytesleft = bufsize;
r = iconv(cd, &pin, &inbytesleft, &pout, &outbytesleft); r = iconv(cd, &pin, &inbytesleft, &pout, &outbytesleft);
if (r != (size_t)(-1)) if (r != (size_t)(-1))
r = iconv(cd, NULL, NULL, &pout, &outbytesleft); r = iconv(cd, NULL, NULL, &pout, &outbytesleft);
*pout = 0; *pout = 0;
#ifdef USE_LIBICONV_DLL #ifdef USE_LIBICONV_DLL
if (use_dll) if (use_dll)
printf("%s: ", dllpath); printf("%s: ", dllpath);
#endif #endif
printf("%s(%s) -> ", from, tohex(fromstr, fromsize)); printf("%s(%s) -> ", from, tohex(fromstr, fromsize));
printf("%s(%s%s%s): ", to, tohex(tostr, tosize), printf("%s(%s%s%s): ", to, tohex(tostr, tosize),
errcode == 0 ? "" : ":", errcode == 0 ? "" : ":",
errcode == 0 ? "" : errstr(errcode)); errcode == 0 ? "" : errstr(errcode));
if (strcmp(outbuf, tostr) == 0 && errno == errcode) if (strcmp(outbuf, tostr) == 0 && errno == errcode)
printf("OK\n"); printf("OK\n");
else else
{ {
printf("RESULT(%s:%s): ", tohex(outbuf, sizeof(outbuf) - outbytesleft), printf("RESULT(%s:%s): ", tohex(outbuf, sizeof(outbuf) - outbytesleft),
errstr(errno)); errstr(errno));
printf("NG: line=%d\n", line); printf("NG: line=%d\n", line);
exit(1); exit(1);
} }
} }
#define STATIC_STRLEN(arr) (sizeof(arr) - 1) #define STATIC_STRLEN(arr) (sizeof(arr) - 1)
#define success(from, fromstr, to, tostr) test(from, fromstr, STATIC_STRLEN(fromstr), to, tostr, STATIC_STRLEN(tostr), 0, BUFSIZ, __LINE__) #define success(from, fromstr, to, tostr) test(from, fromstr, STATIC_STRLEN(fromstr), to, tostr, STATIC_STRLEN(tostr), 0, BUFSIZ, __LINE__)
#define einval(from, fromstr, to, tostr) test(from, fromstr, STATIC_STRLEN(fromstr), to, tostr, STATIC_STRLEN(tostr), EINVAL, BUFSIZ, __LINE__) #define einval(from, fromstr, to, tostr) test(from, fromstr, STATIC_STRLEN(fromstr), to, tostr, STATIC_STRLEN(tostr), EINVAL, BUFSIZ, __LINE__)
#define eilseq(from, fromstr, to, tostr) test(from, fromstr, STATIC_STRLEN(fromstr), to, tostr, STATIC_STRLEN(tostr), EILSEQ, BUFSIZ, __LINE__) #define eilseq(from, fromstr, to, tostr) test(from, fromstr, STATIC_STRLEN(fromstr), to, tostr, STATIC_STRLEN(tostr), EILSEQ, BUFSIZ, __LINE__)
#define e2big(from, fromstr, to, tostr, bufsize) test(from, fromstr, STATIC_STRLEN(fromstr), to, tostr, STATIC_STRLEN(tostr), E2BIG, bufsize, __LINE__) #define e2big(from, fromstr, to, tostr, bufsize) test(from, fromstr, STATIC_STRLEN(fromstr), to, tostr, STATIC_STRLEN(tostr), E2BIG, bufsize, __LINE__)
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
#ifdef USE_LIBICONV_DLL #ifdef USE_LIBICONV_DLL
/* test use of dll if $DEFAULT_LIBICONV_DLL was defined. */ /* test use of dll if $DEFAULT_LIBICONV_DLL was defined. */
if (setdll("")) if (setdll(""))
{ {
success("ascii", "ABC", "ascii", "ABC"); success("ascii", "ABC", "ascii", "ABC");
success("ascii", "ABC", "utf-16be", "\x00\x41\x00\x42\x00\x43"); success("ascii", "ABC", "utf-16be", "\x00\x41\x00\x42\x00\x43");
} }
else else
{ {
printf("\nDLL TEST IS SKIPPED\n\n"); printf("\nDLL TEST IS SKIPPED\n\n");
} }
setdll("none"); setdll("none");
#endif #endif
if (check_enc("ascii", 20127)) if (check_enc("ascii", 20127))
{ {
success("ascii", "ABC", "ascii", "ABC"); success("ascii", "ABC", "ascii", "ABC");
/* MSB is dropped. Hmm... */ /* MSB is dropped. Hmm... */
success("ascii", "\x80\xFF", "ascii", "\x00\x7F"); success("ascii", "\x80\xFF", "ascii", "\x00\x7F");
} }
/* unicode (CP1200 CP1201 CP12000 CP12001 CP65001) */ /* unicode (CP1200 CP1201 CP12000 CP12001 CP65001) */
if (check_enc("utf-8", 65001) if (check_enc("utf-8", 65001)
&& check_enc("utf-16be", 1201) && check_enc("utf-16le", 1200) && check_enc("utf-16be", 1201) && check_enc("utf-16le", 1200)
&& check_enc("utf-32be", 12001) && check_enc("utf-32le", 12000) && check_enc("utf-32be", 12001) && check_enc("utf-32le", 12000)
) )
{ {
/* Test the BOM behavior /* Test the BOM behavior
* 1. Remove the BOM when "fromcode" is utf-16 or utf-32. * 1. Remove the BOM when "fromcode" is utf-16 or utf-32.
* 2. Add the BOM when "tocode" is utf-16 or utf-32. */ * 2. Add the BOM when "tocode" is utf-16 or utf-32. */
success("utf-16", "\xFE\xFF\x01\x02", "utf-16be", "\x01\x02"); success("utf-16", "\xFE\xFF\x01\x02", "utf-16be", "\x01\x02");
success("utf-16", "\xFF\xFE\x02\x01", "utf-16be", "\x01\x02"); success("utf-16", "\xFF\xFE\x02\x01", "utf-16be", "\x01\x02");
success("utf-32", "\x00\x00\xFE\xFF\x00\x00\x01\x02", "utf-32be", "\x00\x00\x01\x02"); success("utf-32", "\x00\x00\xFE\xFF\x00\x00\x01\x02", "utf-32be", "\x00\x00\x01\x02");
success("utf-32", "\xFF\xFE\x00\x00\x02\x01\x00\x00", "utf-32be", "\x00\x00\x01\x02"); success("utf-32", "\xFF\xFE\x00\x00\x02\x01\x00\x00", "utf-32be", "\x00\x00\x01\x02");
success("utf-16", "\xFE\xFF\x00\x01", "utf-8", "\x01"); success("utf-16", "\xFE\xFF\x00\x01", "utf-8", "\x01");
#ifndef GLIB_COMPILATION #ifndef GLIB_COMPILATION
success("utf-8", "\x01", "utf-16", "\xFE\xFF\x00\x01"); success("utf-8", "\x01", "utf-16", "\xFE\xFF\x00\x01");
success("utf-8", "\x01", "utf-32", "\x00\x00\xFE\xFF\x00\x00\x00\x01"); success("utf-8", "\x01", "utf-32", "\x00\x00\xFE\xFF\x00\x00\x00\x01");
#else #else
success("utf-8", "\x01", "utf-16", "\xFF\xFE\x01\x00"); success("utf-8", "\x01", "utf-16", "\xFF\xFE\x01\x00");
success("utf-8", "\x01", "utf-32", "\xFF\xFE\x00\x00\x01\x00\x00\x00"); success("utf-8", "\x01", "utf-32", "\xFF\xFE\x00\x00\x01\x00\x00\x00");
#endif #endif
success("utf-16be", "\xFE\xFF\x01\x02", "utf-16be", "\xFE\xFF\x01\x02"); success("utf-16be", "\xFE\xFF\x01\x02", "utf-16be", "\xFE\xFF\x01\x02");
success("utf-16le", "\xFF\xFE\x02\x01", "utf-16be", "\xFE\xFF\x01\x02"); success("utf-16le", "\xFF\xFE\x02\x01", "utf-16be", "\xFE\xFF\x01\x02");
success("utf-32be", "\x00\x00\xFE\xFF\x00\x00\x01\x02", "utf-32be", "\x00\x00\xFE\xFF\x00\x00\x01\x02"); success("utf-32be", "\x00\x00\xFE\xFF\x00\x00\x01\x02", "utf-32be", "\x00\x00\xFE\xFF\x00\x00\x01\x02");
success("utf-32le", "\xFF\xFE\x00\x00\x02\x01\x00\x00", "utf-32be", "\x00\x00\xFE\xFF\x00\x00\x01\x02"); success("utf-32le", "\xFF\xFE\x00\x00\x02\x01\x00\x00", "utf-32be", "\x00\x00\xFE\xFF\x00\x00\x01\x02");
success("utf-16be", "\xFE\xFF\x00\x01", "utf-8", "\xEF\xBB\xBF\x01"); success("utf-16be", "\xFE\xFF\x00\x01", "utf-8", "\xEF\xBB\xBF\x01");
success("utf-8", "\xEF\xBB\xBF\x01", "utf-8", "\xEF\xBB\xBF\x01"); success("utf-8", "\xEF\xBB\xBF\x01", "utf-8", "\xEF\xBB\xBF\x01");
success("utf-16be", "\x01\x02", "utf-16le", "\x02\x01"); success("utf-16be", "\x01\x02", "utf-16le", "\x02\x01");
success("utf-16le", "\x02\x01", "utf-16be", "\x01\x02"); success("utf-16le", "\x02\x01", "utf-16be", "\x01\x02");
success("utf-16be", "\xFE\xFF", "utf-16le", "\xFF\xFE"); success("utf-16be", "\xFE\xFF", "utf-16le", "\xFF\xFE");
success("utf-16le", "\xFF\xFE", "utf-16be", "\xFE\xFF"); success("utf-16le", "\xFF\xFE", "utf-16be", "\xFE\xFF");
success("utf-32be", "\x00\x00\x03\x04", "utf-32le", "\x04\x03\x00\x00"); success("utf-32be", "\x00\x00\x03\x04", "utf-32le", "\x04\x03\x00\x00");
success("utf-32le", "\x04\x03\x00\x00", "utf-32be", "\x00\x00\x03\x04"); success("utf-32le", "\x04\x03\x00\x00", "utf-32be", "\x00\x00\x03\x04");
success("utf-32be", "\x00\x00\xFF\xFF", "utf-16be", "\xFF\xFF"); success("utf-32be", "\x00\x00\xFF\xFF", "utf-16be", "\xFF\xFF");
success("utf-16be", "\xFF\xFF", "utf-32be", "\x00\x00\xFF\xFF"); success("utf-16be", "\xFF\xFF", "utf-32be", "\x00\x00\xFF\xFF");
success("utf-32be", "\x00\x01\x00\x00", "utf-16be", "\xD8\x00\xDC\x00"); success("utf-32be", "\x00\x01\x00\x00", "utf-16be", "\xD8\x00\xDC\x00");
success("utf-16be", "\xD8\x00\xDC\x00", "utf-32be", "\x00\x01\x00\x00"); success("utf-16be", "\xD8\x00\xDC\x00", "utf-32be", "\x00\x01\x00\x00");
success("utf-32be", "\x00\x10\xFF\xFF", "utf-16be", "\xDB\xFF\xDF\xFF"); success("utf-32be", "\x00\x10\xFF\xFF", "utf-16be", "\xDB\xFF\xDF\xFF");
success("utf-16be", "\xDB\xFF\xDF\xFF", "utf-32be", "\x00\x10\xFF\xFF"); success("utf-16be", "\xDB\xFF\xDF\xFF", "utf-32be", "\x00\x10\xFF\xFF");
eilseq("utf-32be", "\x00\x11\x00\x00", "utf-16be", ""); eilseq("utf-32be", "\x00\x11\x00\x00", "utf-16be", "");
eilseq("utf-16be", "\xDB\xFF\xE0\x00", "utf-32be", ""); eilseq("utf-16be", "\xDB\xFF\xE0\x00", "utf-32be", "");
success("utf-8", "\xE3\x81\x82", "utf-16be", "\x30\x42"); success("utf-8", "\xE3\x81\x82", "utf-16be", "\x30\x42");
einval("utf-8", "\xE3", "utf-16be", ""); einval("utf-8", "\xE3", "utf-16be", "");
} }
/* Japanese (CP932 CP20932 CP50220 CP50221 CP50222 CP51932) */ /* Japanese (CP932 CP20932 CP50220 CP50221 CP50222 CP51932) */
if (check_enc("cp932", 932) if (check_enc("cp932", 932)
&& check_enc("cp20932", 20932) && check_enc("euc-jp", 51932) && check_enc("cp20932", 20932) && check_enc("euc-jp", 51932)
&& check_enc("cp50220", 50220) && check_enc("cp50221", 50221) && check_enc("cp50220", 50220) && check_enc("cp50221", 50221)
&& check_enc("cp50222", 50222) && check_enc("iso-2022-jp", 50221)) && check_enc("cp50222", 50222) && check_enc("iso-2022-jp", 50221))
{ {
/* Test the compatibility for each other Japanese codepage. /* Test the compatibility for each other Japanese codepage.
* And validate the escape sequence handling for iso-2022-jp. */ * And validate the escape sequence handling for iso-2022-jp. */
success("utf-16be", "\xFF\x5E", "cp932", "\x81\x60"); success("utf-16be", "\xFF\x5E", "cp932", "\x81\x60");
success("utf-16be", "\x30\x1C", "cp932", "\x81\x60"); success("utf-16be", "\x30\x1C", "cp932", "\x81\x60");
success("utf-16be", "\xFF\x5E", "cp932//nocompat", "\x81\x60"); success("utf-16be", "\xFF\x5E", "cp932//nocompat", "\x81\x60");
eilseq("utf-16be", "\x30\x1C", "cp932//nocompat", ""); eilseq("utf-16be", "\x30\x1C", "cp932//nocompat", "");
success("euc-jp", "\xA4\xA2", "utf-16be", "\x30\x42"); success("euc-jp", "\xA4\xA2", "utf-16be", "\x30\x42");
einval("euc-jp", "\xA4\xA2\xA4", "utf-16be", "\x30\x42"); einval("euc-jp", "\xA4\xA2\xA4", "utf-16be", "\x30\x42");
eilseq("euc-jp", "\xA4\xA2\xFF\xFF", "utf-16be", "\x30\x42"); eilseq("euc-jp", "\xA4\xA2\xFF\xFF", "utf-16be", "\x30\x42");
success("cp932", "\x81\x60", "iso-2022-jp", "\x1B\x24\x42\x21\x41\x1B\x28\x42"); success("cp932", "\x81\x60", "iso-2022-jp", "\x1B\x24\x42\x21\x41\x1B\x28\x42");
success("UTF-16BE", "\xFF\x5E", "iso-2022-jp", "\x1B\x24\x42\x21\x41\x1B\x28\x42"); success("UTF-16BE", "\xFF\x5E", "iso-2022-jp", "\x1B\x24\x42\x21\x41\x1B\x28\x42");
eilseq("UTF-16BE", "\x30\x1C", "iso-2022-jp//nocompat", ""); eilseq("UTF-16BE", "\x30\x1C", "iso-2022-jp//nocompat", "");
success("UTF-16BE", "\x30\x42\x30\x44", "iso-2022-jp", "\x1B\x24\x42\x24\x22\x24\x24\x1B\x28\x42"); success("UTF-16BE", "\x30\x42\x30\x44", "iso-2022-jp", "\x1B\x24\x42\x24\x22\x24\x24\x1B\x28\x42");
success("iso-2022-jp", "\x1B\x24\x42\x21\x41\x1B\x28\x42", "UTF-16BE", "\xFF\x5E"); success("iso-2022-jp", "\x1B\x24\x42\x21\x41\x1B\x28\x42", "UTF-16BE", "\xFF\x5E");
} }
/* /*
* test for //translit * test for //translit
* U+FF41 (FULLWIDTH LATIN SMALL LETTER A) <-> U+0062 (LATIN SMALL LETTER A) * U+FF41 (FULLWIDTH LATIN SMALL LETTER A) <-> U+0062 (LATIN SMALL LETTER A)
*/ */
eilseq("UTF-16BE", "\xFF\x41", "iso-8859-1", ""); eilseq("UTF-16BE", "\xFF\x41", "iso-8859-1", "");
success("UTF-16BE", "\xFF\x41", "iso-8859-1//translit", "a"); success("UTF-16BE", "\xFF\x41", "iso-8859-1//translit", "a");
/* /*
* TODO: * TODO:
* Test for state after iconv() failed. * Test for state after iconv() failed.
* Ensure iconv() error is safe and continuable. * Ensure iconv() error is safe and continuable.
*/ */
return 0; return 0;
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,331 +1,331 @@
/* Opal endpoint interface for Freeswitch Modular Media Switching Software Library / /* Opal endpoint interface for Freeswitch Modular Media Switching Software Library /
* Soft-Switch Application * Soft-Switch Application
* *
* Version: MPL 1.1 * Version: MPL 1.1
* *
* Copyright (c) 2007 Tuyan Ozipek (tuyanozipek@gmail.com) * Copyright (c) 2007 Tuyan Ozipek (tuyanozipek@gmail.com)
* Copyright (c) 2008-2012 Vox Lucida Pty. Ltd. (robertj@voxlucida.com.au) * Copyright (c) 2008-2012 Vox Lucida Pty. Ltd. (robertj@voxlucida.com.au)
* *
* The contents of this file are subject to the Mozilla Public License Version * The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with * 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at * the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/ * http://www.mozilla.org/MPL/
* *
* Software distributed under the License is distributed on an "AS IS" basis, * Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the * for the specific language governing rights and limitations under the
* License. * License.
* *
* Contributor(s): * Contributor(s):
* Tuyan Ozipek (tuyanozipek@gmail.com) * Tuyan Ozipek (tuyanozipek@gmail.com)
* Lukasz Zwierko (lzwierko@gmail.com) * Lukasz Zwierko (lzwierko@gmail.com)
* Robert Jongbloed (robertj@voxlucida.com.au) * Robert Jongbloed (robertj@voxlucida.com.au)
* *
*/ */
#ifndef __FREESWITCH_MOD_OPAL__ #ifndef __FREESWITCH_MOD_OPAL__
#define __FREESWITCH_MOD_OPAL__ #define __FREESWITCH_MOD_OPAL__
#if defined(__GNUC__) && defined(HAVE_VISIBILITY) #if defined(__GNUC__) && defined(HAVE_VISIBILITY)
#pragma GCC visibility push(default) #pragma GCC visibility push(default)
#endif #endif
#include <ptlib.h> #include <ptlib.h>
#include <opal/manager.h> #include <opal/manager.h>
#ifndef OPAL_CHECK_VERSION #ifndef OPAL_CHECK_VERSION
#define OPAL_CHECK_VERSION(a,b,c) 0 #define OPAL_CHECK_VERSION(a,b,c) 0
#endif #endif
#if !OPAL_CHECK_VERSION(3,12,8) #if !OPAL_CHECK_VERSION(3,12,8)
#error OPAL is too old to use, must be >= 2.12.8 #error OPAL is too old to use, must be >= 2.12.8
#endif #endif
#include <ep/localep.h> #include <ep/localep.h>
#include <h323/h323ep.h> #include <h323/h323ep.h>
#include <iax2/iax2ep.h> #include <iax2/iax2ep.h>
#if defined(__GNUC__) && defined(HAVE_VISIBILITY) #if defined(__GNUC__) && defined(HAVE_VISIBILITY)
#pragma GCC visibility pop #pragma GCC visibility pop
#endif #endif
#undef strcasecmp #undef strcasecmp
#undef strncasecmp #undef strncasecmp
#include <switch.h> #include <switch.h>
#define MODNAME "mod_opal" #define MODNAME "mod_opal"
#define HAVE_T38 OPAL_T38_CAPABILITY #define HAVE_T38 OPAL_T38_CAPABILITY
class FSEndPoint; class FSEndPoint;
class FSManager; class FSManager;
class FSProcess : public PLibraryProcess class FSProcess : public PLibraryProcess
{ {
PCLASSINFO(FSProcess, PLibraryProcess); PCLASSINFO(FSProcess, PLibraryProcess);
public: public:
FSProcess(); FSProcess();
~FSProcess(); ~FSProcess();
bool Initialise(switch_loadable_module_interface_t *iface); bool Initialise(switch_loadable_module_interface_t *iface);
FSManager & GetManager() const FSManager & GetManager() const
{ {
return *m_manager; return *m_manager;
} }
protected: protected:
FSManager * m_manager; FSManager * m_manager;
}; };
struct FSListener struct FSListener
{ {
FSListener() : m_port(H323EndPoint::DefaultTcpSignalPort) { } FSListener() : m_port(H323EndPoint::DefaultTcpSignalPort) { }
PString m_name; PString m_name;
PIPSocket::Address m_address; PIPSocket::Address m_address;
uint16_t m_port; uint16_t m_port;
}; };
class FSManager : public OpalManager class FSManager : public OpalManager
{ {
PCLASSINFO(FSManager, OpalManager); PCLASSINFO(FSManager, OpalManager);
public: public:
FSManager(); FSManager();
bool Initialise(switch_loadable_module_interface_t *iface); bool Initialise(switch_loadable_module_interface_t *iface);
switch_status_t ReadConfig(int reload); switch_status_t ReadConfig(int reload);
switch_endpoint_interface_t *GetSwitchInterface() const { return m_FreeSwitch; } switch_endpoint_interface_t *GetSwitchInterface() const { return m_FreeSwitch; }
const PString & GetContext() const { return m_context; } const PString & GetContext() const { return m_context; }
const PString & GetDialPlan() const { return m_dialplan; } const PString & GetDialPlan() const { return m_dialplan; }
const PString & GetCodecPrefs() const { return m_codecPrefs; } const PString & GetCodecPrefs() const { return m_codecPrefs; }
bool GetDisableTranscoding() const { return m_disableTranscoding; } bool GetDisableTranscoding() const { return m_disableTranscoding; }
private: private:
switch_endpoint_interface_t *m_FreeSwitch; switch_endpoint_interface_t *m_FreeSwitch;
H323EndPoint *m_h323ep; H323EndPoint *m_h323ep;
IAX2EndPoint *m_iaxep; IAX2EndPoint *m_iaxep;
FSEndPoint *m_fsep; FSEndPoint *m_fsep;
PString m_context; PString m_context;
PString m_dialplan; PString m_dialplan;
PString m_codecPrefs; PString m_codecPrefs;
bool m_disableTranscoding; bool m_disableTranscoding;
PString m_gkAddress; PString m_gkAddress;
PString m_gkIdentifer; PString m_gkIdentifer;
PString m_gkInterface; PString m_gkInterface;
list <FSListener> m_listeners; list <FSListener> m_listeners;
}; };
class FSEndPoint : public OpalLocalEndPoint class FSEndPoint : public OpalLocalEndPoint
{ {
PCLASSINFO(FSEndPoint, OpalLocalEndPoint); PCLASSINFO(FSEndPoint, OpalLocalEndPoint);
public: public:
FSEndPoint(FSManager & manager); FSEndPoint(FSManager & manager);
virtual OpalLocalConnection *CreateConnection(OpalCall & call, void *userData, unsigned options, OpalConnection::StringOptions * stringOptions); virtual OpalLocalConnection *CreateConnection(OpalCall & call, void *userData, unsigned options, OpalConnection::StringOptions * stringOptions);
FSManager & GetManager() const { return m_manager; } FSManager & GetManager() const { return m_manager; }
protected: protected:
FSManager & m_manager; FSManager & m_manager;
}; };
class FSConnection; class FSConnection;
class FSMediaStream : public OpalMediaStream class FSMediaStream : public OpalMediaStream
{ {
PCLASSINFO(FSMediaStream, OpalMediaStream); PCLASSINFO(FSMediaStream, OpalMediaStream);
public: public:
FSMediaStream( FSMediaStream(
FSConnection & conn, FSConnection & conn,
const OpalMediaFormat & mediaFormat, ///< Media format for stream const OpalMediaFormat & mediaFormat, ///< Media format for stream
unsigned sessionID, ///< Session number for stream unsigned sessionID, ///< Session number for stream
bool isSource ///< Is a source stream bool isSource ///< Is a source stream
); );
virtual PBoolean Open(); virtual PBoolean Open();
virtual PBoolean IsSynchronous() const; virtual PBoolean IsSynchronous() const;
virtual PBoolean RequiresPatchThread(OpalMediaStream *) const; virtual PBoolean RequiresPatchThread(OpalMediaStream *) const;
switch_status_t read_frame(switch_frame_t **frame, switch_io_flag_t flags); switch_status_t read_frame(switch_frame_t **frame, switch_io_flag_t flags);
switch_status_t write_frame(const switch_frame_t *frame, switch_io_flag_t flags); switch_status_t write_frame(const switch_frame_t *frame, switch_io_flag_t flags);
protected: protected:
virtual void InternalClose(); virtual void InternalClose();
int StartReadWrite(PatchPtr & mediaPatch) const; int StartReadWrite(PatchPtr & mediaPatch) const;
private: private:
bool CheckPatchAndLock(); bool CheckPatchAndLock();
FSConnection &m_connection; FSConnection &m_connection;
switch_timer_t *m_switchTimer; switch_timer_t *m_switchTimer;
switch_codec_t *m_switchCodec; switch_codec_t *m_switchCodec;
switch_frame_t m_readFrame; switch_frame_t m_readFrame;
RTP_DataFrame m_readRTP; RTP_DataFrame m_readRTP;
}; };
#define DECLARE_CALLBACK0(name) \ #define DECLARE_CALLBACK0(name) \
static switch_status_t name(switch_core_session_t *session) { \ static switch_status_t name(switch_core_session_t *session) { \
FSConnection *tech_pvt = (FSConnection *) switch_core_session_get_private(session); \ FSConnection *tech_pvt = (FSConnection *) switch_core_session_get_private(session); \
return tech_pvt != NULL ? tech_pvt->name() : SWITCH_STATUS_FALSE; } \ return tech_pvt != NULL ? tech_pvt->name() : SWITCH_STATUS_FALSE; } \
switch_status_t name() switch_status_t name()
#define DECLARE_CALLBACK1(name, type1, name1) \ #define DECLARE_CALLBACK1(name, type1, name1) \
static switch_status_t name(switch_core_session_t *session, type1 name1) { \ static switch_status_t name(switch_core_session_t *session, type1 name1) { \
FSConnection *tech_pvt = (FSConnection *) switch_core_session_get_private(session); \ FSConnection *tech_pvt = (FSConnection *) switch_core_session_get_private(session); \
return tech_pvt != NULL ? tech_pvt->name(name1) : SWITCH_STATUS_FALSE; } \ return tech_pvt != NULL ? tech_pvt->name(name1) : SWITCH_STATUS_FALSE; } \
switch_status_t name(type1 name1) switch_status_t name(type1 name1)
#define DECLARE_CALLBACK3(name, type1, name1, type2, name2, type3, name3) \ #define DECLARE_CALLBACK3(name, type1, name1, type2, name2, type3, name3) \
static switch_status_t name(switch_core_session_t *session, type1 name1, type2 name2, type3 name3) { \ static switch_status_t name(switch_core_session_t *session, type1 name1, type2 name2, type3 name3) { \
FSConnection *tech_pvt = (FSConnection *) switch_core_session_get_private(session); \ FSConnection *tech_pvt = (FSConnection *) switch_core_session_get_private(session); \
return tech_pvt != NULL ? tech_pvt->name(name1, name2, name3) : SWITCH_STATUS_FALSE; } \ return tech_pvt != NULL ? tech_pvt->name(name1, name2, name3) : SWITCH_STATUS_FALSE; } \
switch_status_t name(type1 name1, type2 name2, type3 name3) switch_status_t name(type1 name1, type2 name2, type3 name3)
class FSConnection : public OpalLocalConnection class FSConnection : public OpalLocalConnection
{ {
PCLASSINFO(FSConnection, OpalLocalConnection) PCLASSINFO(FSConnection, OpalLocalConnection)
public: public:
struct outgoing_params { struct outgoing_params {
switch_event_t *var_event; switch_event_t *var_event;
switch_caller_profile_t *outbound_profile; switch_caller_profile_t *outbound_profile;
switch_core_session_t **new_session; switch_core_session_t **new_session;
switch_memory_pool_t **pool; switch_memory_pool_t **pool;
switch_originate_flag_t flags; switch_originate_flag_t flags;
switch_call_cause_t *cancel_cause; switch_call_cause_t *cancel_cause;
switch_call_cause_t fail_cause; switch_call_cause_t fail_cause;
}; };
FSConnection(OpalCall & call, FSConnection(OpalCall & call,
FSEndPoint & endpoint, FSEndPoint & endpoint,
unsigned options, unsigned options,
OpalConnection::StringOptions * stringOptions, OpalConnection::StringOptions * stringOptions,
outgoing_params * params); outgoing_params * params);
virtual bool OnOutgoingSetUp(); virtual bool OnOutgoingSetUp();
virtual bool OnIncoming(); virtual bool OnIncoming();
virtual void OnEstablished(); virtual void OnEstablished();
virtual void OnReleased(); virtual void OnReleased();
virtual PBoolean SetAlerting(const PString & calleeName, PBoolean withMedia); virtual PBoolean SetAlerting(const PString & calleeName, PBoolean withMedia);
virtual OpalMediaStream *CreateMediaStream(const OpalMediaFormat &, unsigned, PBoolean); virtual OpalMediaStream *CreateMediaStream(const OpalMediaFormat &, unsigned, PBoolean);
virtual void OnPatchMediaStream(PBoolean isSource, OpalMediaPatch & patch); virtual void OnPatchMediaStream(PBoolean isSource, OpalMediaPatch & patch);
virtual OpalMediaFormatList GetMediaFormats() const; virtual OpalMediaFormatList GetMediaFormats() const;
virtual PBoolean SendUserInputTone(char tone, unsigned duration); virtual PBoolean SendUserInputTone(char tone, unsigned duration);
#if HAVE_T38 #if HAVE_T38
virtual void OnSwitchedT38(bool toT38, bool success); virtual void OnSwitchedT38(bool toT38, bool success);
virtual void OnSwitchingT38(bool toT38); virtual void OnSwitchingT38(bool toT38);
#endif #endif
DECLARE_CALLBACK0(on_init); DECLARE_CALLBACK0(on_init);
DECLARE_CALLBACK0(on_destroy); DECLARE_CALLBACK0(on_destroy);
DECLARE_CALLBACK0(on_routing); DECLARE_CALLBACK0(on_routing);
DECLARE_CALLBACK0(on_execute); DECLARE_CALLBACK0(on_execute);
DECLARE_CALLBACK0(on_hangup); DECLARE_CALLBACK0(on_hangup);
DECLARE_CALLBACK0(on_exchange_media); DECLARE_CALLBACK0(on_exchange_media);
DECLARE_CALLBACK0(on_soft_execute); DECLARE_CALLBACK0(on_soft_execute);
DECLARE_CALLBACK1(kill_channel, int, sig); DECLARE_CALLBACK1(kill_channel, int, sig);
DECLARE_CALLBACK1(send_dtmf, const switch_dtmf_t *, dtmf); DECLARE_CALLBACK1(send_dtmf, const switch_dtmf_t *, dtmf);
DECLARE_CALLBACK1(receive_message, switch_core_session_message_t *, msg); DECLARE_CALLBACK1(receive_message, switch_core_session_message_t *, msg);
DECLARE_CALLBACK1(receive_event, switch_event_t *, event); DECLARE_CALLBACK1(receive_event, switch_event_t *, event);
DECLARE_CALLBACK0(state_change); DECLARE_CALLBACK0(state_change);
DECLARE_CALLBACK3(read_audio_frame, switch_frame_t **, frame, switch_io_flag_t, flags, int, stream_id); DECLARE_CALLBACK3(read_audio_frame, switch_frame_t **, frame, switch_io_flag_t, flags, int, stream_id);
DECLARE_CALLBACK3(write_audio_frame, switch_frame_t *, frame, switch_io_flag_t, flags, int, stream_id); DECLARE_CALLBACK3(write_audio_frame, switch_frame_t *, frame, switch_io_flag_t, flags, int, stream_id);
DECLARE_CALLBACK3(read_video_frame, switch_frame_t **, frame, switch_io_flag_t, flag, int, stream_id); DECLARE_CALLBACK3(read_video_frame, switch_frame_t **, frame, switch_io_flag_t, flag, int, stream_id);
DECLARE_CALLBACK3(write_video_frame, switch_frame_t *, frame, switch_io_flag_t, flag, int, stream_id); DECLARE_CALLBACK3(write_video_frame, switch_frame_t *, frame, switch_io_flag_t, flag, int, stream_id);
__inline switch_core_session_t *GetSession() const __inline switch_core_session_t *GetSession() const
{ {
return m_fsSession; return m_fsSession;
} }
__inline switch_channel_t *GetChannel() const __inline switch_channel_t *GetChannel() const
{ {
return m_fsChannel; return m_fsChannel;
} }
bool IsChannelReady() const bool IsChannelReady() const
{ {
return m_fsChannel != NULL && switch_channel_ready(m_fsChannel); return m_fsChannel != NULL && switch_channel_ready(m_fsChannel);
} }
bool NeedFlushAudio() bool NeedFlushAudio()
{ {
if (!m_flushAudio) if (!m_flushAudio)
return false; return false;
m_flushAudio = false; m_flushAudio = false;
return true; return true;
} }
protected: protected:
void SetCodecs(); void SetCodecs();
bool WaitForMedia(); bool WaitForMedia();
#if HAVE_T38 #if HAVE_T38
void SetT38OptionsFromMediaFormat(const OpalMediaFormat & mediaFormat, const char * varname); void SetT38OptionsFromMediaFormat(const OpalMediaFormat & mediaFormat, const char * varname);
bool IndicateSwitchedT38(); bool IndicateSwitchedT38();
void AbortT38(); void AbortT38();
#endif #endif
switch_status_t read_frame(const OpalMediaType & mediaType, switch_frame_t **frame, switch_io_flag_t flags); switch_status_t read_frame(const OpalMediaType & mediaType, switch_frame_t **frame, switch_io_flag_t flags);
switch_status_t write_frame(const OpalMediaType & mediaType, const switch_frame_t *frame, switch_io_flag_t flags); switch_status_t write_frame(const OpalMediaType & mediaType, const switch_frame_t *frame, switch_io_flag_t flags);
private: private:
FSEndPoint &m_endpoint; FSEndPoint &m_endpoint;
switch_core_session_t *m_fsSession; switch_core_session_t *m_fsSession;
switch_channel_t *m_fsChannel; switch_channel_t *m_fsChannel;
PSyncPoint m_rxAudioOpened; PSyncPoint m_rxAudioOpened;
PSyncPoint m_txAudioOpened; PSyncPoint m_txAudioOpened;
OpalMediaFormatList m_switchMediaFormats; OpalMediaFormatList m_switchMediaFormats;
// If FS ever supports more than one audio and one video, this needs to change // If FS ever supports more than one audio and one video, this needs to change
switch_timer_t m_read_timer; switch_timer_t m_read_timer;
switch_codec_t m_read_codec; switch_codec_t m_read_codec;
switch_codec_t m_write_codec; switch_codec_t m_write_codec;
switch_timer_t m_vid_read_timer; switch_timer_t m_vid_read_timer;
switch_codec_t m_vid_read_codec; switch_codec_t m_vid_read_codec;
switch_codec_t m_vid_write_codec; switch_codec_t m_vid_write_codec;
switch_frame_t m_dummy_frame; switch_frame_t m_dummy_frame;
bool m_flushAudio; bool m_flushAudio;
bool m_udptl; bool m_udptl;
friend PBoolean FSMediaStream::Open(); friend PBoolean FSMediaStream::Open();
}; };
#endif /* __FREESWITCH_MOD_OPAL__ */ #endif /* __FREESWITCH_MOD_OPAL__ */
/* For Emacs: /* For Emacs:
* Local Variables: * Local Variables:
* mode:c * mode:c
* indent-tabs-mode:nil * indent-tabs-mode:nil
* tab-width:4 * tab-width:4
* c-basic-offset:4 * c-basic-offset:4
* End: * End:
* For VIM: * For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:s: * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:s:
*/ */

View File

@ -79,27 +79,27 @@
such a type exists and the standard includes do not define it. */ such a type exists and the standard includes do not define it. */
#cmakedefine uint8_t unsigned char #cmakedefine uint8_t unsigned char
#ifdef HAVE_INTTYPES_H #ifdef HAVE_INTTYPES_H
#include <inttypes.h> #include <inttypes.h>
#endif #endif
#include <stdlib.h> #include <stdlib.h>
/* AMF number */ /* AMF number */
typedef typedef
#if SIZEOF_FLOAT == 8 #if SIZEOF_FLOAT == 8
float float
#elif SIZEOF_DOUBLE == 8 #elif SIZEOF_DOUBLE == 8
double double
#elif SIZEOF_LONG_DOUBLE == 8 #elif SIZEOF_LONG_DOUBLE == 8
long double long double
#else #else
uint64_t uint64_t
#endif #endif
number64_t; number64_t;
/* custom read/write function type */ /* custom read/write function type */
typedef size_t (*read_proc_t)(void * out_buffer, size_t size, void * user_data); typedef size_t (*read_proc_t)(void * out_buffer, size_t size, void * user_data);
typedef size_t (*write_proc_t)(const void * in_buffer, size_t size, void * user_data); typedef size_t (*write_proc_t)(const void * in_buffer, size_t size, void * user_data);
#endif /* __AMF_H__ */ #endif /* __AMF_H__ */

View File

@ -1 +1 @@
#define PERL_LIB "@PERL_LIB@" #define PERL_LIB "@PERL_LIB@"

View File

@ -49,9 +49,9 @@
#include <math.h> #include <math.h>
#include <ctype.h> #include <ctype.h>
void gregorian_to_jalali(/* output */ int *j_y, int *j_m, int *j_d, void gregorian_to_jalali(/* output */ int *j_y, int *j_m, int *j_d,
/* input */ int g_y, int g_m, int g_d); /* input */ int g_y, int g_m, int g_d);
void jalali_to_gregorian(/* output */ int *g_y, int *g_m, int *g_d, void jalali_to_gregorian(/* output */ int *g_y, int *g_m, int *g_d,
/* input */ int j_y, int j_m, int j_d); /* input */ int j_y, int j_m, int j_d);
SWITCH_MODULE_LOAD_FUNCTION(mod_say_fa_load); SWITCH_MODULE_LOAD_FUNCTION(mod_say_fa_load);
@ -575,108 +575,108 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_say_fa_load)
int g_days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int g_days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int j_days_in_month[12] = {31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29}; int j_days_in_month[12] = {31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29};
void gregorian_to_jalali(int *j_y, int *j_m, int *j_d, void gregorian_to_jalali(int *j_y, int *j_m, int *j_d,
int g_y, int g_m, int g_d) int g_y, int g_m, int g_d)
{ {
int gy, gm, gd; int gy, gm, gd;
int jy, jm, jd; int jy, jm, jd;
long g_day_no, j_day_no; long g_day_no, j_day_no;
int j_np; int j_np;
int i; int i;
gy = g_y-1600; gy = g_y-1600;
gm = g_m-1; gm = g_m-1;
gd = g_d-1; gd = g_d-1;
g_day_no = 365*gy+(gy+3)/4-(gy+99)/100+(gy+399)/400; g_day_no = 365*gy+(gy+3)/4-(gy+99)/100+(gy+399)/400;
for (i=0;i<gm;++i) for (i=0;i<gm;++i)
g_day_no += g_days_in_month[i]; g_day_no += g_days_in_month[i];
if (gm>1 && ((gy%4==0 && gy%100!=0) || (gy%400==0))) if (gm>1 && ((gy%4==0 && gy%100!=0) || (gy%400==0)))
/* leap and after Feb */ /* leap and after Feb */
++g_day_no; ++g_day_no;
g_day_no += gd; g_day_no += gd;
j_day_no = g_day_no-79; j_day_no = g_day_no-79;
j_np = j_day_no / 12053; j_np = j_day_no / 12053;
j_day_no %= 12053; j_day_no %= 12053;
jy = 979+33*j_np+4*(j_day_no/1461); jy = 979+33*j_np+4*(j_day_no/1461);
j_day_no %= 1461; j_day_no %= 1461;
if (j_day_no >= 366) { if (j_day_no >= 366) {
jy += (j_day_no-1)/365; jy += (j_day_no-1)/365;
j_day_no = (j_day_no-1)%365; j_day_no = (j_day_no-1)%365;
} }
for (i = 0; i < 11 && j_day_no >= j_days_in_month[i]; ++i) { for (i = 0; i < 11 && j_day_no >= j_days_in_month[i]; ++i) {
j_day_no -= j_days_in_month[i]; j_day_no -= j_days_in_month[i];
} }
jm = i+1; jm = i+1;
jd = j_day_no+1; jd = j_day_no+1;
*j_y = jy; *j_y = jy;
*j_m = jm; *j_m = jm;
*j_d = jd; *j_d = jd;
} }
void jalali_to_gregorian(int *g_y, int *g_m, int *g_d, void jalali_to_gregorian(int *g_y, int *g_m, int *g_d,
int j_y, int j_m, int j_d) int j_y, int j_m, int j_d)
{ {
int gy, gm, gd; int gy, gm, gd;
int jy, jm, jd; int jy, jm, jd;
long g_day_no, j_day_no; long g_day_no, j_day_no;
int leap; int leap;
int i; int i;
jy = j_y-979; jy = j_y-979;
jm = j_m-1; jm = j_m-1;
jd = j_d-1; jd = j_d-1;
j_day_no = 365*jy + (jy/33)*8 + (jy%33+3)/4; j_day_no = 365*jy + (jy/33)*8 + (jy%33+3)/4;
for (i=0; i < jm; ++i) for (i=0; i < jm; ++i)
j_day_no += j_days_in_month[i]; j_day_no += j_days_in_month[i];
j_day_no += jd; j_day_no += jd;
g_day_no = j_day_no+79; g_day_no = j_day_no+79;
gy = 1600 + 400*(g_day_no/146097); /* 146097 = 365*400 + 400/4 - 400/100 + 400/400 */ gy = 1600 + 400*(g_day_no/146097); /* 146097 = 365*400 + 400/4 - 400/100 + 400/400 */
g_day_no = g_day_no % 146097; g_day_no = g_day_no % 146097;
leap = 1; leap = 1;
if (g_day_no >= 36525) /* 36525 = 365*100 + 100/4 */ if (g_day_no >= 36525) /* 36525 = 365*100 + 100/4 */
{ {
g_day_no--; g_day_no--;
gy += 100*(g_day_no/36524); /* 36524 = 365*100 + 100/4 - 100/100 */ gy += 100*(g_day_no/36524); /* 36524 = 365*100 + 100/4 - 100/100 */
g_day_no = g_day_no % 36524; g_day_no = g_day_no % 36524;
if (g_day_no >= 365) if (g_day_no >= 365)
g_day_no++; g_day_no++;
else else
leap = 0; leap = 0;
} }
gy += 4*(g_day_no/1461); /* 1461 = 365*4 + 4/4 */ gy += 4*(g_day_no/1461); /* 1461 = 365*4 + 4/4 */
g_day_no %= 1461; g_day_no %= 1461;
if (g_day_no >= 366) { if (g_day_no >= 366) {
leap = 0; leap = 0;
g_day_no--; g_day_no--;
gy += g_day_no/365; gy += g_day_no/365;
g_day_no = g_day_no % 365; g_day_no = g_day_no % 365;
} }
for (i = 0; g_day_no >= g_days_in_month[i] + (i == 1 && leap); i++) for (i = 0; g_day_no >= g_days_in_month[i] + (i == 1 && leap); i++)
g_day_no -= g_days_in_month[i] + (i == 1 && leap); g_day_no -= g_days_in_month[i] + (i == 1 && leap);
gm = i+1; gm = i+1;
gd = g_day_no+1; gd = g_day_no+1;
*g_y = gy; *g_y = gy;
*g_m = gm; *g_m = gm;
*g_d = gd; *g_d = gd;
} }
/* For Emacs: /* For Emacs:

File diff suppressed because it is too large Load Diff