remove asterisk 1.2 because of build breakages and obsolescence

git-svn-id: svn://svn.openwrt.org/openwrt/packages@13811 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
nbd 2009-01-02 02:30:09 +00:00
parent 52e53e2910
commit 14ae170476
24 changed files with 0 additions and 6649 deletions

View File

@ -1,683 +0,0 @@
#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id$
include $(TOPDIR)/rules.mk
PKG_NAME:=asterisk
PKG_VERSION:=1.2.24
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://ftp.digium.com/pub/asterisk/old-releases/ \
ftp://ftp.digium.com/pub/asterisk/old-releases
PKG_MD5SUM:=63dc8b7be4cd10375c5fbda893c780bc
PKG_BUILD_DEPENDS:= openh323 pwlib
include $(INCLUDE_DIR)/package.mk
define Package/asterisk/Default
SUBMENU:=asterisk (Complete Open Source PBX), v1.2.x
SECTION:=net
CATEGORY:=Network
URL:=http://www.asterisk.org/
endef
define Package/asterisk/Default/description
Asterisk is a complete PBX in software. It provides all of the features
you would expect from a PBX and more. Asterisk does voice over IP in three
protocols, and can interoperate with almost all standards-based telephony
equipment using relatively inexpensive hardware.
endef
define Package/asterisk
$(call Package/asterisk/Default)
DEPENDS:=+libncurses +libpthread @!TARGET_avr32
TITLE:=Complete Open Source PBX
endef
define Package/asterisk/description
$(call Package/asterisk/Default/description)
endef
define Package/asterisk-mini
$(call Package/asterisk/Default)
DEPENDS:=+libncurses +libpthread @!TARGET_avr32
PROVIDES:=asterisk
TITLE:=Minimal Open Source PBX
endef
define Package/asterisk-mini/description
$(call Package/asterisk/Default/description)
This package contains only the following modules:
- app_dial
- chan_iax2
- chan_local
- chan_sip
- codec_gsm
- codec_ulaw
- format_gsm
- format_pcm
- format_wav
- format_wav_gsm
- pbx_config
- res_features
- res_musiconhold
endef
define Package/asterisk-mysql
$(call Package/asterisk/Default)
DEPENDS:=asterisk +libmysqlclient
TITLE:=MySQL support
endef
define Package/asterisk-mysql/description
$(call Package/asterisk/Default/description)
This package contains MySQL support modules for Asterisk.
endef
define Package/asterisk-pgsql
$(call Package/asterisk/Default)
DEPENDS:=asterisk +libpq
TITLE:=PostgreSQL support
endef
define Package/asterisk-pgsql/description
$(call Package/asterisk/Default/description)
This package contains PostgreSQL support modules for Asterisk.
endef
define Package/asterisk-sqlite
$(call Package/asterisk/Default)
DEPENDS:=asterisk +libsqlite2
TITLE:=SQLite modules
endef
define Package/asterisk-sqlite/description
$(call Package/asterisk/Default/description)
This package contains SQLite support modules for Asterisk.
endef
define Package/asterisk-sounds
$(call Package/asterisk/Default)
DEPENDS:=asterisk
TITLE:=Sound files
endef
define Package/asterisk-sounds/description
$(call Package/asterisk/Default/description)
This package contains sound files for Asterisk.
endef
define Package/asterisk-voicemail
$(call Package/asterisk/Default)
DEPENDS:=asterisk
TITLE:=Voicemail support
endef
define Package/asterisk-voicemail/description
$(call Package/asterisk/Default/description)
This package contains voicemail related modules for Asterisk.
endef
define Package/asterisk-app-meetme
$(call Package/asterisk/Default)
DEPENDS:=asterisk +zaptel-libtonezone @BROKEN
TITLE:=MeetMe Confererencing support
endef
define Package/asterisk-app-meetme/description
$(call Package/asterisk/Default/description)
This package provides the application MeetMe and conferencing support to
Asterisk.
endef
define Package/asterisk-chan-bluetooth
$(call Package/asterisk/Default)
DEPENDS:=asterisk +bluez-libs
TITLE:=Bluetooth HandsFreeProfile support
endef
define Package/asterisk-chan-bluetooth/description
$(call Package/asterisk/Default/description)
This package provides Bluetooth HandsFreeProfile support to Asterisk.
endef
define Package/asterisk-chan-h323
$(call Package/asterisk/Default)
DEPENDS:=asterisk +uclibcxx
TITLE:=H.323 support
endef
define Package/asterisk-chan-h323/description
$(call Package/asterisk/Default/description)
This package provides H.323 support to Asterisk.
endef
define Package/asterisk-chan-mgcp
$(call Package/asterisk/Default)
DEPENDS:=asterisk
TITLE:=MGCP support
endef
define Package/asterisk-chan-mgcp/description
$(call Package/asterisk/Default/description)
This package provides MGCP (Media Gateway Control Protocol) support
to Asterisk.
endef
define Package/asterisk-chan-oss
$(call Package/asterisk/Default)
DEPENDS:=asterisk
TITLE:=OSS soundcards support
endef
define Package/asterisk-chan-oss/description
$(call Package/asterisk/Default/description)
Channel driver for OSS soundcards
endef
define Package/asterisk-chan-skinny
$(call Package/asterisk/Default)
DEPENDS:=asterisk
TITLE:=Skinny Client Control Protocol support
endef
define Package/asterisk-chan-skinny/description
$(call Package/asterisk/Default/description)
This package provided Skinny Client Control Protocol support to
Asterisk.
endef
define Package/asterisk-codec-ilbc
$(call Package/asterisk/Default)
DEPENDS:=asterisk
TITLE:=ILBC Translator
endef
define Package/asterisk-codec-ilbc/description
$(call Package/asterisk/Default/description)
This package contains the ILBC (Internet Low Bitrate Codec) translator
for Asterisk.
endef
define Package/asterisk-codec-lpc10
$(call Package/asterisk/Default)
DEPENDS:=asterisk
TITLE:=LPC10 2.4kbps voice codec Translator
endef
define Package/asterisk-codec-lpc10/description
$(call Package/asterisk/Default/description)
This package contains the LPC10 (Linear Predictor Code) 2.4kbps voice
codec translator for Asterisk.
endef
define Package/asterisk-codec-speex
$(call Package/asterisk/Default)
DEPENDS:=asterisk +libspeex
TITLE:=Speex/PCM16 Codec Translator
endef
define Package/asterisk-codec-speex/description
$(call Package/asterisk/Default/description)
This package contains the Speex speech compression codec translator for
Asterisk.
endef
define Package/asterisk-pbx-dundi
$(call Package/asterisk/Default)
DEPENDS:=asterisk
TITLE:=DUNDi support
endef
define Package/asterisk-pbx-dundi/description
$(call Package/asterisk/Default/description)
This package provides DUNDi (Distributed Universal Number Discovery)
support to Asterisk.
endef
define Package/asterisk-res-agi
$(call Package/asterisk/Default)
DEPENDS:=asterisk
TITLE:=AGI support
endef
define Package/asterisk-res-agi/description
$(call Package/asterisk/Default/description)
This package provides AGI (Asterisk Gateway Interface) support to
Asterisk.
endef
define Package/asterisk-res-crypto
$(call Package/asterisk/Default)
DEPENDS:=asterisk +libopenssl
TITLE:=Cryptographic Digital Signatures support
endef
define Package/asterisk-res-crypto/description
$(call Package/asterisk/Default/description)
This package provides Cryptographic Digital Signatures support to
Asterisk.
endef
EXTRA_CFLAGS:= $(TARGET_CPPFLAGS)
EXTRA_LDFLAGS:= $(TARGET_LDFLAGS)
ifneq ($(SDK)$(CONFIG_PACKAGE_asterisk-app-meetme),)
EXTRA_APP_MODULES+= app_meetme.so
endif
ifneq ($(SDK)$(CONFIG_PACKAGE_asterisk-chan-bluetooth),)
EXTRA_CHAN_MODULES+= chan_bluetooth.so
endif
ifneq ($(SDK)$(CONFIG_PACKAGE_asterisk-chan-h323),)
EXTRA_DEFINES+= \
OPENH323DIR="$(BUILD_DIR)/openh323" \
PWLIBDIR="$(BUILD_DIR)/pwlib" \
CXXLIBS="-nodefaultlibs -luClibc++"
EXTRA_CHAN_MODULES+= chan_h323.so
define Build/Compile/chan-h323
$(MAKE) -C "$(PKG_BUILD_DIR)/channels/h323" \
$(TARGET_CONFIGURE_OPTS) \
$(EXTRA_DEFINES) \
optnoshared
endef
endif
ifneq ($(SDK)$(CONFIG_PACKAGE_asterisk-codec-speex),)
EXTRA_CFLAGS+= -I$(STAGING_DIR)/usr/include/speex
EXTRA_CODEC_MODULES+= codec_speex.so
endif
ifneq ($(SDK)$(CONFIG_PACKAGE_asterisk-res-crypto),)
EXTRA_RES_MODULES+= res_crypto.so
endif
ifneq ($(SDK)$(CONFIG_PACKAGE_asterisk-mysql),)
EXTRA_CFLAGS+= -I$(STAGING_DIR)/usr/include/mysql
EXTRA_LDFLAGS+= -L$(STAGING_DIR)/usr/lib/mysql
EXTRA_APP_MODULES+= app_sql_mysql.so
EXTRA_CDR_MODULES+= cdr_mysql.so
EXTRA_RES_MODULES+= res_config_mysql.so
endif
ifneq ($(SDK)$(CONFIG_PACKAGE_asterisk-pgsql),)
EXTRA_APP_MODULES+= app_sql_postgres.so
EXTRA_CDR_MODULES+= cdr_pgsql.so
endif
ifneq ($(SDK)$(CONFIG_PACKAGE_asterisk-sqlite),)
EXTRA_CDR_MODULES+= cdr_sqlite.so
endif
define Build/Configure
endef
define Build/Compile
$(call Build/Compile/chan-h323)
$(MAKE) -C "$(PKG_BUILD_DIR)" \
CROSS_ARCH="Linux" \
CROSS_COMPILE="$(TARGET_CROSS)" \
CROSS_COMPILE_BIN="/void/" \
CROSS_COMPILE_TARGET="/void/" \
$(TARGET_CONFIGURE_OPTS) \
HOST_CC="$(HOSTCC)" \
OPTIMIZE="$(TARGET_CFLAGS)" \
PROC="$(ARCH)" \
DEBUG="" \
OPTIONS="-DLOW_MEMORY -Dlinux" \
EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
EXTRA_LDFLAGS="$(EXTRA_LDFLAGS)" \
EXTRA_APP_MODULES="$(EXTRA_APP_MODULES)" \
EXTRA_CDR_MODULES="$(EXTRA_CDR_MODULES)" \
EXTRA_CHAN_MODULES="$(EXTRA_CHAN_MODULES)" \
EXTRA_CODEC_MODULES="$(EXTRA_CODEC_MODULES)" \
EXTRA_RES_MODULES="$(EXTRA_RES_MODULES)" \
DESTDIR="$(PKG_INSTALL_DIR)" \
ASTVARLIBDIR="/usr/lib/asterisk" \
$(EXTRA_DEFINES) \
all install samples
$(SED) 's|/var/lib/asterisk|/usr/lib/asterisk|g' $(PKG_INSTALL_DIR)/etc/asterisk/musiconhold.conf
rm -f $(PKG_INSTALL_DIR)/etc/asterisk/*.old
endef
define Build/InstallDev
mkdir -p $(1)/usr/include
$(CP) $(PKG_INSTALL_DIR)/usr/include/asterisk \
$(1)/usr/include/
endef
define Package/asterisk/conffiles
/etc/asterisk/asterisk.conf
/etc/asterisk/agents.conf
/etc/asterisk/alarmreceiver.conf
/etc/asterisk/cdr_manager.conf
/etc/asterisk/codecs.conf
/etc/asterisk/enum.conf
/etc/asterisk/extconfig.conf
/etc/asterisk/extensions.conf
/etc/asterisk/features.conf
/etc/asterisk/iax.conf
/etc/asterisk/iaxprov.conf
/etc/asterisk/indications.conf
/etc/asterisk/logger.conf
/etc/asterisk/manager.conf
/etc/asterisk/modules.conf
/etc/asterisk/musiconhold.conf
/etc/asterisk/osp.conf
/etc/asterisk/privacy.conf
/etc/asterisk/queues.conf
/etc/asterisk/rtp.conf
/etc/asterisk/sip.conf
endef
define Package/asterisk/install
$(CP) $(PKG_INSTALL_DIR)/* $(1)
rm -rf $(1)/usr/sbin/astgenkey
rm -rf $(1)/usr/bin
rm -rf $(1)/usr/share
rm -rf $(1)/usr/include
rm -rf $(1)/var
(cd $(1)/usr/lib/asterisk; \
rm -rf agi-bin; \
rm -rf images; \
rm -rf keys/*; \
rm -rf mohmp3/*.mp3; \
rm -rf sounds/*; \
cd modules; \
rm -rf *adsi* *festival* *modem* *meetme* *oss* *phone* *intercom* \
*mp3* *nbscat* *mysql* *postgres* *pgsql* *voicemail* *speex* \
*zap* *jpeg*; \
rm -f chan_bluetooth.so ; \
rm -f chan_h323.so ; \
rm -f chan_mgcp.so ; \
rm -f chan_skinny.so ; \
rm -f chan_oss.so ; \
rm -f {codec,format}_ilbc.so ; \
rm -f codec_lpc10.so ; \
rm -f pbx_dundi.so ; \
rm -f res_agi.so ; \
rm -f res_crypto.so ; \
)
(cd $(1)/etc/asterisk; \
rm -f *odbc* *mysql* *postgres* *pgsql* *voicemail* *adsi* *oss* *alsa* \
*festival* *modem* *meetme* *phone* *tds* *vofr* *rpt* *vpb* \
*zapata*; \
rm -f bluetooth.conf ; \
rm -f mgcp.conf ; \
rm -f skinny.conf ; \
rm -f oss.conf ; \
rm -f dundi.conf ; \
)
$(INSTALL_DATA) ./files/modules.conf $(1)/etc/asterisk/
$(INSTALL_DIR) $(1)/etc/default
$(INSTALL_DATA) ./files/asterisk.default $(1)/etc/default/asterisk
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/asterisk.init $(1)/etc/init.d/asterisk
endef
define Package/asterisk-mini/conffiles
/etc/asterisk/asterisk.conf
/etc/asterisk/enum.conf
/etc/asterisk/extconfig.conf
/etc/asterisk/extensions.conf
/etc/asterisk/features.conf
/etc/asterisk/iax.conf
/etc/asterisk/iaxprov.conf
/etc/asterisk/logger.conf
/etc/asterisk/manager.conf
/etc/asterisk/modules.conf
/etc/asterisk/musiconhold.conf
/etc/asterisk/rtp.conf
/etc/asterisk/sip.conf
endef
define Package/asterisk-mini/install
$(INSTALL_DIR) $(1)/etc/asterisk
for f in asterisk enum extconfig extensions features iax iaxprov \
logger manager modules musiconhold rtp sip; do \
$(CP) $(PKG_INSTALL_DIR)/etc/asterisk/$$$$f.conf $(1)/etc/asterisk/ ; \
done
$(INSTALL_DATA) ./files/modules.conf $(1)/etc/asterisk/
$(INSTALL_DIR) $(1)/usr/lib/asterisk
$(CP) $(PKG_INSTALL_DIR)/usr/lib/asterisk/firmware $(1)/usr/lib/asterisk/
$(INSTALL_DIR) $(1)/usr/lib/asterisk/keys
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
for f in app_dial chan_iax2 chan_local chan_sip codec_gsm \
codec_ulaw format_gsm format_pcm format_wav format_wav_gsm \
pbx_config res_features res_musiconhold; do \
$(CP) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/$$$$f.so $(1)/usr/lib/asterisk/modules/ ; \
done
$(INSTALL_DIR) $(1)/usr/lib/asterisk/mohmp3
$(INSTALL_DIR) $(1)/usr/lib/asterisk/sounds
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/asterisk $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/safe_asterisk $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/etc/default
$(INSTALL_DATA) ./files/asterisk.default $(1)/etc/default/asterisk
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/asterisk.init $(1)/etc/init.d/asterisk
endef
define Package/asterisk-app-meetme/conffiles
/etc/asterisk/meetme.conf
endef
define Package/asterisk-app-meetme/install
$(INSTALL_DIR) $(1)/etc/asterisk
$(INSTALL_DATA) $(PKG_BUILD_DIR)/configs/meetme.conf.sample $(1)/etc/asterisk/meetme.conf
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
$(INSTALL_BIN) $(PKG_BUILD_DIR)/apps/app_meetme.so $(1)/usr/lib/asterisk/modules/
endef
define Package/asterisk-chan-bluetooth/conffiles
/etc/asterisk/bluetooth.conf
endef
define Package/asterisk-chan-bluetooth/install
$(INSTALL_DIR) $(1)/etc/asterisk
$(INSTALL_DATA) $(PKG_BUILD_DIR)/configs/bluetooth.conf $(1)/etc/asterisk/bluetooth.conf
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
$(INSTALL_BIN) $(PKG_BUILD_DIR)/channels/chan_bluetooth.so $(1)/usr/lib/asterisk/modules/
endef
define Package/asterisk-chan-h323/conffiles
/etc/asterisk/h323.conf
endef
define Package/asterisk-chan-h323/install
$(INSTALL_DIR) $(1)/etc/asterisk
$(INSTALL_DATA) $(PKG_BUILD_DIR)/channels/h323/h323.conf.sample $(1)/etc/asterisk/h323.conf
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
$(INSTALL_BIN) $(PKG_BUILD_DIR)/channels/chan_h323.so $(1)/usr/lib/asterisk/modules/
endef
define Package/asterisk-chan-mgcp/conffiles
/etc/asterisk/mgcp.conf
endef
define Package/asterisk-chan-mgcp/install
$(INSTALL_DIR) $(1)/etc/asterisk
$(INSTALL_DATA) $(PKG_BUILD_DIR)/configs/mgcp.conf.sample $(1)/etc/asterisk/mgcp.conf
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
$(INSTALL_BIN) $(PKG_BUILD_DIR)/channels/chan_mgcp.so $(1)/usr/lib/asterisk/modules/
endef
define Package/asterisk-chan-oss/conffiles
/etc/asterisk/oss.conf
endef
define Package/asterisk-chan-oss/install
$(INSTALL_DIR) $(1)/etc/asterisk
$(INSTALL_DATA) $(PKG_BUILD_DIR)/configs/oss.conf.sample $(1)/etc/asterisk/oss.conf
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
$(INSTALL_BIN) $(PKG_BUILD_DIR)/channels/chan_oss.so $(1)/usr/lib/asterisk/modules/
endef
define Package/asterisk-chan-skinny/conffiles
/etc/asterisk/skinny.conf
endef
define Package/asterisk-chan-skinny/install
$(INSTALL_DIR) $(1)/etc/asterisk
$(INSTALL_DATA) $(PKG_BUILD_DIR)/configs/skinny.conf.sample $(1)/etc/asterisk/skinny.conf
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
$(INSTALL_BIN) $(PKG_BUILD_DIR)/channels/chan_skinny.so $(1)/usr/lib/asterisk/modules/
endef
define Package/asterisk-code-ilbc/install
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
$(INSTALL_BIN) $(PKG_BUILD_DIR)/codecs/codec_ilbc.so $(1)/usr/lib/asterisk/modules/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/formats/format_ilbc.so $(1)/usr/lib/asterisk/modules/
endef
define Package/asterisk-codec-lpc10/install
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
$(INSTALL_BIN) $(PKG_BUILD_DIR)/codecs/codec_lpc10.so $(1)/usr/lib/asterisk/modules/
endef
define Package/asterisk-codec-speex/install
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
$(INSTALL_BIN) $(PKG_BUILD_DIR)/codecs/codec_speex.so $(1)/usr/lib/asterisk/modules/
endef
define Package/asterisk-pbx-dundi/conffiles
/etc/asterisk/dundi.conf
endef
define Package/asterisk-pbx-dundi/install
$(INSTALL_DIR) $(1)/etc/asterisk
$(INSTALL_DATA) $(PKG_BUILD_DIR)/configs/dundi.conf.sample $(1)/etc/asterisk/dundi.conf
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
$(INSTALL_BIN) $(PKG_BUILD_DIR)/pbx/pbx_dundi.so $(1)/usr/lib/asterisk/modules/
endef
define Package/asterisk-res-agi/install
$(INSTALL_DIR) $(1)/usr/lib/asterisk/agi-bin
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
$(INSTALL_BIN) $(PKG_BUILD_DIR)/res/res_agi.so $(1)/usr/lib/asterisk/modules/
endef
define Package/asterisk-res-crypto/install
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
$(INSTALL_BIN) $(PKG_BUILD_DIR)/res/res_crypto.so $(1)/usr/lib/asterisk/modules/
endef
define Package/asterisk-mysql/conffiles
/etc/asterisk/cdr_mysql.conf
endef
define Package/asterisk-mysql/install
$(INSTALL_DIR) $(1)/etc/asterisk
$(INSTALL_CONF) $(PKG_BUILD_DIR)/configs/cdr_mysql.conf.sample $(1)/etc/asterisk/cdr_mysql.conf
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
$(INSTALL_BIN) $(PKG_BUILD_DIR)/apps/app_sql_mysql.so $(1)/usr/lib/asterisk/modules/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/cdr/cdr_mysql.so $(1)/usr/lib/asterisk/modules/
endef
define Package/asterisk-pgsql/conffiles
/etc/asterisk/cdr_pgsql.conf
endef
define Package/asterisk-pgsql/install
$(INSTALL_DIR) $(1)/etc/asterisk
$(INSTALL_CONF) $(PKG_BUILD_DIR)/configs/cdr_pgsql.conf.sample $(1)/etc/asterisk/cdr_pgsql.conf
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
$(INSTALL_BIN) $(PKG_BUILD_DIR)/apps/app_sql_postgres.so $(1)/usr/lib/asterisk/modules/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/cdr/cdr_pgsql.so $(1)/usr/lib/asterisk/modules/
endef
define Package/asterisk-sqlite/install
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
$(INSTALL_BIN) $(PKG_BUILD_DIR)/cdr/cdr_sqlite.so $(1)/usr/lib/asterisk/modules/
endef
define Package/asterisk-sounds/install
$(INSTALL_DIR) $(1)/usr/lib/asterisk/sounds
$(CP) $(PKG_BUILD_DIR)/sounds/* $(1)/usr/lib/asterisk/sounds/
rm -f $(1)/usr/lib/asterisk/sounds/*.mp3
rm -f $(1)/usr/lib/asterisk/sounds/vm-*
endef
define Package/asterisk-voicemail/conffiles
/etc/asterisk/voicemail.conf
endef
define Package/asterisk-voicemail/install
$(INSTALL_DIR) $(1)/etc/asterisk
$(INSTALL_DATA) $(PKG_BUILD_DIR)/configs/voicemail.conf.sample $(1)/etc/asterisk/voicemail.conf
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
$(INSTALL_BIN) $(PKG_BUILD_DIR)/apps/*voicemail.so $(1)/usr/lib/asterisk/modules/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/res/res_adsi.so $(1)/usr/lib/asterisk/modules/
$(INSTALL_DIR) $(1)/usr/lib/asterisk/sounds
$(CP) $(PKG_BUILD_DIR)/sounds/vm-*.gsm $(1)/usr/lib/asterisk/sounds/
endef
$(eval $(call BuildPackage,asterisk))
$(eval $(call BuildPackage,asterisk-app-meetme))
$(eval $(call BuildPackage,asterisk-chan-bluetooth))
$(eval $(call BuildPackage,asterisk-chan-h323))
$(eval $(call BuildPackage,asterisk-chan-mgcp))
$(eval $(call BuildPackage,asterisk-chan-oss))
$(eval $(call BuildPackage,asterisk-chan-skinny))
$(eval $(call BuildPackage,asterisk-codec-ilbc))
$(eval $(call BuildPackage,asterisk-codec-lpc10))
$(eval $(call BuildPackage,asterisk-codec-speex))
$(eval $(call BuildPackage,asterisk-pbx-dundi))
$(eval $(call BuildPackage,asterisk-res-agi))
$(eval $(call BuildPackage,asterisk-res-crypto))
$(eval $(call BuildPackage,asterisk-mini))
$(eval $(call BuildPackage,asterisk-mysql))
$(eval $(call BuildPackage,asterisk-pgsql))
$(eval $(call BuildPackage,asterisk-sqlite))
$(eval $(call BuildPackage,asterisk-sounds))
$(eval $(call BuildPackage,asterisk-voicemail))

View File

@ -1,4 +0,0 @@
## startup options for /etc/init.d/asterisk
DEST=""
OPTIONS=""

View File

@ -1,21 +0,0 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
START=50
DEFAULT=/etc/default/asterisk
DEST=
OPTIONS=
start() {
[ -f $DEFAULT ] && . $DEFAULT
mkdir -p $DEST/var/run
mkdir -p $DEST/var/log/asterisk
mkdir -p $DEST/var/spool/asterisk
[ -f $DEST/usr/lib/asterisk/astdb ] && mv $DEST/usr/lib/asterisk/astdb $DEST/var/spool/asterisk/
[ -h $DEST/usr/lib/asterisk/astdb ] || ln -sf $DEST/var/spool/asterisk/astdb $DEST/usr/lib/asterisk/
/usr/sbin/asterisk $OPTIONS
}
stop() {
[ -f $DEST/var/run/asterisk.pid ] && kill $(cat $DEST/var/run/asterisk.pid) >/dev/null 2>&1
}

View File

@ -1,140 +0,0 @@
;
; Asterisk configuration file
;
; Module Loader configuration file
;
[modules]
autoload=yes
;
; Any modules that need to be loaded before the Asterisk core has been
; initialized (just after the logger has been initialized) can be loaded
; using 'preload'. This will frequently be needed if you wish to map all
; module configuration files into Realtime storage, since the Realtime
; driver will need to be loaded before the modules using those configuration
; files are initialized.
;
; An example of loading ODBC support would be:
;preload => res_odbc.so
;preload => res_config_odbc.so
;
noload => res_config_mysql.so ;
noload => res_crypto.so ; Cryptographic Digital Signatures
; load => res_features.so ; Call Parking Resource
noload => res_indications.so ; Indications Configuration
noload => res_monitor.so ; Call Monitoring Resource
; load => res_musiconhold.so ; Music On Hold Resource
noload => cdr_csv.so ; Comma Separated Values CDR Backend
noload => cdr_custom.so ; Customizable Comma Separated Values CDR Backend
noload => cdr_manager.so ; Asterisk Call Manager CDR Backend
noload => cdr_mysql.so ; MySQL CDR Backend
noload => cdr_pgsql.so ; PostgreSQL CDR Backend
noload => cdr_sqlite.so ; SQLite CDR Backend
noload => chan_agent.so ; Agent Proxy Channel
; load => chan_iax2.so ; Inter Asterisk eXchange (Ver 2)
; load => chan_local.so ; Local Proxy Channel
noload => chan_oss.so ; Channel driver for OSS sound cards
; load => chan_sip.so ; Session Initiation Protocol (SIP)
noload => codec_a_mu.so ; A-law and Mulaw direct Coder/Decoder
noload => codec_adpcm.so ; Adaptive Differential PCM Coder/Decoder
noload => codec_alaw.so ; A-law Coder/Decoder
noload => codec_g726.so ; ITU G.726-32kbps G726 Transcoder
; load => codec_gsm.so ; GSM/PCM16 (signed linear) Codec Translation
; load => codec_ulaw.so ; Mu-law Coder/Decoder
noload => codec_speex.so ; Speex/PCM16 (signed linear) Codec Translator
noload => format_au.so ; Sun Microsystems AU format (signed linear)
noload => format_g723.so ; G.723.1 Simple Timestamp File Format
noload => format_g726.so ; Raw G.726 (16/24/32/40kbps) data
noload => format_g729.so ; Raw G729 data
; load => format_gsm.so ; Raw GSM data
noload => format_h263.so ; Raw h263 data
noload => format_jpeg.so ; JPEG (Joint Picture Experts Group) Image
; load => format_pcm.so ; Raw uLaw 8khz Audio support (PCM)
noload => format_pcm_alaw.so ; Raw aLaw 8khz PCM Audio support
noload => format_sln.so ; Raw Signed Linear Audio support (SLN)
noload => format_vox.so ; Dialogic VOX (ADPCM) File Format
; load => format_wav.so ; Microsoft WAV format (8000hz Signed Line
; load => format_wav_gsm.so ; Microsoft WAV format (Proprietary GSM)
noload => app_alarmreceiver.so ; Alarm Receiver Application
noload => app_authenticate.so ; Authentication Application
noload => app_cdr.so ; Make sure asterisk doesn't save CDR
noload => app_chanisavail.so ; Check if channel is available
noload => app_chanspy.so ; Listen in on any channel
noload => app_controlplayback.so ; Control Playback Application
noload => app_cut.so ; Cuts up variables
noload => app_db.so ; Database access functions
; load => app_dial.so ; Dialing Application
noload => app_dictate.so ; Virtual Dictation Machine Application
noload => app_directory.so ; Extension Directory
noload => app_directed_pickup.so ; Directed Call Pickup Support
noload => app_disa.so ; DISA (Direct Inward System Access) Application
noload => app_dumpchan.so ; Dump channel variables Application
; load => app_echo.so ; Simple Echo Application
noload => app_enumlookup.so ; ENUM Lookup
noload => app_eval.so ; Reevaluates strings
noload => app_exec.so ; Executes applications
noload => app_externalivr.so ; External IVR application interface
noload => app_forkcdr.so ; Fork The CDR into 2 seperate entities
noload => app_getcpeid.so ; Get ADSI CPE ID
noload => app_groupcount.so ; Group Management Routines
noload => app_ices.so ; Encode and Stream via icecast and ices
noload => app_image.so ; Image Transmission Application
noload => app_lookupblacklist.so ; Look up Caller*ID name/number from black
noload => app_lookupcidname.so ; Look up CallerID Name from local database
; load => app_macro.so ; Extension Macros
noload => app_math.so ; A simple math Application
noload => app_md5.so ; MD5 checksum Application
noload => app_meetme.so ; MeetMe conferencing
; load => app_milliwatt.so ; Digital Milliwatt (mu-law) Test Application
noload => app_mixmonitor.so ; Record a call and mix the audio during the recording
noload => app_parkandannounce.so ; Call Parking and Announce Application
; load => app_playback.so ; Trivial Playback Application
noload => app_privacy.so ; Require phone number to be entered
noload => app_queue.so ; True Call Queueing
noload => app_random.so ; Random goto
noload => app_read.so ; Read Variable Application
noload => app_readfile.so ; Read in a file
noload => app_realtime.so ; Realtime Data Lookup/Rewrite
noload => app_record.so ; Trivial Record Application
; load => app_sayunixtime.so ; Say time
noload => app_senddtmf.so ; Send DTMF digits Application
noload => app_sendtext.so ; Send Text Applications
noload => app_setcallerid.so ; Set CallerID Application
noload => app_setcdruserfield.so ; CDR user field apps
noload => app_setcidname.so ; Set CallerID Name
noload => app_setcidnum.so ; Set CallerID Number
noload => app_setrdnis.so ; Set RDNIS Number
noload => app_settransfercapability.so ; Set ISDN Transfer Capability
noload => app_sms.so ; SMS/PSTN handler
noload => app_softhangup.so ; Hangs up the requested channel
noload => app_sql_mysql.so ; Simple MySQL Interface
noload => app_sql_postgres.so ; Simple PostgreSQL Interface
noload => app_stack.so ; Stack Routines
noload => app_system.so ; Generic System() application
noload => app_talkdetect.so ; Playback with Talk Detection
noload => app_test.so ; Interface Test Application
noload => app_transfer.so ; Transfer
noload => app_txtcidname.so ; TXTCIDName
noload => app_url.so ; Send URL Applications
noload => app_userevent.so ; Custom User Event Application
; load => app_verbose.so ; Send verbose output
noload => app_waitforring.so ; Waits until first ring after time
noload => app_waitforsilence.so ; Wait For Silence Application
noload => app_while.so ; While Loops and Conditional Execution
noload => func_callerid.so ; Caller ID related dialplan functions
noload => func_enum.so ; ENUM Functions
noload => func_uri.so ; URI encoding / decoding functions
noload => pbx_ael.so ; Asterisk Extension Language Compiler
; load => pbx_config.so ; Text Extension Configuration
noload => pbx_functions.so ; Builtin dialplan functions
noload => pbx_loopback.so ; Loopback Switch
noload => pbx_realtime.so ; Realtime Switch
noload => pbx_spool.so ; Outgoing Spool Support
noload => pbx_wilcalu.so ; Wil Cal U (Auto Dialer)
;
; Module names listed in "global" section will have symbols globally
; exported to modules loaded after them.
;
[global]
chan_modem.so=no

View File

@ -1,12 +0,0 @@
diff -Nru asterisk-1.2.14.org/channels/chan_iax2.c asterisk-1.2.14/channels/chan_iax2.c
--- asterisk-1.2.14.org/channels/chan_iax2.c 2006-12-09 16:45:37.000000000 +0100
+++ asterisk-1.2.14/channels/chan_iax2.c 2006-12-27 08:46:38.000000000 +0100
@@ -1191,7 +1191,7 @@
last++;
else
last = s;
- snprintf(s2, strlen(s) + 100, "/var/tmp/%s-%ld", last, (unsigned long)rand());
+ snprintf(s2, strlen(s) + 100, "/tmp/%s-%ld", last, (unsigned long)rand());
res = stat(s, &stbuf);
if (res < 0) {
ast_log(LOG_WARNING, "Failed to stat '%s': %s\n", s, strerror(errno));

View File

@ -1,18 +0,0 @@
diff -Nru asterisk-1.2.24.org/dns.c asterisk-1.2.24/dns.c
--- asterisk-1.2.24.org/dns.c 2007-07-16 22:46:58.000000000 +0200
+++ asterisk-1.2.24/dns.c 2007-09-04 18:53:32.000000000 +0200
@@ -237,7 +237,13 @@
#if defined(res_ndestroy)
#define HAS_RES_NDESTROY
#endif
-#else
+#endif
+
+#ifdef __UCLIBC__
+#undef HAS_RES_NINIT
+#endif
+
+#ifndef HAS_RES_NINIT
AST_MUTEX_DEFINE_STATIC(res_lock);
#if 0
#warning "Warning, res_ninit is missing... Could have reentrancy issues"

View File

@ -1,14 +0,0 @@
diff -Nru asterisk-1.2.14.org/db1-ast/Makefile asterisk-1.2.14/db1-ast/Makefile
--- asterisk-1.2.14.org/db1-ast/Makefile 2006-04-30 16:27:56.000000000 +0200
+++ asterisk-1.2.14/db1-ast/Makefile 2006-12-27 08:52:14.000000000 +0100
@@ -32,8 +32,8 @@
$(LIBDB): $(OBJS)
rm -f $@
- ar cq $@ $(OBJS)
- ranlib $@
+ $(AR) cq $@ $(OBJS)
+ $(RANLIB) $@
$(LIBDBSO): $(SHOBJS)
$(CC) -Wl,-O1 -Wl,--version-script=libdb.map -Wl,-soname=$(LIBDBSO) -shared -o $@ $^

View File

@ -1,28 +0,0 @@
diff -Nru asterisk-1.2.14.org/codecs/lpc10/Makefile asterisk-1.2.14/codecs/lpc10/Makefile
--- asterisk-1.2.14.org/codecs/lpc10/Makefile 2005-11-29 19:24:39.000000000 +0100
+++ asterisk-1.2.14/codecs/lpc10/Makefile 2006-12-27 08:54:16.000000000 +0100
@@ -34,6 +34,7 @@
ifneq ($(PROC),ppc)
ifneq ($(PROC),x86_64)
ifneq ($(PROC),alpha)
+ifneq ($(PROC),mipsel)
#The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
#This works for even old (2.96) versions of gcc and provides a small boost either way.
#A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn.t support it.
@@ -53,6 +54,7 @@
endif
endif
endif
+endif
LIB = $(LIB_TARGET_DIR)/liblpc10.a
@@ -69,7 +71,7 @@
$(LIB): $(OBJ)
$(AR) cr $@ $(OBJ)
- ranlib $@
+ $(RANLIB) $@
clean:
-rm -f *.o $(LIB)

View File

@ -1,14 +0,0 @@
diff -Nru asterisk-1.2.14.org/stdtime/Makefile asterisk-1.2.14/stdtime/Makefile
--- asterisk-1.2.14.org/stdtime/Makefile 2005-11-29 19:24:39.000000000 +0100
+++ asterisk-1.2.14/stdtime/Makefile 2006-12-27 08:56:14.000000000 +0100
@@ -3,8 +3,8 @@
all: libtime.a
libtime.a: $(OBJS)
- ar rv $@ $(OBJS)
- ranlib $@
+ $(AR) rv $@ $(OBJS)
+ $(RANLIB) $@
install:

File diff suppressed because it is too large Load Diff

View File

@ -1,449 +0,0 @@
diff -Nru asterisk-1.2.14.org/apps/app_sql_mysql.c asterisk-1.2.14/apps/app_sql_mysql.c
--- asterisk-1.2.14.org/apps/app_sql_mysql.c 1970-01-01 01:00:00.000000000 +0100
+++ asterisk-1.2.14/apps/app_sql_mysql.c 2006-12-27 09:00:04.000000000 +0100
@@ -0,0 +1,445 @@
+/*
+ * Asterisk -- A telephony toolkit for Linux.
+ *
+ * Connect to MySQL
+ *
+ * Copyright (C) 2004, Constantine Filin and Christos Ricudis
+ *
+ * Christos Ricudis <ricudis@itc.auth.gr>
+ * Constantine Filin <cf@intermedia.net>
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <mysql.h>
+
+#include <asterisk/file.h>
+#include <asterisk/logger.h>
+#include <asterisk/channel.h>
+#include <asterisk/pbx.h>
+#include <asterisk/module.h>
+#include <asterisk/linkedlists.h>
+#include <asterisk/chanvars.h>
+#include <asterisk/lock.h>
+
+#define EXTRA_LOG 0
+
+static char *tdesc = "Simple Mysql Interface";
+
+static char *app = "MYSQL";
+
+static char *synopsis = "Do several mySQLy things";
+
+static char *descrip =
+"MYSQL(): Do several mySQLy things\n"
+"Syntax:\n"
+" MYSQL(Connect connid dhhost dbuser dbpass dbname)\n"
+" Connects to a database. Arguments contain standard MySQL parameters\n"
+" passed to function mysql_real_connect. Connection identifer returned\n"
+" in ${var}\n"
+" MYSQL(Query resultid ${connid} query-string)\n"
+" Executes standard MySQL query contained in query-string using established\n"
+" connection identified by ${connection_identifier}. Result of query is\n"
+" is stored in ${var}.\n"
+" MYSQL(Fetch fetchid ${resultid} var1 var2 ... varN)\n"
+" Fetches a single row from a result set contained in ${result_identifier}.\n"
+" Assigns returned fields to ${var1} ... ${varn}. ${fetchid} is set TRUE\n"
+" if additional rows exist in result set.\n"
+" MYSQL(Clear ${resultid})\n"
+" Frees memory and datastructures associated with result set.\n"
+" MYSQL(Disconnect ${connid})\n"
+" Disconnects from named connection to MySQL.\n"
+" On exit, always returns 0. Sets MYSQL_STATUS to 0 on success and -1 on error.\n";
+
+/*
+EXAMPLES OF USE :
+
+exten => s,2,MYSQL(Connect connid localhost asterisk mypass credit)
+exten => s,3,MYSQL(Query resultid ${connid} SELECT username,credit FROM credit WHERE callerid=${CALLERIDNUM})
+exten => s,4,MYSQL(Fetch fetchid ${resultid} datavar1 datavar2)
+exten => s,5,GotoIf(${fetchid}?6:8)
+exten => s,6,Festival("User ${datavar1} currently has credit balance of ${datavar2} dollars.")
+exten => s,7,Goto(s,4)
+exten => s,8,MYSQL(Clear ${resultid})
+exten => s,9,MYSQL(Disconnect ${connid})
+*/
+
+STANDARD_LOCAL_USER;
+LOCAL_USER_DECL;
+
+AST_MUTEX_DEFINE_STATIC(_mysql_mutex);
+
+#define AST_MYSQL_ID_DUMMY 0
+#define AST_MYSQL_ID_CONNID 1
+#define AST_MYSQL_ID_RESID 2
+#define AST_MYSQL_ID_FETCHID 3
+
+struct ast_MYSQL_id {
+ int identifier_type; /* 0=dummy, 1=connid, 2=resultid */
+ int identifier;
+ void *data;
+ AST_LIST_ENTRY(ast_MYSQL_id) entries;
+} *ast_MYSQL_id;
+
+AST_LIST_HEAD(MYSQLidshead,ast_MYSQL_id) _mysql_ids_head;
+
+/* helpful procs */
+static void *find_identifier(int identifier,int identifier_type) {
+ struct MYSQLidshead *headp;
+ struct ast_MYSQL_id *i;
+ void *res=NULL;
+ int found=0;
+
+ headp=&_mysql_ids_head;
+
+ if (AST_LIST_LOCK(headp)) {
+ ast_log(LOG_WARNING,"Unable to lock identifiers list\n");
+ } else {
+ AST_LIST_TRAVERSE(headp,i,entries) {
+ if ((i->identifier==identifier) && (i->identifier_type==identifier_type)) {
+ found=1;
+ res=i->data;
+ break;
+ }
+ }
+ if (!found) {
+ ast_log(LOG_WARNING,"Identifier %d, identifier_type %d not found in identifier list\n",identifier,identifier_type);
+ }
+ AST_LIST_UNLOCK(headp);
+ }
+
+ return res;
+}
+
+static int add_identifier(int identifier_type,void *data) {
+ struct ast_MYSQL_id *i,*j;
+ struct MYSQLidshead *headp;
+ int maxidentifier=0;
+
+ headp=&_mysql_ids_head;
+ i=NULL;
+ j=NULL;
+
+ if (AST_LIST_LOCK(headp)) {
+ ast_log(LOG_WARNING,"Unable to lock identifiers list\n");
+ return(-1);
+ } else {
+ i=malloc(sizeof(struct ast_MYSQL_id));
+ AST_LIST_TRAVERSE(headp,j,entries) {
+ if (j->identifier>maxidentifier) {
+ maxidentifier=j->identifier;
+ }
+ }
+ i->identifier=maxidentifier+1;
+ i->identifier_type=identifier_type;
+ i->data=data;
+ AST_LIST_INSERT_HEAD(headp,i,entries);
+ AST_LIST_UNLOCK(headp);
+ }
+ return i->identifier;
+}
+
+static int del_identifier(int identifier,int identifier_type) {
+ struct ast_MYSQL_id *i;
+ struct MYSQLidshead *headp;
+ int found=0;
+
+ headp=&_mysql_ids_head;
+
+ if (AST_LIST_LOCK(headp)) {
+ ast_log(LOG_WARNING,"Unable to lock identifiers list\n");
+ } else {
+ AST_LIST_TRAVERSE(headp,i,entries) {
+ if ((i->identifier==identifier) &&
+ (i->identifier_type==identifier_type)) {
+ AST_LIST_REMOVE(headp,i,entries);
+ free(i);
+ found=1;
+ break;
+ }
+ }
+ AST_LIST_UNLOCK(headp);
+ }
+
+ if (found==0) {
+ ast_log(LOG_WARNING,"Could not find identifier %d, identifier_type %d in list to delete\n",identifier,identifier_type);
+ return(-1);
+ } else {
+ return(0);
+ }
+}
+
+static int set_asterisk_int(struct ast_channel *chan, char *varname, int id) {
+ if( id>=0 ) {
+ char s[100] = "";
+ snprintf(s, sizeof(s)-1, "%d", id);
+#if EXTRA_LOG
+ ast_log(LOG_WARNING,"MYSQL: setting var '%s' to value '%s'\n",varname,s);
+#endif
+ pbx_builtin_setvar_helper(chan,varname,s);
+ }
+ return id;
+}
+
+static int add_identifier_and_set_asterisk_int(struct ast_channel *chan, char *varname, int identifier_type, void *data) {
+ return set_asterisk_int(chan,varname,add_identifier(identifier_type,data));
+}
+
+static int safe_scan_int( char** data, char* delim, int def ) {
+ char* end;
+ int res = def;
+ char* s = strsep(data,delim);
+ if( s ) {
+ res = strtol(s,&end,10);
+ if (*end) res = def; /* not an integer */
+ }
+ return res;
+}
+
+/* MYSQL operations */
+static int aMYSQL_connect(struct ast_channel *chan, char *data) {
+
+ MYSQL *mysql;
+
+ char *connid_var;
+ char *dbhost;
+ char *dbuser;
+ char *dbpass;
+ char *dbname;
+
+ strsep(&data," "); // eat the first token, we already know it :P
+
+ connid_var=strsep(&data," ");
+ dbhost=strsep(&data," ");
+ dbuser=strsep(&data," ");
+ dbpass=strsep(&data," ");
+ dbname=strsep(&data,"\n");
+
+ if( connid_var && dbhost && dbuser && dbpass && dbname ) {
+ mysql = mysql_init(NULL);
+ if (mysql) {
+ if (mysql_real_connect(mysql,dbhost,dbuser,dbpass,dbname,0,NULL,0)) {
+ add_identifier_and_set_asterisk_int(chan,connid_var,AST_MYSQL_ID_CONNID,mysql);
+ return 0;
+ }
+ else {
+ ast_log(LOG_WARNING,"mysql_real_connect(mysql,%s,%s,dbpass,%s,...) failed\n",dbhost,dbuser,dbname);
+ }
+ }
+ else {
+ ast_log(LOG_WARNING,"myslq_init returned NULL\n");
+ }
+ }
+ else {
+ ast_log(LOG_WARNING,"MYSQL(connect is missing some arguments\n");
+ }
+
+ return -1;
+}
+
+static int aMYSQL_query(struct ast_channel *chan, char *data) {
+
+ MYSQL *mysql;
+ MYSQL_RES *mysqlres;
+
+ char *resultid_var;
+ int connid;
+ char *querystring;
+
+ strsep(&data," "); // eat the first token, we already know it :P
+
+ resultid_var = strsep(&data," ");
+ connid = safe_scan_int(&data," ",-1);
+ querystring = strsep(&data,"\n");
+
+ if (resultid_var && (connid>=0) && querystring) {
+ if ((mysql=find_identifier(connid,AST_MYSQL_ID_CONNID))!=NULL) {
+ mysql_query(mysql,querystring);
+ if ((mysqlres=mysql_use_result(mysql))!=NULL) {
+ add_identifier_and_set_asterisk_int(chan,resultid_var,AST_MYSQL_ID_RESID,mysqlres);
+ return 0;
+ }
+ else if( mysql_field_count(mysql)==0 ) {
+ return 0; // See http://dev.mysql.com/doc/mysql/en/mysql_field_count.html
+ }
+ else {
+ ast_log(LOG_WARNING,"aMYSQL_query: mysql_store_result() failed on query %s\n",querystring);
+ }
+ }
+ else {
+ ast_log(LOG_WARNING,"aMYSQL_query: Invalid connection identifier %d passed in aMYSQL_query\n",connid);
+ }
+ }
+ else {
+ ast_log(LOG_WARNING,"aMYSQL_query: missing some arguments\n");
+ }
+
+ return -1;
+}
+
+
+static int aMYSQL_fetch(struct ast_channel *chan, char *data) {
+
+ MYSQL_RES *mysqlres;
+ MYSQL_ROW mysqlrow;
+
+ char *fetchid_var,*s5,*s6;
+ int resultid,numFields,j;
+
+ strsep(&data," "); // eat the first token, we already know it :P
+
+ fetchid_var = strsep(&data," ");
+ resultid = safe_scan_int(&data," ",-1);
+
+ if (fetchid_var && (resultid>=0) ) {
+ if ((mysqlres=find_identifier(resultid,AST_MYSQL_ID_RESID))!=NULL) {
+ /* Grab the next row */
+ if ((mysqlrow=mysql_fetch_row(mysqlres))!=NULL) {
+ numFields=mysql_num_fields(mysqlres);
+ for (j=0;j<numFields;j++) {
+ s5=strsep(&data," ");
+ if (s5==NULL) {
+ ast_log(LOG_WARNING,"ast_MYSQL_fetch: More fields (%d) than variables (%d)\n",numFields,j);
+ break;
+ }
+ s6=mysqlrow[j];
+ pbx_builtin_setvar_helper(chan,s5, s6 ? s6 : "NULL");
+ }
+#ifdef EXTRA_LOG
+ ast_log(LOG_WARNING,"ast_MYSQL_fetch: numFields=%d\n",numFields);
+#endif
+ set_asterisk_int(chan,fetchid_var,1); // try more rows
+ } else {
+#if EXTRA_LOG
+ ast_log(LOG_WARNING,"ast_MYSQL_fetch : EOF\n");
+#endif
+ set_asterisk_int(chan,fetchid_var,0); // no more rows
+ }
+ return 0;
+ }
+ else {
+ ast_log(LOG_WARNING,"aMYSQL_fetch: Invalid result identifier %d passed\n",resultid);
+ }
+ }
+ else {
+ ast_log(LOG_WARNING,"aMYSQL_fetch: missing some arguments\n");
+ }
+
+ return -1;
+}
+
+static int aMYSQL_clear(struct ast_channel *chan, char *data) {
+
+ MYSQL_RES *mysqlres;
+
+ int id;
+ strsep(&data," "); // eat the first token, we already know it :P
+ id = safe_scan_int(&data," \n",-1);
+ if ((mysqlres=find_identifier(id,AST_MYSQL_ID_RESID))==NULL) {
+ ast_log(LOG_WARNING,"Invalid result identifier %d passed in aMYSQL_clear\n",id);
+ } else {
+ mysql_free_result(mysqlres);
+ del_identifier(id,AST_MYSQL_ID_RESID);
+ }
+
+ return 0;
+}
+
+static int aMYSQL_disconnect(struct ast_channel *chan, char *data) {
+
+ MYSQL *mysql;
+ int id;
+ strsep(&data," "); // eat the first token, we already know it :P
+
+ id = safe_scan_int(&data," \n",-1);
+ if ((mysql=find_identifier(id,AST_MYSQL_ID_CONNID))==NULL) {
+ ast_log(LOG_WARNING,"Invalid connection identifier %d passed in aMYSQL_disconnect\n",id);
+ } else {
+ mysql_close(mysql);
+ del_identifier(id,AST_MYSQL_ID_CONNID);
+ }
+
+ return 0;
+}
+
+static int MYSQL_exec(struct ast_channel *chan, void *data)
+{
+ struct localuser *u;
+ int result;
+ char sresult[10];
+
+#if EXTRA_LOG
+ fprintf(stderr,"MYSQL_exec: data=%s\n",(char*)data);
+#endif
+
+ if (!data) {
+ ast_log(LOG_WARNING, "APP_MYSQL requires an argument (see manual)\n");
+ return -1;
+ }
+
+ LOCAL_USER_ADD(u);
+ result=0;
+
+ ast_mutex_lock(&_mysql_mutex);
+
+ if (strncasecmp("connect",data,strlen("connect"))==0) {
+ result=aMYSQL_connect(chan,ast_strdupa(data));
+ } else if (strncasecmp("query",data,strlen("query"))==0) {
+ result=aMYSQL_query(chan,ast_strdupa(data));
+ } else if (strncasecmp("fetch",data,strlen("fetch"))==0) {
+ result=aMYSQL_fetch(chan,ast_strdupa(data));
+ } else if (strncasecmp("clear",data,strlen("clear"))==0) {
+ result=aMYSQL_clear(chan,ast_strdupa(data));
+ } else if (strncasecmp("disconnect",data,strlen("disconnect"))==0) {
+ result=aMYSQL_disconnect(chan,ast_strdupa(data));
+ } else {
+ ast_log(LOG_WARNING, "Unknown argument to MYSQL application : %s\n",(char *)data);
+ result=-1;
+ }
+
+ ast_mutex_unlock(&_mysql_mutex);
+
+ LOCAL_USER_REMOVE(u);
+ snprintf(sresult, sizeof(sresult), "%d", result);
+ pbx_builtin_setvar_helper(chan, "MYSQL_STATUS", sresult);
+ return 0;
+}
+
+int unload_module(void)
+{
+ STANDARD_HANGUP_LOCALUSERS;
+ return ast_unregister_application(app);
+}
+
+int load_module(void)
+{
+ struct MYSQLidshead *headp = &_mysql_ids_head;
+ AST_LIST_HEAD_INIT(headp);
+ return ast_register_application(app, MYSQL_exec, synopsis, descrip);
+}
+
+char *description(void)
+{
+ return tdesc;
+}
+
+int usecount(void)
+{
+ int res;
+ STANDARD_USECOUNT(res);
+ return res;
+}
+
+char *key()
+{
+ return ASTERISK_GPL_KEY;
+}

