mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-13 15:50:59 +00:00
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:
parent
31f98efc5c
commit
d6574e8c0f
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
The Cepstral SDK for Windows should be placed in c:\dev\cepstral
|
||||
ex. C:\dev\cepstral\sdk\include
|
||||
This SDK can be obtained from http://cepstral.com/
|
||||
The Cepstral SDK for Windows should be placed in c:\dev\cepstral
|
||||
ex. C:\dev\cepstral\sdk\include
|
||||
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/
|
@ -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());
|
||||
|
||||
#if 0
|
||||
size = MultiByteToWideChar(CP_OEMCP, 0, username, strlen(username)+1, UserName, 0);
|
||||
UserName=(wchar_t*)GlobalAlloc(GME M_ZEROINIT, size);
|
||||
ret = MultiByteToWideChar(CP_OEMCP, 0, username, strlen(username)+1, UserName, size);
|
||||
if(ret == 0)
|
||||
getError(GetLastError());
|
||||
size = MultiByteToWideChar(CP_OEMCP, 0, username, strlen(username)+1, UserName, 0);
|
||||
UserName=(wchar_t*)GlobalAlloc(GME M_ZEROINIT, size);
|
||||
ret = MultiByteToWideChar(CP_OEMCP, 0, username, strlen(username)+1, UserName, size);
|
||||
if(ret == 0)
|
||||
getError(GetLastError());
|
||||
#endif //0
|
||||
return (-1);
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
#ifndef LIBCTB_WIN32_GETOPT_H_INCLUDED_
|
||||
#define LIBCTB_WIN32_GETOPT_H_INCLUDED_
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: win32/getopt.h
|
||||
// Purpose:
|
||||
// Author: Joachim Buermann
|
||||
// Copyright: (c) 2010 Joachim Buermann
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern char* optarg;
|
||||
extern int optind;
|
||||
|
||||
int getopt(int argc, char* argv[], char* optstring);
|
||||
|
||||
#endif
|
||||
#ifndef LIBCTB_WIN32_GETOPT_H_INCLUDED_
|
||||
#define LIBCTB_WIN32_GETOPT_H_INCLUDED_
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: win32/getopt.h
|
||||
// Purpose:
|
||||
// Author: Joachim Buermann
|
||||
// Copyright: (c) 2010 Joachim Buermann
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern char* optarg;
|
||||
extern int optind;
|
||||
|
||||
int getopt(int argc, char* argv[], char* optstring);
|
||||
|
||||
#endif
|
||||
|
@ -1,414 +1,414 @@
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Win32 include file
|
||||
* for accessing the 32-bit GPIB DLL (gpib-32.dll)
|
||||
*
|
||||
*
|
||||
* Contains user variables (ibsta, iberr, ibcnt, ibcntl),
|
||||
* function prototypes and useful defined constants for
|
||||
* calling NI-488 and NI-488.2 routines from a Microsoft
|
||||
* C/C++ Win32 application.
|
||||
*
|
||||
*
|
||||
* Copyright 1998 National Instruments Corporation
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef DECL_32_H // ensure we are only included once
|
||||
#define DECL_32_H
|
||||
|
||||
#include "windows.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* HANDY CONSTANTS FOR USE BY APPLICATION PROGRAMS ... */
|
||||
/***************************************************************************/
|
||||
#define UNL 0x3f /* GPIB unlisten command */
|
||||
#define UNT 0x5f /* GPIB untalk command */
|
||||
#define GTL 0x01 /* GPIB go to local */
|
||||
#define SDC 0x04 /* GPIB selected device clear */
|
||||
#define PPC 0x05 /* GPIB parallel poll configure */
|
||||
#define GET 0x08 /* GPIB group execute trigger */
|
||||
#define TCT 0x09 /* GPIB take control */
|
||||
#define LLO 0x11 /* GPIB local lock out */
|
||||
#define DCL 0x14 /* GPIB device clear */
|
||||
#define PPU 0.16 /* GPIB parallel poll unconfigure */
|
||||
#define SPE 0x18 /* GPIB serial poll enable */
|
||||
#define SPD 0x19 /* GPIB serial poll disable */
|
||||
#define PPE 0x60 /* GPIB parallel poll enable */
|
||||
#define PPD 0x70 /* GPIB parallel poll disable */
|
||||
|
||||
/* GPIB status bit vector : */
|
||||
/* global variable ibsta and wait mask */
|
||||
|
||||
#define ERR (1<<15) /* Error detected */
|
||||
#define TIMO (1<<14) /* Timeout */
|
||||
#define END (1<<13) /* EOI or EOS detected */
|
||||
#define SRQI (1<<12) /* SRQ detected by CIC */
|
||||
#define RQS (1<<11) /* Device needs service */
|
||||
#define CMPL (1<<8) /* I/O completed */
|
||||
#define LOK (1<<7) /* Local lockout state */
|
||||
#define REM (1<<6) /* Remote state */
|
||||
#define CIC (1<<5) /* Controller-in-Charge */
|
||||
#define ATN (1<<4) /* Attention asserted */
|
||||
#define TACS (1<<3) /* Talker active */
|
||||
#define LACS (1<<2) /* Listener active */
|
||||
#define DTAS (1<<1) /* Device trigger state */
|
||||
#define DCAS (1<<0) /* Device clear state */
|
||||
|
||||
/* Error messages returned in global variable iberr */
|
||||
|
||||
#define EDVR 0 /* System error */
|
||||
#define ECIC 1 /* Function requires GPIB board to be CIC */
|
||||
#define ENOL 2 /* Write function detected no Listeners */
|
||||
#define EADR 3 /* Interface board not addressed correctly*/
|
||||
#define EARG 4 /* Invalid argument to function call */
|
||||
#define ESAC 5 /* Function requires GPIB board to be SAC */
|
||||
#define EABO 6 /* I/O operation aborted */
|
||||
#define ENEB 7 /* Non-existent interface board */
|
||||
#define EDMA 8 /* Error performing DMA */
|
||||
#define EOIP 10 /* I/O operation started before previous */
|
||||
/* operation completed */
|
||||
#define ECAP 11 /* No capability for intended operation */
|
||||
#define EFSO 12 /* File system operation error */
|
||||
#define EBUS 14 /* Command error during device call */
|
||||
#define ESTB 15 /* Serial poll status byte lost */
|
||||
#define ESRQ 16 /* SRQ remains asserted */
|
||||
#define ETAB 20 /* The return buffer is full. */
|
||||
#define ELCK 21 /* Address or board is locked. */
|
||||
|
||||
/* EOS mode bits */
|
||||
|
||||
#define BIN (1<<12) /* Eight bit compare */
|
||||
#define XEOS (1<<11) /* Send END with EOS byte */
|
||||
#define REOS (1<<10) /* Terminate read on EOS */
|
||||
|
||||
/* Timeout values and meanings */
|
||||
|
||||
#define TNONE 0 /* Infinite timeout (disabled) */
|
||||
#define T10us 1 /* Timeout of 10 us (ideal) */
|
||||
#define T30us 2 /* Timeout of 30 us (ideal) */
|
||||
#define T100us 3 /* Timeout of 100 us (ideal) */
|
||||
#define T300us 4 /* Timeout of 300 us (ideal) */
|
||||
#define T1ms 5 /* Timeout of 1 ms (ideal) */
|
||||
#define T3ms 6 /* Timeout of 3 ms (ideal) */
|
||||
#define T10ms 7 /* Timeout of 10 ms (ideal) */
|
||||
#define T30ms 8 /* Timeout of 30 ms (ideal) */
|
||||
#define T100ms 9 /* Timeout of 100 ms (ideal) */
|
||||
#define T300ms 10 /* Timeout of 300 ms (ideal) */
|
||||
#define T1s 11 /* Timeout of 1 s (ideal) */
|
||||
#define T3s 12 /* Timeout of 3 s (ideal) */
|
||||
#define T10s 13 /* Timeout of 10 s (ideal) */
|
||||
#define T30s 14 /* Timeout of 30 s (ideal) */
|
||||
#define T100s 15 /* Timeout of 100 s (ideal) */
|
||||
#define T300s 16 /* Timeout of 300 s (ideal) */
|
||||
#define T1000s 17 /* Timeout of 1000 s (ideal) */
|
||||
|
||||
|
||||
/* IBLN Constants */
|
||||
#define NO_SAD 0
|
||||
#define ALL_SAD -1
|
||||
|
||||
|
||||
/* The following constants are used for the second parameter of the
|
||||
* ibconfig function. They are the "option" selection codes.
|
||||
*/
|
||||
#define IbcPAD 0x0001 /* Primary Address */
|
||||
#define IbcSAD 0x0002 /* Secondary Address */
|
||||
#define IbcTMO 0x0003 /* Timeout Value */
|
||||
#define IbcEOT 0x0004 /* Send EOI with last data byte? */
|
||||
#define IbcPPC 0x0005 /* Parallel Poll Configure */
|
||||
#define IbcREADDR 0x0006 /* Repeat Addressing */
|
||||
#define IbcAUTOPOLL 0x0007 /* Disable Auto Serial Polling */
|
||||
#define IbcCICPROT 0x0008 /* Use the CIC Protocol? */
|
||||
#define IbcIRQ 0x0009 /* Use PIO for I/O */
|
||||
#define IbcSC 0x000A /* Board is System Controller? */
|
||||
#define IbcSRE 0x000B /* Assert SRE on device calls? */
|
||||
#define IbcEOSrd 0x000C /* Terminate reads on EOS */
|
||||
#define IbcEOSwrt 0x000D /* Send EOI with EOS character */
|
||||
#define IbcEOScmp 0x000E /* Use 7 or 8-bit EOS compare */
|
||||
#define IbcEOSchar 0x000F /* The EOS character. */
|
||||
#define IbcPP2 0x0010 /* Use Parallel Poll Mode 2. */
|
||||
#define IbcTIMING 0x0011 /* NORMAL, HIGH, or VERY_HIGH timing. */
|
||||
#define IbcDMA 0x0012 /* Use DMA for I/O */
|
||||
#define IbcReadAdjust 0x0013 /* Swap bytes during an ibrd. */
|
||||
#define IbcWriteAdjust 0x014 /* Swap bytes during an ibwrt. */
|
||||
#define IbcSendLLO 0x0017 /* Enable/disable the sending of LLO. */
|
||||
#define IbcSPollTime 0x0018 /* Set the timeout value for serial polls. */
|
||||
#define IbcPPollTime 0x0019 /* Set the parallel poll length period. */
|
||||
#define IbcEndBitIsNormal 0x001A /* Remove EOS from END bit of IBSTA. */
|
||||
#define IbcUnAddr 0x001B /* Enable/disable device unaddressing. */
|
||||
#define IbcSignalNumber 0x001C /* Set UNIX signal number - unsupported */
|
||||
#define IbcBlockIfLocked 0x001D /* Enable/disable blocking for locked boards/devices */
|
||||
#define IbcHSCableLength 0x001F /* Length of cable specified for high speed timing.*/
|
||||
#define IbcIst 0x0020 /* Set the IST bit. */
|
||||
#define IbcRsv 0x0021 /* Set the RSV byte. */
|
||||
|
||||
/*
|
||||
* Constants that can be used (in addition to the ibconfig constants)
|
||||
* when calling the ibask() function.
|
||||
*/
|
||||
|
||||
#define IbaPAD IbcPAD
|
||||
#define IbaSAD IbcSAD
|
||||
#define IbaTMO IbcTMO
|
||||
#define IbaEOT IbcEOT
|
||||
#define IbaPPC IbcPPC
|
||||
#define IbaREADDR IbcREADDR
|
||||
#define IbaAUTOPOLL IbcAUTOPOLL
|
||||
#define IbaCICPROT IbcCICPROT
|
||||
#define IbaIRQ IbcIRQ
|
||||
#define IbaSC IbcSC
|
||||
#define IbaSRE IbcSRE
|
||||
#define IbaEOSrd IbcEOSrd
|
||||
#define IbaEOSwrt IbcEOSwrt
|
||||
#define IbaEOScmp IbcEOScmp
|
||||
#define IbaEOSchar IbcEOSchar
|
||||
#define IbaPP2 IbcPP2
|
||||
#define IbaTIMING IbcTIMING
|
||||
#define IbaDMA IbcDMA
|
||||
#define IbaReadAdjust IbcReadAdjust
|
||||
#define IbaWriteAdjust IbcWriteAdjust
|
||||
#define IbaSendLLO IbcSendLLO
|
||||
#define IbaSPollTime IbcSPollTime
|
||||
#define IbaPPollTime IbcPPollTime
|
||||
#define IbaEndBitIsNormal IbcEndBitIsNormal
|
||||
#define IbaUnAddr IbcUnAddr
|
||||
#define IbaSignalNumber IbcSignalNumber
|
||||
#define IbaBlockIfLocked IbcBlockIfLocked
|
||||
#define IbaHSCableLength IbcHSCableLength
|
||||
#define IbaIst IbcIst
|
||||
#define IbaRsv IbcRsv
|
||||
|
||||
#define IbaBNA 0x0200 /* A device's access board. */
|
||||
|
||||
|
||||
/* Values used by the Send 488.2 command. */
|
||||
#define NULLend 0x00 /* Do nothing at the end of a transfer.*/
|
||||
#define NLend 0x01 /* Send NL with EOI after a transfer. */
|
||||
#define DABend 0x02 /* Send EOI with the last DAB. */
|
||||
|
||||
/* Value used by the 488.2 Receive command.
|
||||
*/
|
||||
#define STOPend 0x0100
|
||||
|
||||
|
||||
/* Address type (for 488.2 calls) */
|
||||
|
||||
typedef short Addr4882_t; /* System dependent: must be 16 bits */
|
||||
|
||||
/*
|
||||
* 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
|
||||
* lower 8-bits and the secondary address goes in the upper 8-bits.
|
||||
*/
|
||||
#define MakeAddr(pad, sad) ((Addr4882_t)(((pad)&0xFF) | ((sad)<<8)))
|
||||
|
||||
/*
|
||||
* This value is used to terminate an address list. It should be
|
||||
* assigned to the last entry.
|
||||
*/
|
||||
#ifndef NOADDR
|
||||
#define NOADDR (Addr4882_t)((unsigned short)0xFFFF)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The following two macros are used to "break apart" an address list
|
||||
* entry. They take an unsigned integer and return either the primary
|
||||
* or secondary address stored in the integer.
|
||||
*/
|
||||
#define GetPAD(val) ((val) & 0xFF)
|
||||
#define GetSAD(val) (((val) >> 8) & 0xFF)
|
||||
|
||||
/* iblines constants */
|
||||
|
||||
#define ValidEOI (short)0x0080
|
||||
#define ValidATN (short)0x0040
|
||||
#define ValidSRQ (short)0x0020
|
||||
#define ValidREN (short)0x0010
|
||||
#define ValidIFC (short)0x0008
|
||||
#define ValidNRFD (short)0x0004
|
||||
#define ValidNDAC (short)0x0002
|
||||
#define ValidDAV (short)0x0001
|
||||
#define BusEOI (short)0x8000
|
||||
#define BusATN (short)0x4000
|
||||
#define BusSRQ (short)0x2000
|
||||
#define BusREN (short)0x1000
|
||||
#define BusIFC (short)0x0800
|
||||
#define BusNRFD (short)0x0400
|
||||
#define BusNDAC (short)0x0200
|
||||
#define BusDAV (short)0x0100
|
||||
|
||||
/****
|
||||
**** typedef for ibnotify callback ****
|
||||
****/
|
||||
typedef int (__stdcall * GpibNotifyCallback_t)(int, int, int, long, PVOID);
|
||||
|
||||
#define IBNOTIFY_REARM_FAILED 0xE00A003F
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* iblockx and ibunlockx definitions --- for use with GPIB-ENET only !! */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#define TIMMEDIATE -1
|
||||
#define TINFINITE -2
|
||||
#define MAX_LOCKSHARENAME_LENGTH 64
|
||||
|
||||
#if defined(UNICODE)
|
||||
#define iblockx iblockxW
|
||||
#else
|
||||
#define iblockx iblockxA
|
||||
#endif
|
||||
|
||||
extern int __stdcall iblockxA (int ud, int LockWaitTime, PCHAR LockShareName);
|
||||
extern int __stdcall iblockxW (int ud, int LockWaitTime, PWCHAR LockShareName);
|
||||
extern int __stdcall ibunlockx (int ud);
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* IBSTA, IBERR, IBCNT, IBCNTL and FUNCTION PROTOTYPES */
|
||||
/* ( only included if not accessing the 32-bit DLL directly ) */
|
||||
/***************************************************************************/
|
||||
#if !defined(GPIB_DIRECT_ACCESS)
|
||||
|
||||
/*
|
||||
* Set up access to the user variables (ibsta, iberr, ibcnt, ibcntl).
|
||||
* These are declared and exported by the 32-bit DLL. Separate copies
|
||||
* exist for each process that accesses the DLL. They are shared by
|
||||
* multiple threads of a single process.
|
||||
*/
|
||||
|
||||
extern int ibsta;
|
||||
extern int iberr;
|
||||
extern int ibcnt;
|
||||
extern long ibcntl;
|
||||
|
||||
|
||||
#if defined(UNICODE)
|
||||
#define ibbna ibbnaW
|
||||
#define ibfind ibfindW
|
||||
#define ibrdf ibrdfW
|
||||
#define ibwrtf ibwrtfW
|
||||
#else
|
||||
#define ibbna ibbnaA
|
||||
#define ibfind ibfindA
|
||||
#define ibrdf ibrdfA
|
||||
#define ibwrtf ibwrtfA
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Extern 32-bit GPIB DLL functions
|
||||
*/
|
||||
|
||||
/* NI-488 Function Prototypes */
|
||||
extern int __stdcall ibfindA (LPCSTR udname);
|
||||
extern int __stdcall ibbnaA (int ud, LPCSTR udname);
|
||||
extern int __stdcall ibrdfA (int ud, LPCSTR filename);
|
||||
extern int __stdcall ibwrtfA (int ud, LPCSTR filename);
|
||||
|
||||
extern int __stdcall ibfindW (LPCWSTR udname);
|
||||
extern int __stdcall ibbnaW (int ud, LPCWSTR udname);
|
||||
extern int __stdcall ibrdfW (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 ibcac (int ud, int v);
|
||||
extern int __stdcall ibclr (int ud);
|
||||
extern int __stdcall ibcmd (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 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 ibdma (int ud, int v);
|
||||
extern int __stdcall ibeos (int ud, int v);
|
||||
extern int __stdcall ibeot (int ud, int v);
|
||||
extern int __stdcall ibgts (int ud, int v);
|
||||
extern int __stdcall ibist (int ud, int v);
|
||||
extern int __stdcall iblines (int ud, PSHORT result);
|
||||
extern int __stdcall ibln (int ud, int pad, int sad, PSHORT listen);
|
||||
extern int __stdcall ibloc (int ud);
|
||||
extern int __stdcall ibnotify (int ud, int mask, GpibNotifyCallback_t Callback, PVOID RefData);
|
||||
extern int __stdcall ibonl (int ud, int v);
|
||||
extern int __stdcall ibpad (int ud, int v);
|
||||
extern int __stdcall ibpct (int ud);
|
||||
extern int __stdcall ibpoke (int ud, long option, long v);
|
||||
extern int __stdcall ibppc (int ud, int v);
|
||||
extern int __stdcall ibrd (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 ibrsc (int ud, int v);
|
||||
extern int __stdcall ibrsp (int ud, PCHAR spr);
|
||||
extern int __stdcall ibrsv (int ud, int v);
|
||||
extern int __stdcall ibsad (int ud, int v);
|
||||
extern int __stdcall ibsic (int ud);
|
||||
extern int __stdcall ibsre (int ud, int v);
|
||||
extern int __stdcall ibstop (int ud);
|
||||
extern int __stdcall ibtmo (int ud, int v);
|
||||
extern int __stdcall ibtrg (int ud);
|
||||
extern int __stdcall ibwait (int ud, int mask);
|
||||
extern int __stdcall ibwrt (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
|
||||
extern int __stdcall iblock (int ud);
|
||||
extern int __stdcall ibunlock (int ud);
|
||||
|
||||
/**************************************************************************/
|
||||
/* Functions to access Thread-Specific copies of the GPIB global vars */
|
||||
|
||||
extern int __stdcall ThreadIbsta (void);
|
||||
extern int __stdcall ThreadIberr (void);
|
||||
extern int __stdcall ThreadIbcnt (void);
|
||||
extern long __stdcall ThreadIbcntl (void);
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* NI-488.2 Function Prototypes */
|
||||
|
||||
extern void __stdcall AllSpoll (int boardID, Addr4882_t * addrlist, PSHORT results);
|
||||
extern void __stdcall DevClear (int boardID, Addr4882_t addr);
|
||||
extern void __stdcall DevClearList (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 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 PPoll (int boardID, PSHORT result);
|
||||
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 PassControl (int boardID, Addr4882_t addr);
|
||||
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 Receive (int boardID, Addr4882_t addr, PVOID buffer, long cnt, int Termination);
|
||||
extern void __stdcall ReceiveSetup (int boardID, Addr4882_t addr);
|
||||
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 SendCmds (int boardID, PVOID buffer, long cnt);
|
||||
extern void __stdcall SendDataBytes (int boardID, PVOID buffer, long cnt, int eot_mode);
|
||||
extern void __stdcall SendIFC (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 SendSetup (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 TestSys (int boardID, Addr4882_t * addrlist, PSHORT results);
|
||||
extern void __stdcall Trigger (int boardID, Addr4882_t addr);
|
||||
extern void __stdcall TriggerList (int boardID, Addr4882_t * addrlist);
|
||||
extern void __stdcall WaitSRQ (int boardID, PSHORT result);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // DECL_32_H
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Win32 include file
|
||||
* for accessing the 32-bit GPIB DLL (gpib-32.dll)
|
||||
*
|
||||
*
|
||||
* Contains user variables (ibsta, iberr, ibcnt, ibcntl),
|
||||
* function prototypes and useful defined constants for
|
||||
* calling NI-488 and NI-488.2 routines from a Microsoft
|
||||
* C/C++ Win32 application.
|
||||
*
|
||||
*
|
||||
* Copyright 1998 National Instruments Corporation
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef DECL_32_H // ensure we are only included once
|
||||
#define DECL_32_H
|
||||
|
||||
#include "windows.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* HANDY CONSTANTS FOR USE BY APPLICATION PROGRAMS ... */
|
||||
/***************************************************************************/
|
||||
#define UNL 0x3f /* GPIB unlisten command */
|
||||
#define UNT 0x5f /* GPIB untalk command */
|
||||
#define GTL 0x01 /* GPIB go to local */
|
||||
#define SDC 0x04 /* GPIB selected device clear */
|
||||
#define PPC 0x05 /* GPIB parallel poll configure */
|
||||
#define GET 0x08 /* GPIB group execute trigger */
|
||||
#define TCT 0x09 /* GPIB take control */
|
||||
#define LLO 0x11 /* GPIB local lock out */
|
||||
#define DCL 0x14 /* GPIB device clear */
|
||||
#define PPU 0.16 /* GPIB parallel poll unconfigure */
|
||||
#define SPE 0x18 /* GPIB serial poll enable */
|
||||
#define SPD 0x19 /* GPIB serial poll disable */
|
||||
#define PPE 0x60 /* GPIB parallel poll enable */
|
||||
#define PPD 0x70 /* GPIB parallel poll disable */
|
||||
|
||||
/* GPIB status bit vector : */
|
||||
/* global variable ibsta and wait mask */
|
||||
|
||||
#define ERR (1<<15) /* Error detected */
|
||||
#define TIMO (1<<14) /* Timeout */
|
||||
#define END (1<<13) /* EOI or EOS detected */
|
||||
#define SRQI (1<<12) /* SRQ detected by CIC */
|
||||
#define RQS (1<<11) /* Device needs service */
|
||||
#define CMPL (1<<8) /* I/O completed */
|
||||
#define LOK (1<<7) /* Local lockout state */
|
||||
#define REM (1<<6) /* Remote state */
|
||||
#define CIC (1<<5) /* Controller-in-Charge */
|
||||
#define ATN (1<<4) /* Attention asserted */
|
||||
#define TACS (1<<3) /* Talker active */
|
||||
#define LACS (1<<2) /* Listener active */
|
||||
#define DTAS (1<<1) /* Device trigger state */
|
||||
#define DCAS (1<<0) /* Device clear state */
|
||||
|
||||
/* Error messages returned in global variable iberr */
|
||||
|
||||
#define EDVR 0 /* System error */
|
||||
#define ECIC 1 /* Function requires GPIB board to be CIC */
|
||||
#define ENOL 2 /* Write function detected no Listeners */
|
||||
#define EADR 3 /* Interface board not addressed correctly*/
|
||||
#define EARG 4 /* Invalid argument to function call */
|
||||
#define ESAC 5 /* Function requires GPIB board to be SAC */
|
||||
#define EABO 6 /* I/O operation aborted */
|
||||
#define ENEB 7 /* Non-existent interface board */
|
||||
#define EDMA 8 /* Error performing DMA */
|
||||
#define EOIP 10 /* I/O operation started before previous */
|
||||
/* operation completed */
|
||||
#define ECAP 11 /* No capability for intended operation */
|
||||
#define EFSO 12 /* File system operation error */
|
||||
#define EBUS 14 /* Command error during device call */
|
||||
#define ESTB 15 /* Serial poll status byte lost */
|
||||
#define ESRQ 16 /* SRQ remains asserted */
|
||||
#define ETAB 20 /* The return buffer is full. */
|
||||
#define ELCK 21 /* Address or board is locked. */
|
||||
|
||||
/* EOS mode bits */
|
||||
|
||||
#define BIN (1<<12) /* Eight bit compare */
|
||||
#define XEOS (1<<11) /* Send END with EOS byte */
|
||||
#define REOS (1<<10) /* Terminate read on EOS */
|
||||
|
||||
/* Timeout values and meanings */
|
||||
|
||||
#define TNONE 0 /* Infinite timeout (disabled) */
|
||||
#define T10us 1 /* Timeout of 10 us (ideal) */
|
||||
#define T30us 2 /* Timeout of 30 us (ideal) */
|
||||
#define T100us 3 /* Timeout of 100 us (ideal) */
|
||||
#define T300us 4 /* Timeout of 300 us (ideal) */
|
||||
#define T1ms 5 /* Timeout of 1 ms (ideal) */
|
||||
#define T3ms 6 /* Timeout of 3 ms (ideal) */
|
||||
#define T10ms 7 /* Timeout of 10 ms (ideal) */
|
||||
#define T30ms 8 /* Timeout of 30 ms (ideal) */
|
||||
#define T100ms 9 /* Timeout of 100 ms (ideal) */
|
||||
#define T300ms 10 /* Timeout of 300 ms (ideal) */
|
||||
#define T1s 11 /* Timeout of 1 s (ideal) */
|
||||
#define T3s 12 /* Timeout of 3 s (ideal) */
|
||||
#define T10s 13 /* Timeout of 10 s (ideal) */
|
||||
#define T30s 14 /* Timeout of 30 s (ideal) */
|
||||
#define T100s 15 /* Timeout of 100 s (ideal) */
|
||||
#define T300s 16 /* Timeout of 300 s (ideal) */
|
||||
#define T1000s 17 /* Timeout of 1000 s (ideal) */
|
||||
|
||||
|
||||
/* IBLN Constants */
|
||||
#define NO_SAD 0
|
||||
#define ALL_SAD -1
|
||||
|
||||
|
||||
/* The following constants are used for the second parameter of the
|
||||
* ibconfig function. They are the "option" selection codes.
|
||||
*/
|
||||
#define IbcPAD 0x0001 /* Primary Address */
|
||||
#define IbcSAD 0x0002 /* Secondary Address */
|
||||
#define IbcTMO 0x0003 /* Timeout Value */
|
||||
#define IbcEOT 0x0004 /* Send EOI with last data byte? */
|
||||
#define IbcPPC 0x0005 /* Parallel Poll Configure */
|
||||
#define IbcREADDR 0x0006 /* Repeat Addressing */
|
||||
#define IbcAUTOPOLL 0x0007 /* Disable Auto Serial Polling */
|
||||
#define IbcCICPROT 0x0008 /* Use the CIC Protocol? */
|
||||
#define IbcIRQ 0x0009 /* Use PIO for I/O */
|
||||
#define IbcSC 0x000A /* Board is System Controller? */
|
||||
#define IbcSRE 0x000B /* Assert SRE on device calls? */
|
||||
#define IbcEOSrd 0x000C /* Terminate reads on EOS */
|
||||
#define IbcEOSwrt 0x000D /* Send EOI with EOS character */
|
||||
#define IbcEOScmp 0x000E /* Use 7 or 8-bit EOS compare */
|
||||
#define IbcEOSchar 0x000F /* The EOS character. */
|
||||
#define IbcPP2 0x0010 /* Use Parallel Poll Mode 2. */
|
||||
#define IbcTIMING 0x0011 /* NORMAL, HIGH, or VERY_HIGH timing. */
|
||||
#define IbcDMA 0x0012 /* Use DMA for I/O */
|
||||
#define IbcReadAdjust 0x0013 /* Swap bytes during an ibrd. */
|
||||
#define IbcWriteAdjust 0x014 /* Swap bytes during an ibwrt. */
|
||||
#define IbcSendLLO 0x0017 /* Enable/disable the sending of LLO. */
|
||||
#define IbcSPollTime 0x0018 /* Set the timeout value for serial polls. */
|
||||
#define IbcPPollTime 0x0019 /* Set the parallel poll length period. */
|
||||
#define IbcEndBitIsNormal 0x001A /* Remove EOS from END bit of IBSTA. */
|
||||
#define IbcUnAddr 0x001B /* Enable/disable device unaddressing. */
|
||||
#define IbcSignalNumber 0x001C /* Set UNIX signal number - unsupported */
|
||||
#define IbcBlockIfLocked 0x001D /* Enable/disable blocking for locked boards/devices */
|
||||
#define IbcHSCableLength 0x001F /* Length of cable specified for high speed timing.*/
|
||||
#define IbcIst 0x0020 /* Set the IST bit. */
|
||||
#define IbcRsv 0x0021 /* Set the RSV byte. */
|
||||
|
||||
/*
|
||||
* Constants that can be used (in addition to the ibconfig constants)
|
||||
* when calling the ibask() function.
|
||||
*/
|
||||
|
||||
#define IbaPAD IbcPAD
|
||||
#define IbaSAD IbcSAD
|
||||
#define IbaTMO IbcTMO
|
||||
#define IbaEOT IbcEOT
|
||||
#define IbaPPC IbcPPC
|
||||
#define IbaREADDR IbcREADDR
|
||||
#define IbaAUTOPOLL IbcAUTOPOLL
|
||||
#define IbaCICPROT IbcCICPROT
|
||||
#define IbaIRQ IbcIRQ
|
||||
#define IbaSC IbcSC
|
||||
#define IbaSRE IbcSRE
|
||||
#define IbaEOSrd IbcEOSrd
|
||||
#define IbaEOSwrt IbcEOSwrt
|
||||
#define IbaEOScmp IbcEOScmp
|
||||
#define IbaEOSchar IbcEOSchar
|
||||
#define IbaPP2 IbcPP2
|
||||
#define IbaTIMING IbcTIMING
|
||||
#define IbaDMA IbcDMA
|
||||
#define IbaReadAdjust IbcReadAdjust
|
||||
#define IbaWriteAdjust IbcWriteAdjust
|
||||
#define IbaSendLLO IbcSendLLO
|
||||
#define IbaSPollTime IbcSPollTime
|
||||
#define IbaPPollTime IbcPPollTime
|
||||
#define IbaEndBitIsNormal IbcEndBitIsNormal
|
||||
#define IbaUnAddr IbcUnAddr
|
||||
#define IbaSignalNumber IbcSignalNumber
|
||||
#define IbaBlockIfLocked IbcBlockIfLocked
|
||||
#define IbaHSCableLength IbcHSCableLength
|
||||
#define IbaIst IbcIst
|
||||
#define IbaRsv IbcRsv
|
||||
|
||||
#define IbaBNA 0x0200 /* A device's access board. */
|
||||
|
||||
|
||||
/* Values used by the Send 488.2 command. */
|
||||
#define NULLend 0x00 /* Do nothing at the end of a transfer.*/
|
||||
#define NLend 0x01 /* Send NL with EOI after a transfer. */
|
||||
#define DABend 0x02 /* Send EOI with the last DAB. */
|
||||
|
||||
/* Value used by the 488.2 Receive command.
|
||||
*/
|
||||
#define STOPend 0x0100
|
||||
|
||||
|
||||
/* Address type (for 488.2 calls) */
|
||||
|
||||
typedef short Addr4882_t; /* System dependent: must be 16 bits */
|
||||
|
||||
/*
|
||||
* 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
|
||||
* lower 8-bits and the secondary address goes in the upper 8-bits.
|
||||
*/
|
||||
#define MakeAddr(pad, sad) ((Addr4882_t)(((pad)&0xFF) | ((sad)<<8)))
|
||||
|
||||
/*
|
||||
* This value is used to terminate an address list. It should be
|
||||
* assigned to the last entry.
|
||||
*/
|
||||
#ifndef NOADDR
|
||||
#define NOADDR (Addr4882_t)((unsigned short)0xFFFF)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The following two macros are used to "break apart" an address list
|
||||
* entry. They take an unsigned integer and return either the primary
|
||||
* or secondary address stored in the integer.
|
||||
*/
|
||||
#define GetPAD(val) ((val) & 0xFF)
|
||||
#define GetSAD(val) (((val) >> 8) & 0xFF)
|
||||
|
||||
/* iblines constants */
|
||||
|
||||
#define ValidEOI (short)0x0080
|
||||
#define ValidATN (short)0x0040
|
||||
#define ValidSRQ (short)0x0020
|
||||
#define ValidREN (short)0x0010
|
||||
#define ValidIFC (short)0x0008
|
||||
#define ValidNRFD (short)0x0004
|
||||
#define ValidNDAC (short)0x0002
|
||||
#define ValidDAV (short)0x0001
|
||||
#define BusEOI (short)0x8000
|
||||
#define BusATN (short)0x4000
|
||||
#define BusSRQ (short)0x2000
|
||||
#define BusREN (short)0x1000
|
||||
#define BusIFC (short)0x0800
|
||||
#define BusNRFD (short)0x0400
|
||||
#define BusNDAC (short)0x0200
|
||||
#define BusDAV (short)0x0100
|
||||
|
||||
/****
|
||||
**** typedef for ibnotify callback ****
|
||||
****/
|
||||
typedef int (__stdcall * GpibNotifyCallback_t)(int, int, int, long, PVOID);
|
||||
|
||||
#define IBNOTIFY_REARM_FAILED 0xE00A003F
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* iblockx and ibunlockx definitions --- for use with GPIB-ENET only !! */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#define TIMMEDIATE -1
|
||||
#define TINFINITE -2
|
||||
#define MAX_LOCKSHARENAME_LENGTH 64
|
||||
|
||||
#if defined(UNICODE)
|
||||
#define iblockx iblockxW
|
||||
#else
|
||||
#define iblockx iblockxA
|
||||
#endif
|
||||
|
||||
extern int __stdcall iblockxA (int ud, int LockWaitTime, PCHAR LockShareName);
|
||||
extern int __stdcall iblockxW (int ud, int LockWaitTime, PWCHAR LockShareName);
|
||||
extern int __stdcall ibunlockx (int ud);
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* IBSTA, IBERR, IBCNT, IBCNTL and FUNCTION PROTOTYPES */
|
||||
/* ( only included if not accessing the 32-bit DLL directly ) */
|
||||
/***************************************************************************/
|
||||
#if !defined(GPIB_DIRECT_ACCESS)
|
||||
|
||||
/*
|
||||
* Set up access to the user variables (ibsta, iberr, ibcnt, ibcntl).
|
||||
* These are declared and exported by the 32-bit DLL. Separate copies
|
||||
* exist for each process that accesses the DLL. They are shared by
|
||||
* multiple threads of a single process.
|
||||
*/
|
||||
|
||||
extern int ibsta;
|
||||
extern int iberr;
|
||||
extern int ibcnt;
|
||||
extern long ibcntl;
|
||||
|
||||
|
||||
#if defined(UNICODE)
|
||||
#define ibbna ibbnaW
|
||||
#define ibfind ibfindW
|
||||
#define ibrdf ibrdfW
|
||||
#define ibwrtf ibwrtfW
|
||||
#else
|
||||
#define ibbna ibbnaA
|
||||
#define ibfind ibfindA
|
||||
#define ibrdf ibrdfA
|
||||
#define ibwrtf ibwrtfA
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Extern 32-bit GPIB DLL functions
|
||||
*/
|
||||
|
||||
/* NI-488 Function Prototypes */
|
||||
extern int __stdcall ibfindA (LPCSTR udname);
|
||||
extern int __stdcall ibbnaA (int ud, LPCSTR udname);
|
||||
extern int __stdcall ibrdfA (int ud, LPCSTR filename);
|
||||
extern int __stdcall ibwrtfA (int ud, LPCSTR filename);
|
||||
|
||||
extern int __stdcall ibfindW (LPCWSTR udname);
|
||||
extern int __stdcall ibbnaW (int ud, LPCWSTR udname);
|
||||
extern int __stdcall ibrdfW (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 ibcac (int ud, int v);
|
||||
extern int __stdcall ibclr (int ud);
|
||||
extern int __stdcall ibcmd (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 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 ibdma (int ud, int v);
|
||||
extern int __stdcall ibeos (int ud, int v);
|
||||
extern int __stdcall ibeot (int ud, int v);
|
||||
extern int __stdcall ibgts (int ud, int v);
|
||||
extern int __stdcall ibist (int ud, int v);
|
||||
extern int __stdcall iblines (int ud, PSHORT result);
|
||||
extern int __stdcall ibln (int ud, int pad, int sad, PSHORT listen);
|
||||
extern int __stdcall ibloc (int ud);
|
||||
extern int __stdcall ibnotify (int ud, int mask, GpibNotifyCallback_t Callback, PVOID RefData);
|
||||
extern int __stdcall ibonl (int ud, int v);
|
||||
extern int __stdcall ibpad (int ud, int v);
|
||||
extern int __stdcall ibpct (int ud);
|
||||
extern int __stdcall ibpoke (int ud, long option, long v);
|
||||
extern int __stdcall ibppc (int ud, int v);
|
||||
extern int __stdcall ibrd (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 ibrsc (int ud, int v);
|
||||
extern int __stdcall ibrsp (int ud, PCHAR spr);
|
||||
extern int __stdcall ibrsv (int ud, int v);
|
||||
extern int __stdcall ibsad (int ud, int v);
|
||||
extern int __stdcall ibsic (int ud);
|
||||
extern int __stdcall ibsre (int ud, int v);
|
||||
extern int __stdcall ibstop (int ud);
|
||||
extern int __stdcall ibtmo (int ud, int v);
|
||||
extern int __stdcall ibtrg (int ud);
|
||||
extern int __stdcall ibwait (int ud, int mask);
|
||||
extern int __stdcall ibwrt (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
|
||||
extern int __stdcall iblock (int ud);
|
||||
extern int __stdcall ibunlock (int ud);
|
||||
|
||||
/**************************************************************************/
|
||||
/* Functions to access Thread-Specific copies of the GPIB global vars */
|
||||
|
||||
extern int __stdcall ThreadIbsta (void);
|
||||
extern int __stdcall ThreadIberr (void);
|
||||
extern int __stdcall ThreadIbcnt (void);
|
||||
extern long __stdcall ThreadIbcntl (void);
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* NI-488.2 Function Prototypes */
|
||||
|
||||
extern void __stdcall AllSpoll (int boardID, Addr4882_t * addrlist, PSHORT results);
|
||||
extern void __stdcall DevClear (int boardID, Addr4882_t addr);
|
||||
extern void __stdcall DevClearList (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 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 PPoll (int boardID, PSHORT result);
|
||||
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 PassControl (int boardID, Addr4882_t addr);
|
||||
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 Receive (int boardID, Addr4882_t addr, PVOID buffer, long cnt, int Termination);
|
||||
extern void __stdcall ReceiveSetup (int boardID, Addr4882_t addr);
|
||||
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 SendCmds (int boardID, PVOID buffer, long cnt);
|
||||
extern void __stdcall SendDataBytes (int boardID, PVOID buffer, long cnt, int eot_mode);
|
||||
extern void __stdcall SendIFC (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 SendSetup (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 TestSys (int boardID, Addr4882_t * addrlist, PSHORT results);
|
||||
extern void __stdcall Trigger (int boardID, Addr4882_t addr);
|
||||
extern void __stdcall TriggerList (int boardID, Addr4882_t * addrlist);
|
||||
extern void __stdcall WaitSRQ (int boardID, PSHORT result);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // DECL_32_H
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
#include <stddef.h>
|
||||
typedef void* iconv_t;
|
||||
iconv_t iconv_open(const char *tocode, const char *fromcode);
|
||||
int iconv_close(iconv_t cd);
|
||||
size_t iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
|
||||
#include <stddef.h>
|
||||
typedef void* iconv_t;
|
||||
iconv_t iconv_open(const char *tocode, const char *fromcode);
|
||||
int iconv_close(iconv_t cd);
|
||||
size_t iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
|
||||
|
@ -1,54 +1,54 @@
|
||||
HRESULT WINAPI ConvertINetString(
|
||||
LPDWORD lpdwMode,
|
||||
DWORD dwSrcEncoding,
|
||||
DWORD dwDstEncoding,
|
||||
LPCSTR lpSrcStr,
|
||||
LPINT lpnSrcSize,
|
||||
LPBYTE lpDstStr,
|
||||
LPINT lpnDstSize
|
||||
);
|
||||
|
||||
HRESULT WINAPI ConvertINetMultiByteToUnicode(
|
||||
LPDWORD lpdwMode,
|
||||
DWORD dwSrcEncoding,
|
||||
LPCSTR lpSrcStr,
|
||||
LPINT lpnMultiCharCount,
|
||||
LPWSTR lpDstStr,
|
||||
LPINT lpnWideCharCount
|
||||
);
|
||||
|
||||
HRESULT WINAPI ConvertINetUnicodeToMultiByte(
|
||||
LPDWORD lpdwMode,
|
||||
DWORD dwEncoding,
|
||||
LPCWSTR lpSrcStr,
|
||||
LPINT lpnWideCharCount,
|
||||
LPSTR lpDstStr,
|
||||
LPINT lpnMultiCharCount
|
||||
);
|
||||
|
||||
HRESULT WINAPI IsConvertINetStringAvailable(
|
||||
DWORD dwSrcEncoding,
|
||||
DWORD dwDstEncoding
|
||||
);
|
||||
|
||||
HRESULT WINAPI LcidToRfc1766A(
|
||||
LCID Locale,
|
||||
LPSTR pszRfc1766,
|
||||
int nChar
|
||||
);
|
||||
|
||||
HRESULT WINAPI LcidToRfc1766W(
|
||||
LCID Locale,
|
||||
LPWSTR pszRfc1766,
|
||||
int nChar
|
||||
);
|
||||
|
||||
HRESULT WINAPI Rfc1766ToLcidA(
|
||||
LCID *pLocale,
|
||||
LPSTR pszRfc1766
|
||||
);
|
||||
|
||||
HRESULT WINAPI Rfc1766ToLcidW(
|
||||
LCID *pLocale,
|
||||
LPWSTR pszRfc1766
|
||||
);
|
||||
HRESULT WINAPI ConvertINetString(
|
||||
LPDWORD lpdwMode,
|
||||
DWORD dwSrcEncoding,
|
||||
DWORD dwDstEncoding,
|
||||
LPCSTR lpSrcStr,
|
||||
LPINT lpnSrcSize,
|
||||
LPBYTE lpDstStr,
|
||||
LPINT lpnDstSize
|
||||
);
|
||||
|
||||
HRESULT WINAPI ConvertINetMultiByteToUnicode(
|
||||
LPDWORD lpdwMode,
|
||||
DWORD dwSrcEncoding,
|
||||
LPCSTR lpSrcStr,
|
||||
LPINT lpnMultiCharCount,
|
||||
LPWSTR lpDstStr,
|
||||
LPINT lpnWideCharCount
|
||||
);
|
||||
|
||||
HRESULT WINAPI ConvertINetUnicodeToMultiByte(
|
||||
LPDWORD lpdwMode,
|
||||
DWORD dwEncoding,
|
||||
LPCWSTR lpSrcStr,
|
||||
LPINT lpnWideCharCount,
|
||||
LPSTR lpDstStr,
|
||||
LPINT lpnMultiCharCount
|
||||
);
|
||||
|
||||
HRESULT WINAPI IsConvertINetStringAvailable(
|
||||
DWORD dwSrcEncoding,
|
||||
DWORD dwDstEncoding
|
||||
);
|
||||
|
||||
HRESULT WINAPI LcidToRfc1766A(
|
||||
LCID Locale,
|
||||
LPSTR pszRfc1766,
|
||||
int nChar
|
||||
);
|
||||
|
||||
HRESULT WINAPI LcidToRfc1766W(
|
||||
LCID Locale,
|
||||
LPWSTR pszRfc1766,
|
||||
int nChar
|
||||
);
|
||||
|
||||
HRESULT WINAPI Rfc1766ToLcidA(
|
||||
LCID *pLocale,
|
||||
LPSTR pszRfc1766
|
||||
);
|
||||
|
||||
HRESULT WINAPI Rfc1766ToLcidW(
|
||||
LCID *pLocale,
|
||||
LPWSTR pszRfc1766
|
||||
);
|
||||
|
@ -1,3 +1,3 @@
|
||||
win_iconv is a iconv library using Win32 API to conversion.
|
||||
win_iconv is placed in the public domain.
|
||||
Yukihiro Nakadaira <yukihiro.nakadaira@gmail.com>
|
||||
win_iconv is a iconv library using Win32 API to conversion.
|
||||
win_iconv is placed in the public domain.
|
||||
Yukihiro Nakadaira <yukihiro.nakadaira@gmail.com>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,261 +1,261 @@
|
||||
|
||||
#include "win_iconv.c"
|
||||
#include <stdio.h>
|
||||
|
||||
const char *
|
||||
tohex(const char *str, int size)
|
||||
{
|
||||
static char buf[BUFSIZ];
|
||||
char *pbuf = buf;
|
||||
int i;
|
||||
buf[0] = 0;
|
||||
for (i = 0; i < size; ++i)
|
||||
pbuf += sprintf(pbuf, "%02X", str[i] & 0xFF);
|
||||
return buf;
|
||||
}
|
||||
|
||||
const char *
|
||||
errstr(int errcode)
|
||||
{
|
||||
static char buf[BUFSIZ];
|
||||
switch (errcode)
|
||||
{
|
||||
case 0: return "NOERROR";
|
||||
case EINVAL: return "EINVAL";
|
||||
case EILSEQ: return "EILSEQ";
|
||||
case E2BIG: return "E2BIG";
|
||||
}
|
||||
sprintf(buf, "%d\n", errcode);
|
||||
return buf;
|
||||
}
|
||||
|
||||
#ifdef USE_LIBICONV_DLL
|
||||
int use_dll;
|
||||
|
||||
int
|
||||
setdll(const char *dllpath)
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
rec_iconv_t cd;
|
||||
|
||||
sprintf(buf, "WINICONV_LIBICONV_DLL=%s", dllpath);
|
||||
putenv(buf);
|
||||
if (libiconv_iconv_open(&cd, "ascii", "ascii"))
|
||||
{
|
||||
FreeLibrary(cd.hlibiconv);
|
||||
use_dll = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
use_dll = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We can test the codepage that is installed in the system.
|
||||
*/
|
||||
int
|
||||
check_enc(const char *encname, int codepage)
|
||||
{
|
||||
iconv_t cd;
|
||||
int cp;
|
||||
cd = iconv_open("utf-8", encname);
|
||||
if (cd == (iconv_t)(-1))
|
||||
{
|
||||
printf("%s(%d) IS NOT SUPPORTED: SKIP THE TEST\n", encname, codepage);
|
||||
return FALSE;
|
||||
}
|
||||
cp = ((rec_iconv_t *)cd)->from.codepage;
|
||||
if (cp != codepage)
|
||||
{
|
||||
printf("%s(%d) ALIAS IS MAPPED TO DIFFERENT CODEPAGE (%d)\n", encname, codepage, cp);
|
||||
exit(1);
|
||||
}
|
||||
iconv_close(cd);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int use_dll;
|
||||
|
||||
void
|
||||
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];
|
||||
const char *pin;
|
||||
char *pout;
|
||||
size_t inbytesleft;
|
||||
size_t outbytesleft;
|
||||
iconv_t cd;
|
||||
size_t r;
|
||||
char dllpath[_MAX_PATH];
|
||||
|
||||
cd = iconv_open(to, from);
|
||||
if (cd == (iconv_t)(-1))
|
||||
{
|
||||
printf("%s -> %s: NG: INVALID ENCODING NAME: line=%d\n", from, to, line);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#ifdef USE_LIBICONV_DLL
|
||||
if (((rec_iconv_t *)cd)->hlibiconv != NULL)
|
||||
GetModuleFileName(((rec_iconv_t *)cd)->hlibiconv, dllpath, sizeof(dllpath));
|
||||
|
||||
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);
|
||||
exit(1);
|
||||
}
|
||||
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);
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
errno = 0;
|
||||
|
||||
pin = fromstr;
|
||||
pout = outbuf;
|
||||
inbytesleft = fromsize;
|
||||
outbytesleft = bufsize;
|
||||
r = iconv(cd, &pin, &inbytesleft, &pout, &outbytesleft);
|
||||
if (r != (size_t)(-1))
|
||||
r = iconv(cd, NULL, NULL, &pout, &outbytesleft);
|
||||
*pout = 0;
|
||||
|
||||
#ifdef USE_LIBICONV_DLL
|
||||
if (use_dll)
|
||||
printf("%s: ", dllpath);
|
||||
#endif
|
||||
printf("%s(%s) -> ", from, tohex(fromstr, fromsize));
|
||||
printf("%s(%s%s%s): ", to, tohex(tostr, tosize),
|
||||
errcode == 0 ? "" : ":",
|
||||
errcode == 0 ? "" : errstr(errcode));
|
||||
if (strcmp(outbuf, tostr) == 0 && errno == errcode)
|
||||
printf("OK\n");
|
||||
else
|
||||
{
|
||||
printf("RESULT(%s:%s): ", tohex(outbuf, sizeof(outbuf) - outbytesleft),
|
||||
errstr(errno));
|
||||
printf("NG: line=%d\n", line);
|
||||
exit(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 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 e2big(from, fromstr, to, tostr, bufsize) test(from, fromstr, STATIC_STRLEN(fromstr), to, tostr, STATIC_STRLEN(tostr), E2BIG, bufsize, __LINE__)
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
#ifdef USE_LIBICONV_DLL
|
||||
/* test use of dll if $DEFAULT_LIBICONV_DLL was defined. */
|
||||
if (setdll(""))
|
||||
{
|
||||
success("ascii", "ABC", "ascii", "ABC");
|
||||
success("ascii", "ABC", "utf-16be", "\x00\x41\x00\x42\x00\x43");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\nDLL TEST IS SKIPPED\n\n");
|
||||
}
|
||||
|
||||
setdll("none");
|
||||
#endif
|
||||
|
||||
if (check_enc("ascii", 20127))
|
||||
{
|
||||
success("ascii", "ABC", "ascii", "ABC");
|
||||
/* MSB is dropped. Hmm... */
|
||||
success("ascii", "\x80\xFF", "ascii", "\x00\x7F");
|
||||
}
|
||||
|
||||
/* unicode (CP1200 CP1201 CP12000 CP12001 CP65001) */
|
||||
if (check_enc("utf-8", 65001)
|
||||
&& check_enc("utf-16be", 1201) && check_enc("utf-16le", 1200)
|
||||
&& check_enc("utf-32be", 12001) && check_enc("utf-32le", 12000)
|
||||
)
|
||||
{
|
||||
/* Test the BOM behavior
|
||||
* 1. Remove the BOM when "fromcode" 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", "\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", "\xFF\xFE\x00\x00\x02\x01\x00\x00", "utf-32be", "\x00\x00\x01\x02");
|
||||
success("utf-16", "\xFE\xFF\x00\x01", "utf-8", "\x01");
|
||||
#ifndef GLIB_COMPILATION
|
||||
success("utf-8", "\x01", "utf-16", "\xFE\xFF\x00\x01");
|
||||
success("utf-8", "\x01", "utf-32", "\x00\x00\xFE\xFF\x00\x00\x00\x01");
|
||||
#else
|
||||
success("utf-8", "\x01", "utf-16", "\xFF\xFE\x01\x00");
|
||||
success("utf-8", "\x01", "utf-32", "\xFF\xFE\x00\x00\x01\x00\x00\x00");
|
||||
#endif
|
||||
|
||||
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-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-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-16be", "\x01\x02", "utf-16le", "\x02\x01");
|
||||
success("utf-16le", "\x02\x01", "utf-16be", "\x01\x02");
|
||||
success("utf-16be", "\xFE\xFF", "utf-16le", "\xFF\xFE");
|
||||
success("utf-16le", "\xFF\xFE", "utf-16be", "\xFE\xFF");
|
||||
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-32be", "\x00\x00\xFF\xFF", "utf-16be", "\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-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-16be", "\xDB\xFF\xDF\xFF", "utf-32be", "\x00\x10\xFF\xFF");
|
||||
eilseq("utf-32be", "\x00\x11\x00\x00", "utf-16be", "");
|
||||
eilseq("utf-16be", "\xDB\xFF\xE0\x00", "utf-32be", "");
|
||||
success("utf-8", "\xE3\x81\x82", "utf-16be", "\x30\x42");
|
||||
einval("utf-8", "\xE3", "utf-16be", "");
|
||||
}
|
||||
|
||||
/* Japanese (CP932 CP20932 CP50220 CP50221 CP50222 CP51932) */
|
||||
if (check_enc("cp932", 932)
|
||||
&& check_enc("cp20932", 20932) && check_enc("euc-jp", 51932)
|
||||
&& check_enc("cp50220", 50220) && check_enc("cp50221", 50221)
|
||||
&& check_enc("cp50222", 50222) && check_enc("iso-2022-jp", 50221))
|
||||
{
|
||||
/* Test the compatibility for each other Japanese codepage.
|
||||
* And validate the escape sequence handling for iso-2022-jp. */
|
||||
success("utf-16be", "\xFF\x5E", "cp932", "\x81\x60");
|
||||
success("utf-16be", "\x30\x1C", "cp932", "\x81\x60");
|
||||
success("utf-16be", "\xFF\x5E", "cp932//nocompat", "\x81\x60");
|
||||
eilseq("utf-16be", "\x30\x1C", "cp932//nocompat", "");
|
||||
success("euc-jp", "\xA4\xA2", "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");
|
||||
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");
|
||||
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("iso-2022-jp", "\x1B\x24\x42\x21\x41\x1B\x28\x42", "UTF-16BE", "\xFF\x5E");
|
||||
}
|
||||
|
||||
/*
|
||||
* test for //translit
|
||||
* U+FF41 (FULLWIDTH LATIN SMALL LETTER A) <-> U+0062 (LATIN SMALL LETTER A)
|
||||
*/
|
||||
eilseq("UTF-16BE", "\xFF\x41", "iso-8859-1", "");
|
||||
success("UTF-16BE", "\xFF\x41", "iso-8859-1//translit", "a");
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
* Test for state after iconv() failed.
|
||||
* Ensure iconv() error is safe and continuable.
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#include "win_iconv.c"
|
||||
#include <stdio.h>
|
||||
|
||||
const char *
|
||||
tohex(const char *str, int size)
|
||||
{
|
||||
static char buf[BUFSIZ];
|
||||
char *pbuf = buf;
|
||||
int i;
|
||||
buf[0] = 0;
|
||||
for (i = 0; i < size; ++i)
|
||||
pbuf += sprintf(pbuf, "%02X", str[i] & 0xFF);
|
||||
return buf;
|
||||
}
|
||||
|
||||
const char *
|
||||
errstr(int errcode)
|
||||
{
|
||||
static char buf[BUFSIZ];
|
||||
switch (errcode)
|
||||
{
|
||||
case 0: return "NOERROR";
|
||||
case EINVAL: return "EINVAL";
|
||||
case EILSEQ: return "EILSEQ";
|
||||
case E2BIG: return "E2BIG";
|
||||
}
|
||||
sprintf(buf, "%d\n", errcode);
|
||||
return buf;
|
||||
}
|
||||
|
||||
#ifdef USE_LIBICONV_DLL
|
||||
int use_dll;
|
||||
|
||||
int
|
||||
setdll(const char *dllpath)
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
rec_iconv_t cd;
|
||||
|
||||
sprintf(buf, "WINICONV_LIBICONV_DLL=%s", dllpath);
|
||||
putenv(buf);
|
||||
if (libiconv_iconv_open(&cd, "ascii", "ascii"))
|
||||
{
|
||||
FreeLibrary(cd.hlibiconv);
|
||||
use_dll = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
use_dll = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We can test the codepage that is installed in the system.
|
||||
*/
|
||||
int
|
||||
check_enc(const char *encname, int codepage)
|
||||
{
|
||||
iconv_t cd;
|
||||
int cp;
|
||||
cd = iconv_open("utf-8", encname);
|
||||
if (cd == (iconv_t)(-1))
|
||||
{
|
||||
printf("%s(%d) IS NOT SUPPORTED: SKIP THE TEST\n", encname, codepage);
|
||||
return FALSE;
|
||||
}
|
||||
cp = ((rec_iconv_t *)cd)->from.codepage;
|
||||
if (cp != codepage)
|
||||
{
|
||||
printf("%s(%d) ALIAS IS MAPPED TO DIFFERENT CODEPAGE (%d)\n", encname, codepage, cp);
|
||||
exit(1);
|
||||
}
|
||||
iconv_close(cd);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int use_dll;
|
||||
|
||||
void
|
||||
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];
|
||||
const char *pin;
|
||||
char *pout;
|
||||
size_t inbytesleft;
|
||||
size_t outbytesleft;
|
||||
iconv_t cd;
|
||||
size_t r;
|
||||
char dllpath[_MAX_PATH];
|
||||
|
||||
cd = iconv_open(to, from);
|
||||
if (cd == (iconv_t)(-1))
|
||||
{
|
||||
printf("%s -> %s: NG: INVALID ENCODING NAME: line=%d\n", from, to, line);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#ifdef USE_LIBICONV_DLL
|
||||
if (((rec_iconv_t *)cd)->hlibiconv != NULL)
|
||||
GetModuleFileName(((rec_iconv_t *)cd)->hlibiconv, dllpath, sizeof(dllpath));
|
||||
|
||||
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);
|
||||
exit(1);
|
||||
}
|
||||
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);
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
errno = 0;
|
||||
|
||||
pin = fromstr;
|
||||
pout = outbuf;
|
||||
inbytesleft = fromsize;
|
||||
outbytesleft = bufsize;
|
||||
r = iconv(cd, &pin, &inbytesleft, &pout, &outbytesleft);
|
||||
if (r != (size_t)(-1))
|
||||
r = iconv(cd, NULL, NULL, &pout, &outbytesleft);
|
||||
*pout = 0;
|
||||
|
||||
#ifdef USE_LIBICONV_DLL
|
||||
if (use_dll)
|
||||
printf("%s: ", dllpath);
|
||||
#endif
|
||||
printf("%s(%s) -> ", from, tohex(fromstr, fromsize));
|
||||
printf("%s(%s%s%s): ", to, tohex(tostr, tosize),
|
||||
errcode == 0 ? "" : ":",
|
||||
errcode == 0 ? "" : errstr(errcode));
|
||||
if (strcmp(outbuf, tostr) == 0 && errno == errcode)
|
||||
printf("OK\n");
|
||||
else
|
||||
{
|
||||
printf("RESULT(%s:%s): ", tohex(outbuf, sizeof(outbuf) - outbytesleft),
|
||||
errstr(errno));
|
||||
printf("NG: line=%d\n", line);
|
||||
exit(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 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 e2big(from, fromstr, to, tostr, bufsize) test(from, fromstr, STATIC_STRLEN(fromstr), to, tostr, STATIC_STRLEN(tostr), E2BIG, bufsize, __LINE__)
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
#ifdef USE_LIBICONV_DLL
|
||||
/* test use of dll if $DEFAULT_LIBICONV_DLL was defined. */
|
||||
if (setdll(""))
|
||||
{
|
||||
success("ascii", "ABC", "ascii", "ABC");
|
||||
success("ascii", "ABC", "utf-16be", "\x00\x41\x00\x42\x00\x43");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\nDLL TEST IS SKIPPED\n\n");
|
||||
}
|
||||
|
||||
setdll("none");
|
||||
#endif
|
||||
|
||||
if (check_enc("ascii", 20127))
|
||||
{
|
||||
success("ascii", "ABC", "ascii", "ABC");
|
||||
/* MSB is dropped. Hmm... */
|
||||
success("ascii", "\x80\xFF", "ascii", "\x00\x7F");
|
||||
}
|
||||
|
||||
/* unicode (CP1200 CP1201 CP12000 CP12001 CP65001) */
|
||||
if (check_enc("utf-8", 65001)
|
||||
&& check_enc("utf-16be", 1201) && check_enc("utf-16le", 1200)
|
||||
&& check_enc("utf-32be", 12001) && check_enc("utf-32le", 12000)
|
||||
)
|
||||
{
|
||||
/* Test the BOM behavior
|
||||
* 1. Remove the BOM when "fromcode" 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", "\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", "\xFF\xFE\x00\x00\x02\x01\x00\x00", "utf-32be", "\x00\x00\x01\x02");
|
||||
success("utf-16", "\xFE\xFF\x00\x01", "utf-8", "\x01");
|
||||
#ifndef GLIB_COMPILATION
|
||||
success("utf-8", "\x01", "utf-16", "\xFE\xFF\x00\x01");
|
||||
success("utf-8", "\x01", "utf-32", "\x00\x00\xFE\xFF\x00\x00\x00\x01");
|
||||
#else
|
||||
success("utf-8", "\x01", "utf-16", "\xFF\xFE\x01\x00");
|
||||
success("utf-8", "\x01", "utf-32", "\xFF\xFE\x00\x00\x01\x00\x00\x00");
|
||||
#endif
|
||||
|
||||
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-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-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-16be", "\x01\x02", "utf-16le", "\x02\x01");
|
||||
success("utf-16le", "\x02\x01", "utf-16be", "\x01\x02");
|
||||
success("utf-16be", "\xFE\xFF", "utf-16le", "\xFF\xFE");
|
||||
success("utf-16le", "\xFF\xFE", "utf-16be", "\xFE\xFF");
|
||||
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-32be", "\x00\x00\xFF\xFF", "utf-16be", "\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-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-16be", "\xDB\xFF\xDF\xFF", "utf-32be", "\x00\x10\xFF\xFF");
|
||||
eilseq("utf-32be", "\x00\x11\x00\x00", "utf-16be", "");
|
||||
eilseq("utf-16be", "\xDB\xFF\xE0\x00", "utf-32be", "");
|
||||
success("utf-8", "\xE3\x81\x82", "utf-16be", "\x30\x42");
|
||||
einval("utf-8", "\xE3", "utf-16be", "");
|
||||
}
|
||||
|
||||
/* Japanese (CP932 CP20932 CP50220 CP50221 CP50222 CP51932) */
|
||||
if (check_enc("cp932", 932)
|
||||
&& check_enc("cp20932", 20932) && check_enc("euc-jp", 51932)
|
||||
&& check_enc("cp50220", 50220) && check_enc("cp50221", 50221)
|
||||
&& check_enc("cp50222", 50222) && check_enc("iso-2022-jp", 50221))
|
||||
{
|
||||
/* Test the compatibility for each other Japanese codepage.
|
||||
* And validate the escape sequence handling for iso-2022-jp. */
|
||||
success("utf-16be", "\xFF\x5E", "cp932", "\x81\x60");
|
||||
success("utf-16be", "\x30\x1C", "cp932", "\x81\x60");
|
||||
success("utf-16be", "\xFF\x5E", "cp932//nocompat", "\x81\x60");
|
||||
eilseq("utf-16be", "\x30\x1C", "cp932//nocompat", "");
|
||||
success("euc-jp", "\xA4\xA2", "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");
|
||||
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");
|
||||
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("iso-2022-jp", "\x1B\x24\x42\x21\x41\x1B\x28\x42", "UTF-16BE", "\xFF\x5E");
|
||||
}
|
||||
|
||||
/*
|
||||
* test for //translit
|
||||
* U+FF41 (FULLWIDTH LATIN SMALL LETTER A) <-> U+0062 (LATIN SMALL LETTER A)
|
||||
*/
|
||||
eilseq("UTF-16BE", "\xFF\x41", "iso-8859-1", "");
|
||||
success("UTF-16BE", "\xFF\x41", "iso-8859-1//translit", "a");
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
* Test for state after iconv() failed.
|
||||
* Ensure iconv() error is safe and continuable.
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,331 +1,331 @@
|
||||
/* Opal endpoint interface for Freeswitch Modular Media Switching Software Library /
|
||||
* Soft-Switch Application
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* Copyright (c) 2007 Tuyan Ozipek (tuyanozipek@gmail.com)
|
||||
* 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
|
||||
* 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
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Tuyan Ozipek (tuyanozipek@gmail.com)
|
||||
* Lukasz Zwierko (lzwierko@gmail.com)
|
||||
* Robert Jongbloed (robertj@voxlucida.com.au)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __FREESWITCH_MOD_OPAL__
|
||||
#define __FREESWITCH_MOD_OPAL__
|
||||
|
||||
#if defined(__GNUC__) && defined(HAVE_VISIBILITY)
|
||||
#pragma GCC visibility push(default)
|
||||
#endif
|
||||
|
||||
#include <ptlib.h>
|
||||
#include <opal/manager.h>
|
||||
|
||||
#ifndef OPAL_CHECK_VERSION
|
||||
#define OPAL_CHECK_VERSION(a,b,c) 0
|
||||
#endif
|
||||
|
||||
#if !OPAL_CHECK_VERSION(3,12,8)
|
||||
#error OPAL is too old to use, must be >= 2.12.8
|
||||
#endif
|
||||
|
||||
#include <ep/localep.h>
|
||||
#include <h323/h323ep.h>
|
||||
#include <iax2/iax2ep.h>
|
||||
|
||||
#if defined(__GNUC__) && defined(HAVE_VISIBILITY)
|
||||
#pragma GCC visibility pop
|
||||
#endif
|
||||
|
||||
#undef strcasecmp
|
||||
#undef strncasecmp
|
||||
|
||||
#include <switch.h>
|
||||
|
||||
#define MODNAME "mod_opal"
|
||||
|
||||
#define HAVE_T38 OPAL_T38_CAPABILITY
|
||||
|
||||
|
||||
|
||||
class FSEndPoint;
|
||||
class FSManager;
|
||||
|
||||
|
||||
class FSProcess : public PLibraryProcess
|
||||
{
|
||||
PCLASSINFO(FSProcess, PLibraryProcess);
|
||||
public:
|
||||
FSProcess();
|
||||
~FSProcess();
|
||||
|
||||
bool Initialise(switch_loadable_module_interface_t *iface);
|
||||
|
||||
FSManager & GetManager() const
|
||||
{
|
||||
return *m_manager;
|
||||
}
|
||||
|
||||
protected:
|
||||
FSManager * m_manager;
|
||||
};
|
||||
|
||||
|
||||
struct FSListener
|
||||
{
|
||||
FSListener() : m_port(H323EndPoint::DefaultTcpSignalPort) { }
|
||||
|
||||
PString m_name;
|
||||
PIPSocket::Address m_address;
|
||||
uint16_t m_port;
|
||||
};
|
||||
|
||||
|
||||
class FSManager : public OpalManager
|
||||
{
|
||||
PCLASSINFO(FSManager, OpalManager);
|
||||
|
||||
public:
|
||||
FSManager();
|
||||
|
||||
bool Initialise(switch_loadable_module_interface_t *iface);
|
||||
|
||||
switch_status_t ReadConfig(int reload);
|
||||
|
||||
switch_endpoint_interface_t *GetSwitchInterface() const { return m_FreeSwitch; }
|
||||
const PString & GetContext() const { return m_context; }
|
||||
const PString & GetDialPlan() const { return m_dialplan; }
|
||||
const PString & GetCodecPrefs() const { return m_codecPrefs; }
|
||||
bool GetDisableTranscoding() const { return m_disableTranscoding; }
|
||||
|
||||
private:
|
||||
switch_endpoint_interface_t *m_FreeSwitch;
|
||||
|
||||
H323EndPoint *m_h323ep;
|
||||
IAX2EndPoint *m_iaxep;
|
||||
FSEndPoint *m_fsep;
|
||||
|
||||
PString m_context;
|
||||
PString m_dialplan;
|
||||
PString m_codecPrefs;
|
||||
bool m_disableTranscoding;
|
||||
PString m_gkAddress;
|
||||
PString m_gkIdentifer;
|
||||
PString m_gkInterface;
|
||||
|
||||
list <FSListener> m_listeners;
|
||||
};
|
||||
|
||||
|
||||
class FSEndPoint : public OpalLocalEndPoint
|
||||
{
|
||||
PCLASSINFO(FSEndPoint, OpalLocalEndPoint);
|
||||
public:
|
||||
FSEndPoint(FSManager & manager);
|
||||
|
||||
virtual OpalLocalConnection *CreateConnection(OpalCall & call, void *userData, unsigned options, OpalConnection::StringOptions * stringOptions);
|
||||
|
||||
FSManager & GetManager() const { return m_manager; }
|
||||
|
||||
protected:
|
||||
FSManager & m_manager;
|
||||
};
|
||||
|
||||
|
||||
class FSConnection;
|
||||
|
||||
|
||||
class FSMediaStream : public OpalMediaStream
|
||||
{
|
||||
PCLASSINFO(FSMediaStream, OpalMediaStream);
|
||||
public:
|
||||
FSMediaStream(
|
||||
FSConnection & conn,
|
||||
const OpalMediaFormat & mediaFormat, ///< Media format for stream
|
||||
unsigned sessionID, ///< Session number for stream
|
||||
bool isSource ///< Is a source stream
|
||||
);
|
||||
|
||||
virtual PBoolean Open();
|
||||
virtual PBoolean IsSynchronous() const;
|
||||
virtual PBoolean RequiresPatchThread(OpalMediaStream *) const;
|
||||
|
||||
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);
|
||||
|
||||
protected:
|
||||
virtual void InternalClose();
|
||||
int StartReadWrite(PatchPtr & mediaPatch) const;
|
||||
|
||||
private:
|
||||
bool CheckPatchAndLock();
|
||||
|
||||
FSConnection &m_connection;
|
||||
switch_timer_t *m_switchTimer;
|
||||
switch_codec_t *m_switchCodec;
|
||||
switch_frame_t m_readFrame;
|
||||
RTP_DataFrame m_readRTP;
|
||||
};
|
||||
|
||||
|
||||
#define DECLARE_CALLBACK0(name) \
|
||||
static switch_status_t name(switch_core_session_t *session) { \
|
||||
FSConnection *tech_pvt = (FSConnection *) switch_core_session_get_private(session); \
|
||||
return tech_pvt != NULL ? tech_pvt->name() : SWITCH_STATUS_FALSE; } \
|
||||
switch_status_t name()
|
||||
|
||||
#define DECLARE_CALLBACK1(name, type1, name1) \
|
||||
static switch_status_t name(switch_core_session_t *session, type1 name1) { \
|
||||
FSConnection *tech_pvt = (FSConnection *) switch_core_session_get_private(session); \
|
||||
return tech_pvt != NULL ? tech_pvt->name(name1) : SWITCH_STATUS_FALSE; } \
|
||||
switch_status_t name(type1 name1)
|
||||
|
||||
#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) { \
|
||||
FSConnection *tech_pvt = (FSConnection *) switch_core_session_get_private(session); \
|
||||
return tech_pvt != NULL ? tech_pvt->name(name1, name2, name3) : SWITCH_STATUS_FALSE; } \
|
||||
switch_status_t name(type1 name1, type2 name2, type3 name3)
|
||||
|
||||
|
||||
|
||||
|
||||
class FSConnection : public OpalLocalConnection
|
||||
{
|
||||
PCLASSINFO(FSConnection, OpalLocalConnection)
|
||||
|
||||
public:
|
||||
struct outgoing_params {
|
||||
switch_event_t *var_event;
|
||||
switch_caller_profile_t *outbound_profile;
|
||||
switch_core_session_t **new_session;
|
||||
switch_memory_pool_t **pool;
|
||||
switch_originate_flag_t flags;
|
||||
switch_call_cause_t *cancel_cause;
|
||||
switch_call_cause_t fail_cause;
|
||||
};
|
||||
|
||||
FSConnection(OpalCall & call,
|
||||
FSEndPoint & endpoint,
|
||||
unsigned options,
|
||||
OpalConnection::StringOptions * stringOptions,
|
||||
outgoing_params * params);
|
||||
|
||||
virtual bool OnOutgoingSetUp();
|
||||
virtual bool OnIncoming();
|
||||
virtual void OnEstablished();
|
||||
virtual void OnReleased();
|
||||
virtual PBoolean SetAlerting(const PString & calleeName, PBoolean withMedia);
|
||||
virtual OpalMediaStream *CreateMediaStream(const OpalMediaFormat &, unsigned, PBoolean);
|
||||
virtual void OnPatchMediaStream(PBoolean isSource, OpalMediaPatch & patch);
|
||||
virtual OpalMediaFormatList GetMediaFormats() const;
|
||||
virtual PBoolean SendUserInputTone(char tone, unsigned duration);
|
||||
#if HAVE_T38
|
||||
virtual void OnSwitchedT38(bool toT38, bool success);
|
||||
virtual void OnSwitchingT38(bool toT38);
|
||||
#endif
|
||||
|
||||
DECLARE_CALLBACK0(on_init);
|
||||
DECLARE_CALLBACK0(on_destroy);
|
||||
DECLARE_CALLBACK0(on_routing);
|
||||
DECLARE_CALLBACK0(on_execute);
|
||||
DECLARE_CALLBACK0(on_hangup);
|
||||
|
||||
DECLARE_CALLBACK0(on_exchange_media);
|
||||
DECLARE_CALLBACK0(on_soft_execute);
|
||||
|
||||
DECLARE_CALLBACK1(kill_channel, int, sig);
|
||||
DECLARE_CALLBACK1(send_dtmf, const switch_dtmf_t *, dtmf);
|
||||
DECLARE_CALLBACK1(receive_message, switch_core_session_message_t *, msg);
|
||||
DECLARE_CALLBACK1(receive_event, switch_event_t *, event);
|
||||
DECLARE_CALLBACK0(state_change);
|
||||
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(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);
|
||||
|
||||
__inline switch_core_session_t *GetSession() const
|
||||
{
|
||||
return m_fsSession;
|
||||
}
|
||||
|
||||
__inline switch_channel_t *GetChannel() const
|
||||
{
|
||||
return m_fsChannel;
|
||||
}
|
||||
|
||||
bool IsChannelReady() const
|
||||
{
|
||||
return m_fsChannel != NULL && switch_channel_ready(m_fsChannel);
|
||||
}
|
||||
|
||||
bool NeedFlushAudio()
|
||||
{
|
||||
if (!m_flushAudio)
|
||||
return false;
|
||||
m_flushAudio = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected:
|
||||
void SetCodecs();
|
||||
bool WaitForMedia();
|
||||
#if HAVE_T38
|
||||
void SetT38OptionsFromMediaFormat(const OpalMediaFormat & mediaFormat, const char * varname);
|
||||
bool IndicateSwitchedT38();
|
||||
void AbortT38();
|
||||
#endif
|
||||
|
||||
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);
|
||||
|
||||
private:
|
||||
FSEndPoint &m_endpoint;
|
||||
switch_core_session_t *m_fsSession;
|
||||
switch_channel_t *m_fsChannel;
|
||||
PSyncPoint m_rxAudioOpened;
|
||||
PSyncPoint m_txAudioOpened;
|
||||
OpalMediaFormatList m_switchMediaFormats;
|
||||
|
||||
// If FS ever supports more than one audio and one video, this needs to change
|
||||
switch_timer_t m_read_timer;
|
||||
switch_codec_t m_read_codec;
|
||||
switch_codec_t m_write_codec;
|
||||
|
||||
switch_timer_t m_vid_read_timer;
|
||||
switch_codec_t m_vid_read_codec;
|
||||
switch_codec_t m_vid_write_codec;
|
||||
|
||||
switch_frame_t m_dummy_frame;
|
||||
|
||||
bool m_flushAudio;
|
||||
bool m_udptl;
|
||||
|
||||
friend PBoolean FSMediaStream::Open();
|
||||
};
|
||||
|
||||
|
||||
#endif /* __FREESWITCH_MOD_OPAL__ */
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
* indent-tabs-mode:nil
|
||||
* tab-width:4
|
||||
* c-basic-offset:4
|
||||
* End:
|
||||
* For VIM:
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:s:
|
||||
*/
|
||||
/* Opal endpoint interface for Freeswitch Modular Media Switching Software Library /
|
||||
* Soft-Switch Application
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* Copyright (c) 2007 Tuyan Ozipek (tuyanozipek@gmail.com)
|
||||
* 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
|
||||
* 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
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Tuyan Ozipek (tuyanozipek@gmail.com)
|
||||
* Lukasz Zwierko (lzwierko@gmail.com)
|
||||
* Robert Jongbloed (robertj@voxlucida.com.au)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __FREESWITCH_MOD_OPAL__
|
||||
#define __FREESWITCH_MOD_OPAL__
|
||||
|
||||
#if defined(__GNUC__) && defined(HAVE_VISIBILITY)
|
||||
#pragma GCC visibility push(default)
|
||||
#endif
|
||||
|
||||
#include <ptlib.h>
|
||||
#include <opal/manager.h>
|
||||
|
||||
#ifndef OPAL_CHECK_VERSION
|
||||
#define OPAL_CHECK_VERSION(a,b,c) 0
|
||||
#endif
|
||||
|
||||
#if !OPAL_CHECK_VERSION(3,12,8)
|
||||
#error OPAL is too old to use, must be >= 2.12.8
|
||||
#endif
|
||||
|
||||
#include <ep/localep.h>
|
||||
#include <h323/h323ep.h>
|
||||
#include <iax2/iax2ep.h>
|
||||
|
||||
#if defined(__GNUC__) && defined(HAVE_VISIBILITY)
|
||||
#pragma GCC visibility pop
|
||||
#endif
|
||||
|
||||
#undef strcasecmp
|
||||
#undef strncasecmp
|
||||
|
||||
#include <switch.h>
|
||||
|
||||
#define MODNAME "mod_opal"
|
||||
|
||||
#define HAVE_T38 OPAL_T38_CAPABILITY
|
||||
|
||||
|
||||
|
||||
class FSEndPoint;
|
||||
class FSManager;
|
||||
|
||||
|
||||
class FSProcess : public PLibraryProcess
|
||||
{
|
||||
PCLASSINFO(FSProcess, PLibraryProcess);
|
||||
public:
|
||||
FSProcess();
|
||||
~FSProcess();
|
||||
|
||||
bool Initialise(switch_loadable_module_interface_t *iface);
|
||||
|
||||
FSManager & GetManager() const
|
||||
{
|
||||
return *m_manager;
|
||||
}
|
||||
|
||||
protected:
|
||||
FSManager * m_manager;
|
||||
};
|
||||
|
||||
|
||||
struct FSListener
|
||||
{
|
||||
FSListener() : m_port(H323EndPoint::DefaultTcpSignalPort) { }
|
||||
|
||||
PString m_name;
|
||||
PIPSocket::Address m_address;
|
||||
uint16_t m_port;
|
||||
};
|
||||
|
||||
|
||||
class FSManager : public OpalManager
|
||||
{
|
||||
PCLASSINFO(FSManager, OpalManager);
|
||||
|
||||
public:
|
||||
FSManager();
|
||||
|
||||
bool Initialise(switch_loadable_module_interface_t *iface);
|
||||
|
||||
switch_status_t ReadConfig(int reload);
|
||||
|
||||
switch_endpoint_interface_t *GetSwitchInterface() const { return m_FreeSwitch; }
|
||||
const PString & GetContext() const { return m_context; }
|
||||
const PString & GetDialPlan() const { return m_dialplan; }
|
||||
const PString & GetCodecPrefs() const { return m_codecPrefs; }
|
||||
bool GetDisableTranscoding() const { return m_disableTranscoding; }
|
||||
|
||||
private:
|
||||
switch_endpoint_interface_t *m_FreeSwitch;
|
||||
|
||||
H323EndPoint *m_h323ep;
|
||||
IAX2EndPoint *m_iaxep;
|
||||
FSEndPoint *m_fsep;
|
||||
|
||||
PString m_context;
|
||||
PString m_dialplan;
|
||||
PString m_codecPrefs;
|
||||
bool m_disableTranscoding;
|
||||
PString m_gkAddress;
|
||||
PString m_gkIdentifer;
|
||||
PString m_gkInterface;
|
||||
|
||||
list <FSListener> m_listeners;
|
||||
};
|
||||
|
||||
|
||||
class FSEndPoint : public OpalLocalEndPoint
|
||||
{
|
||||
PCLASSINFO(FSEndPoint, OpalLocalEndPoint);
|
||||
public:
|
||||
FSEndPoint(FSManager & manager);
|
||||
|
||||
virtual OpalLocalConnection *CreateConnection(OpalCall & call, void *userData, unsigned options, OpalConnection::StringOptions * stringOptions);
|
||||
|
||||
FSManager & GetManager() const { return m_manager; }
|
||||
|
||||
protected:
|
||||
FSManager & m_manager;
|
||||
};
|
||||
|
||||
|
||||
class FSConnection;
|
||||
|
||||
|
||||
class FSMediaStream : public OpalMediaStream
|
||||
{
|
||||
PCLASSINFO(FSMediaStream, OpalMediaStream);
|
||||
public:
|
||||
FSMediaStream(
|
||||
FSConnection & conn,
|
||||
const OpalMediaFormat & mediaFormat, ///< Media format for stream
|
||||
unsigned sessionID, ///< Session number for stream
|
||||
bool isSource ///< Is a source stream
|
||||
);
|
||||
|
||||
virtual PBoolean Open();
|
||||
virtual PBoolean IsSynchronous() const;
|
||||
virtual PBoolean RequiresPatchThread(OpalMediaStream *) const;
|
||||
|
||||
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);
|
||||
|
||||
protected:
|
||||
virtual void InternalClose();
|
||||
int StartReadWrite(PatchPtr & mediaPatch) const;
|
||||
|
||||
private:
|
||||
bool CheckPatchAndLock();
|
||||
|
||||
FSConnection &m_connection;
|
||||
switch_timer_t *m_switchTimer;
|
||||
switch_codec_t *m_switchCodec;
|
||||
switch_frame_t m_readFrame;
|
||||
RTP_DataFrame m_readRTP;
|
||||
};
|
||||
|
||||
|
||||
#define DECLARE_CALLBACK0(name) \
|
||||
static switch_status_t name(switch_core_session_t *session) { \
|
||||
FSConnection *tech_pvt = (FSConnection *) switch_core_session_get_private(session); \
|
||||
return tech_pvt != NULL ? tech_pvt->name() : SWITCH_STATUS_FALSE; } \
|
||||
switch_status_t name()
|
||||
|
||||
#define DECLARE_CALLBACK1(name, type1, name1) \
|
||||
static switch_status_t name(switch_core_session_t *session, type1 name1) { \
|
||||
FSConnection *tech_pvt = (FSConnection *) switch_core_session_get_private(session); \
|
||||
return tech_pvt != NULL ? tech_pvt->name(name1) : SWITCH_STATUS_FALSE; } \
|
||||
switch_status_t name(type1 name1)
|
||||
|
||||
#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) { \
|
||||
FSConnection *tech_pvt = (FSConnection *) switch_core_session_get_private(session); \
|
||||
return tech_pvt != NULL ? tech_pvt->name(name1, name2, name3) : SWITCH_STATUS_FALSE; } \
|
||||
switch_status_t name(type1 name1, type2 name2, type3 name3)
|
||||
|
||||
|
||||
|
||||
|
||||
class FSConnection : public OpalLocalConnection
|
||||
{
|
||||
PCLASSINFO(FSConnection, OpalLocalConnection)
|
||||
|
||||
public:
|
||||
struct outgoing_params {
|
||||
switch_event_t *var_event;
|
||||
switch_caller_profile_t *outbound_profile;
|
||||
switch_core_session_t **new_session;
|
||||
switch_memory_pool_t **pool;
|
||||
switch_originate_flag_t flags;
|
||||
switch_call_cause_t *cancel_cause;
|
||||
switch_call_cause_t fail_cause;
|
||||
};
|
||||
|
||||
FSConnection(OpalCall & call,
|
||||
FSEndPoint & endpoint,
|
||||
unsigned options,
|
||||
OpalConnection::StringOptions * stringOptions,
|
||||
outgoing_params * params);
|
||||
|
||||
virtual bool OnOutgoingSetUp();
|
||||
virtual bool OnIncoming();
|
||||
virtual void OnEstablished();
|
||||
virtual void OnReleased();
|
||||
virtual PBoolean SetAlerting(const PString & calleeName, PBoolean withMedia);
|
||||
virtual OpalMediaStream *CreateMediaStream(const OpalMediaFormat &, unsigned, PBoolean);
|
||||
virtual void OnPatchMediaStream(PBoolean isSource, OpalMediaPatch & patch);
|
||||
virtual OpalMediaFormatList GetMediaFormats() const;
|
||||
virtual PBoolean SendUserInputTone(char tone, unsigned duration);
|
||||
#if HAVE_T38
|
||||
virtual void OnSwitchedT38(bool toT38, bool success);
|
||||
virtual void OnSwitchingT38(bool toT38);
|
||||
#endif
|
||||
|
||||
DECLARE_CALLBACK0(on_init);
|
||||
DECLARE_CALLBACK0(on_destroy);
|
||||
DECLARE_CALLBACK0(on_routing);
|
||||
DECLARE_CALLBACK0(on_execute);
|
||||
DECLARE_CALLBACK0(on_hangup);
|
||||
|
||||
DECLARE_CALLBACK0(on_exchange_media);
|
||||
DECLARE_CALLBACK0(on_soft_execute);
|
||||
|
||||
DECLARE_CALLBACK1(kill_channel, int, sig);
|
||||
DECLARE_CALLBACK1(send_dtmf, const switch_dtmf_t *, dtmf);
|
||||
DECLARE_CALLBACK1(receive_message, switch_core_session_message_t *, msg);
|
||||
DECLARE_CALLBACK1(receive_event, switch_event_t *, event);
|
||||
DECLARE_CALLBACK0(state_change);
|
||||
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(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);
|
||||
|
||||
__inline switch_core_session_t *GetSession() const
|
||||
{
|
||||
return m_fsSession;
|
||||
}
|
||||
|
||||
__inline switch_channel_t *GetChannel() const
|
||||
{
|
||||
return m_fsChannel;
|
||||
}
|
||||
|
||||
bool IsChannelReady() const
|
||||
{
|
||||
return m_fsChannel != NULL && switch_channel_ready(m_fsChannel);
|
||||
}
|
||||
|
||||
bool NeedFlushAudio()
|
||||
{
|
||||
if (!m_flushAudio)
|
||||
return false;
|
||||
m_flushAudio = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected:
|
||||
void SetCodecs();
|
||||
bool WaitForMedia();
|
||||
#if HAVE_T38
|
||||
void SetT38OptionsFromMediaFormat(const OpalMediaFormat & mediaFormat, const char * varname);
|
||||
bool IndicateSwitchedT38();
|
||||
void AbortT38();
|
||||
#endif
|
||||
|
||||
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);
|
||||
|
||||
private:
|
||||
FSEndPoint &m_endpoint;
|
||||
switch_core_session_t *m_fsSession;
|
||||
switch_channel_t *m_fsChannel;
|
||||
PSyncPoint m_rxAudioOpened;
|
||||
PSyncPoint m_txAudioOpened;
|
||||
OpalMediaFormatList m_switchMediaFormats;
|
||||
|
||||
// If FS ever supports more than one audio and one video, this needs to change
|
||||
switch_timer_t m_read_timer;
|
||||
switch_codec_t m_read_codec;
|
||||
switch_codec_t m_write_codec;
|
||||
|
||||
switch_timer_t m_vid_read_timer;
|
||||
switch_codec_t m_vid_read_codec;
|
||||
switch_codec_t m_vid_write_codec;
|
||||
|
||||
switch_frame_t m_dummy_frame;
|
||||
|
||||
bool m_flushAudio;
|
||||
bool m_udptl;
|
||||
|
||||
friend PBoolean FSMediaStream::Open();
|
||||
};
|
||||
|
||||
|
||||
#endif /* __FREESWITCH_MOD_OPAL__ */
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
* indent-tabs-mode:nil
|
||||
* tab-width:4
|
||||
* c-basic-offset:4
|
||||
* End:
|
||||
* For VIM:
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:s:
|
||||
*/
|
||||
|
@ -79,27 +79,27 @@
|
||||
such a type exists and the standard includes do not define it. */
|
||||
#cmakedefine uint8_t unsigned char
|
||||
|
||||
#ifdef HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#ifdef HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/* AMF number */
|
||||
typedef
|
||||
#if SIZEOF_FLOAT == 8
|
||||
float
|
||||
#elif SIZEOF_DOUBLE == 8
|
||||
double
|
||||
#elif SIZEOF_LONG_DOUBLE == 8
|
||||
long double
|
||||
#else
|
||||
uint64_t
|
||||
#endif
|
||||
typedef
|
||||
#if SIZEOF_FLOAT == 8
|
||||
float
|
||||
#elif SIZEOF_DOUBLE == 8
|
||||
double
|
||||
#elif SIZEOF_LONG_DOUBLE == 8
|
||||
long double
|
||||
#else
|
||||
uint64_t
|
||||
#endif
|
||||
number64_t;
|
||||
|
||||
/* 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);
|
||||
|
||||
#endif /* __AMF_H__ */
|
||||
|
@ -1 +1 @@
|
||||
#define PERL_LIB "@PERL_LIB@"
|
||||
#define PERL_LIB "@PERL_LIB@"
|
||||
|
@ -49,9 +49,9 @@
|
||||
#include <math.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);
|
||||
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);
|
||||
|
||||
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 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,
|
||||
int g_y, int g_m, int g_d)
|
||||
{
|
||||
int gy, gm, gd;
|
||||
int jy, jm, jd;
|
||||
long g_day_no, j_day_no;
|
||||
int j_np;
|
||||
|
||||
int i;
|
||||
|
||||
gy = g_y-1600;
|
||||
gm = g_m-1;
|
||||
gd = g_d-1;
|
||||
|
||||
g_day_no = 365*gy+(gy+3)/4-(gy+99)/100+(gy+399)/400;
|
||||
for (i=0;i<gm;++i)
|
||||
g_day_no += g_days_in_month[i];
|
||||
if (gm>1 && ((gy%4==0 && gy%100!=0) || (gy%400==0)))
|
||||
/* leap and after Feb */
|
||||
++g_day_no;
|
||||
g_day_no += gd;
|
||||
|
||||
j_day_no = g_day_no-79;
|
||||
|
||||
j_np = j_day_no / 12053;
|
||||
j_day_no %= 12053;
|
||||
|
||||
jy = 979+33*j_np+4*(j_day_no/1461);
|
||||
j_day_no %= 1461;
|
||||
|
||||
if (j_day_no >= 366) {
|
||||
jy += (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) {
|
||||
j_day_no -= j_days_in_month[i];
|
||||
}
|
||||
jm = i+1;
|
||||
jd = j_day_no+1;
|
||||
*j_y = jy;
|
||||
*j_m = jm;
|
||||
*j_d = jd;
|
||||
void gregorian_to_jalali(int *j_y, int *j_m, int *j_d,
|
||||
int g_y, int g_m, int g_d)
|
||||
{
|
||||
int gy, gm, gd;
|
||||
int jy, jm, jd;
|
||||
long g_day_no, j_day_no;
|
||||
int j_np;
|
||||
|
||||
int i;
|
||||
|
||||
gy = g_y-1600;
|
||||
gm = g_m-1;
|
||||
gd = g_d-1;
|
||||
|
||||
g_day_no = 365*gy+(gy+3)/4-(gy+99)/100+(gy+399)/400;
|
||||
for (i=0;i<gm;++i)
|
||||
g_day_no += g_days_in_month[i];
|
||||
if (gm>1 && ((gy%4==0 && gy%100!=0) || (gy%400==0)))
|
||||
/* leap and after Feb */
|
||||
++g_day_no;
|
||||
g_day_no += gd;
|
||||
|
||||
j_day_no = g_day_no-79;
|
||||
|
||||
j_np = j_day_no / 12053;
|
||||
j_day_no %= 12053;
|
||||
|
||||
jy = 979+33*j_np+4*(j_day_no/1461);
|
||||
j_day_no %= 1461;
|
||||
|
||||
if (j_day_no >= 366) {
|
||||
jy += (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) {
|
||||
j_day_no -= j_days_in_month[i];
|
||||
}
|
||||
jm = i+1;
|
||||
jd = j_day_no+1;
|
||||
*j_y = jy;
|
||||
*j_m = jm;
|
||||
*j_d = jd;
|
||||
}
|
||||
|
||||
void jalali_to_gregorian(int *g_y, int *g_m, int *g_d,
|
||||
int j_y, int j_m, int j_d)
|
||||
{
|
||||
int gy, gm, gd;
|
||||
int jy, jm, jd;
|
||||
long g_day_no, j_day_no;
|
||||
int leap;
|
||||
|
||||
int i;
|
||||
|
||||
jy = j_y-979;
|
||||
jm = j_m-1;
|
||||
jd = j_d-1;
|
||||
|
||||
j_day_no = 365*jy + (jy/33)*8 + (jy%33+3)/4;
|
||||
for (i=0; i < jm; ++i)
|
||||
j_day_no += j_days_in_month[i];
|
||||
|
||||
j_day_no += jd;
|
||||
|
||||
g_day_no = j_day_no+79;
|
||||
|
||||
gy = 1600 + 400*(g_day_no/146097); /* 146097 = 365*400 + 400/4 - 400/100 + 400/400 */
|
||||
g_day_no = g_day_no % 146097;
|
||||
|
||||
leap = 1;
|
||||
if (g_day_no >= 36525) /* 36525 = 365*100 + 100/4 */
|
||||
{
|
||||
g_day_no--;
|
||||
gy += 100*(g_day_no/36524); /* 36524 = 365*100 + 100/4 - 100/100 */
|
||||
g_day_no = g_day_no % 36524;
|
||||
|
||||
if (g_day_no >= 365)
|
||||
g_day_no++;
|
||||
else
|
||||
leap = 0;
|
||||
}
|
||||
|
||||
gy += 4*(g_day_no/1461); /* 1461 = 365*4 + 4/4 */
|
||||
g_day_no %= 1461;
|
||||
|
||||
if (g_day_no >= 366) {
|
||||
leap = 0;
|
||||
|
||||
g_day_no--;
|
||||
gy += 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++)
|
||||
g_day_no -= g_days_in_month[i] + (i == 1 && leap);
|
||||
gm = i+1;
|
||||
gd = g_day_no+1;
|
||||
|
||||
*g_y = gy;
|
||||
*g_m = gm;
|
||||
*g_d = gd;
|
||||
void jalali_to_gregorian(int *g_y, int *g_m, int *g_d,
|
||||
int j_y, int j_m, int j_d)
|
||||
{
|
||||
int gy, gm, gd;
|
||||
int jy, jm, jd;
|
||||
long g_day_no, j_day_no;
|
||||
int leap;
|
||||
|
||||
int i;
|
||||
|
||||
jy = j_y-979;
|
||||
jm = j_m-1;
|
||||
jd = j_d-1;
|
||||
|
||||
j_day_no = 365*jy + (jy/33)*8 + (jy%33+3)/4;
|
||||
for (i=0; i < jm; ++i)
|
||||
j_day_no += j_days_in_month[i];
|
||||
|
||||
j_day_no += jd;
|
||||
|
||||
g_day_no = j_day_no+79;
|
||||
|
||||
gy = 1600 + 400*(g_day_no/146097); /* 146097 = 365*400 + 400/4 - 400/100 + 400/400 */
|
||||
g_day_no = g_day_no % 146097;
|
||||
|
||||
leap = 1;
|
||||
if (g_day_no >= 36525) /* 36525 = 365*100 + 100/4 */
|
||||
{
|
||||
g_day_no--;
|
||||
gy += 100*(g_day_no/36524); /* 36524 = 365*100 + 100/4 - 100/100 */
|
||||
g_day_no = g_day_no % 36524;
|
||||
|
||||
if (g_day_no >= 365)
|
||||
g_day_no++;
|
||||
else
|
||||
leap = 0;
|
||||
}
|
||||
|
||||
gy += 4*(g_day_no/1461); /* 1461 = 365*4 + 4/4 */
|
||||
g_day_no %= 1461;
|
||||
|
||||
if (g_day_no >= 366) {
|
||||
leap = 0;
|
||||
|
||||
g_day_no--;
|
||||
gy += 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++)
|
||||
g_day_no -= g_days_in_month[i] + (i == 1 && leap);
|
||||
gm = i+1;
|
||||
gd = g_day_no+1;
|
||||
|
||||
*g_y = gy;
|
||||
*g_m = gm;
|
||||
*g_d = gd;
|
||||
}
|
||||
|
||||
/* For Emacs:
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user