View File

@ -1,522 +0,0 @@
diff -Nru asterisk-1.2.14.org/cdr/cdr_mysql.c asterisk-1.2.14/cdr/cdr_mysql.c
--- asterisk-1.2.14.org/cdr/cdr_mysql.c 1970-01-01 01:00:00.000000000 +0100
+++ asterisk-1.2.14/cdr/cdr_mysql.c 2006-12-27 09:02:18.000000000 +0100
@@ -0,0 +1,493 @@
+/*
+ * Asterisk -- A telephony toolkit for Linux.
+ *
+ * MySQL CDR logger
+ *
+ * James Sharp <jsharp@psychoses.org>
+ *
+ * Modified August 2003
+ * Tilghman Lesher <asterisk__cdr__cdr_mysql__200308@the-tilghman.com>
+ *
+ * Modified August 6, 2005
+ * Joseph Benden <joe@thrallingpenguin.com>
+ * Added mysql connection timeout parameter
+ * Added an automatic reconnect as to not lose a cdr record
+ * Cleaned up the original code to match the coding guidelines
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License.
+ *
+ */
+
+#include <sys/types.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <time.h>
+
+#include <mysql.h>
+#include <errmsg.h>
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <errno.h>
+
+#include <asterisk/config.h>
+#include <asterisk/options.h>
+#include <asterisk/channel.h>
+#include <asterisk/cdr.h>
+#include <asterisk/module.h>
+#include <asterisk/logger.h>
+#include <asterisk/cli.h>
+
+#define DATE_FORMAT "%Y-%m-%d %T"
+
+static char *desc = "MySQL CDR Backend";
+static char *name = "mysql";
+static char *config = "cdr_mysql.conf";
+static char *hostname = NULL, *dbname = NULL, *dbuser = NULL, *password = NULL, *dbsock = NULL, *dbtable = NULL;
+static int hostname_alloc = 0, dbname_alloc = 0, dbuser_alloc = 0, password_alloc = 0, dbsock_alloc = 0, dbtable_alloc = 0;
+static int dbport = 0;
+static int connected = 0;
+static time_t connect_time = 0;
+static int records = 0;
+static int totalrecords = 0;
+static int userfield = 0;
+static unsigned int timeout = 0;
+
+AST_MUTEX_DEFINE_STATIC(mysql_lock);
+
+static MYSQL mysql;
+
+static char cdr_mysql_status_help[] =
+"Usage: cdr mysql status\n"
+" Shows current connection status for cdr_mysql\n";
+
+static int handle_cdr_mysql_status(int fd, int argc, char *argv[])
+{
+ if (connected) {
+ char status[256], status2[100] = "";
+ int ctime = time(NULL) - connect_time;
+ if (dbport)
+ snprintf(status, 255, "Connected to %s@%s, port %d", dbname, hostname, dbport);
+ else if (dbsock)
+ snprintf(status, 255, "Connected to %s on socket file %s", dbname, dbsock);
+ else
+ snprintf(status, 255, "Connected to %s@%s", dbname, hostname);
+
+ if (dbuser && *dbuser)
+ snprintf(status2, 99, " with username %s", dbuser);
+ if (dbtable && *dbtable)
+ snprintf(status2, 99, " using table %s", dbtable);
+ if (ctime > 31536000) {
+ ast_cli(fd, "%s%s for %d years, %d days, %d hours, %d minutes, %d seconds.\n", status, status2, ctime / 31536000, (ctime % 31536000) / 86400, (ctime % 86400) / 3600, (ctime % 3600) / 60, ctime % 60);
+ } else if (ctime > 86400) {
+ ast_cli(fd, "%s%s for %d days, %d hours, %d minutes, %d seconds.\n", status, status2, ctime / 86400, (ctime % 86400) / 3600, (ctime % 3600) / 60, ctime % 60);
+ } else if (ctime > 3600) {
+ ast_cli(fd, "%s%s for %d hours, %d minutes, %d seconds.\n", status, status2, ctime / 3600, (ctime % 3600) / 60, ctime % 60);
+ } else if (ctime > 60) {
+ ast_cli(fd, "%s%s for %d minutes, %d seconds.\n", status, status2, ctime / 60, ctime % 60);
+ } else {
+ ast_cli(fd, "%s%s for %d seconds.\n", status, status2, ctime);
+ }
+ if (records == totalrecords)
+ ast_cli(fd, " Wrote %d records since last restart.\n", totalrecords);
+ else
+ ast_cli(fd, " Wrote %d records since last restart and %d records since last reconnect.\n", totalrecords, records);
+ return RESULT_SUCCESS;
+ } else {
+ ast_cli(fd, "Not currently connected to a MySQL server.\n");
+ return RESULT_FAILURE;
+ }
+}
+
+static struct ast_cli_entry cdr_mysql_status_cli =
+ { { "cdr", "mysql", "status", NULL },
+ handle_cdr_mysql_status, "Show connection status of cdr_mysql",
+ cdr_mysql_status_help, NULL };
+
+static int mysql_log(struct ast_cdr *cdr)
+{
+ struct tm tm;
+ struct timeval tv;
+ struct localuser *u;
+ char *userfielddata = NULL;
+ char sqlcmd[2048], timestr[128];
+ char *clid=NULL, *dcontext=NULL, *channel=NULL, *dstchannel=NULL, *lastapp=NULL, *lastdata=NULL;
+ int retries = 5;
+#ifdef MYSQL_LOGUNIQUEID
+ char *uniqueid = NULL;
+#endif
+
+ ast_mutex_lock(&mysql_lock);
+
+ memset(sqlcmd, 0, 2048);
+
+ localtime_r(&cdr->start.tv_sec, &tm);
+ strftime(timestr, 128, DATE_FORMAT, &tm);
+
+db_reconnect:
+ if ((!connected) && (hostname || dbsock) && dbuser && password && dbname && dbtable ) {
+ /* Attempt to connect */
+ mysql_init(&mysql);
+ /* Add option to quickly timeout the connection */
+ if (timeout && mysql_options(&mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *)&timeout)!=0) {
+ ast_log(LOG_ERROR, "cdr_mysql: mysql_options returned (%d) %s\n", mysql_errno(&mysql), mysql_error(&mysql));
+ }
+ if (mysql_real_connect(&mysql, hostname, dbuser, password, dbname, dbport, dbsock, 0)) {
+ connected = 1;
+ connect_time = time(NULL);
+ records = 0;
+ } else {
+ ast_log(LOG_ERROR, "cdr_mysql: cannot connect to database server %s.\n", hostname);
+ connected = 0;
+ }
+ } else {
+ /* Long connection - ping the server */
+ int error;
+ if ((error = mysql_ping(&mysql))) {
+ connected = 0;
+ records = 0;
+ switch (error) {
+ case CR_SERVER_GONE_ERROR:
+ case CR_SERVER_LOST:
+ ast_log(LOG_ERROR, "cdr_mysql: Server has gone away. Attempting to reconnect.\n");
+ break;
+ default:
+ ast_log(LOG_ERROR, "cdr_mysql: Unknown connection error: (%d) %s\n", mysql_errno(&mysql), mysql_error(&mysql));
+ }
+ retries--;
+ if (retries)
+ goto db_reconnect;
+ else
+ ast_log(LOG_ERROR, "cdr_mysql: Retried to connect fives times, giving up.\n");
+ }
+ }
+
+ /* Maximum space needed would be if all characters needed to be escaped, plus a trailing NULL */
+ /* WARNING: This code previously used mysql_real_escape_string, but the use of said function
+ requires an active connection to a database. If we are not connected, then this function
+ cannot be used. This is a problem since we need to store off the SQL statement into our
+ spool file for later restoration.
+ So the question is, what's the best way to handle this? This works for now.
+ */
+ if ((clid = alloca(strlen(cdr->clid) * 2 + 1)) != NULL)
+ mysql_escape_string(clid, cdr->clid, strlen(cdr->clid));
+ if ((dcontext = alloca(strlen(cdr->dcontext) * 2 + 1)) != NULL)
+ mysql_escape_string(dcontext, cdr->dcontext, strlen(cdr->dcontext));
+ if ((channel = alloca(strlen(cdr->channel) * 2 + 1)) != NULL)
+ mysql_escape_string(channel, cdr->channel, strlen(cdr->channel));
+ if ((dstchannel = alloca(strlen(cdr->dstchannel) * 2 + 1)) != NULL)
+ mysql_escape_string(dstchannel, cdr->dstchannel, strlen(cdr->dstchannel));
+ if ((lastapp = alloca(strlen(cdr->lastapp) * 2 + 1)) != NULL)
+ mysql_escape_string(lastapp, cdr->lastapp, strlen(cdr->lastapp));
+ if ((lastdata = alloca(strlen(cdr->lastdata) * 2 + 1)) != NULL)
+ mysql_escape_string(lastdata, cdr->lastdata, strlen(cdr->lastdata));
+#ifdef MYSQL_LOGUNIQUEID
+ if ((uniqueid = alloca(strlen(cdr->uniqueid) * 2 + 1)) != NULL)
+ mysql_escape_string(uniqueid, cdr->uniqueid, strlen(cdr->uniqueid));
+#endif
+ if (userfield && ((userfielddata = alloca(strlen(cdr->userfield) * 2 + 1)) != NULL))
+ mysql_escape_string(userfielddata, cdr->userfield, strlen(cdr->userfield));
+
+ /* Check for all alloca failures above at once */
+#ifdef MYSQL_LOGUNIQUEID
+ if ((!clid) || (!dcontext) || (!channel) || (!dstchannel) || (!lastapp) || (!lastdata) || (!uniqueid)) {
+#else
+ if ((!clid) || (!dcontext) || (!channel) || (!dstchannel) || (!lastapp) || (!lastdata)) {
+#endif
+ ast_log(LOG_ERROR, "cdr_mysql: Out of memory error (insert fails)\n");
+ ast_mutex_unlock(&mysql_lock);
+ return -1;
+ }
+
+ ast_log(LOG_DEBUG, "cdr_mysql: inserting a CDR record.\n");
+
+ if (userfield && userfielddata) {
+#ifdef MYSQL_LOGUNIQUEID
+ sprintf(sqlcmd, "INSERT INTO %s (calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid,userfield) VALUES ('%s','%s','%s','%s','%s', '%s','%s','%s','%s',%i,%i,'%s',%i,'%s','%s','%s')", dbtable, timestr, clid, cdr->src, cdr->dst, dcontext, channel, dstchannel, lastapp, lastdata, cdr->duration, cdr->billsec, ast_cdr_disp2str(cdr->disposition), cdr->amaflags, cdr->accountcode, uniqueid, userfielddata);
+#else
+ sprintf(sqlcmd, "INSERT INTO %s (calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode,userfield) VALUES ('%s','%s','%s','%s','%s', '%s','%s','%s','%s',%i,%i,'%s',%i,'%s','%s')", dbtable, timestr, clid, cdr->src, cdr->dst, dcontext,channel, dstchannel, lastapp, lastdata, cdr->duration, cdr->billsec, ast_cdr_disp2str(cdr->disposition), cdr->amaflags, cdr->accountcode, userfielddata);
+#endif
+ } else {
+#ifdef MYSQL_LOGUNIQUEID
+ sprintf(sqlcmd, "INSERT INTO %s (calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid) VALUES ('%s','%s','%s','%s','%s', '%s','%s','%s','%s',%i,%i,'%s',%i,'%s','%s')", dbtable, timestr, clid, cdr->src, cdr->dst, dcontext,channel, dstchannel, lastapp, lastdata, cdr->duration, cdr->billsec, ast_cdr_disp2str(cdr->disposition), cdr->amaflags, cdr->accountcode, uniqueid);
+#else
+ sprintf(sqlcmd, "INSERT INTO %s (calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode) VALUES ('%s','%s','%s','%s','%s', '%s','%s','%s','%s',%i,%i,'%s',%i,'%s')", dbtable, timestr, clid, cdr->src, cdr->dst, dcontext, channel, dstchannel, lastapp, lastdata, cdr->duration, cdr->billsec, ast_cdr_disp2str(cdr->disposition), cdr->amaflags, cdr->accountcode);
+#endif
+ }
+
+ ast_log(LOG_DEBUG, "cdr_mysql: SQL command as follows: %s\n", sqlcmd);
+
+ if (connected) {
+ if (mysql_real_query(&mysql, sqlcmd, strlen(sqlcmd))) {
+ ast_log(LOG_ERROR, "mysql_cdr: Failed to insert into database: (%d) %s", mysql_errno(&mysql), mysql_error(&mysql));
+ connected = 0;
+ } else {
+ records++;
+ totalrecords++;
+ }
+ }
+ ast_mutex_unlock(&mysql_lock);
+ return 0;
+}
+
+char *description(void)
+{
+ return desc;
+}
+
+static int my_unload_module(void)
+{
+ ast_cli_unregister(&cdr_mysql_status_cli);
+ if (connected) {
+ mysql_close(&mysql);
+ connected = 0;
+ records = 0;
+ }
+ if (hostname && hostname_alloc) {
+ free(hostname);
+ hostname = NULL;
+ hostname_alloc = 0;
+ }
+ if (dbname && dbname_alloc) {
+ free(dbname);
+ dbname = NULL;
+ dbname_alloc = 0;
+ }
+ if (dbuser && dbuser_alloc) {
+ free(dbuser);
+ dbuser = NULL;
+ dbuser_alloc = 0;
+ }
+ if (dbsock && dbsock_alloc) {
+ free(dbsock);
+ dbsock = NULL;
+ dbsock_alloc = 0;
+ }
+ if (dbtable && dbtable_alloc) {
+ free(dbtable);
+ dbtable = NULL;
+ dbtable_alloc = 0;
+ }
+ if (password && password_alloc) {
+ free(password);
+ password = NULL;
+ password_alloc = 0;
+ }
+ dbport = 0;
+ ast_cdr_unregister(name);
+ return 0;
+}
+
+static int my_load_module(void)
+{
+ int res;
+ struct ast_config *cfg;
+ struct ast_variable *var;
+ char *tmp;
+
+ cfg = ast_config_load(config);
+ if (!cfg) {
+ ast_log(LOG_WARNING, "Unable to load config for mysql CDR's: %s\n", config);
+ return 0;
+ }
+
+ var = ast_variable_browse(cfg, "global");
+ if (!var) {
+ /* nothing configured */
+ return 0;
+ }
+
+ tmp = ast_variable_retrieve(cfg, "global", "hostname");
+ if (tmp) {
+ hostname = malloc(strlen(tmp) + 1);
+ if (hostname != NULL) {
+ hostname_alloc = 1;
+ strcpy(hostname, tmp);
+ } else {
+ ast_log(LOG_ERROR, "Out of memory error.\n");
+ return -1;
+ }
+ } else {
+ ast_log(LOG_WARNING, "MySQL server hostname not specified. Assuming localhost\n");
+ hostname = "localhost";
+ }
+
+ tmp = ast_variable_retrieve(cfg, "global", "dbname");
+ if (tmp) {
+ dbname = malloc(strlen(tmp) + 1);
+ if (dbname != NULL) {
+ dbname_alloc = 1;
+ strcpy(dbname, tmp);
+ } else {
+ ast_log(LOG_ERROR, "Out of memory error.\n");
+ return -1;
+ }
+ } else {
+ ast_log(LOG_WARNING, "MySQL database not specified. Assuming asteriskcdrdb\n");
+ dbname = "asteriskcdrdb";
+ }
+
+ tmp = ast_variable_retrieve(cfg, "global", "user");
+ if (tmp) {
+ dbuser = malloc(strlen(tmp) + 1);
+ if (dbuser != NULL) {
+ dbuser_alloc = 1;
+ strcpy(dbuser, tmp);
+ } else {
+ ast_log(LOG_ERROR, "Out of memory error.\n");
+ return -1;
+ }
+ } else {
+ ast_log(LOG_WARNING, "MySQL database user not specified. Assuming root\n");
+ dbuser = "root";
+ }
+
+ tmp = ast_variable_retrieve(cfg, "global", "sock");
+ if (tmp) {
+ dbsock = malloc(strlen(tmp) + 1);
+ if (dbsock != NULL) {
+ dbsock_alloc = 1;
+ strcpy(dbsock, tmp);
+ } else {
+ ast_log(LOG_ERROR, "Out of memory error.\n");
+ return -1;
+ }
+ } else {
+ ast_log(LOG_WARNING, "MySQL database sock file not specified. Using default\n");
+ dbsock = NULL;
+ }
+
+ tmp = ast_variable_retrieve(cfg, "global", "table");
+ if (tmp) {
+ dbtable = malloc(strlen(tmp) + 1);
+ if (dbtable != NULL) {
+ dbtable_alloc = 1;
+ strcpy(dbtable, tmp);
+ } else {
+ ast_log(LOG_ERROR, "Out of memory error.\n");
+ return -1;
+ }
+ } else {
+ ast_log(LOG_NOTICE, "MySQL database table not specified. Assuming \"cdr\"\n");
+ dbtable = "cdr";
+ }
+
+ tmp = ast_variable_retrieve(cfg, "global", "password");
+ if (tmp) {
+ password = malloc(strlen(tmp) + 1);
+ if (password != NULL) {
+ password_alloc = 1;
+ strcpy(password, tmp);
+ } else {
+ ast_log(LOG_ERROR, "Out of memory error.\n");
+ return -1;
+ }
+ } else {
+ ast_log(LOG_WARNING, "MySQL database password not specified. Assuming blank\n");
+ password = "";
+ }
+
+ tmp = ast_variable_retrieve(cfg, "global", "port");
+ if (tmp) {
+ if (sscanf(tmp, "%d", &dbport) < 1) {
+ ast_log(LOG_WARNING, "Invalid MySQL port number. Using default\n");
+ dbport = 0;
+ }
+ }
+
+ tmp = ast_variable_retrieve(cfg, "global", "timeout");
+ if (tmp) {
+ if (sscanf(tmp,"%d", &timeout) < 1) {
+ ast_log(LOG_WARNING, "Invalid MySQL timeout number. Using default\n");
+ timeout = 0;
+ }
+ }
+
+ tmp = ast_variable_retrieve(cfg, "global", "userfield");
+ if (tmp) {
+ if (sscanf(tmp, "%d", &userfield) < 1) {
+ ast_log(LOG_WARNING, "Invalid MySQL configurtation file\n");
+ userfield = 0;
+ }
+ }
+
+ ast_config_destroy(cfg);
+
+ ast_log(LOG_DEBUG, "cdr_mysql: got hostname of %s\n", hostname);
+ ast_log(LOG_DEBUG, "cdr_mysql: got port of %d\n", dbport);
+ ast_log(LOG_DEBUG, "cdr_mysql: got a timeout of %d\n", timeout);
+ if (dbsock)
+ ast_log(LOG_DEBUG, "cdr_mysql: got sock file of %s\n", dbsock);
+ ast_log(LOG_DEBUG, "cdr_mysql: got user of %s\n", dbuser);
+ ast_log(LOG_DEBUG, "cdr_mysql: got dbname of %s\n", dbname);
+ ast_log(LOG_DEBUG, "cdr_mysql: got password of %s\n", password);
+
+ mysql_init(&mysql);
+
+ if (timeout && mysql_options(&mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *)&timeout)!=0) {
+ ast_log(LOG_ERROR, "cdr_mysql: mysql_options returned (%d) %s\n", mysql_errno(&mysql), mysql_error(&mysql));
+ }
+
+ if (!mysql_real_connect(&mysql, hostname, dbuser, password, dbname, dbport, dbsock, 0)) {
+ ast_log(LOG_ERROR, "Failed to connect to mysql database %s on %s.\n", dbname, hostname);
+ connected = 0;
+ records = 0;
+ } else {
+ ast_log(LOG_DEBUG, "Successfully connected to MySQL database.\n");
+ connected = 1;
+ records = 0;
+ connect_time = time(NULL);
+ }
+
+ res = ast_cdr_register(name, desc, mysql_log);
+ if (res) {
+ ast_log(LOG_ERROR, "Unable to register MySQL CDR handling\n");
+ } else {
+ res = ast_cli_register(&cdr_mysql_status_cli);
+ }
+
+ return res;
+}
+
+int load_module(void)
+{
+ return my_load_module();
+}
+
+int unload_module(void)
+{
+ return my_unload_module();
+}
+
+int reload(void)
+{
+ int ret;
+
+ ast_mutex_lock(&mysql_lock);
+ my_unload_module();
+ ret = my_load_module();
+ ast_mutex_unlock(&mysql_lock);
+
+ return ret;
+}
+
+int usecount(void)
+{
+ /* Simplistic use count */
+ if (ast_mutex_trylock(&mysql_lock)) {
+ return 1;
+ } else {
+ ast_mutex_unlock(&mysql_lock);
+ return 0;
+ }
+}
+
+char *key()
+{
+ return ASTERISK_GPL_KEY;
+}
diff -Nru asterisk-1.2.14.org/configs/cdr_mysql.conf.sample asterisk-1.2.14/configs/cdr_mysql.conf.sample
--- asterisk-1.2.14.org/configs/cdr_mysql.conf.sample 1970-01-01 01:00:00.000000000 +0100
+++ asterisk-1.2.14/configs/cdr_mysql.conf.sample 2006-12-27 09:02:18.000000000 +0100
@@ -0,0 +1,21 @@
+;
+; Note - if the database server is hosted on the same machine as the
+; asterisk server, you can achieve a local Unix socket connection by
+; setting hostname=localhost
+;
+; port and sock are both optional parameters. If hostname is specified
+; and is not "localhost", then cdr_mysql will attempt to connect to the
+; port specified or use the default port. If hostname is not specified
+; or if hostname is "localhost", then cdr_mysql will attempt to connect
+; to the socket file specified by sock or otherwise use the default socket
+; file.
+;
+;[global]
+;hostname=database.host.name
+;dbname=asteriskcdrdb
+;table=cdr
+;password=password
+;user=asteriskcdruser
+;port=3306
+;sock=/tmp/mysql.sock
+;userfield=1

View File

@ -1,13 +0,0 @@
diff -Nru asterisk-1.2.14.org/include/asterisk/compat.h asterisk-1.2.14/include/asterisk/compat.h
--- asterisk-1.2.14.org/include/asterisk/compat.h 2005-11-29 19:24:39.000000000 +0100
+++ asterisk-1.2.14/include/asterisk/compat.h 2006-12-27 09:07:28.000000000 +0100
@@ -75,7 +75,9 @@
#define HAVE_STRTOQ
#ifdef _BSD_SOURCE
+#ifndef __UCLIBC__
#define HAVE_GETLOADAVG
+#endif /* __UCLIBC__ */
#endif
#ifdef __linux__

View File

@ -1,42 +0,0 @@
diff -Nru asterisk-1.2.14.org/apps/Makefile asterisk-1.2.14/apps/Makefile
--- asterisk-1.2.14.org/apps/Makefile 2006-04-30 15:38:22.000000000 +0200
+++ asterisk-1.2.14/apps/Makefile 2006-12-27 09:08:57.000000000 +0100
@@ -45,7 +45,7 @@
#APPS+=app_rpt.so
ifndef WITHOUT_ZAPTEL
-ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/linux/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/zaptel.h),)
+ifneq ($(wildcard $(STAGING_DIR)/usr/include/linux/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/zaptel.h),)
APPS+=app_zapras.so app_meetme.so app_flash.so app_zapbarge.so app_zapscan.so app_page.so
endif
endif # WITHOUT_ZAPTEL
@@ -83,6 +83,9 @@
#CFLAGS+=-DEXTENDED_ODBC_STORAGE
# See doc/README.odbcstorage for more information
+CFLAGS += $(EXTRA_CFLAGS)
+APPS += $(EXTRA_APP_MODULES)
+
all: $(APPS)
clean:
@@ -102,14 +105,17 @@
app_curl.so: app_curl.o
$(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(CURLLIBS)
+app_sql_mysql.so: app_sql_mysql.o
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(EXTRA_LDFLAGS) -lmysqlclient
+
app_sql_postgres.o: app_sql_postgres.c
$(CC) -pipe -I$(CROSS_COMPILE_TARGET)/usr/local/pgsql/include -I$(CROSS_COMPILE_TARGET)/usr/include/postgresql $(CFLAGS) -c -o app_sql_postgres.o app_sql_postgres.c
app_sql_postgres.so: app_sql_postgres.o
- $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -L/usr/local/pgsql/lib -lpq
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(EXTRA_LDFLAGS) -lpq
app_sql_odbc.so: app_sql_odbc.o
- $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lodbc
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(EXTRA_LDFLAGS) -lodbc
ifeq (SunOS,$(shell uname))
app_chanspy.so: app_chanspy.o

View File

@ -1,37 +0,0 @@
diff -Nru asterisk-1.2.14.org/cdr/Makefile asterisk-1.2.14/cdr/Makefile
--- asterisk-1.2.14.org/cdr/Makefile 2006-11-16 21:29:28.000000000 +0100
+++ asterisk-1.2.14/cdr/Makefile 2006-12-27 09:10:57.000000000 +0100
@@ -111,6 +111,9 @@
MODS+=cdr_sqlite.so
endif
+CFLAGS += $(EXTRA_CFLAGS)
+MODS += $(EXTRA_CDR_MODULES)
+
all: depend $(MODS)
install: all
@@ -127,16 +130,19 @@
endif
cdr_odbc.so: cdr_odbc.o
- $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lodbc $(MLFLAGS)
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(EXTRA_LDFLAGS) -lodbc $(MLFLAGS)
cdr_tds.so: cdr_tds.o
- $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -ltds $(MLFLAGS)
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(EXTRA_LDFLAGS) -ltds $(MLFLAGS)
+
+cdr_mysql.so: cdr_mysql.o
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(EXTRA_LDFLAGS) -lmysqlclient -lz $(MLFLAGS)
cdr_pgsql.so: cdr_pgsql.o
- $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lpq -lz $(MLFLAGS)
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(EXTRA_LDFLAGS) -lpq -lz $(MLFLAGS)
cdr_sqlite.so: cdr_sqlite.o
- $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lsqlite $(MLFLAGS)
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(EXTRA_LDFLAGS) -lsqlite $(MLFLAGS)
depend: .depend

View File

@ -1,40 +0,0 @@
diff -Nru asterisk-1.2.14.org/channels/Makefile asterisk-1.2.14/channels/Makefile
--- asterisk-1.2.14.org/channels/Makefile 2006-08-17 23:57:19.000000000 +0200
+++ asterisk-1.2.14/channels/Makefile 2006-12-27 09:12:28.000000000 +0100
@@ -110,7 +110,7 @@
endif
ifndef WITHOUT_ZAPTEL
-ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/linux/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/pkg/include/zaptel.h),)
+ifneq ($(wildcard $(STAGING_DIR)/usr/include/linux/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/pkg/include/zaptel.h),)
ifeq (${OSARCH},NetBSD)
SOLINK+=-L$(CROSS_COMPILE_TARGET)/usr/pkg/lib
endif
@@ -151,6 +151,9 @@
#CFLAGS+=$(shell [ -f $(ZAPDIR)/libzap.a ] && echo "-I$(ZAPDIR)")
+CFLAGS += $(EXTRA_CFLAGS)
+CHANNEL_LIBS += $(EXTRA_CHAN_MODULES)
+
all: depend $(CHANNEL_LIBS)
clean:
@@ -158,7 +161,7 @@
rm -f busy.h ringtone.h gentone gentone-ulaw
%.so : %.o
- $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} ${LIBS}
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB}
ifneq ($(wildcard .depend),)
include .depend
@@ -204,7 +207,7 @@
$(CC) -c $(CFLAGS) -o chan_zap.o chan_zap.c
chan_zap.so: chan_zap.o
- $(CC) $(SOLINK) -o $@ $< $(ZAPPRI) $(ZAPR2) -ltonezone
+ $(CC) $(SOLINK) -o $@ $< $(ZAPPRI) $(ZAPR2) $(EXTRA_LDFLAGS) -ltonezone
chan_sip.so: chan_sip.o
$(CC) $(SOLINK) -o $@ ${CYGSOLINK} chan_sip.o ${CYGSOLIB}

View File

@ -1,48 +0,0 @@
--- asterisk-1.2.14/codecs/gsm/Makefile.orig 2007-02-21 23:03:07.000000000 +0100
+++ asterisk-1.2.14/codecs/gsm/Makefile 2007-02-21 23:03:40.000000000 +0100
@@ -241,6 +241,10 @@
ifneq ($(shell uname -m),armv4l)
ifneq ($(shell uname -m),sparc64)
ifneq (${PROC},arm)
+ifneq (${PROC},armeb)
+ifneq (${PROC},mipsel)
+ifneq (${PROC},mips)
+ifneq (${PROC},powerpc)
ifneq ($(shell uname -m), parisc)
ifneq ($(shell uname -m),s390)
GSM_SOURCES+= $(SRC)/k6opt.s
@@ -255,6 +258,10 @@
endif
endif
endif
+endif
+endif
+endif
+endif
TOAST_SOURCES = $(SRC)/toast.c \
$(SRC)/toast_lin.c \
@@ -308,6 +314,11 @@
ifneq ($(shell uname -m), alpha)
ifneq ($(shell uname -m), sparc64)
ifneq ($(shell uname -m), armv4l)
+ifneq (${PROC}, arm)
+ifneq (${PROC}, armeb)
+ifneq (${PROC}, mipsel)
+ifneq (${PROC}, mips)
+ifneq (${PROC}, powerpc)
ifneq ($(shell uname -m), parisc)
ifneq ($(shell uname -m),s390)
GSM_OBJECTS+= $(SRC)/k6opt.o
@@ -321,6 +331,11 @@
endif
endif
endif
+endif
+endif
+endif
+endif
+endif
TOAST_OBJECTS = $(SRC)/toast.o \
$(SRC)/toast_lin.o \

View File

@ -1,13 +0,0 @@
diff -Nru asterisk-1.2.14.org/codecs/Makefile asterisk-1.2.14/codecs/Makefile
--- asterisk-1.2.14.org/codecs/Makefile 2005-11-29 19:24:39.000000000 +0100
+++ asterisk-1.2.14/codecs/Makefile 2006-12-27 09:15:57.000000000 +0100
@@ -72,6 +72,9 @@
codec_adpcm.so codec_ulaw.so codec_alaw.so codec_a_mu.so \
codec_g726.so
+CFLAGS += $(EXTRA_CFLAGS)
+CODECS += $(EXTRA_CODEC_MODULES)
+
all: depend $(CODECS)
clean:

View File

@ -1,53 +0,0 @@
diff -Nru asterisk-1.2.14.org/Makefile asterisk-1.2.14/Makefile
--- asterisk-1.2.14.org/Makefile 2006-12-11 22:55:43.000000000 +0100
+++ asterisk-1.2.14/Makefile 2006-12-27 09:16:50.000000000 +0100
@@ -356,16 +356,6 @@
netsock.o slinfactory.o ast_expr2.o ast_expr2f.o \
cryptostub.o
-ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/sys/poll.h),)
- OBJS+= poll.o
- ASTCFLAGS+=-DPOLLCOMPAT
-endif
-
-ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/dlfcn.h),)
- OBJS+= dlfcn.o
- ASTCFLAGS+=-DDLFCNCOMPAT
-endif
-
ifeq ($(OSARCH),Linux)
LIBS+=-ldl -lpthread -lncurses -lm -lresolv #-lnjamd
else
@@ -420,8 +410,6 @@
HAVEDOT=no
endif
-LIBS+=-lssl
-
_all: all
@echo " +--------- Asterisk Build Complete ---------+"
@echo " + Asterisk has successfully been built, but +"
@@ -447,12 +435,12 @@
cd editline && unset CFLAGS LIBS && CFLAGS="$(OPTIMIZE)" ./configure ; \
editline/libedit.a: FORCE
- cd editline && unset CFLAGS LIBS && test -f config.h || CFLAGS="$(OPTIMIZE)" ./configure
+ cd editline && unset CFLAGS LIBS && test -f config.h || CFLAGS="$(OPTIMIZE) $(EXTRA_CFLAGS)" LDFLAGS="$(EXTRA_LDFLAGS)" ./configure
$(MAKE) -C editline libedit.a
db1-ast/libdb1.a: FORCE
@if [ -d db1-ast ]; then \
- $(MAKE) -C db1-ast libdb1.a ; \
+ $(MAKE) OORG="$(OPTIMIZE)" -C db1-ast libdb1.a ; \
else \
echo "You need to do a cvs update -d not just cvs update"; \
exit 1; \
@@ -530,7 +518,7 @@
fi
rm -f include/asterisk/build.h.tmp
$(CC) -c -o buildinfo.o $(CFLAGS) buildinfo.c
- $(CC) $(DEBUG) $(ASTOBJ) $(ASTLINK) $(OBJS) buildinfo.o $(LIBEDIT) db1-ast/libdb1.a stdtime/libtime.a $(LIBS)
+ $(CC) $(DEBUG) $(ASTOBJ) $(ASTLINK) $(OBJS) buildinfo.o $(LIBEDIT) db1-ast/libdb1.a stdtime/libtime.a $(EXTRA_LDFLAGS) $(LIBS)
muted: muted.o
$(CC) $(AUDIO_LIBS) -o muted muted.o

View File

@ -1,22 +0,0 @@
diff -Nru asterisk-1.2.14.org/pbx/Makefile asterisk-1.2.14/pbx/Makefile
--- asterisk-1.2.14.org/pbx/Makefile 2005-11-29 19:24:39.000000000 +0100
+++ asterisk-1.2.14/pbx/Makefile 2006-12-27 09:17:58.000000000 +0100
@@ -38,6 +38,9 @@
KDE_CONSOLE_OBJS=pbx_kdeconsole_main.o pbx_kdeconsole.o
+CFLAGS += $(EXTRA_CFLAGS)
+PBX_LIBS += $(EXTRA_PBX_MODULES)
+
all: depend $(PBX_LIBS)
clean:
@@ -59,7 +62,7 @@
$(CC) $(SOLINK) -o $@ $(KDE_CONSOLE_OBJS) $(KDE_LIBS)
pbx_dundi.so: dundi-parser.o pbx_dundi.o
- $(CC) $(SOLINK) -o $@ ${CYGSOLINK} pbx_dundi.o dundi-parser.o -lz ${CYGSOLIB}
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} pbx_dundi.o dundi-parser.o $(EXTRA_LDFLAGS) -lz ${CYGSOLIB}
%.moc : %.h
$(MOC) $< -o $@

View File

@ -1,44 +0,0 @@
diff -Nru asterisk-1.2.14.org/res/Makefile asterisk-1.2.14/res/Makefile
--- asterisk-1.2.14.org/res/Makefile 2005-11-29 19:24:39.000000000 +0100
+++ asterisk-1.2.14/res/Makefile 2006-12-27 09:18:45.000000000 +0100
@@ -55,7 +55,7 @@
CFLAGS+=
ifndef WITHOUT_ZAPTEL
-ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/linux/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/zaptel.h),)
+ifneq ($(wildcard $(STAGING_DIR)/usr/include/linux/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/zaptel.h),)
CFLAGS+=-DZAPATA_MOH
endif
endif # WITHOUT_ZAPTEL
@@ -69,6 +69,9 @@
CFLAGS+=-DOPENSSL_NO_KRB5 -fPIC
endif
+CFLAGS += $(EXTRA_CFLAGS)
+MODS += $(EXTRA_RES_MODULES)
+
all: depend $(MODS)
install: all
@@ -89,7 +92,7 @@
fi
res_crypto.so: res_crypto.o
- $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(CRYPTO_LIBS)
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(EXTRA_LDFLAGS) $(CRYPTO_LIBS)
clean:
rm -f *.so *.o .depend
@@ -109,6 +112,12 @@
res_config_odbc.so: res_config_odbc.o
$(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} ${CYG_RES_CONFIG_ODBC_LIB}
+res_config_mysql.so: res_config_mysql.o
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(EXTRA_LDFLAGS) -lmysqlclient -lz
+
+res_sqlite.so: res_sqlite.o
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(EXTRA_LDFLAGS) -lsqlite
+
ifneq ($(wildcard .depend),)
include .depend
endif

View File

@ -1,698 +0,0 @@
diff -Nru asterisk-1.2.14.org/configs/res_mysql.conf.sample asterisk-1.2.14/configs/res_mysql.conf.sample
--- asterisk-1.2.14.org/configs/res_mysql.conf.sample 1970-01-01 01:00:00.000000000 +0100
+++ asterisk-1.2.14/configs/res_mysql.conf.sample 2006-12-27 09:19:45.000000000 +0100
@@ -0,0 +1,15 @@
+;
+; Sample configuration for res_config_mysql.c
+;
+; The value of dbhost may be either a hostname or an IP address.
+; If dbhost is commented out or the string "localhost", a connection
+; to the local host is assumed and dbsock is used instead of TCP/IP
+; to connect to the server.
+;
+[general]
+;dbhost = 127.0.0.1
+;dbname = asterisk
+;dbuser = myuser
+;dbpass = mypass
+;dbport = 3306
+;dbsock = /tmp/mysql.sock
diff -Nru asterisk-1.2.14.org/res/res_config_mysql.c asterisk-1.2.14/res/res_config_mysql.c
--- asterisk-1.2.14.org/res/res_config_mysql.c 1970-01-01 01:00:00.000000000 +0100
+++ asterisk-1.2.14/res/res_config_mysql.c 2006-12-27 09:19:45.000000000 +0100
@@ -0,0 +1,675 @@
+/*
+ * Asterisk -- A telephony toolkit for Linux.
+ *
+ * Copyright (C) 1999-2005, Digium, Inc.
+ *
+ * Mark Spencer <markster@digium.com> - Asterisk Author
+ * Matthew Boehm <mboehm@cytelcom.com> - MySQL RealTime Driver Author
+ *
+ * res_config_mysql.c <mysql plugin for RealTime configuration engine>
+ *
+ * v2.0 - (10-07-05) - mutex_lock fixes (bug #4973, comment #0034602)
+ *
+ * v1.9 - (08-19-05) - Added support to correctly honor the family database specified
+ * in extconfig.conf (bug #4973)
+ *
+ * v1.8 - (04-21-05) - Modified return values of update_mysql to better indicate
+ * what really happened.
+ *
+ * v1.7 - (01-28-05) - Fixed non-initialization of ast_category struct
+ * in realtime_multi_mysql function which caused segfault.
+ *
+ * v1.6 - (00-00-00) - Skipped to bring comments into sync with version number in CVS.
+ *
+ * v1.5.1 - (01-26-05) - Added better(?) locking stuff
+ *
+ * v1.5 - (01-26-05) - Brought up to date with new config.h changes (bug #3406)
+ * - Added in extra locking provided by georg (bug #3248)
+ *
+ * v1.4 - (12-02-04) - Added realtime_multi_mysql function
+ * This function will return an ast_config with categories,
+ * unlike standard realtime_mysql which only returns
+ * a linked list of ast_variables
+ *
+ * v1.3 - (12-01-04) - Added support other operators
+ * Ex: =, !=, LIKE, NOT LIKE, RLIKE, etc...
+ *
+ * v1.2 - (11-DD-04) - Added reload. Updated load and unload.
+ * Code beautification (doc/CODING-GUIDELINES)
+ */
+
+#include <asterisk/channel.h>
+#include <asterisk/logger.h>
+#include <asterisk/config.h>
+#include <asterisk/module.h>
+#include <asterisk/lock.h>
+#include <asterisk/options.h>
+#include <asterisk/cli.h>
+#include <asterisk/utils.h>
+#include <stdlib.h>
+#include <string.h>
+#include <mysql.h>
+#include <mysql_version.h>
+#include <errmsg.h>
+
+static char *res_config_mysql_desc = "MySQL RealTime Configuration Driver";
+
+AST_MUTEX_DEFINE_STATIC(mysql_lock);
+#define RES_CONFIG_MYSQL_CONF "res_mysql.conf"
+MYSQL mysql;
+static char dbhost[50];
+static char dbuser[50];
+static char dbpass[50];
+static char dbname[50];
+static char dbsock[50];
+static int dbport;
+static int connected;
+static time_t connect_time;
+
+static int parse_config(void);
+static int mysql_reconnect(const char *database);
+static int realtime_mysql_status(int fd, int argc, char **argv);
+
+STANDARD_LOCAL_USER;
+
+LOCAL_USER_DECL;
+
+static char cli_realtime_mysql_status_usage[] =
+"Usage: realtime mysql status\n"
+" Shows connection information for the MySQL RealTime driver\n";
+
+static struct ast_cli_entry cli_realtime_mysql_status = {
+ { "realtime", "mysql", "status", NULL }, realtime_mysql_status,
+ "Shows connection information for the MySQL RealTime driver", cli_realtime_mysql_status_usage, NULL };
+
+static struct ast_variable *realtime_mysql(const char *database, const char *table, va_list ap)
+{
+ MYSQL_RES *result;
+ MYSQL_ROW row;
+ MYSQL_FIELD *fields;
+ int numFields, i;
+ char sql[256];
+ char *stringp;
+ char *chunk;
+ char *op;
+ const char *newparam, *newval;
+ struct ast_variable *var=NULL, *prev=NULL;
+
+ if(!table) {
+ ast_log(LOG_WARNING, "MySQL RealTime: No table specified.\n");
+ return NULL;
+ }
+
+ /* Get the first parameter and first value in our list of passed paramater/value pairs */
+ newparam = va_arg(ap, const char *);
+ newval = va_arg(ap, const char *);
+ if(!newparam || !newval) {
+ ast_log(LOG_WARNING, "MySQL RealTime: Realtime retrieval requires at least 1 parameter and 1 value to search on.\n");
+ mysql_close(&mysql);
+ return NULL;
+ }
+
+ /* Create the first part of the query using the first parameter/value pairs we just extracted
+ If there is only 1 set, then we have our query. Otherwise, loop thru the list and concat */
+
+ if(!strchr(newparam, ' ')) op = " ="; else op = "";
+
+ snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE %s%s '%s'", table, newparam, op, newval);
+ while((newparam = va_arg(ap, const char *))) {
+ newval = va_arg(ap, const char *);
+ if(!strchr(newparam, ' ')) op = " ="; else op = "";
+ snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " AND %s%s '%s'", newparam, op, newval);
+ }
+ va_end(ap);
+
+ ast_log(LOG_DEBUG, "MySQL RealTime: Retrieve SQL: %s\n", sql);
+
+ /* We now have our complete statement; Lets connect to the server and execute it. */
+ ast_mutex_lock(&mysql_lock);
+ if(!mysql_reconnect(database)) {
+ ast_mutex_unlock(&mysql_lock);
+ return NULL;
+ }
+
+ if(mysql_real_query(&mysql, sql, strlen(sql))) {
+ ast_log(LOG_WARNING, "MySQL RealTime: Failed to query database. Check debug for more info.\n");
+ ast_log(LOG_DEBUG, "MySQL RealTime: Query: %s\n", sql);
+ ast_log(LOG_DEBUG, "MySQL RealTime: Query Failed because: %s\n", mysql_error(&mysql));
+ ast_mutex_unlock(&mysql_lock);
+ return NULL;
+ }
+
+ if((result = mysql_store_result(&mysql))) {
+ numFields = mysql_num_fields(result);
+ fields = mysql_fetch_fields(result);
+
+ while((row = mysql_fetch_row(result))) {
+ for(i = 0; i < numFields; i++) {
+ stringp = row[i];
+ while(stringp) {
+ chunk = strsep(&stringp, ";");
+ if(chunk && !ast_strlen_zero(ast_strip(chunk))) {
+ if(prev) {
+ prev->next = ast_variable_new(fields[i].name, chunk);
+ if (prev->next) {
+ prev = prev->next;
+ }
+ } else {
+ prev = var = ast_variable_new(fields[i].name, chunk);
+ }
+ }
+ }
+ }
+ }
+ } else {
+ ast_log(LOG_WARNING, "MySQL RealTime: Could not find any rows in table %s.\n", table);
+ }
+
+ ast_mutex_unlock(&mysql_lock);
+ mysql_free_result(result);
+
+ return var;
+}
+
+static struct ast_config *realtime_multi_mysql(const char *database, const char *table, va_list ap)
+{
+ MYSQL_RES *result;
+ MYSQL_ROW row;
+ MYSQL_FIELD *fields;
+ int numFields, i;
+ char sql[256];
+ const char *initfield = NULL;
+ char *stringp;
+ char *chunk;
+ char *op;
+ const char *newparam, *newval;
+ struct ast_realloca ra;
+ struct ast_variable *var=NULL;
+ struct ast_config *cfg = NULL;
+ struct ast_category *cat = NULL;
+
+ if(!table) {
+ ast_log(LOG_WARNING, "MySQL RealTime: No table specified.\n");
+ return NULL;
+ }
+
+ memset(&ra, 0, sizeof(ra));
+
+ cfg = ast_config_new();
+ if (!cfg) {
+ /* If I can't alloc memory at this point, why bother doing anything else? */
+ ast_log(LOG_WARNING, "Out of memory!\n");
+ return NULL;
+ }
+
+ /* Get the first parameter and first value in our list of passed paramater/value pairs */
+ newparam = va_arg(ap, const char *);
+ newval = va_arg(ap, const char *);
+ if(!newparam || !newval) {
+ ast_log(LOG_WARNING, "MySQL RealTime: Realtime retrieval requires at least 1 parameter and 1 value to search on.\n");
+ mysql_close(&mysql);
+ return NULL;
+ }
+
+ initfield = ast_strdupa(newparam);
+ if(initfield && (op = strchr(initfield, ' '))) {
+ *op = '\0';
+ }
+
+ /* Create the first part of the query using the first parameter/value pairs we just extracted
+ If there is only 1 set, then we have our query. Otherwise, loop thru the list and concat */
+
+ if(!strchr(newparam, ' ')) op = " ="; else op = "";
+
+ snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE %s%s '%s'", table, newparam, op, newval);
+ while((newparam = va_arg(ap, const char *))) {
+ newval = va_arg(ap, const char *);
+ if(!strchr(newparam, ' ')) op = " ="; else op = "";
+ snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " AND %s%s '%s'", newparam, op, newval);
+ }
+
+ if(initfield) {
+ snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " ORDER BY %s", initfield);
+ }
+
+ va_end(ap);
+
+ ast_log(LOG_DEBUG, "MySQL RealTime: Retrieve SQL: %s\n", sql);
+
+ /* We now have our complete statement; Lets connect to the server and execute it. */
+ ast_mutex_lock(&mysql_lock);
+ if(!mysql_reconnect(database)) {
+ ast_mutex_unlock(&mysql_lock);
+ return NULL;
+ }
+
+ if(mysql_real_query(&mysql, sql, strlen(sql))) {
+ ast_log(LOG_WARNING, "MySQL RealTime: Failed to query database. Check debug for more info.\n");
+ ast_log(LOG_DEBUG, "MySQL RealTime: Query: %s\n", sql);
+ ast_log(LOG_DEBUG, "MySQL RealTime: Query Failed because: %s\n", mysql_error(&mysql));
+ ast_mutex_unlock(&mysql_lock);
+ return NULL;
+ }
+
+ if((result = mysql_store_result(&mysql))) {
+ numFields = mysql_num_fields(result);
+ fields = mysql_fetch_fields(result);
+
+ while((row = mysql_fetch_row(result))) {
+ var = NULL;
+ cat = ast_category_new("");
+ if(!cat) {
+ ast_log(LOG_WARNING, "Out of memory!\n");
+ continue;
+ }
+ for(i = 0; i < numFields; i++) {
+ stringp = row[i];
+ while(stringp) {
+ chunk = strsep(&stringp, ";");
+ if(chunk && !ast_strlen_zero(ast_strip(chunk))) {
+ if(initfield && !strcmp(initfield, fields[i].name)) {
+ ast_category_rename(cat, chunk);
+ }
+ var = ast_variable_new(fields[i].name, chunk);
+ ast_variable_append(cat, var);
+ }
+ }
+ }
+ ast_category_append(cfg, cat);
+ }
+ } else {
+ ast_log(LOG_WARNING, "MySQL RealTime: Could not find any rows in table %s.\n", table);
+ }
+
+ ast_mutex_unlock(&mysql_lock);
+ mysql_free_result(result);
+
+ return cfg;
+}
+
+static int update_mysql(const char *database, const char *table, const char *keyfield, const char *lookup, va_list ap)
+{
+ my_ulonglong numrows;
+ char sql[256];
+ const char *newparam, *newval;
+
+ if(!table) {
+ ast_log(LOG_WARNING, "MySQL RealTime: No table specified.\n");
+ return -1;
+ }
+
+ /* Get the first parameter and first value in our list of passed paramater/value pairs */
+ newparam = va_arg(ap, const char *);
+ newval = va_arg(ap, const char *);
+ if(!newparam || !newval) {
+ ast_log(LOG_WARNING, "MySQL RealTime: Realtime retrieval requires at least 1 parameter and 1 value to search on.\n");
+ mysql_close(&mysql);
+ return -1;
+ }
+
+ /* Create the first part of the query using the first parameter/value pairs we just extracted
+ If there is only 1 set, then we have our query. Otherwise, loop thru the list and concat */
+
+ snprintf(sql, sizeof(sql), "UPDATE %s SET %s = '%s'", table, newparam, newval);
+ while((newparam = va_arg(ap, const char *))) {
+ newval = va_arg(ap, const char *);
+ snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), ", %s = '%s'", newparam, newval);
+ }
+ va_end(ap);
+ snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " WHERE %s = '%s'", keyfield, lookup);
+
+ ast_log(LOG_DEBUG,"MySQL RealTime: Update SQL: %s\n", sql);
+
+ /* We now have our complete statement; Lets connect to the server and execute it. */
+ ast_mutex_lock(&mysql_lock);
+ if(!mysql_reconnect(database)) {
+ ast_mutex_unlock(&mysql_lock);
+ return -1;
+ }
+
+ if(mysql_real_query(&mysql, sql, strlen(sql))) {
+ ast_log(LOG_WARNING, "MySQL RealTime: Failed to query database. Check debug for more info.\n");
+ ast_log(LOG_DEBUG, "MySQL RealTime: Query: %s\n", sql);
+ ast_log(LOG_DEBUG, "MySQL RealTime: Query Failed because: %s\n", mysql_error(&mysql));
+ ast_mutex_unlock(&mysql_lock);
+ return -1;
+ }
+
+ numrows = mysql_affected_rows(&mysql);
+ ast_mutex_unlock(&mysql_lock);
+
+ ast_log(LOG_DEBUG,"MySQL RealTime: Updated %llu rows on table: %s\n", numrows, table);
+
+ /* From http://dev.mysql.com/doc/mysql/en/mysql-affected-rows.html
+ * An integer greater than zero indicates the number of rows affected
+ * Zero indicates that no records were updated
+ * -1 indicates that the query returned an error (although, if the query failed, it should have been caught above.)
+ */
+
+ if(numrows >= 0)
+ return (int)numrows;
+
+ return -1;
+}
+
+static struct ast_config *config_mysql(const char *database, const char *table, const char *file, struct ast_config *cfg)
+{
+ MYSQL_RES *result;
+ MYSQL_ROW row;
+ my_ulonglong num_rows;
+ struct ast_config *new;
+ struct ast_variable *cur_v, *new_v;
+ struct ast_category *cur_cat, *new_cat;
+ char sql[250] = "";
+ char last[80] = "";
+ int cat_started = 0;
+ int var_started = 0;
+ int last_cat_metric = 0;
+
+ last[0] = '\0';
+
+ if(!file || !strcmp(file, RES_CONFIG_MYSQL_CONF)) {
+ ast_log(LOG_WARNING, "MySQL RealTime: Cannot configure myself.\n");
+ return NULL;
+ }
+
+ snprintf(sql, sizeof(sql), "SELECT category, var_name, var_val, cat_metric FROM %s WHERE filename='%s' and commented=0 ORDER BY filename, cat_metric desc, var_metric asc, category, var_name, var_val, id", table, file);
+
+ ast_log(LOG_DEBUG, "MySQL RealTime: Static SQL: %s\n", sql);
+
+ /* We now have our complete statement; Lets connect to the server and execute it. */
+ ast_mutex_lock(&mysql_lock);
+ if(!mysql_reconnect(database)) {
+ ast_mutex_unlock(&mysql_lock);
+ return NULL;
+ }
+
+ if(mysql_real_query(&mysql, sql, strlen(sql))) {
+ ast_log(LOG_WARNING, "MySQL RealTime: Failed to query database. Check debug for more info.\n");
+ ast_log(LOG_DEBUG, "MySQL RealTime: Query: %s\n", sql);
+ ast_log(LOG_DEBUG, "MySQL RealTime: Query Failed because: %s\n", mysql_error(&mysql));
+ ast_mutex_unlock(&mysql_lock);
+ return NULL;
+ }
+
+ if((result = mysql_store_result(&mysql))) {
+ num_rows = mysql_num_rows(result);
+ ast_log(LOG_DEBUG, "MySQL RealTime: Found %llu rows.\n", num_rows);
+
+ /* There might exist a better way to access the column names other than counting,
+ but I believe that would require another loop that we don't need. */
+
+ while((row = mysql_fetch_row(result))) {
+ if(!strcmp(row[1], "#include")) {
+ if (!ast_config_internal_load(row[2], cfg)) {
+ mysql_free_result(result);
+ ast_mutex_unlock(&mysql_lock);
+ return NULL;
+ }
+ continue;
+ }
+
+ if(strcmp(last, row[0]) || last_cat_metric != atoi(row[3])) {
+ cur_cat = ast_category_new(row[0]);
+ if (!cur_cat) {
+ ast_log(LOG_WARNING, "Out of memory!\n");
+ break;
+ }
+ strcpy(last, row[0]);
+ last_cat_metric = atoi(row[3]);
+ ast_category_append(cfg, cur_cat);
+ }
+ new_v = ast_variable_new(row[1], row[2]);
+ ast_variable_append(cur_cat, new_v);
+ }
+ } else {
+ ast_log(LOG_WARNING, "MySQL RealTime: Could not find config '%s' in database.\n", file);
+ }
+
+ mysql_free_result(result);
+ ast_mutex_unlock(&mysql_lock);
+
+ return cfg;
+}
+
+static struct ast_config_engine mysql_engine = {
+ .name = "mysql",
+ .load_func = config_mysql,
+ .realtime_func = realtime_mysql,
+ .realtime_multi_func = realtime_multi_mysql,
+ .update_func = update_mysql
+};
+
+int load_module (void)
+{
+ parse_config();
+
+ ast_mutex_lock(&mysql_lock);
+
+ if(!mysql_reconnect(NULL)) {
+ ast_log(LOG_WARNING, "MySQL RealTime: Couldn't establish connection. Check debug.\n");
+ ast_log(LOG_DEBUG, "MySQL RealTime: Cannot Connect: %s\n", mysql_error(&mysql));
+ }
+
+ ast_config_engine_register(&mysql_engine);
+ if(option_verbose) {
+ ast_verbose("MySQL RealTime driver loaded.\n");
+ }
+ ast_cli_register(&cli_realtime_mysql_status);
+
+ ast_mutex_unlock(&mysql_lock);
+
+ return 0;
+}
+
+int unload_module (void)
+{
+ /* Aquire control before doing anything to the module itself. */
+ ast_mutex_lock(&mysql_lock);
+
+ mysql_close(&mysql);
+ ast_cli_unregister(&cli_realtime_mysql_status);
+ ast_config_engine_deregister(&mysql_engine);
+ if(option_verbose) {
+ ast_verbose("MySQL RealTime unloaded.\n");
+ }
+
+ STANDARD_HANGUP_LOCALUSERS;
+
+ /* Unlock so something else can destroy the lock. */
+ ast_mutex_unlock(&mysql_lock);
+
+ return 0;
+}
+
+int reload (void)
+{
+ /* Aquire control before doing anything to the module itself. */
+ ast_mutex_lock(&mysql_lock);
+
+ mysql_close(&mysql);
+ connected = 0;
+ parse_config();
+
+ if(!mysql_reconnect(NULL)) {
+ ast_log(LOG_WARNING, "MySQL RealTime: Couldn't establish connection. Check debug.\n");
+ ast_log(LOG_DEBUG, "MySQL RealTime: Cannot Connect: %s\n", mysql_error(&mysql));
+ }
+
+ ast_verbose(VERBOSE_PREFIX_2 "MySQL RealTime reloaded.\n");
+
+ /* Done reloading. Release lock so others can now use driver. */
+ ast_mutex_unlock(&mysql_lock);
+
+ return 0;
+}
+
+int parse_config (void)
+{
+ struct ast_config *config;
+ char *s;
+
+ config = ast_config_load(RES_CONFIG_MYSQL_CONF);
+
+ if(config) {
+ if(!(s=ast_variable_retrieve(config, "general", "dbuser"))) {
+ ast_log(LOG_WARNING, "MySQL RealTime: No database user found, using 'asterisk' as default.\n");
+ strncpy(dbuser, "asterisk", sizeof(dbuser) - 1);
+ } else {
+ strncpy(dbuser, s, sizeof(dbuser) - 1);
+ }
+
+ if(!(s=ast_variable_retrieve(config, "general", "dbpass"))) {
+ ast_log(LOG_WARNING, "MySQL RealTime: No database password found, using 'asterisk' as default.\n");
+ strncpy(dbpass, "asterisk", sizeof(dbpass) - 1);
+ } else {
+ strncpy(dbpass, s, sizeof(dbpass) - 1);
+ }
+
+ if(!(s=ast_variable_retrieve(config, "general", "dbhost"))) {
+ ast_log(LOG_WARNING, "MySQL RealTime: No database host found, using localhost via socket.\n");
+ dbhost[0] = '\0';
+ } else {
+ strncpy(dbhost, s, sizeof(dbhost) - 1);
+ }
+
+ if(!(s=ast_variable_retrieve(config, "general", "dbname"))) {
+ ast_log(LOG_WARNING, "MySQL RealTime: No database name found, using 'asterisk' as default.\n");
+ strncpy(dbname, "asterisk", sizeof(dbname) - 1);
+ } else {
+ strncpy(dbname, s, sizeof(dbname) - 1);
+ }
+
+ if(!(s=ast_variable_retrieve(config, "general", "dbport"))) {
+ ast_log(LOG_WARNING, "MySQL RealTime: No database port found, using 3306 as default.\n");
+ dbport = 3306;
+ } else {
+ dbport = atoi(s);
+ }
+
+ if(dbhost && !(s=ast_variable_retrieve(config, "general", "dbsock"))) {
+ ast_log(LOG_WARNING, "MySQL RealTime: No database socket found, using '/tmp/mysql.sock' as default.\n");
+ strncpy(dbsock, "/tmp/mysql.sock", sizeof(dbsock) - 1);
+ } else {
+ strncpy(dbsock, s, sizeof(dbsock) - 1);
+ }
+ }
+ ast_config_destroy(config);
+
+ if(dbhost) {
+ ast_log(LOG_DEBUG, "MySQL RealTime Host: %s\n", dbhost);
+ ast_log(LOG_DEBUG, "MySQL RealTime Port: %i\n", dbport);
+ } else {
+ ast_log(LOG_DEBUG, "MySQL RealTime Socket: %s\n", dbsock);
+ }
+ ast_log(LOG_DEBUG, "MySQL RealTime User: %s\n", dbuser);
+ ast_log(LOG_DEBUG, "MySQL RealTime Password: %s\n", dbpass);
+
+ return 1;
+}
+
+char *description (void)
+{
+ return res_config_mysql_desc;
+}
+
+int usecount (void)
+{
+ /* Try and get a lock. If unsuccessful, than that means another thread is using the mysql object. */
+ if(ast_mutex_trylock(&mysql_lock)) {
+ ast_log(LOG_DEBUG, "MySQL RealTime: Module usage count is 1.\n");
+ return 1;
+ }
+ ast_mutex_unlock(&mysql_lock);
+ return 0;
+}
+
+char *key ()
+{
+ return ASTERISK_GPL_KEY;
+}
+
+static int mysql_reconnect(const char *database)
+{
+ char my_database[50];
+
+ if(!database || ast_strlen_zero(database))
+ ast_copy_string(my_database, dbname, sizeof(my_database));
+ else
+ ast_copy_string(my_database, database, sizeof(my_database));
+
+ /* mutex lock should have been locked before calling this function. */
+
+ if((!connected) && (dbhost || dbsock) && dbuser && dbpass && my_database) {
+ if(!mysql_init(&mysql)) {
+ ast_log(LOG_WARNING, "MySQL RealTime: Insufficient memory to allocate MySQL resource.\n");
+ connected = 0;
+ return 0;
+ }
+ if(mysql_real_connect(&mysql, dbhost, dbuser, dbpass, my_database, dbport, dbsock, 0)) {
+ ast_log(LOG_DEBUG, "MySQL RealTime: Successfully connected to database.\n");
+ connected = 1;
+ connect_time = time(NULL);
+ return 1;
+ } else {
+ ast_log(LOG_ERROR, "MySQL RealTime: Failed to connect database server %s on %s. Check debug for more info.\n", dbname, dbhost);
+ ast_log(LOG_DEBUG, "MySQL RealTime: Cannot Connect: %s\n", mysql_error(&mysql));
+ connected = 0;
+ return 0;
+ }
+ } else {
+ if(mysql_ping(&mysql) != 0) {
+ connected = 0;
+ ast_log(LOG_ERROR, "MySQL RealTime: Failed to reconnect. Check debug for more info.\n");
+ ast_log(LOG_DEBUG, "MySQL RealTime: Server Error: %s\n", mysql_error(&mysql));
+ return 0;
+ }
+
+ connected = 1;
+
+ if(mysql_select_db(&mysql, my_database) != 0) {
+ ast_log(LOG_WARNING, "MySQL RealTime: Unable to select database: %s. Still Connected.\n", my_database);
+ ast_log(LOG_DEBUG, "MySQL RealTime: Database Select Failed: %s\n", mysql_error(&mysql));
+ return 0;
+ }
+
+ ast_log(LOG_DEBUG, "MySQL RealTime: Everything is fine.\n");
+ return 1;
+ }
+}
+
+static int realtime_mysql_status(int fd, int argc, char **argv)
+{
+ char status[256], status2[100] = "";
+ int ctime = time(NULL) - connect_time;
+
+ if(mysql_reconnect(NULL)) {
+ if(dbhost) {
+ snprintf(status, 255, "Connected to %s@%s, port %d", dbname, dbhost, dbport);
+ } else if(dbsock) {
+ snprintf(status, 255, "Connected to %s on socket file %s", dbname, dbsock);
+ } else {
+ snprintf(status, 255, "Connected to %s@%s", dbname, dbhost);
+ }
+
+ if(dbuser && *dbuser) {
+ snprintf(status2, 99, " with username %s", dbuser);
+ }
+
+ if (ctime > 31536000) {
+ ast_cli(fd, "%s%s for %d years, %d days, %d hours, %d minutes, %d seconds.\n", status, status2, ctime / 31536000, (ctime % 31536000) / 86400, (ctime % 86400) / 3600, (ctime % 3600) / 60, ctime % 60);
+ } else if (ctime > 86400) {
+ ast_cli(fd, "%s%s for %d days, %d hours, %d minutes, %d seconds.\n", status, status2, ctime / 86400, (ctime % 86400) / 3600, (ctime % 3600) / 60, ctime % 60);
+ } else if (ctime > 3600) {
+ ast_cli(fd, "%s%s for %d hours, %d minutes, %d seconds.\n", status, status2, ctime / 3600, (ctime % 3600) / 60, ctime % 60);
+ } else if (ctime > 60) {
+ ast_cli(fd, "%s%s for %d minutes, %d seconds.\n", status, status2, ctime / 60, ctime % 60);
+ } else {
+ ast_cli(fd, "%s%s for %d seconds.\n", status, status2, ctime);
+ }
+
+ return RESULT_SUCCESS;
+ } else {
+ return RESULT_FAILURE;
+ }
+}

View File

@ -1,21 +0,0 @@
diff -Nru asterisk-1.2.14.org/codecs/ilbc/Makefile asterisk-1.2.14/codecs/ilbc/Makefile
--- asterisk-1.2.14.org/codecs/ilbc/Makefile 2005-11-29 19:24:39.000000000 +0100
+++ asterisk-1.2.14/codecs/ilbc/Makefile 2006-12-27 09:21:07.000000000 +0100
@@ -1,5 +1,5 @@
ARCH=$(PROC)
-CFLAGS+=-Wall -O3 -funroll-loops
+CFLAGS+=-Wall $(OPTIMIZE) -funroll-loops
ifneq (${OSARCH},CYGWIN)
CFLAGS += -fPIC
endif
@@ -15,8 +15,8 @@
$(LIB): $(OBJS)
- ar cr $(LIB) $(OBJS)
- ranlib $(LIB)
+ $(AR) cr $(LIB) $(OBJS)
+ $(RANLIB) $(LIB)
clean:
rm -f $(LIB) *.o

View File

@ -1,43 +0,0 @@
diff -Nru asterisk-1.2.24.org/channels/Makefile asterisk-1.2.24/channels/Makefile
--- asterisk-1.2.24.org/channels/h323/Makefile 2007-03-06 16:17:16.000000000 +0100
+++ asterisk-1.2.24/channels/h323/Makefile 2007-09-04 18:37:58.000000000 +0200
@@ -21,9 +21,8 @@
OPENH323DIR=$(HOME)/openh323
endif
-clean:
- rm -f *.so *.o .depend
-
+include $(OPENH323DIR)/openh323u.mak
+
$(SOURCES):: $(SOURCES:.cxx=.cpp)
ln -f $< $@
@@ -31,7 +30,6 @@
touch $(SOURCES)
libchanh323.a: $(OBJS)
- include $(OPENH323DIR)/openh323u.mak
ar crv $@ $(OBJS)
Makefile.ast: FORCE
diff -Nru asterisk-1.2.14.org/channels/Makefile asterisk-1.2.14/channels/Makefile
--- asterisk-1.2.14.org/channels/Makefile 2006-08-17 23:57:19.000000000 +0200
+++ asterisk-1.2.14/channels/Makefile 2006-12-27 09:22:09.000000000 +0100
@@ -15,6 +15,7 @@
#
CHANNEL_LIBS=chan_sip.so chan_agent.so chan_mgcp.so chan_iax2.so chan_local.so chan_skinny.so chan_features.so
+CXXLIBS=-lstdc++
ifneq (${OSARCH},CYGWIN)
# if you really, really want to use these drivers, uncomment the line below
@@ -228,7 +229,7 @@
ifeq (${OSARCH},Linux)
chan_h323.so: chan_h323.o h323/libchanh323.a h323/Makefile.ast
- $(CC) $(SOLINK) $(H323LDFLAGS) -o $@ $< h323/libchanh323.a $(H323LDLIBS) -lstdc++
+ $(CC) $(SOLINK) $(H323LDFLAGS) -o $@ $< h323/libchanh323.a $(H323LDLIBS) $(CXXLIBS)
else
chan_h323.so: chan_h323.o h323/libchanh323.a
$(CC) $(SOLINK) -o $@ $< h323/libchanh323.a $(CHANH323LIB) -L$(PWLIBDIR)/lib $(PTLIB) -L$(OPENH323DIR)/lib $(H323LIB) -L/usr/lib -lcrypto -lssl -lexpat