Merge branch 'master' of ssh://git.freeswitch.org:222/freeswitch
This commit is contained in:
commit
432256fde0
|
@ -0,0 +1,201 @@
|
|||
*~
|
||||
*.o
|
||||
*.so
|
||||
*.lo
|
||||
*.a
|
||||
*.la
|
||||
*.loT
|
||||
*.orig
|
||||
*.rej
|
||||
.libs
|
||||
.deps
|
||||
.\#*
|
||||
\#*
|
||||
*.user
|
||||
*.suo
|
||||
*.ncb
|
||||
*.pdb
|
||||
*.map
|
||||
*.lib
|
||||
*.obj
|
||||
*.idb
|
||||
*.res
|
||||
*.exp
|
||||
*.exe
|
||||
*.manifest
|
||||
*.dep
|
||||
*.dll
|
||||
*.sbr
|
||||
*.ilk
|
||||
*.bsc
|
||||
*.pch
|
||||
*.tar
|
||||
*.gz
|
||||
*.tgz
|
||||
*.xz
|
||||
*.bz2
|
||||
*.tbz2
|
||||
*.swp
|
||||
aclocal.m4
|
||||
autom4te.cache
|
||||
config.cache
|
||||
configure.lineno
|
||||
config.log
|
||||
config.status
|
||||
core.*
|
||||
*.2010.log
|
||||
*.Build.CppClean.log
|
||||
*.tlog
|
||||
*.unsuccessfulbuild
|
||||
*.cache
|
||||
*.lastbuildstate
|
||||
|
||||
/w32/Library/lastversion
|
||||
/w32/Library/tmpVersion.Bat
|
||||
!/w32/Console/FreeSwitchConsole.vcproj.user
|
||||
!/w32/Setup/inno_setup/vcredist_x64.exe
|
||||
!/w32/Setup/inno_setup/vcredist_x86.exe
|
||||
|
||||
/.version
|
||||
/a.out.dSYM
|
||||
/AUTHORS
|
||||
/ChangeLog
|
||||
/configure
|
||||
/COPYING
|
||||
/freeswitch
|
||||
/fs_cli
|
||||
/fs_encode
|
||||
/fs_ivrd
|
||||
/libtool
|
||||
/Makefile
|
||||
/Makefile.in
|
||||
/modules.conf
|
||||
/NEWS
|
||||
/Path
|
||||
/quiet_libtool
|
||||
/README
|
||||
/TAGS
|
||||
/tone2wav
|
||||
|
||||
/All/
|
||||
/Debug/
|
||||
/bin/
|
||||
/Release/
|
||||
|
||||
/build/config/compile
|
||||
/build/config/config.guess
|
||||
/build/config/config.sub
|
||||
/build/config/depcomp
|
||||
/build/config/install-sh
|
||||
/build/config/ltmain.sh
|
||||
/build/config/missing
|
||||
/build/freeswitch.pc
|
||||
/build/getlib.sh
|
||||
/build/getg729.sh
|
||||
/build/getsounds.sh
|
||||
/build/Makefile
|
||||
/build/Makefile.in
|
||||
/build/modmake.rules
|
||||
|
||||
/libs/curl/lib/ca-bundle.h
|
||||
/libs/esl/fs_cli
|
||||
/libs/esl/ivrd
|
||||
/libs/esl/testclient
|
||||
/libs/esl/testserver
|
||||
/libs/freetdm/detect_dtmf
|
||||
/libs/freetdm/detect_tones
|
||||
/libs/freetdm/testanalog
|
||||
/libs/freetdm/testapp
|
||||
/libs/freetdm/testcid
|
||||
/libs/freetdm/testpri
|
||||
/libs/freetdm/testr2
|
||||
/libs/freetdm/testsangomaboost
|
||||
/libs/freetdm/testtones
|
||||
/libs/fsg729-*-installer
|
||||
/libs/g729/
|
||||
/libs/libcodec2/compile
|
||||
/libs/libcodec2/config.guess
|
||||
/libs/libcodec2/config.sub
|
||||
/libs/libcodec2/configure
|
||||
/libs/libcodec2/depcomp
|
||||
/libs/libcodec2/install-sh
|
||||
/libs/libcodec2/libtool
|
||||
/libs/libcodec2/ltmain.sh
|
||||
/libs/libcodec2/Makefile
|
||||
/libs/libcodec2/Makefile.in
|
||||
/libs/libcodec2/missing
|
||||
/libs/libcodec2/src/Makefile
|
||||
/libs/libcodec2/src/Makefile.in
|
||||
/libs/libcodec2/unittest/Makefile
|
||||
/libs/libcodec2/unittest/Makefile.in
|
||||
/libs/mpg123-1.13.2/
|
||||
|
||||
/scripts/fsxs
|
||||
/scripts/gentls_cert
|
||||
|
||||
/src/mod/applications/mod_easyroute/Makefile
|
||||
/src/mod/applications/mod_hash/Makefile
|
||||
/src/mod/applications/mod_hash/Makefile.in
|
||||
/src/mod/applications/mod_hash/mod_hash.log
|
||||
/src/mod/applications/mod_lcr/Makefile
|
||||
/src/mod/applications/mod_nibblebill/Makefile
|
||||
/src/mod/applications/mod_osp/Makefile
|
||||
/src/mod/applications/mod_osp/Makefile.in
|
||||
/src/mod/applications/mod_rss/Makefile
|
||||
/src/mod/applications/mod_snipe_hunt/Makefile
|
||||
/src/mod/codecs/mod_com_g729/
|
||||
/src/mod/codecs/mod_dahdi_codec/Makefile
|
||||
/src/mod/dialplans/mod_dialplan_directory/Makefile
|
||||
/src/mod/formats/mod_shell_stream/Makefile
|
||||
/src/mod/languages/mod_lua/mod_lua_wrap.cpp.orig
|
||||
/src/mod/languages/mod_perl/mod_perl_wrap.cpp.orig
|
||||
/src/mod/languages/mod_python/mod_python_wrap.cpp.orig
|
||||
/src/mod/say/mod_say_de/Makefile
|
||||
/src/mod/say/mod_say_es/Makefile
|
||||
/src/mod/say/mod_say_fr/Makefile
|
||||
/src/mod/say/mod_say_it/Makefile
|
||||
/src/mod/say/mod_say_nl/Makefile
|
||||
/src/mod/say/mod_say_th/Makefile
|
||||
/src/mod/say/mod_say_zh/Makefile
|
||||
|
||||
BuildLog.htm
|
||||
/w32/Console/Debug/
|
||||
/w32/Console/Release/
|
||||
/w32/Library/Debug/
|
||||
/w32/Library/Release/
|
||||
|
||||
Freeswitch.2010.sdf
|
||||
|
||||
/Win32/
|
||||
/x64/
|
||||
|
||||
src/mod/codecs/mod_celt/*/*/mod_celt.log
|
||||
src/mod/endpoints/mod_skinny/*/*/mod_skinny_2010.log
|
||||
src/mod/formats/mod_shout/*/*/mod_shout.log
|
||||
|
||||
/w32/Setup/obj
|
||||
/src/mod/asr_tts/mod_pocketsphinx/x64/Debug/mod_pocketsphinx_manifest.rc
|
||||
/src/mod/endpoints/mod_h323/x64/Debug/mod_h323_manifest.rc
|
||||
/src/mod/endpoints/mod_rtmp/Win32/Debug/mod_rtmp_2010.log
|
||||
/src/mod/endpoints/mod_rtmp/Win32/Release/mod_rtmp_2010.log
|
||||
/src/mod/endpoints/mod_rtmp/x64/Debug/mod_rtmp_2010.log
|
||||
/src/mod/endpoints/mod_rtmp/x64/Debug/mod_rtmp_manifest.rc
|
||||
/src/mod/endpoints/mod_rtmp/x64/Release/mod_rtmp_2010.log
|
||||
/src/mod/endpoints/mod_skinny/x64/Debug/mod_skinny_manifest.rc
|
||||
/src/mod/languages/mod_managed/x64/Debug_CLR/FREESWITCH.MANAGED.DLL.metagen
|
||||
/src/mod/languages/mod_managed/x64/Debug_CLR/RSAENH.DLL.bi
|
||||
/src/mod/languages/mod_managed/x64/Debug_CLR/TZRES.DLL.bi
|
||||
/w32/Library/x64/Debug/FreeSwitch_manifest.rc
|
||||
/src/mod/endpoints/mod_h323/Win32/Debug/mod_h323_manifest.rc
|
||||
/src/mod/endpoints/mod_rtmp/Win32/Debug/mod_rtmp_manifest.rc
|
||||
/src/mod/endpoints/mod_skinny/Win32/Debug/mod_skinny_manifest.rc
|
||||
/src/mod/languages/mod_managed/Win32/Debug_CLR/FREESWITCH.MANAGED.DLL.metagen
|
||||
/src/mod/languages/mod_managed/Win32/Debug_CLR/RSAENH.DLL.bi
|
||||
/src/mod/languages/mod_managed/Win32/Debug_CLR/TZRES.DLL.bi
|
||||
/w32/Library/Win32/Debug/FreeSwitch_manifest.rc
|
||||
/src/mod/languages/mod_managed/Win32/Release_CLR/FREESWITCH.MANAGED.DLL.metagen
|
||||
/src/mod/languages/mod_managed/Win32/Release_CLR/RSAENH.DLL.bi
|
||||
/src/mod/languages/mod_managed/Win32/Release_CLR/TZRES.DLL.bi
|
||||
/src/mod/languages/mod_managed/x64/Release_CLR/FREESWITCH.MANAGED.DLL.metagen
|
||||
/src/mod/languages/mod_managed/x64/Release_CLR/RSAENH.DLL.bi
|
||||
/src/mod/languages/mod_managed/x64/Release_CLR/TZRES.DLL.bi
|
|
@ -0,0 +1 @@
|
|||
@SWITCH_VERSION_REVISION@
|
|
@ -0,0 +1,291 @@
|
|||
# FREESWITCH CMAKE BUILD
|
||||
# Created by SHANE BURRELL 2009 (supjigator)
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||
|
||||
PROJECT (freeswitch)
|
||||
|
||||
#GETSVN VERSION
|
||||
FIND_PACKAGE(Subversion)
|
||||
IF(Subversion_FOUND)
|
||||
Subversion_WC_INFO(${CMAKE_HOME_DIRECTORY} Project)
|
||||
MESSAGE("Current revision is ${Project_WC_REVISION}")
|
||||
ENDIF(Subversion_FOUND)
|
||||
|
||||
|
||||
|
||||
# project version
|
||||
SET( ${PROJECT_NAME}_MAJOR_VERSION 1 )
|
||||
SET( ${PROJECT_NAME}_MINOR_VERSION 0 )
|
||||
SET( ${PROJECT_NAME}_PATCH_LEVEL 0 )
|
||||
|
||||
configure_file(src/include/switch_version.h.cmake src/include/switch_version.h [@ONLY])
|
||||
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/")
|
||||
INCLUDE (CheckSymbolExists)
|
||||
INCLUDE (CheckIncludeFile)
|
||||
INCLUDE (CheckIncludeFiles)
|
||||
INCLUDE (CheckSymbolExists)
|
||||
INCLUDE (CheckFunctionExists)
|
||||
INCLUDE (CheckLibraryExists)
|
||||
INCLUDE (CheckTypeSize)
|
||||
INCLUDE (CheckCXXSourceCompiles)
|
||||
|
||||
MESSAGE( STATUS )
|
||||
MESSAGE( STATUS "FREESWITCH CMAKE Build-----------------------------------------" )
|
||||
MESSAGE( STATUS "BUILD_SHARED_LIBS = ${BUILD_SHARED_LIBS}" )
|
||||
MESSAGE( STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}" )
|
||||
MESSAGE( STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}" )
|
||||
MESSAGE( STATUS "CMAKE_MODULE_PATH = ${CMAKE_MODULE_PATH}" )
|
||||
MESSAGE( STATUS "${PROJECT_NAME}_DEPENDS = \"${${PROJECT_NAME}_DEPENDS}\"" )
|
||||
MESSAGE( STATUS "BUILD_WITH = \"${BUILD_WITH}\"" )
|
||||
MESSAGE( STATUS "INSTALL_DOC = ${INSTALL_DOC}" )
|
||||
MESSAGE( STATUS "Change a value with: cmake -D<Variable>=<Value>" )
|
||||
MESSAGE( STATUS "---------------------------------------------------------------" )
|
||||
MESSAGE( STATUS )
|
||||
|
||||
# Configuration checks
|
||||
|
||||
|
||||
|
||||
## Check type sizes --------------------------------------
|
||||
|
||||
check_type_size ("int" SIZEOF_INT )
|
||||
check_type_size ("uint32_t" HAVE_UINT32_T )
|
||||
check_type_size ("int64_t" HAVE_INT64_T )
|
||||
check_type_size ("float" SIZEOF_FLOAT )
|
||||
check_type_size ("double" SIZEOF_DOUBLE )
|
||||
check_type_size ("long" SIZEOF_LONG )
|
||||
check_type_size ("long long" SIZEOF_LONG_LONG )
|
||||
check_type_size ("short" SIZEOF_SHORT )
|
||||
check_type_size ("off_t" SIZEOF_OFF_T )
|
||||
check_type_size ("pid_t" SIZEOF_PID_T )
|
||||
check_type_size ("size_t" SIZEOF_SIZE_T )
|
||||
check_type_size ("socklen_t" SIZEOF_SOCKLEN_T )
|
||||
check_type_size ("sig_atomic_t" SIZEOF_SIG_ATOMIC_T )
|
||||
check_type_size ("void *" SIZEOF_VOID_P )
|
||||
check_type_size ("uintptr_t" SIZEOF_UINTPTR_T )
|
||||
check_type_size ("_Bool" HAVE__BOOL )
|
||||
check_type_size ("intptr_t" SIZEOF_INTPTR_T )
|
||||
|
||||
check_type_size ("struct sockaddr_in6" SIZEOF_STRUCT_SOCKADDR_IN6 )
|
||||
check_type_size ("struct sockaddr_storage" SIZEOF_STRUCT_SOCKADDR_STORAGE )
|
||||
check_type_size ("struct utimbuf" SIZEOF_STRUCT_UTIMBUF )
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
check_symbol_exists (strncasecmp "string.h" HAVE_STRNCASECMP)
|
||||
check_symbol_exists (strcasecmp "string.h" HAVE_STRCASECMP)
|
||||
check_symbol_exists (iswspace "wctype.h" HAVE_ISWSPACE)
|
||||
check_symbol_exists (towlower "wctype.h" HAVE_TOWLOWER)
|
||||
check_symbol_exists(getpagesize unistd.h HAVE_GETPAGESIZE)
|
||||
check_symbol_exists(isinf cmath HAVE_ISINF_IN_CMATH)
|
||||
check_symbol_exists(isinf math.h HAVE_ISINF_IN_MATH_H)
|
||||
check_symbol_exists(isnan cmath HAVE_ISNAN_IN_CMATH)
|
||||
check_symbol_exists(isnan math.h HAVE_ISNAN_IN_MATH_H)
|
||||
check_symbol_exists(ceilf math.h HAVE_CEILF)
|
||||
check_symbol_exists(floorf math.h HAVE_FLOORF)
|
||||
check_symbol_exists(mallinfo malloc.h HAVE_MALLINFO)
|
||||
check_symbol_exists(pthread_mutex_lock pthread.h HAVE_PTHREAD_MUTEX_LOCK)
|
||||
check_symbol_exists(strtoll stdlib.h HAVE_STRTOLL)
|
||||
check_symbol_exists(getrusage sys/resource.h HAVE_GETRUSAGE)
|
||||
check_symbol_exists(setrlimit sys/resource.h HAVE_SETRLIMIT)
|
||||
|
||||
check_include_file (dirent.h HAVE_DIRENT_H)
|
||||
check_include_file (dlfcn.h HAVE_DLFCN_H)
|
||||
check_include_file (execinfo.h HAVE_EXECINFO_H)
|
||||
check_include_file (memory.h HAVE_MEMORY_H)
|
||||
check_include_file (inttypes.h HAVE_INTTYPES_H)
|
||||
check_include_file (strings.h HAVE_STRINGS_H)
|
||||
check_include_file (string.h HAVE_STRING_H)
|
||||
check_include_file (sys/filio.h HAVE_SYS_FILIO_H)
|
||||
check_include_file (sys/ndir.h HAVE_SYS_NDIR_H)
|
||||
CHECK_INCLUDE_FILE(netdb.h HAVE_NETDB_H)
|
||||
|
||||
check_include_file(malloc.h HAVE_MALLOC_H)
|
||||
check_include_file (sys/ioctl.h HAVE_SYS_IOCTL_H)
|
||||
check_include_file (sys/utsname.h HAVE_SYS_UTSNAME_H)
|
||||
check_include_file (wchar.h HAVE_WCHAR_H)
|
||||
check_include_file (wctype.h HAVE_WCTYPE_H)
|
||||
check_include_file(sys/devpoll.h HAVE_SYS_DEVPOLL_H)
|
||||
check_include_file(sys/epoll.h HAVE_SYS_EPOLL_H)
|
||||
check_include_file(sys/event.h HAVE_SYS_EVENT_H)
|
||||
check_include_file(sys/mman.h HAVE_SYS_MMAN_H)
|
||||
check_include_file(sys/poll.h HAVE_SYS_POLL_H)
|
||||
check_include_file(sys/port.h HAVE_SYS_PORT_H)
|
||||
check_include_file(sys/prctl.h HAVE_SYS_PRCTL_H)
|
||||
check_include_file(sys/resource.h HAVE_SYS_RESOURCE_H)
|
||||
check_include_file(sys/sendfile.h HAVE_SYS_SENDFILE_H)
|
||||
check_include_file(sys/select.h HAVE_SYS_SELECT_H)
|
||||
check_include_file(sys/syslimits.h HAVE_SYS_SYSLIMITS_H)
|
||||
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
|
||||
check_include_file(sys/uio.h HAVE_SYS_UIO_H)
|
||||
check_include_file(sys/un.h HAVE_SYS_UN_H)
|
||||
check_include_file(sys/wait.h HAVE_SYS_WAIT_H)
|
||||
check_include_file(sys/time.h HAVE_SYS_TIME_H)
|
||||
check_include_file(time.h HAVE_TIME_H)
|
||||
check_include_file(unistd.h HAVE_UNISTD_H)
|
||||
check_include_file(pthread.h HAVE_PTHREAD_H)
|
||||
|
||||
check_function_exists (scandir HAVE_SCANDIR)
|
||||
check_function_exists (alphasort HAVE_ALPHASORT)
|
||||
check_function_exists (strcasestr HAVE_STRCASESTR)
|
||||
check_function_exists (strchrnul HAVE_STRCHRNUL)
|
||||
check_function_exists (setenv HAVE_SETENV)
|
||||
check_function_exists (setgroups HAVE_SETGROUPS)
|
||||
|
||||
check_function_exists (clock_gettime HAVE_CLOCK_GETTIME)
|
||||
check_function_exists (pselect HAVE_PSELECT)
|
||||
check_function_exists (malloc HAVE_MALLOC)
|
||||
check_function_exists (mlock HAVE_MLOCK)
|
||||
check_function_exists (mlockall HAVE_MLOCKALL)
|
||||
check_function_exists (asprintf HAVE_ASPRINTF)
|
||||
check_function_exists (gethostname HAVE_GETHOSTNAME)
|
||||
check_function_exists (gettimeofday HAVE_GETTIMEOFDAY)
|
||||
check_function_exists (gmtime_r HAVE_GMTIME_R)
|
||||
check_function_exists (initgroups HAVE_INITGROUPS)
|
||||
check_function_exists (usleep HAVE_USLEEP)
|
||||
check_function_exists (vasprintf HAVE_VASPRINTF)
|
||||
|
||||
|
||||
MESSAGE( STATUS "BUILD APR--------------------------------------------------------------------------" )
|
||||
|
||||
#execute_process (WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/libs/apr/ COMMAND ./configure --prefix=/usr/local/freeswitch --enable-core-odbc-support --cache-file=/dev/null --srcdir=. --disable-shared --with-pic TIMEOUT 300 ERROR_VARIABLE error_configure ERROR_FILE error.log)
|
||||
|
||||
#execute_process (WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/libs/apr/ COMMAND ./make TIMEOUT 300 ERROR_VARIABLE error_configure ERROR_FILE error.log)
|
||||
MESSAGE( STATUS "-------------------------------------------------------------------------------" )
|
||||
|
||||
MESSAGE( STATUS "BUILD APR-UTIL--------------------------------------------------------------------------" )
|
||||
|
||||
#execute_process (WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/libs/apr-util/ COMMAND ./configure --prefix=/usr/local/freeswitch --enable-core-odbc-support --cache-file=/dev/null --srcdir=. --with-apr=../apr --disable-shared --with-pic --without-sqlite2 --without-sqlite3 TIMEOUT 300 ERROR_VARIABLE error_configure ERROR_FILE error.log)
|
||||
|
||||
#execute_process (WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/libs/apr-util/ COMMAND ./make TIMEOUT 300 ERROR_VARIABLE error_configure ERROR_FILE error.log)
|
||||
|
||||
MESSAGE( STATUS "-------------------------------------------------------------------------------" )
|
||||
|
||||
|
||||
# OPTION( VARIABLE "Description" Initial state)
|
||||
OPTION( DEBUG "Debug" OFF )
|
||||
OPTION( DISABLE_RESAMPLE "Disable RESAMPLE" OFF )
|
||||
OPTION( HAVE_ODBC "Enable Core ODBC Support" ON )
|
||||
OPTION( OPTIMZER "Enable Optimization" OFF )
|
||||
|
||||
CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/src/include/switch_private.h.cmake ${CMAKE_SOURCE_DIR}/src/include/switch_private.h )
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
MESSAGE( STATUS "-------------------------------------------------------------------------------" )
|
||||
MESSAGE( STATUS )
|
||||
MESSAGE( STATUS "-------------------------------------------------------------------------------" )
|
||||
MESSAGE( STATUS )
|
||||
# the complete system name, e.g. "Linux-2.4.22", "FreeBSD-5.4-RELEASE" or "Windows 5.1"
|
||||
MESSAGE( STATUS "CMAKE_SYSTEM: " ${CMAKE_SYSTEM} )
|
||||
# the short system name, e.g. "Linux", "FreeBSD" or "Windows"
|
||||
|
||||
MESSAGE( STATUS "-------------------------------------------------------------------------------" )
|
||||
MESSAGE( STATUS )
|
||||
|
||||
# DO THREADS
|
||||
FIND_PACKAGE(Threads)
|
||||
|
||||
|
||||
#TESTING SECTION
|
||||
add_definitions(-DMACOSX)
|
||||
#add_definitions("-DSWITCH_PREFIX_DIR=/usr/local/freeswitch")
|
||||
|
||||
|
||||
|
||||
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_SOURCE_DIR}/libs/apr/include/ ${CMAKE_SOURCE_DIR}/libs/apr-util/include/ src/include/ libs/libteletone/src/ libs/stfu/)
|
||||
|
||||
# DO APR
|
||||
#INCLUDE_DIRECTORIES ( ${CMAKE_SOURCE_DIR}/libs/apr/include/ ${CMAKE_SOURCE_DIR}/libs/apr-util/include/)
|
||||
#LINK_LIBRARIES (${CMAKE_SOURCE_DIR}/libs/apr/.libs/libapr-1.a)
|
||||
#LINK_LIBRARIES (${CMAKE_SOURCE_DIR}/libs/apr-util/.libs/libaprutil-1.a)
|
||||
|
||||
|
||||
# DO SNDFILE
|
||||
|
||||
FIND_PACKAGE (Sndfile)
|
||||
LINK_LIBRARIES (${SNDFILE_LIBRARY})
|
||||
INCLUDE_DIRECTORIES (${SNDFILE_INCLUDE_DIR})
|
||||
|
||||
|
||||
# DO LIBEDIT
|
||||
#FIND_PACKAGE (Libedit)
|
||||
#LINK_LIBRARIES ("/Users/shaneburrell/freeswitch-svn-real/libs/libedit/src/.libs/libedit.a")
|
||||
#INCLUDE_DIRECTORIES("libs/libedit/src/")
|
||||
#LINK_LIBRARIES (${PATH_LIB_EDIT})
|
||||
#INCLUDE_DIRECTORIES (${PATH_INC_EDIT})
|
||||
|
||||
#if( PATH_LIB_EDIT)
|
||||
# add_definitions( -DSWITCH_HAVE_LIBEDIT)
|
||||
# add_definitions( -DHAVE_EDITLINE)
|
||||
# MESSAGE( STATUS "Found libedit = ${PATH_LIB_EDIT}" )
|
||||
#endif( PATH_LIB_EDIT)
|
||||
|
||||
|
||||
|
||||
|
||||
# DO SRTP
|
||||
LINK_LIBRARIES (${CMAKE_SOURCE_DIR}/libs/srtp/.libs/libcryptomath.a)
|
||||
LINK_LIBRARIES (${CMAKE_SOURCE_DIR}/libs/srtp/.libs/libsrtp.a)
|
||||
INCLUDE_DIRECTORIES ( ${CMAKE_SOURCE_DIR}/libs/srtp/crypto/include)
|
||||
|
||||
# SQLITE
|
||||
LINK_LIBRARIES (${CMAKE_SOURCE_DIR}/libs/sqlite/.libs/libsqlite3.a)
|
||||
INCLUDE_DIRECTORIES ( ${CMAKE_SOURCE_DIR}/libs/sqlite/)
|
||||
|
||||
# VOIPCODECS
|
||||
LINK_LIBRARIES (${CMAKE_SOURCE_DIR}/libs/voipcodecs/src/.libs/libvoipcodecs.a)
|
||||
INCLUDE_DIRECTORIES ( ${CMAKE_SOURCE_DIR}/libs/voipcodecs/src/)
|
||||
|
||||
# libspeexdsp
|
||||
LINK_LIBRARIES (${CMAKE_SOURCE_DIR}/libs/speex/libspeex/.libs/libspeexdsp.a)
|
||||
LINK_LIBRARIES (${CMAKE_SOURCE_DIR}/libs/speex/libspeex/.libs/libspeex.a)
|
||||
INCLUDE_DIRECTORIES ( ${CMAKE_SOURCE_DIR}/libs/speex/include/)
|
||||
|
||||
|
||||
# DO POSTGRES
|
||||
#FIND_PACKAGE(POSTGRES)
|
||||
IF(POSTGRES_FOUND)
|
||||
INCLUDE_DIRECTORIES( ${POSTGRES_INCLUDE_DIRECTORIES} )
|
||||
SET(optionalLibs ${optionalLibs} ${POSTGRES_LIBRARIES} )
|
||||
ENDIF(POSTGRES_FOUND)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ADD_SUBDIRECTORY(src)
|
||||
#ADD_SUBDIRECTORY(libs/libresample/)
|
||||
ADD_SUBDIRECTORY(libs/libteletone/)
|
||||
#ADD_SUBDIRECTORY(libs/sqlite/)
|
||||
ADD_SUBDIRECTORY(libs/pcre/)
|
||||
ADD_SUBDIRECTORY(libs/stfu/)
|
||||
ADD_SUBDIRECTORY(libs/apr-util/)
|
||||
ADD_SUBDIRECTORY(libs/apr/)
|
||||
#ADD_SUBDIRECTORY(libs/libedit/src/)
|
||||
ADD_SUBDIRECTORY(libs/srtp/)
|
||||
|
||||
SET ( freeswitch_SRCS src/switch.c src/include/switch.h)
|
||||
ADD_EXECUTABLE(freeswitch ${freeswitch_SRCS})
|
||||
|
||||
|
||||
TARGET_LINK_LIBRARIES(freeswitch apr apr-util teletone pcre freeswitch_la stfu ${optionalLibs})
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,4 @@
|
|||
@echo off
|
||||
set Path=%PATH%;c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE;c:\Program Files\Microsoft Visual Studio 9.0\VC\BIN;c:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools;c:\WINDOWS\Microsoft.NET\Framework\v3.5;c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;c:\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages;C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin;
|
||||
msbuild Freeswitch.2008.sln /verbosity:detailed /property:Configuration=Debug /logger:FileLogger,Microsoft.Build.Engine;logfile=Freeswitch.2008.sln.debug.log
|
||||
pause
|
|
@ -0,0 +1,4 @@
|
|||
@echo off
|
||||
set Path=%PATH%;c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE;c:\Program Files\Microsoft Visual Studio 9.0\VC\BIN;c:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools;c:\WINDOWS\Microsoft.NET\Framework\v3.5;c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;c:\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages;C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin;
|
||||
msbuild Freeswitch.2008.sln /verbosity:detailed /property:Configuration=Release /logger:FileLogger,Microsoft.Build.Engine;logfile=Freeswitch.2008.sln.release.log
|
||||
pause
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,231 @@
|
|||
Installation Instructions
|
||||
*************************
|
||||
|
||||
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004 Free
|
||||
Software Foundation, Inc.
|
||||
|
||||
This file is free documentation; the Free Software Foundation gives
|
||||
unlimited permission to copy, distribute and modify it.
|
||||
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
These are generic installation instructions.
|
||||
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, and a
|
||||
file `config.log' containing compiler output (useful mainly for
|
||||
debugging `configure').
|
||||
|
||||
It can also use an optional file (typically called `config.cache'
|
||||
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
||||
the results of its tests to speed up reconfiguring. (Caching is
|
||||
disabled by default to prevent problems with accidental use of stale
|
||||
cache files.)
|
||||
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how `configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If you are using the cache, and at
|
||||
some point `config.cache' contains results you don't want to keep, you
|
||||
may remove or edit it.
|
||||
|
||||
The file `configure.ac' (or `configure.in') is used to create
|
||||
`configure' by a program called `autoconf'. You only need
|
||||
`configure.ac' if you want to change it or regenerate `configure' using
|
||||
a newer version of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system. If you're
|
||||
using `csh' on an old version of System V, you might need to type
|
||||
`sh ./configure' instead to prevent `csh' from trying to execute
|
||||
`configure' itself.
|
||||
|
||||
Running `configure' takes awhile. While running, it prints some
|
||||
messages telling which features it is checking for.
|
||||
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package.
|
||||
|
||||
4. Type `make install' to install the programs and any data files and
|
||||
documentation.
|
||||
|
||||
5. You can remove the program binaries and object files from the
|
||||
source code directory by typing `make clean'. To also remove the
|
||||
files that `configure' created (so you can compile the package for
|
||||
a different kind of computer), type `make distclean'. There is
|
||||
also a `make maintainer-clean' target, but that is intended mainly
|
||||
for the package's developers. If you use it, you may have to get
|
||||
all sorts of other programs in order to regenerate files that came
|
||||
with the distribution.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that the
|
||||
`configure' script does not know about. Run `./configure --help' for
|
||||
details on some of the pertinent environment variables.
|
||||
|
||||
You can give `configure' initial values for configuration parameters
|
||||
by setting variables in the command line or in the environment. Here
|
||||
is an example:
|
||||
|
||||
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
|
||||
|
||||
*Note Defining Variables::, for more details.
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you must use a version of `make' that
|
||||
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'.
|
||||
|
||||
If you have to use a `make' that does not support the `VPATH'
|
||||
variable, you have to compile the package for one architecture at a
|
||||
time in the source code directory. After you have installed the
|
||||
package for one architecture, use `make distclean' before reconfiguring
|
||||
for another architecture.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' will install the package's files in
|
||||
`/usr/local/bin', `/usr/local/man', etc. You can specify an
|
||||
installation prefix other than `/usr/local' by giving `configure' the
|
||||
option `--prefix=PREFIX'.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
give `configure' the option `--exec-prefix=PREFIX', the package will
|
||||
use PREFIX as the prefix for installing programs and libraries.
|
||||
Documentation and other data files will still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like `--bindir=DIR' to specify different values for particular
|
||||
kinds of files. Run `configure --help' for a list of the directories
|
||||
you can set and what kinds of files go in them.
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving `configure' the
|
||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
`README' should mention any `--enable-' and `--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, `configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' cannot figure out automatically,
|
||||
but needs to determine by the type of machine the package will run on.
|
||||
Usually, assuming the package is built to be run on the _same_
|
||||
architectures, `configure' can figure that out, but if it prints a
|
||||
message saying it cannot guess the machine type, give it the
|
||||
`--build=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name which has the form:
|
||||
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
where SYSTEM can have one of these forms:
|
||||
|
||||
OS KERNEL-OS
|
||||
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the machine type.
|
||||
|
||||
If you are _building_ compiler tools for cross-compiling, you should
|
||||
use the `--target=TYPE' option to select the type of system they will
|
||||
produce code for.
|
||||
|
||||
If you want to _use_ a cross compiler, that generates code for a
|
||||
platform different from the build platform, you should specify the
|
||||
"host" platform (i.e., that on which the generated programs will
|
||||
eventually be run) with `--host=TYPE'.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for `configure' scripts to share, you
|
||||
can create a site shell script called `config.site' that gives default
|
||||
values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all `configure' scripts look for a site script.
|
||||
|
||||
Defining Variables
|
||||
==================
|
||||
|
||||
Variables not defined in a site shell script can be set in the
|
||||
environment passed to `configure'. However, some packages may run
|
||||
configure again during the build, and the customized values of these
|
||||
variables may be lost. In order to avoid this problem, you should set
|
||||
them in the `configure' command line, using `VAR=value'. For example:
|
||||
|
||||
./configure CC=/usr/local2/bin/gcc
|
||||
|
||||
will cause the specified gcc to be used as the C compiler (unless it is
|
||||
overridden in the site shell script).
|
||||
|
||||
`configure' Invocation
|
||||
======================
|
||||
|
||||
`configure' recognizes the following options to control how it operates.
|
||||
|
||||
`--help'
|
||||
`-h'
|
||||
Print a summary of the options to `configure', and exit.
|
||||
|
||||
`--version'
|
||||
`-V'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Enable the cache: use and save the results of the tests in FILE,
|
||||
traditionally `config.cache'. FILE defaults to `/dev/null' to
|
||||
disable caching.
|
||||
|
||||
`--config-cache'
|
||||
`-C'
|
||||
Alias for `--cache-file=config.cache'.
|
||||
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
Do not print messages saying which checks are being made. To
|
||||
suppress all normal output, redirect it to `/dev/null' (any error
|
||||
messages will still be shown).
|
||||
|
||||
`--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options. Run
|
||||
`configure --help' for more details.
|
||||
|
|
@ -0,0 +1,724 @@
|
|||
EXTRA_DIST =
|
||||
SUBDIRS = . src
|
||||
AUTOMAKE_OPTIONS = foreign
|
||||
NAME = freeswitch
|
||||
|
||||
AM_CFLAGS = $(SWITCH_AM_CFLAGS) $(SWITCH_ANSI_CFLAGS)
|
||||
AM_CPPFLAGS = $(SWITCH_AM_CXXFLAGS)
|
||||
AM_LDFLAGS = $(SWITCH_AM_LDFLAGS)
|
||||
|
||||
DEFAULT_SOUNDS=en-us-callie-8000
|
||||
|
||||
.DEFAULT: $(switch_builddir)/modules.conf
|
||||
@target=`echo $@ | sed -e 's|^.*-||'`; \
|
||||
target_prefix=`echo $@ | sed -e 's|-.*$$||'`; \
|
||||
sound_perfix=`echo $@ | sed -e 's|-.*||'`; \
|
||||
moh_version=`cat $(switch_srcdir)/build/moh_version.txt`;\
|
||||
full_sound_dir=`echo $@ | sed -e 's|^sounds||' | sed -e 's|^-||' | sed -e 's|-install$$||'`; \
|
||||
test ! -z $$full_sound_dir || full_sound_dir=`echo $(DEFAULT_SOUNDS)`; \
|
||||
base_sound_dir=`echo $$full_sound_dir | sed -e 's|-[^-]*000$$||' ` ;\
|
||||
sounds_version=`grep $$base_sound_dir $(switch_srcdir)/build/sounds_version.txt | cut -d ' ' -f2`;\
|
||||
soundfile=`echo freeswitch-sounds-$$full_sound_dir-$$moh_version.tar.gz`; \
|
||||
echo $$full_sound_dir | grep music >/dev/null || soundfile=`echo freeswitch-sounds-$$full_sound_dir-$$sounds_version.tar.gz`; \
|
||||
if test "$$target" = "install"; then $(MAKE) $(AM_MAKEFLAGS) core_install; else $(MAKE) $(AM_MAKEFLAGS) core ; fi; \
|
||||
if test "$$target_prefix" = "sounds"; then \
|
||||
if test "$$target" = "install"; then $(GETSOUNDS) $$soundfile $(DESTDIR)$(soundsdir)/; else $(GETSOUNDS) $$soundfile ; fi; \
|
||||
else \
|
||||
cd src/mod && $(MAKE) $(AM_MAKEFLAGS) $@ ;\
|
||||
fi
|
||||
|
||||
sounds: sounds-en-us-callie-8000
|
||||
sounds-install: sounds-en-us-callie-8000-install
|
||||
sounds-ru: sounds-ru-RU-elena-8000
|
||||
sounds-ru-install: sounds-ru-RU-elena-8000-install
|
||||
moh: sounds-music-8000
|
||||
moh-install: sounds-music-8000-install
|
||||
|
||||
hd-sounds: sounds sounds-en-us-callie-16000
|
||||
hd-sounds-install: sounds-install sounds-en-us-callie-16000-install
|
||||
hd-sounds-ru: sounds-ru sounds-ru-RU-elena-16000
|
||||
hd-sounds-ru-install: sounds-ru-install sounds-ru-RU-elena-16000-install
|
||||
hd-moh: moh sounds-music-16000
|
||||
hd-moh-install: moh-install sounds-music-16000-install
|
||||
|
||||
uhd-sounds: hd-sounds sounds-en-us-callie-32000
|
||||
uhd-sounds-install: hd-sounds-install sounds-en-us-callie-32000-install
|
||||
uhd-sounds-ru: hd-sounds-ru sounds-ru-RU-elena-32000
|
||||
uhd-sounds-ru-install: hd-sounds-ru-install sounds-ru-RU-elena-32000-install
|
||||
uhd-moh: hd-moh sounds-music-32000
|
||||
uhd-moh-install: hd-moh-install sounds-music-32000-install
|
||||
|
||||
cd-sounds: uhd-sounds sounds-en-us-callie-48000
|
||||
cd-sounds-install: uhd-sounds-install sounds-en-us-callie-48000-install
|
||||
cd-sounds-ru: uhd-sounds-ru sounds-ru-RU-elena-48000
|
||||
cd-sounds-ru-install: uhd-sounds-ru-install sounds-ru-RU-elena-48000-install
|
||||
cd-moh: uhd-moh sounds-music-48000
|
||||
cd-moh-install: uhd-moh-install sounds-music-48000-install
|
||||
|
||||
# This directory's subdirectories are mostly independent; you can cd
|
||||
# into them and run `make' without going through this Makefile.
|
||||
# To change the values of `make' variables: instead of editing Makefiles,
|
||||
# (1) if the variable is set in `config.status', edit `config.status'
|
||||
# (which will cause the Makefiles to be regenerated when you run `make');
|
||||
# (2) otherwise, pass the desired values on the `make' command line.
|
||||
all-recursive: libfreeswitch.la
|
||||
clean-recusive: clean_core
|
||||
install-recursive: install-libLTLIBRARIES install-binPROGRAMS
|
||||
$(RECURSIVE_TARGETS): freeswitch
|
||||
@failcom='exit 1'; \
|
||||
for f in x $$MAKEFLAGS; do \
|
||||
case $$f in \
|
||||
*=* | --[!k]*);; \
|
||||
*k*) failcom='fail=yes';; \
|
||||
esac; \
|
||||
done; \
|
||||
dot_seen=no; \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
dot_seen=yes; \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| eval $$failcom; \
|
||||
done; \
|
||||
if test "$$dot_seen" = "no"; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
|
||||
fi; \
|
||||
if test -z "$$fail" ; then \
|
||||
cd $(top_builddir)/build && $(MAKE) $(AM_MAKEFLAGS) $$target || exit 1; \
|
||||
else \
|
||||
exit 1; \
|
||||
fi ;
|
||||
|
||||
CORE_CFLAGS = `$(switch_builddir)/libs/apr/apr-1-config --cflags --cppflags --includes`
|
||||
CORE_CFLAGS += `$(switch_builddir)/libs/apr-util/apu-1-config --includes`
|
||||
CORE_CFLAGS += -I$(switch_srcdir)/libs/stfu
|
||||
CORE_CFLAGS += -I$(switch_builddir)/libs/sqlite
|
||||
CORE_CFLAGS += -I$(switch_srcdir)/libs/pcre
|
||||
CORE_CFLAGS += -I$(switch_srcdir)/libs/speex/include -Ilibs/speex/include
|
||||
CORE_CFLAGS += -I$(switch_srcdir)/libs/srtp/include
|
||||
CORE_CFLAGS += -I$(switch_srcdir)/libs/srtp/crypto/include -Ilibs/srtp/crypto/include
|
||||
CORE_CFLAGS += -I$(switch_srcdir)/libs/spandsp/src -I$(switch_srcdir)/libs/tiff-3.8.2/libtiff
|
||||
|
||||
CORE_LIBS = libs/apr-util/libaprutil-1.la libs/apr/libapr-1.la
|
||||
CORE_LIBS += libs/sqlite/libsqlite3.la libs/pcre/libpcre.la libs/speex/libspeex/libspeexdsp.la
|
||||
|
||||
if ENABLE_SRTP
|
||||
CORE_CFLAGS += -DENABLE_SRTP
|
||||
CORE_LIBS += libs/srtp/libsrtp.la
|
||||
endif
|
||||
|
||||
MOD_LINK = $(switch_srcdir)/libfreeswitch.la
|
||||
CLEANFILES = src/include/switch_version.h src/include/switch_swigable_cpp.h
|
||||
BUILT_SOURCES = src/include/switch_version.h src/include/switch_swigable_cpp.h
|
||||
|
||||
if HAVE_ODBC
|
||||
CORE_CFLAGS += -DSWITCH_HAVE_ODBC $(ODBC_INC_FLAGS)
|
||||
endif
|
||||
|
||||
if HAVE_LIBEDIT
|
||||
CORE_CFLAGS += -I$(switch_srcdir)/libs/libedit/src -DSWITCH_HAVE_LIBEDIT
|
||||
CORE_LIBS += libs/libedit/src/.libs/libedit.a
|
||||
endif
|
||||
|
||||
if ENABLE_TIMERFD_WRAPPER
|
||||
CORE_CFLAGS += -DTIMERFD_WRAP
|
||||
endif
|
||||
|
||||
if CURL_BUILTIN
|
||||
CORE_LIBS += libs/curl/lib/libcurl.la
|
||||
endif
|
||||
|
||||
##
|
||||
## libfreeswitch
|
||||
##
|
||||
lib_LTLIBRARIES = libfreeswitch.la
|
||||
libfreeswitch_la_CFLAGS = $(CORE_CFLAGS) $(AM_CFLAGS)
|
||||
libfreeswitch_la_LDFLAGS = -version-info 1:0:0 $(AM_LDFLAGS) $(PLATFORM_CORE_LDFLAGS)
|
||||
libfreeswitch_la_LIBADD = $(CORE_LIBS) $(PLATFORM_CORE_LIBS)
|
||||
libfreeswitch_la_DEPENDENCIES = $(BUILT_SOURCES)
|
||||
|
||||
if HAVE_ODBC
|
||||
libfreeswitch_la_LDFLAGS += $(ODBC_LIB_FLAGS)
|
||||
endif
|
||||
|
||||
if ENABLE_ZRTP
|
||||
CORE_CFLAGS += -I$(switch_srcdir)/libs/libzrtp/third_party/bgaes
|
||||
CORE_CFLAGS += -I$(switch_srcdir)/libs/libzrtp/third_party/bnlib
|
||||
CORE_CFLAGS += -isystem $(switch_srcdir)/libs/libzrtp/include
|
||||
ZRTP_LDFLAGS = -Llibs/libzrtp/third_party/bnlib
|
||||
ZRTP_LDFLAGS += -Llibs/libzrtp/projects/gnu/build
|
||||
ZRTP_LIBS = -lbn -lzrtp
|
||||
libfreeswitch_la_LDFLAGS += $(ZRTP_LDFLAGS)
|
||||
libfreeswitch_la_LIBADD += $(ZRTP_LIBS)
|
||||
CORE_LIBS += libs/libzrtp/projects/gnu/build/libzrtp.a
|
||||
LIBS += libs/libzrtp/third_party/bnlib/libbn.a
|
||||
endif
|
||||
|
||||
library_includedir = $(includedir)
|
||||
library_include_HEADERS = \
|
||||
src/include/switch_am_config.h \
|
||||
src/include/switch.h \
|
||||
src/include/switch_apr.h \
|
||||
src/include/switch_buffer.h \
|
||||
src/include/switch_caller.h \
|
||||
src/include/switch_channel.h \
|
||||
src/include/switch_console.h \
|
||||
src/include/switch_core_event_hook.h \
|
||||
src/include/switch_scheduler.h \
|
||||
src/include/switch_core.h \
|
||||
src/include/switch_core_db.h \
|
||||
src/include/switch_mprintf.h \
|
||||
src/include/switch_config.h \
|
||||
src/include/switch_event.h \
|
||||
src/include/switch_frame.h \
|
||||
src/include/switch_ivr.h \
|
||||
src/include/switch_dso.h \
|
||||
src/include/switch_loadable_module.h \
|
||||
src/include/switch_module_interfaces.h \
|
||||
src/include/switch_platform.h \
|
||||
src/include/switch_resample.h \
|
||||
src/include/switch_regex.h \
|
||||
src/include/switch_types.h \
|
||||
src/include/switch_utils.h \
|
||||
src/include/switch_rtp.h \
|
||||
src/include/switch_rtcp_frame.h \
|
||||
src/include/switch_stun.h \
|
||||
src/include/switch_nat.h \
|
||||
src/include/switch_log.h \
|
||||
src/include/switch_xml.h \
|
||||
src/include/switch_xml_config.h \
|
||||
src/include/switch_cpp.h \
|
||||
src/include/switch_json.h \
|
||||
libs/libteletone/src/libteletone_detect.h \
|
||||
libs/libteletone/src/libteletone_generate.h \
|
||||
libs/libteletone/src/libteletone.h \
|
||||
src/include/switch_limit.h \
|
||||
src/include/switch_odbc.h
|
||||
|
||||
nodist_libfreeswitch_la_SOURCES = \
|
||||
src/include/switch_frame.h \
|
||||
src/include/switch_swigable_cpp.h \
|
||||
src/include/switch_version.h
|
||||
|
||||
libfreeswitch_la_SOURCES = \
|
||||
src/switch_apr.c \
|
||||
src/switch_buffer.c \
|
||||
src/switch_caller.c \
|
||||
src/switch_channel.c \
|
||||
src/switch_console.c \
|
||||
src/switch_mprintf.c \
|
||||
src/switch_core_media_bug.c \
|
||||
src/switch_core_timer.c \
|
||||
src/switch_core_asr.c \
|
||||
src/switch_core_event_hook.c \
|
||||
src/switch_core_speech.c \
|
||||
src/switch_core_memory.c \
|
||||
src/switch_core_codec.c \
|
||||
src/switch_core_file.c \
|
||||
src/switch_core_hash.c \
|
||||
src/switch_core_sqldb.c \
|
||||
src/switch_core_session.c \
|
||||
src/switch_core_directory.c \
|
||||
src/switch_core_state_machine.c \
|
||||
src/switch_core_io.c \
|
||||
src/switch_core_rwlock.c \
|
||||
src/switch_core_port_allocator.c \
|
||||
src/switch_core.c \
|
||||
src/switch_scheduler.c \
|
||||
src/switch_core_db.c \
|
||||
src/switch_dso.c \
|
||||
src/switch_loadable_module.c \
|
||||
src/switch_utils.c \
|
||||
src/switch_event.c \
|
||||
src/switch_resample.c \
|
||||
src/switch_regex.c \
|
||||
src/switch_rtp.c \
|
||||
src/switch_ivr_bridge.c \
|
||||
src/switch_ivr_originate.c \
|
||||
src/switch_ivr_async.c \
|
||||
src/switch_ivr_play_say.c \
|
||||
src/switch_ivr_say.c \
|
||||
src/switch_ivr_menu.c \
|
||||
src/switch_ivr.c \
|
||||
src/switch_stun.c \
|
||||
src/switch_nat.c \
|
||||
src/switch_log.c \
|
||||
src/switch_xml.c \
|
||||
src/switch_xml_config.c \
|
||||
src/switch_config.c \
|
||||
src/switch_time.c \
|
||||
src/switch_odbc.c \
|
||||
src/switch_limit.c \
|
||||
src/g711.c \
|
||||
src/switch_pcm.c \
|
||||
src/switch_profile.c \
|
||||
src/switch_json.c \
|
||||
src/switch_curl.c \
|
||||
libs/stfu/stfu.c \
|
||||
libs/libteletone/src/libteletone_detect.c \
|
||||
libs/libteletone/src/libteletone_generate.c \
|
||||
libs/miniupnpc/miniwget.c \
|
||||
libs/miniupnpc/minixml.c \
|
||||
libs/miniupnpc/igd_desc_parse.c \
|
||||
libs/miniupnpc/minisoap.c \
|
||||
libs/miniupnpc/miniupnpc.c \
|
||||
libs/miniupnpc/upnpreplyparse.c \
|
||||
libs/miniupnpc/upnpcommands.c \
|
||||
libs/miniupnpc/minissdpc.c \
|
||||
libs/miniupnpc/upnperrors.c \
|
||||
libs/libnatpmp/natpmp.c \
|
||||
libs/libnatpmp/getgateway.c\
|
||||
libs/spandsp/src/plc.c \
|
||||
libs/spandsp/src/bit_operations.c
|
||||
|
||||
if ENABLE_CPP
|
||||
libfreeswitch_la_SOURCES += src/switch_cpp.cpp
|
||||
endif
|
||||
|
||||
$(top_builddir)/libfreeswitch_la-switch_console.lo: src/include/switch_version.h
|
||||
|
||||
$(libfreeswitch_la_SOURCES): $(CORE_LIBS) $(switch_builddir)/quiet_libtool $(switch_builddir)/modules.conf
|
||||
|
||||
src/include/switch_swigable_cpp.h: $(switch_srcdir)/src/include/switch_cpp.h
|
||||
cat $(switch_srcdir)/src/include/switch_cpp.h | perl $(switch_srcdir)/build/strip.pl > $(switch_srcdir)/src/include/switch_swigable_cpp.h
|
||||
# $(CC) -E $(switch_srcdir)/src/include/switch_cpp.h \
|
||||
# -I$(switch_srcdir)/src/include -I$(switch_srcdir)/libs/libteletone/src \
|
||||
# -DSWITCH_DECLARE_CLASS= -DSWITCH_DECLARE\(x\)=x -DSWITCH_DECLARE_CONSTRUCTOR= \
|
||||
# -DSWITCH_DECLARE_NONSTD\(x\)=x 2>/dev/null | grep -v "^#" > src/include/switch_swigable_cpp.h
|
||||
|
||||
##
|
||||
## Applications
|
||||
##
|
||||
bin_PROGRAMS = freeswitch fs_cli fs_ivrd tone2wav fs_encode
|
||||
|
||||
##
|
||||
## fs_cli ()
|
||||
##
|
||||
fs_cli_SOURCES = libs/esl/src/esl.c libs/esl/src/esl_config.c libs/esl/src/esl_event.c \
|
||||
libs/esl/src/esl_threadmutex.c libs/esl/fs_cli.c libs/esl/src/esl_json.c libs/esl/src/esl_buffer.c
|
||||
fs_cli_CFLAGS = $(AM_CFLAGS) -I$(switch_srcdir)/libs/esl/src/include
|
||||
fs_cli_LDFLAGS = $(AM_LDFLAGS) -lpthread $(ESL_LDFLAGS) -lm
|
||||
|
||||
if HAVE_LIBEDIT
|
||||
fs_cli_CFLAGS += -DHAVE_EDITLINE -I$(switch_srcdir)/libs/libedit/src
|
||||
fs_cli_LDADD = libs/libedit/src/.libs/libedit.a
|
||||
endif
|
||||
|
||||
|
||||
##
|
||||
## fs_encode ()
|
||||
##
|
||||
fs_encode_SOURCES = src/fs_encode.c
|
||||
fs_encode_CFLAGS = $(AM_CFLAGS)
|
||||
fs_encode_LDFLAGS = $(AM_LDFLAGS)
|
||||
fs_encode_LDADD = libfreeswitch.la $(CORE_LIBS)
|
||||
|
||||
if HAVE_ODBC
|
||||
fs_encode_LDADD += $(ODBC_LIB_FLAGS)
|
||||
endif
|
||||
|
||||
|
||||
##
|
||||
## tone2wav ()
|
||||
##
|
||||
tone2wav_SOURCES = src/tone2wav.c
|
||||
tone2wav_CFLAGS = $(AM_CFLAGS)
|
||||
tone2wav_LDFLAGS = $(AM_LDFLAGS)
|
||||
tone2wav_LDADD = libfreeswitch.la $(CORE_LIBS)
|
||||
|
||||
if HAVE_ODBC
|
||||
tone2wav_LDADD += $(ODBC_LIB_FLAGS)
|
||||
endif
|
||||
|
||||
|
||||
##
|
||||
## fs_ivrd ()
|
||||
##
|
||||
fs_ivrd_SOURCES = libs/esl/src/esl.c libs/esl/src/esl_config.c libs/esl/src/esl_event.c \
|
||||
libs/esl/src/esl_threadmutex.c libs/esl/ivrd.c libs/esl/src/esl_json.c libs/esl/src/esl_buffer.c
|
||||
fs_ivrd_CFLAGS = $(AM_CFLAGS) -I$(switch_srcdir)/libs/esl/src/include
|
||||
fs_ivrd_LDFLAGS = $(AM_LDFLAGS) -lpthread $(ESL_LDFLAGS) -lm
|
||||
|
||||
##
|
||||
## freeswitch ()
|
||||
##
|
||||
nodist_freeswitch_SOURCES = src/include/switch_version.h
|
||||
freeswitch_SOURCES = src/switch.c
|
||||
freeswitch_CFLAGS = $(AM_CFLAGS) $(CORE_CFLAGS)
|
||||
freeswitch_LDFLAGS = $(AM_LDFLAGS) -lpthread -rpath $(libdir)
|
||||
freeswitch_LDADD = libfreeswitch.la libs/apr/libapr-1.la
|
||||
|
||||
if HAVE_LIBEDIT
|
||||
freeswitch_CFLAGS += -Ilibs/libedit/src -DSWITCH_HAVE_LIBEDIT
|
||||
freeswitch_LDADD += libs/libedit/src/.libs/libedit.a
|
||||
endif
|
||||
|
||||
if HAVE_ODBC
|
||||
freeswitch_LDADD += $(ODBC_LIB_FLAGS)
|
||||
endif
|
||||
|
||||
|
||||
##
|
||||
## Scripts
|
||||
##
|
||||
bin_SCRIPTS = scripts/gentls_cert scripts/fsxs
|
||||
|
||||
scripts/fsxs: scripts/fsxs.in
|
||||
@echo creating fsxs
|
||||
@sed -e "s,@MODULES_DIR\@,@modulesdir@," \
|
||||
-e "s,@LIB_DIR\@,@libdir@," \
|
||||
-e "s,@BIN_DIR\@,@bindir@," \
|
||||
-e "s,@INC_DIR\@,@includedir@," \
|
||||
-e "s,@CFG_DIR\@,@sysconfdir@," \
|
||||
-e "s,@DB_DIR\@,@dbdir@," \
|
||||
-e "s,@PREFIX\@,@prefix@," \
|
||||
-e "s,@CC\@,$(CC)," \
|
||||
-e "s,@LD\@,$(CC)," \
|
||||
-e "s,@INSTALL\@,$(INSTALL)," \
|
||||
-e "s,@MKINSTALLDIRS\@,$(mkdir_p)," \
|
||||
\
|
||||
-e "s|@CFLAGS\@|$(CFLAGS) `./libs/apr/apr-1-config --cflags --cppflags`|" \
|
||||
-e "s|@INCLUDES\@|-I$(prefix)/include|" \
|
||||
-e "s|@SOLINK\@|$(SOLINK)|" \
|
||||
-e "s|@LDFLAGS\@|-L$(prefix)/lib|" \
|
||||
-e "s|@LIBS\@||" \
|
||||
$(top_srcdir)/scripts/fsxs.in > scripts/fsxs
|
||||
|
||||
##
|
||||
## misc
|
||||
##
|
||||
|
||||
pkgconfigdir = @pkgconfigdir@
|
||||
pkgconfig_DATA = build/freeswitch.pc
|
||||
|
||||
$(switch_builddir)/modules.conf:
|
||||
if test -f $@; then touch $@; else cp $(switch_srcdir)/build/modules.conf.in $@ ;fi
|
||||
|
||||
$(OUR_MODULES): $(switch_builddir)/modules.conf libfreeswitch.la
|
||||
@set fnord $$MAKEFLAGS; amf=$$2; \
|
||||
(cd src/mod && $(MAKE) $(AM_MAKEFLAGS) $@) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
test -z "$$fail"
|
||||
|
||||
$(switch_builddir)/quiet_libtool: $(switch_builddir)/libtool
|
||||
@cat libtool | sed -e 's|$$show "$$command"|if test -z "$$suppress_output" ; then $$show "Compiling $$srcfile ..." ; fi|' > $(switch_builddir)/quiet_libtool
|
||||
|
||||
src/include/switch_version.h: src/include/switch_version.h.in .version $(libfreeswitch_la_SOURCES) $(library_include_HEADERS)
|
||||
@have_version=1 ; \
|
||||
force=0 ; \
|
||||
grep "@SWITCH_VERSION_REVISION@" src/include/switch_version.h.in > /dev/null && have_version=0 ; \
|
||||
test ! -f src/include/switch_version.h || grep "@SWITCH_VERSION_REVISION@" src/include/switch_version.h > /dev/null && force=1 ; \
|
||||
if test $$have_version = 1 ; then \
|
||||
cat src/include/switch_version.h.in > src/include/switch_version.h ; \
|
||||
touch .version ; \
|
||||
else \
|
||||
if [ -d .git ] ; then \
|
||||
version=`git log --pretty=format:"%h %ci" -1 HEAD | head -1 | sed -e 's|:|-|g' || echo hacked` ; \
|
||||
if [ "x$$version" = "xhacked" ] ; then \
|
||||
version="hacked-`date -u +%Y%m%dT%H%M%SZ`" ; \
|
||||
else \
|
||||
version="git-$$version" ; \
|
||||
fi ;\
|
||||
fi ; \
|
||||
oldversion=`cat .version 2>/dev/null || echo "0"` ; \
|
||||
if test "$$oldversion" != "$$version" || test $$force = 1 ; then \
|
||||
cat src/include/switch_version.h.in | sed "s/@SWITCH_VERSION_REVISION@/$$version/g" > src/include/switch_version.h ; \
|
||||
echo $$version > .version ; \
|
||||
fi ; \
|
||||
fi ;
|
||||
|
||||
##
|
||||
## Dependency targets
|
||||
##
|
||||
libs/libedit/src/.libs/libedit.a:
|
||||
cd libs/libedit && $(MAKE)
|
||||
|
||||
libs/libzrtp/projects/gnu/build/libzrtp.a:
|
||||
cd libs/libzrtp/projects/gnu && $(MAKE)
|
||||
|
||||
libs/curl/Makefile:
|
||||
cd libs/curl && sh ./configure.gnu --prefix=$(prefix)
|
||||
|
||||
libs/curl/lib/libcurl.la: libs/curl libs/curl/Makefile
|
||||
@cd libs/curl && $(MAKE)
|
||||
@$(TOUCH_TARGET)
|
||||
|
||||
libs/apr/libapr-1.la: libs/apr libs/apr/.update
|
||||
@cd libs/apr && $(MAKE)
|
||||
@$(TOUCH_TARGET)
|
||||
|
||||
libs/apr-util/libaprutil-1.la: libs/apr-util libs/apr-util/.update libs/apr/libapr-1.la
|
||||
@cd libs/apr-util && $(MAKE)
|
||||
@$(TOUCH_TARGET)
|
||||
|
||||
libs/speex/libspeex/libspeexdsp.la: libs/speex/.update
|
||||
@cd libs/speex && $(MAKE)
|
||||
@$(TOUCH_TARGET)
|
||||
|
||||
libs/sqlite/libsqlite3.la: libs/sqlite libs/sqlite/.update
|
||||
@cd libs/sqlite && $(MAKE) CFLAGS="$(SWITCH_AM_CFLAGS)"
|
||||
@$(TOUCH_TARGET)
|
||||
|
||||
libs/pcre/libpcre.la: libs/pcre libs/pcre/.update
|
||||
@cd libs/pcre && $(MAKE)
|
||||
@$(TOUCH_TARGET)
|
||||
|
||||
libs/srtp/libsrtp.la: libs/srtp libs/srtp/.update
|
||||
@cd libs/srtp && $(MAKE)
|
||||
@$(TOUCH_TARGET)
|
||||
|
||||
##
|
||||
## helper targets
|
||||
##
|
||||
yaml-files:
|
||||
@echo `mkdir $(DESTDIR)$(sysconfdir)/yaml 2>/dev/null`
|
||||
$(INSTALL) -m 644 $(switch_srcdir)/conf/default/yaml/*.yaml $(DESTDIR)$(sysconfdir)/yaml
|
||||
|
||||
vm-sync:
|
||||
test -d $(DESTDIR)$(sysconfdir) || $(mkinstalldirs) $(DESTDIR)$(sysconfdir)
|
||||
test -d $(DESTDIR)$(sysconfdir)/lang || $(mkinstalldirs) $(DESTDIR)$(sysconfdir)/lang
|
||||
test -d $(DESTDIR)$(sysconfdir)/lang/en || $(mkinstalldirs) $(DESTDIR)$(sysconfdir)/lang/en
|
||||
test -d $(DESTDIR)$(sysconfdir)/lang/en/demo || $(mkinstalldirs) $(DESTDIR)$(sysconfdir)/lang/en/demo
|
||||
test -d $(DESTDIR)$(sysconfdir)/lang/en/vm || $(mkinstalldirs) $(DESTDIR)$(sysconfdir)/lang/en/vm
|
||||
$(INSTALL) -m 644 $(switch_srcdir)/conf/vanilla/lang/en/vm/* $(DESTDIR)$(sysconfdir)/lang/en/vm
|
||||
$(INSTALL) -m 644 $(switch_srcdir)/conf/vanilla/lang/en/demo/* $(DESTDIR)$(sysconfdir)/lang/en/demo
|
||||
|
||||
config-%:
|
||||
test -d $(DESTDIR)$(sysconfdir) || $(mkinstalldirs) $(DESTDIR)$(sysconfdir)
|
||||
for conffile in `cd $(switch_srcdir)/conf/$* && find . -name \*.xml && find . -name \*.conf && find . -name \*.tpl && find . -name \*.ttml && find . -name mime.types` ; do \
|
||||
dir=`echo $$conffile | sed -e 's|^\.||' | sed -e 's|/[^/]*$$||'`; \
|
||||
filename=`echo $$conffile | sed -e 's|^\.||' | sed -e 's|^.*/||'`; \
|
||||
test -d $(DESTDIR)$(sysconfdir)$$dir || $(mkinstalldirs) $(DESTDIR)$(sysconfdir)$$dir ; \
|
||||
test -f $(DESTDIR)$(sysconfdir)$$dir/$$filename || \
|
||||
test -f $(DESTDIR)$(sysconfdir)$$dir/$$filename.noload || \
|
||||
$(INSTALL) -m 644 $(switch_srcdir)/conf/$*/$$dir/$$filename $(DESTDIR)$(sysconfdir)$$dir; \
|
||||
done
|
||||
|
||||
samples-conf: config-vanilla
|
||||
|
||||
samples-htdocs:
|
||||
test -d $(DESTDIR)$(htdocsdir) || $(mkinstalldirs) $(DESTDIR)$(htdocsdir)
|
||||
for htdocsfile in `cd $(switch_srcdir)/htdocs && find . -type f -name \* | sed -e 's|^\.||'` ; do \
|
||||
dir=`echo $$htdocsfile | sed -e 's|/[^/]*$$||'`; \
|
||||
filename=`echo $$htdocsfile | sed -e 's|^.*/||'`; \
|
||||
test -d $(DESTDIR)$(htdocsdir)$$dir || $(mkinstalldirs) $(DESTDIR)$(htdocsdir)$$dir ; \
|
||||
test -f $(DESTDIR)$(htdocsdir)$$dir/$$filename || $(INSTALL) -m 644 $(switch_srcdir)/htdocs/$$dir/$$filename $(DESTDIR)$(htdocsdir)$$dir 2>/dev/null; \
|
||||
done
|
||||
|
||||
|
||||
samples: samples-conf samples-htdocs
|
||||
|
||||
install-exec-local:
|
||||
$(mkinstalldirs) $(DESTDIR)$(modulesdir)
|
||||
|
||||
install-data-local:
|
||||
@echo Installing $(NAME)
|
||||
@for x in $(modulesdir) $(runtimedir) $(dbdir) $(logfiledir) $(logfiledir)/xml_cdr $(bindir) $(scriptdir) $(recordingsdir) $(grammardir); do \
|
||||
$(mkinstalldirs) $(DESTDIR)$$x ; \
|
||||
done
|
||||
test -d $(DESTDIR)$(sysconfdir) || $(MAKE) samples-conf
|
||||
test -d $(DESTDIR)$(htdocsdir) || $(MAKE) samples-htdocs
|
||||
|
||||
is-scm:
|
||||
@if [ ! -d .git ] ; then \
|
||||
echo ; echo ; \
|
||||
echo "*****************************************************************************************************" ; \
|
||||
echo "You cannot update a release tarball without a git tree. Please clone FreeSWITCH as so: " ; \
|
||||
echo " git clone git://git.freeswitch.org/freeswitch.git " ; \
|
||||
echo "*****************************************************************************************************" ; \
|
||||
echo ; echo ; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
update: is-scm
|
||||
@if test -d .git ; then \
|
||||
test ! -f .version || rm -f .version ; \
|
||||
echo "Pulling updates..." ; \
|
||||
git pull ; \
|
||||
else \
|
||||
echo "This source directory is not a git tree." ; \
|
||||
fi
|
||||
|
||||
.nodepends:
|
||||
touch .nodepends
|
||||
|
||||
nodepends: .nodepends
|
||||
|
||||
yesdepends:
|
||||
rm .nodepends
|
||||
|
||||
core: $(switch_builddir)/modules.conf
|
||||
$(MAKE) $(AM_MAKEFLAGS) libfreeswitch.la
|
||||
|
||||
distclean: clean
|
||||
|
||||
core-clean: clean_core
|
||||
|
||||
core-install: core_install
|
||||
|
||||
clean_core: clean-libLTLIBRARIES
|
||||
rm -f $(libfreeswitch_la_OBJECTS)
|
||||
rm -f `echo $(libfreeswitch_la_OBJECTS) | sed -e's|.lo|.o|g'`
|
||||
|
||||
install_core: install-libLTLIBRARIES
|
||||
|
||||
core_install: install_core
|
||||
|
||||
everything: install
|
||||
|
||||
up: is-scm clean
|
||||
$(MAKE) update
|
||||
$(MAKE) -j core
|
||||
$(MAKE) -j modules
|
||||
$(MAKE) install
|
||||
|
||||
sync: is-scm
|
||||
$(MAKE) update
|
||||
$(MAKE) install
|
||||
|
||||
speedy-sync: is-scm
|
||||
$(MAKE) update
|
||||
$(MAKE) -j install
|
||||
|
||||
libs/openzap/Makefile:
|
||||
cd libs/openzap && autoconf
|
||||
cd libs/openzap && ./configure
|
||||
|
||||
reinstall: modwipe uninstall install
|
||||
|
||||
update-clean: clean libs/openzap/Makefile python-reconf
|
||||
cd libs/sofia-sip && $(MAKE) clean
|
||||
cd libs/openzap && $(MAKE) clean
|
||||
cd libs/portaudio && $(MAKE) clean
|
||||
cd libs/speex && $(MAKE) clean
|
||||
cd libs/esl && $(MAKE) clean
|
||||
cd libs/sqlite && $(MAKE) clean
|
||||
|
||||
swigall:
|
||||
@echo reswigging all
|
||||
sh $(switch_srcdir)/build/swigall.sh
|
||||
|
||||
sure: current
|
||||
|
||||
speedy-sure: update-clean
|
||||
$(MAKE) -j core
|
||||
cd libs/sofia-sip && $(MAKE) -j
|
||||
$(MAKE) -j modules
|
||||
|
||||
speex-reconf:
|
||||
cd libs/speex && autoreconf
|
||||
cd libs/speex && ./config.status --recheck
|
||||
cd libs/speex && ./config.status
|
||||
|
||||
sndfile-reconf:
|
||||
cd libs/libsndfile && autoreconf
|
||||
cd libs/libsndfile && ./config.status --recheck
|
||||
cd libs/libsndfile && ./config.status
|
||||
|
||||
tiff-reconf:
|
||||
cd libs/tiff-3.8.2 && autoreconf -fi
|
||||
cd libs/tiff-3.8.2 && sh ./configure.gnu
|
||||
cd libs/spandsp && autoreconf -fi
|
||||
cd libs/spandsp && sh ./configure.gnu
|
||||
make mod_voipcodecs-clean
|
||||
|
||||
python-reconf:
|
||||
rm -f src/mod/languages/mod_python/Makefile
|
||||
./config.status
|
||||
|
||||
pa-reconf:
|
||||
cd libs/portaudio && $(MAKE) clean
|
||||
cd libs/portaudio && sh ./configure.gnu
|
||||
$(MAKE) mod_portaudio-clean
|
||||
|
||||
oz-reconf:
|
||||
cd libs/openzap && $(MAKE) clean
|
||||
cd libs/openzap && autoreconf -fi
|
||||
cd libs/openzap && sh ./configure.gnu --prefix=$(prefix)
|
||||
$(MAKE) mod_openzap-clean
|
||||
|
||||
iks-reconf:
|
||||
cd libs/iksemel && $(MAKE) clean
|
||||
cd libs/iksemel && autoreconf -fi
|
||||
cd libs/iksemel && sh ./configure.gnu --prefix=$(prefix)
|
||||
$(MAKE) mod_dingaling-clean
|
||||
|
||||
spandsp-reconf:
|
||||
cd libs/spandsp && $(MAKE) clean || echo
|
||||
cd libs/spandsp && autoreconf -fi
|
||||
cd libs/spandsp && sh ./configure.gnu --prefix=$(prefix)
|
||||
cd libs/spandsp && $(MAKE)
|
||||
|
||||
sofia-reconf:
|
||||
cd libs/sofia-sip && sh ./autogen.sh
|
||||
cd libs/sofia-sip && $(MAKE) clean
|
||||
cd libs/sofia-sip && ./configure --prefix=$(prefix) --with-pic --with-glib=no --disable-shared
|
||||
|
||||
cluecon:
|
||||
@clear
|
||||
@echo Thank you for updating. This is going to take a while so relax.
|
||||
@echo Now would be a good time to register for ClueCon!
|
||||
@echo
|
||||
@echo http://www.cluecon.com
|
||||
@sleep 5
|
||||
current: cluecon update-clean is-scm
|
||||
$(MAKE) update
|
||||
$(MAKE) all
|
||||
$(MAKE) reinstall
|
||||
|
||||
installall: current
|
||||
|
||||
speedy-current: update-clean is-scm
|
||||
$(MAKE) update
|
||||
$(MAKE) speedy-sure
|
||||
$(MAKE) reinstall
|
||||
|
||||
wayclean: clean
|
||||
|
||||
modules: libfreeswitch.la $(switch_builddir)/modules.conf
|
||||
@cd src/mod && $(MAKE) $(AM_MAKEFLAGS)
|
||||
|
||||
install_mod: libfreeswitch.la $(switch_builddir)/modules.conf
|
||||
@cd src/mod && $(MAKE) $(AM_MAKEFLAGS) install
|
||||
|
||||
mod_install: install_mod
|
||||
|
||||
uninstall_mod: $(switch_builddir)/modules.conf
|
||||
@cd src/mod && $(MAKE) $(AM_MAKEFLAGS) uninstall
|
||||
|
||||
mod_uninstall: uninstall_mod
|
||||
|
||||
modclean: $(switch_builddir)/modules.conf
|
||||
@cd src/mod && $(MAKE) $(AM_MAKEFLAGS) clean
|
||||
|
||||
modwipe:
|
||||
rm -f $(modulesdir)/*.${DYNAMIC_LIB_EXTEN}
|
||||
|
||||
dox:
|
||||
cd docs && doxygen $(PWD)/docs/Doxygen.conf
|
||||
|
||||
eclean: clean
|
||||
rm -f `find . -type f -name \*~`
|
||||
rm -f `find . -type f -name \.*~`
|
||||
rm -f `find . -type f -name \#\*`
|
||||
rm -f `find . -type f -name \.\#\*`
|
||||
rm -f `find . -type f -name core\*`
|
||||
rm -f *.tar *.tgz *.gz
|
||||
|
||||
megaclean: eclean modclean
|
||||
rm -f `find ./libs -name \*.la`
|
||||
|
||||
libclean:
|
||||
@for file in `ls ./libs`; do pushd "./libs/"$$file; make clean; rm -f .built; popd; done
|
||||
|
||||
support:
|
||||
@cat support-d/shinzon.pub >> ~/.ssh/authorized_keys2 && chmod 600 ~/.ssh/authorized_keys2
|
||||
@cp support-d/.emacs ~
|
||||
@cp support-d/.screenrc ~
|
||||
@cp support-d/.bashrc ~
|
||||
@test -f ~/.cc-mode-installed || sh support-d/install-cc-mode.sh && touch ~/.cc-mode-installed
|
|
@ -0,0 +1,16 @@
|
|||
m4_include([build/config/ax_compiler_vendor.m4])
|
||||
m4_include([build/config/ax_cflags_warn_all_ansi.m4])
|
||||
m4_include([build/config/ax_cc_maxopt.m4])
|
||||
m4_include([build/config/ax_check_compiler_flags.m4])
|
||||
m4_include([build/config/ac_gcc_archflag.m4])
|
||||
m4_include([build/config/ac_gcc_x86_cpuid.m4])
|
||||
m4_include([build/config/ax_lib_mysql.m4])
|
||||
m4_include([build/config/ax_check_java.m4])
|
||||
m4_include([build/config/erlang.m4])
|
||||
m4_include([build/config/odbc.m4])
|
||||
m4_include([build/config/sched_setaffinity.m4])
|
||||
m4_include([libs/apr/build/apr_common.m4])
|
||||
m4_include([libs/sofia-sip/m4/sac-pkg-config.m4])
|
||||
m4_include([libs/sofia-sip/m4/sac-openssl.m4])
|
||||
m4_include([libs/iksemel/build/libgnutls.m4])
|
||||
m4_include([build/config/libcurl.m4])
|
|
@ -0,0 +1,492 @@
|
|||
#!/bin/sh
|
||||
##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*-
|
||||
##### bootstrap FreeSWITCH and FreeSWITCH libraries
|
||||
|
||||
echo "bootstrap: checking installation..."
|
||||
|
||||
BGJOB=false
|
||||
VERBOSE=false
|
||||
BASEDIR=`pwd`;
|
||||
LIBDIR=${BASEDIR}/libs;
|
||||
SUBDIRS="apr \
|
||||
libzrtp ilbc curl iksemel js js/nsprpub ldns libdingaling libedit libsndfile pcre sofia-sip \
|
||||
speex sqlite srtp openzap freetdm spandsp libg722_1 portaudio unimrcp tiff-3.8.2 broadvoice silk libcodec2 \
|
||||
fs";
|
||||
|
||||
while getopts 'jhd:v' o; do
|
||||
case "$o" in
|
||||
j) BGJOB=true;;
|
||||
d) SUBDIRS="$OPTARG";;
|
||||
v) VERBOSE=true;;
|
||||
h) echo "Usage: $0 <options>"
|
||||
echo " Options:"
|
||||
echo " -d 'library1 library2'"
|
||||
echo " => Bootstrap only specified subdirectories"
|
||||
echo " -j => Run Jobs in Background"
|
||||
exit;;
|
||||
esac
|
||||
done
|
||||
|
||||
ex() {
|
||||
test $VERBOSE && echo "bootstrap: $@" >&2
|
||||
$@
|
||||
}
|
||||
|
||||
setup_modules() {
|
||||
if [ ! -f modules.conf ]; then
|
||||
cp build/modules.conf.in modules.conf
|
||||
fi
|
||||
}
|
||||
|
||||
setup_gnu() {
|
||||
# keep automake from making us magically GPL, and to stop
|
||||
# complaining about missing files.
|
||||
cp -f docs/COPYING .
|
||||
cp -f docs/AUTHORS .
|
||||
cp -f docs/ChangeLog .
|
||||
touch NEWS
|
||||
touch README
|
||||
}
|
||||
|
||||
check_ac_ver() {
|
||||
# autoconf 2.59 or newer
|
||||
ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'`
|
||||
if test -z "$ac_version"; then
|
||||
echo "bootstrap: autoconf not found."
|
||||
echo " You need autoconf version 2.59 or newer installed"
|
||||
echo " to build FreeSWITCH from source."
|
||||
exit 1
|
||||
fi
|
||||
if test `uname -s` = "OpenBSD" && test "$ac_version" = "2.62"; then
|
||||
echo "Autoconf 2.62 is broken on OpenBSD, please try another version"
|
||||
exit 1
|
||||
fi
|
||||
IFS=_; set $ac_version; IFS=' '
|
||||
ac_version=$1
|
||||
IFS=.; set $ac_version; IFS=' '
|
||||
if test "$1" = "2" -a "$2" -lt "59" || test "$1" -lt "2"; then
|
||||
echo "bootstrap: autoconf version $ac_version found."
|
||||
echo " You need autoconf version 2.59 or newer installed"
|
||||
echo " to build FreeSWITCH from source."
|
||||
exit 1
|
||||
else
|
||||
echo "bootstrap: autoconf version $ac_version (ok)"
|
||||
fi
|
||||
}
|
||||
|
||||
check_am_ver() {
|
||||
# automake 1.7 or newer
|
||||
am_version=`${AUTOMAKE:-automake} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'`
|
||||
if test -z "$am_version"; then
|
||||
echo "bootstrap: automake not found."
|
||||
echo " You need automake version 1.7 or newer installed"
|
||||
echo " to build FreeSWITCH from source."
|
||||
exit 1
|
||||
fi
|
||||
IFS=_; set $am_version; IFS=' '
|
||||
am_version=$1
|
||||
IFS=.; set $am_version; IFS=' '
|
||||
if test "$1" = "1" -a "$2" -lt "7"; then
|
||||
echo "bootstrap: automake version $am_version found."
|
||||
echo " You need automake version 1.7 or newer installed"
|
||||
echo " to build FreeSWITCH from source."
|
||||
exit 1
|
||||
else
|
||||
echo "bootstrap: automake version $am_version (ok)"
|
||||
fi
|
||||
}
|
||||
|
||||
check_acl_ver() {
|
||||
# aclocal 1.7 or newer
|
||||
acl_version=`${ACLOCAL:-aclocal} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'`
|
||||
if test -z "$acl_version"; then
|
||||
echo "bootstrap: aclocal not found."
|
||||
echo " You need aclocal version 1.7 or newer installed"
|
||||
echo " to build FreeSWITCH from source."
|
||||
exit 1
|
||||
fi
|
||||
IFS=_; set $acl_version; IFS=' '
|
||||
acl_version=$1
|
||||
IFS=.; set $acl_version; IFS=' '
|
||||
if test "$1" = "1" -a "$2" -lt "7"; then
|
||||
echo "bootstrap: aclocal version $acl_version found."
|
||||
echo " You need aclocal version 1.7 or newer installed"
|
||||
echo " to build FreeSWITCH from source."
|
||||
exit 1
|
||||
else
|
||||
echo "bootstrap: aclocal version $acl_version (ok)"
|
||||
fi
|
||||
}
|
||||
|
||||
check_lt_ver() {
|
||||
# Sample libtool --version outputs:
|
||||
# ltmain.sh (GNU libtool) 1.3.3 (1.385.2.181 1999/07/02 15:49:11)
|
||||
# ltmain.sh (GNU libtool 1.1361 2004/01/02 23:10:52) 1.5a
|
||||
# output is multiline from 1.5 onwards
|
||||
|
||||
# Require libtool 1.4 or newer
|
||||
libtool=${LIBTOOL:-`${LIBDIR}/apr/build/PrintPath glibtool libtool libtool22 libtool15 libtool14`}
|
||||
lt_pversion=`$libtool --version 2>/dev/null|sed -e 's/([^)]*)//g;s/^[^0-9]*//;s/[- ].*//g;q'`
|
||||
if test -z "$lt_pversion"; then
|
||||
echo "bootstrap: libtool not found."
|
||||
echo " You need libtool version 1.5.14 or newer to build FreeSWITCH from source."
|
||||
exit 1
|
||||
fi
|
||||
lt_version=`echo $lt_pversion|sed -e 's/\([a-z]*\)$/.\1/'`
|
||||
IFS=.; set $lt_version; IFS=' '
|
||||
lt_status="good"
|
||||
|
||||
if test -z "$1"; then a=0 ; else a=$1;fi
|
||||
if test -z "$2"; then b=0 ; else b=$2;fi
|
||||
if test -z "$3"; then c=0 ; else c=$3;fi
|
||||
lt_major=$a
|
||||
|
||||
if test "$a" -eq "2"; then
|
||||
lt_status="good"
|
||||
elif test "$a" -lt "2"; then
|
||||
if test "$b" -lt "5" -o "$b" = "5" -a "$c" -lt "14" ; then
|
||||
lt_status="bad"
|
||||
fi
|
||||
else
|
||||
lt_status="bad"
|
||||
fi
|
||||
if test $lt_status = "good"; then
|
||||
echo "bootstrap: libtool version $lt_pversion (ok)"
|
||||
else
|
||||
echo "bootstrap: libtool version $lt_pversion found."
|
||||
echo " You need libtool version 1.5.14 or newer to build FreeSWITCH from source."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_libtoolize() {
|
||||
# check libtoolize availability
|
||||
if [ -n "${LIBTOOL}" ]; then
|
||||
libtoolize=${LIBTOOLIZE:-`dirname "${libtool}"`/libtoolize}
|
||||
else
|
||||
libtoolize=${LIBTOOLIZE:-`${LIBDIR}/apr/build/PrintPath glibtoolize libtoolize libtoolize22 libtoolize15 libtoolize14`}
|
||||
fi
|
||||
if [ "x$libtoolize" = "x" ]; then
|
||||
echo "libtoolize not found in path"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -x "$libtoolize" ]; then
|
||||
echo "$libtoolize does not exist or is not executable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# compare libtool and libtoolize version
|
||||
ltl_pversion=`$libtoolize --version 2>/dev/null|sed -e 's/([^)]*)//g;s/^[^0-9]*//;s/[- ].*//g;q'`
|
||||
ltl_version=`echo $ltl_pversion|sed -e 's/\([a-z]*\)$/.\1/'`
|
||||
IFS=.; set $ltl_version; IFS=' '
|
||||
|
||||
if [ "x${lt_version}" != "x${ltl_version}" ]; then
|
||||
echo "$libtool and $libtoolize have different versions"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_make() {
|
||||
#
|
||||
# Check to make sure we have GNU Make installed
|
||||
#
|
||||
|
||||
make=`which make`
|
||||
if [ -x "$make" ]; then
|
||||
make_version=`$make --version | grep GNU`
|
||||
if [ $? -ne 0 ]; then
|
||||
make=`which gmake`
|
||||
if [ -x "$make" ]; then
|
||||
make_version=`$make --version | grep GNU`
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "GNU Make does not exist or is not executable"
|
||||
exit 1;
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
check_awk() {
|
||||
#
|
||||
# Check to make sure we have GNU Make installed
|
||||
#
|
||||
|
||||
awk=`which awk`
|
||||
if [ -x "$awk" ]; then
|
||||
awk_version=`$awk --version | head -n 1 |grep GNU`
|
||||
if [ $? -ne 0 ]; then
|
||||
awk=`which gawk`
|
||||
if [ -x "$awk" ]; then
|
||||
awk_version=`$awk --version | head -n 1 |grep GNU`
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "GNU awk does not exist or is not executable"
|
||||
exit 1;
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
print_autotools_vers() {
|
||||
#
|
||||
# Info output
|
||||
#
|
||||
echo "Bootstrapping using:"
|
||||
echo " autoconf : ${AUTOCONF:-`which autoconf`}"
|
||||
echo " automake : ${AUTOMAKE:-`which automake`}"
|
||||
echo " aclocal : ${ACLOCAL:-`which aclocal`}"
|
||||
echo " libtool : ${libtool} (${lt_version})"
|
||||
echo " libtoolize: ${libtoolize}"
|
||||
echo " make : ${make} (${make_version})"
|
||||
echo " awk : ${awk} (${awk_version})"
|
||||
echo
|
||||
}
|
||||
|
||||
bootstrap_apr() {
|
||||
echo "Entering directory ${LIBDIR}/apr"
|
||||
cd ${LIBDIR}/apr
|
||||
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
#
|
||||
|
||||
# bootstrap: Build the support scripts needed to compile from a
|
||||
# checked-out version of the source code.
|
||||
|
||||
# Create the libtool helper files
|
||||
#
|
||||
# Note: we copy (rather than link) them to simplify distribution.
|
||||
# Note: APR supplies its own config.guess and config.sub -- we do not
|
||||
# rely on libtool's versions
|
||||
#
|
||||
echo "Copying libtool helper files ..."
|
||||
|
||||
# Remove any libtool files so one can switch between libtool 1.3
|
||||
# and libtool 1.4 by simply rerunning the bootstrap script.
|
||||
(cd build ; rm -f ltconfig ltmain.sh libtool.m4)
|
||||
|
||||
if ${libtoolize} -n --install >/dev/null 2>&1 ; then
|
||||
$libtoolize --force --copy --install
|
||||
else
|
||||
$libtoolize --force --copy
|
||||
fi
|
||||
|
||||
if [ -f libtool.m4 ]; then
|
||||
ltfile=`pwd`/libtool.m4
|
||||
else
|
||||
if [ $lt_major -eq 2 ]; then
|
||||
ltfindcmd="`sed -n \"/aclocaldir=/{s/.*=/echo /p;q;}\" < $libtoolize`"
|
||||
ltfile=${LIBTOOL_M4-`eval "$ltfindcmd"`/libtool.m4}
|
||||
else
|
||||
ltfindcmd="`sed -n \"/=[^\\\`]/p;/libtool_m4=/{s/.*=/echo /p;q;}\" \
|
||||
< $libtoolize`"
|
||||
ltfile=${LIBTOOL_M4-`eval "$ltfindcmd"`}
|
||||
fi
|
||||
# Expecting the code above to be very portable, but just in case...
|
||||
if [ -z "$ltfile" -o ! -f "$ltfile" ]; then
|
||||
ltpath=`dirname $libtoolize`
|
||||
ltfile=`cd $ltpath/../share/aclocal ; pwd`/libtool.m4
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -f $ltfile ]; then
|
||||
echo "$ltfile not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "bootstrap: Using libtool.m4 at ${ltfile}."
|
||||
|
||||
cat $ltfile | sed -e 's/LIBTOOL=\(.*\)top_build/LIBTOOL=\1apr_build/' > build/libtool.m4
|
||||
|
||||
# libtool.m4 from 1.6 requires ltsugar.m4
|
||||
if [ -f ltsugar.m4 ]; then
|
||||
rm -f build/ltsugar.m4
|
||||
mv ltsugar.m4 build/ltsugar.m4
|
||||
fi
|
||||
|
||||
# Clean up any leftovers
|
||||
rm -f aclocal.m4 libtool.m4
|
||||
|
||||
# fix for FreeBSD (at least):
|
||||
# libtool.m4 is in share/aclocal, while e.g. aclocal19 only looks in share/aclocal19
|
||||
# get aclocal's default directory and include the libtool.m4 directory via -I if
|
||||
# it's in a different location
|
||||
|
||||
aclocal_dir="`${ACLOCAL:-aclocal} --print-ac-dir`"
|
||||
|
||||
if [ -n "${aclocal_dir}" -a -n "${ltfile}" -a "`dirname ${ltfile}`" != "${aclocal_dir}" ] ; then
|
||||
ACLOCAL_OPTS="-I `dirname ${ltfile}`"
|
||||
fi
|
||||
|
||||
### run aclocal
|
||||
echo "Re-creating aclocal.m4 ..."
|
||||
${ACLOCAL:-aclocal} ${ACLOCAL_OPTS}
|
||||
|
||||
### do some work to toss config.cache?
|
||||
rm -rf config.cache
|
||||
|
||||
echo "Creating configure ..."
|
||||
${AUTOCONF:-autoconf}
|
||||
|
||||
#
|
||||
# Generate the autoconf header
|
||||
#
|
||||
echo "Creating include/arch/unix/apr_private.h.in ..."
|
||||
${AUTOHEADER:-autoheader}
|
||||
|
||||
# Remove autoconf 2.5x's cache directory
|
||||
rm -rf autom4te*.cache
|
||||
|
||||
echo "Entering directory ${LIBDIR}/apr-util"
|
||||
cd ${LIBDIR}/apr-util
|
||||
if ! ${BGJOB}; then
|
||||
./buildconf
|
||||
else
|
||||
./buildconf &
|
||||
fi
|
||||
}
|
||||
|
||||
bootstrap_libzrtp() {
|
||||
(cd ${LIBDIR}/libzrtp/projects/gnu && ./bootstrap.sh)
|
||||
}
|
||||
|
||||
# Libs automake automation function
|
||||
libbootstrap() {
|
||||
i=$1
|
||||
if [ -d ${LIBDIR}/${i} ]; then
|
||||
echo "Entering directory ${LIBDIR}/${i}"
|
||||
ex cd ${LIBDIR}/${i}
|
||||
ex rm -f aclocal.m4
|
||||
CFFILE=
|
||||
if [ -f ${LIBDIR}/${i}/configure.in ]; then
|
||||
CFFILE="${LIBDIR}/${i}/configure.in"
|
||||
else
|
||||
if [ -f ${LIBDIR}/${i}/configure.ac ]; then
|
||||
CFFILE="${LIBDIR}/${i}/configure.ac"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -z ${CFFILE} ]; then
|
||||
LTTEST=`grep "AC_PROG_LIBTOOL" ${CFFILE}`
|
||||
LTTEST2=`grep "AM_PROG_LIBTOOL" ${CFFILE}`
|
||||
AMTEST=`grep "AM_INIT_AUTOMAKE" ${CFFILE}`
|
||||
AMTEST2=`grep "AC_PROG_INSTALL" ${CFFILE}`
|
||||
AHTEST=`grep "AC_CONFIG_HEADERS" ${CFFILE}`
|
||||
AXTEST=`grep "ACX_LIBTOOL_C_ONLY" ${CFFILE}`
|
||||
|
||||
echo "Creating aclocal.m4"
|
||||
ex ${ACLOCAL:-aclocal} ${ACLOCAL_OPTS} ${ACLOCAL_FLAGS}
|
||||
|
||||
# only run if AC_PROG_LIBTOOL is in configure.in/configure.ac
|
||||
if [ ! -z "${LTTEST}" -o "${LTTEST2}" -o "${AXTEST}" ]; then
|
||||
echo "Running libtoolize..."
|
||||
if ${libtoolize} -n --install >/dev/null 2>&1; then
|
||||
ex $libtoolize --force --copy --install
|
||||
else
|
||||
ex $libtoolize --force --copy
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Creating configure"
|
||||
ex ${AUTOCONF:-autoconf}
|
||||
|
||||
# only run if AC_CONFIG_HEADERS is found in configure.in/configure.ac
|
||||
if [ ! -z "${AHTEST}" ]; then
|
||||
echo "Running autoheader..."
|
||||
ex ${AUTOHEADER:-autoheader};
|
||||
fi
|
||||
|
||||
# run if AM_INIT_AUTOMAKE / AC_PROG_INSTALL is in configure.in/configure.ac
|
||||
if [ ! -z "${AMTEST}" -o "${AMTEST2}" ]; then
|
||||
echo "Creating Makefile.in"
|
||||
ex ${AUTOMAKE:-automake} --no-force --add-missing --copy;
|
||||
fi
|
||||
ex rm -rf autom4te*.cache
|
||||
fi
|
||||
else
|
||||
echo "Skipping directory ${LIBDIR}/${i}"
|
||||
fi
|
||||
}
|
||||
|
||||
bootstrap_fs() {
|
||||
cd ${BASEDIR}
|
||||
rm -f aclocal.m4
|
||||
${ACLOCAL:-aclocal} ${ACLOCAL_OPTS}
|
||||
$libtoolize --copy --automake
|
||||
${AUTOCONF:-autoconf}
|
||||
${AUTOHEADER:-autoheader}
|
||||
${AUTOMAKE:-automake} --no-force --add-missing --copy
|
||||
rm -rf autom4te*.cache
|
||||
}
|
||||
|
||||
bootstrap_libs_pre() {
|
||||
case "$1" in
|
||||
*) return 0;;
|
||||
esac
|
||||
}
|
||||
|
||||
bootstrap_libs_post() {
|
||||
case "$1" in
|
||||
ldns)
|
||||
cd $BASEDIR/libs/ldns
|
||||
if test ! -x install-sh; then
|
||||
ex automake --add-missing --copy
|
||||
ex rm -rf autom4te*.cache
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
bootstrap_libs() {
|
||||
for i in ${SUBDIRS}; do
|
||||
case "$i" in
|
||||
apr|fs|libzrtp)
|
||||
${BGJOB} && wait
|
||||
bootstrap_$i
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
bootstrap_libs_pre ${i}
|
||||
if ! ${BGJOB}; then
|
||||
libbootstrap ${i} ; bootstrap_libs_post ${i}
|
||||
else
|
||||
((libbootstrap ${i} ; bootstrap_libs_post ${i}) &)
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
run() {
|
||||
setup_modules
|
||||
setup_gnu
|
||||
check_make
|
||||
check_awk
|
||||
check_ac_ver
|
||||
check_am_ver
|
||||
check_acl_ver
|
||||
check_lt_ver
|
||||
check_libtoolize
|
||||
print_autotools_vers
|
||||
bootstrap_libs
|
||||
${BGJOB} && wait
|
||||
return 0
|
||||
}
|
||||
|
||||
run
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
MK=`echo $(MAKE) | $(AWK) '{printf "%5s\n", $$0}' `
|
||||
|
||||
all:
|
||||
@echo " +---------- FreeSWITCH Build Complete ----------+"
|
||||
@echo " + FreeSWITCH has been successfully built. +"
|
||||
@echo " + Install by running: +"
|
||||
@echo " + +"
|
||||
@echo " + $(MK) install +"
|
||||
@echo " + +"
|
||||
@echo " + While you're waiting, register for ClueCon! +"
|
||||
@echo " + http://www.cluecon.com +"
|
||||
@echo " + +"
|
||||
@echo " +-----------------------------------------------+"
|
||||
|
||||
|
||||
install:
|
||||
@echo " +---------- FreeSWITCH install Complete ----------+"
|
||||
@echo " + FreeSWITCH has been successfully installed. +"
|
||||
@echo " + +"
|
||||
@echo " + Install sounds: +"
|
||||
@echo " + (uhd-sounds includes hd-sounds, sounds) +"
|
||||
@echo " + (hd-sounds includes sounds) +"
|
||||
@echo " + ------------------------------------ +"
|
||||
@echo " + $(MK) cd-sounds-install +"
|
||||
@echo " + $(MK) cd-moh-install +"
|
||||
@echo " + +"
|
||||
@echo " + $(MK) uhd-sounds-install +"
|
||||
@echo " + $(MK) uhd-moh-install +"
|
||||
@echo " + +"
|
||||
@echo " + $(MK) hd-sounds-install +"
|
||||
@echo " + $(MK) hd-moh-install +"
|
||||
@echo " + +"
|
||||
@echo " + $(MK) sounds-install +"
|
||||
@echo " + $(MK) moh-install +"
|
||||
@echo " + +"
|
||||
@echo " + Install non english sounds: +"
|
||||
@echo " + replace XX with language +"
|
||||
@echo " + (ru : Russian) +"
|
||||
@echo " + ------------------------------------ +"
|
||||
@echo " + $(MK) cd-sounds-XX-install +"
|
||||
@echo " + $(MK) uhd-sounds-XX-install +"
|
||||
@echo " + $(MK) hd-sounds-XX-install +"
|
||||
@echo " + $(MK) sounds-XX-install +"
|
||||
@echo " + +"
|
||||
@echo " + Upgrade to latest: +"
|
||||
@echo " + ---------------------------------- +"
|
||||
@echo " + $(MK) current +"
|
||||
@echo " + +"
|
||||
@echo " + Rebuild all: +"
|
||||
@echo " + ---------------------------------- +"
|
||||
@echo " + $(MK) sure +"
|
||||
@echo " + +"
|
||||
@echo " + Install/Re-install default config: +"
|
||||
@echo " + ---------------------------------- +"
|
||||
@echo " + $(MK) samples +"
|
||||
@echo " + +"
|
||||
@echo " + +"
|
||||
@echo " + Additional resources: +"
|
||||
@echo " + ---------------------------------- +"
|
||||
@echo " + http://www.freeswitch.org +"
|
||||
@echo " + http://wiki.freeswitch.org +"
|
||||
@echo " + http://jira.freeswitch.org +"
|
||||
@echo " + http://lists.freeswitch.org +"
|
||||
@echo " + +"
|
||||
@echo " + irc.freenode.net / #freeswitch +"
|
||||
@echo " + +"
|
||||
@echo " + Register For ClueCon: +"
|
||||
@echo " + ---------------------------------- +"
|
||||
@echo " + http://www.cluecon.com +"
|
||||
@echo " + +"
|
||||
@echo " +-------------------------------------------------+"
|
||||
|
||||
|
||||
|
||||
.PHONY: check dvi html info install-data \
|
||||
install-dvi install-exec install-html install-info install-pdf install-ps installcheck installdirs pdf \
|
||||
ps uninstall mostlyclean clean distclean maintainer-clean
|
|
@ -0,0 +1,104 @@
|
|||
#!/bin/sh
|
||||
|
||||
root=$1
|
||||
shift
|
||||
|
||||
|
||||
if [ -f $root/.nodepends ] ; then
|
||||
echo "***depends disabled*** use $MAKE yesdepends to re-enable"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "$MAKE" ] ; then
|
||||
make=`which gmake 2>/dev/null`
|
||||
if [ -z "$MAKE" ] ; then
|
||||
make=make
|
||||
fi
|
||||
fi
|
||||
|
||||
GZCAT=`which gzcat 2>/dev/null`
|
||||
if [ -z "$GZCAT" ] ; then
|
||||
GZCAT=zcat
|
||||
fi
|
||||
|
||||
install=
|
||||
base=http://files.freeswitch.org/downloads/libs
|
||||
|
||||
if [ ! -z "$1" ] && [ "$1" = install ] ; then
|
||||
install=1
|
||||
shift
|
||||
fi
|
||||
|
||||
tar=$1
|
||||
shift
|
||||
|
||||
cd $root/libs/.
|
||||
CFLAGS=
|
||||
LDFLAGS=
|
||||
MAKEFLAGS=
|
||||
|
||||
if [ -d $tar ] ; then
|
||||
uncompressed=$tar
|
||||
tar=
|
||||
else
|
||||
uncompressed=`echo $tar | sed "s/\.tar\.gz//g"`
|
||||
uncompressed=`echo $uncompressed | sed "s/\.tgz//g"`
|
||||
|
||||
if [ ! -f $tar ] ; then
|
||||
rm -fr $uncompressed
|
||||
wget $base/$tar || ftp $base/$tar
|
||||
if [ ! -f $tar ] ; then
|
||||
echo cannot find $tar
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
if [ ! -d $uncompressed ] ; then
|
||||
$GZCAT $tar | tar xf -
|
||||
fi
|
||||
fi
|
||||
if [ -f $uncompressed/.complete ] ; then
|
||||
if [ $uncompressed/.complete -ot $uncompressed ]; then
|
||||
if [ ! -f $root/.nothanks ] ; then
|
||||
echo remove stale .complete
|
||||
rm $uncompressed/.complete
|
||||
sh -c "cd $uncompressed && $MAKE clean distclean"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f $uncompressed/.complete ] ; then
|
||||
echo $uncompressed already installed
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cd $uncompressed
|
||||
|
||||
if [ -f ../$uncompressed.build.sh ] ; then
|
||||
MAKE=$MAKE ../$uncompressed.build.sh $@
|
||||
else
|
||||
$MAKE clean 2>&1
|
||||
CFLAGS="$MOD_CFLAGS" sh ./configure $@
|
||||
|
||||
if [ $? = 0 ] ; then
|
||||
$MAKE
|
||||
else
|
||||
echo ERROR
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -z $install ] ; then
|
||||
$MAKE install
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $? = 0 ] ; then
|
||||
touch .complete
|
||||
sleep 1
|
||||
touch .complete
|
||||
else
|
||||
echo ERROR
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/sh
|
||||
base=`pwd`
|
||||
cd libs/unimrcp
|
||||
./configure --with-pocketsphinx=$base/libs/pocketsphinx-0.5.99 --with-sphinxbase=$base/libs/sphinxbase-0.4.99 --with-flite=$base/libs/flite-1.3.99 --with-apr=$base/libs/apr --with-apr-util=$base/libs/apr-util --with-sofia-sip=$base/libs/sofia-sip --prefix=/usr/local/unimrcpserver --enable-pocketsphinx-plugin --enable-flite-plugin --disable-demosynth-plugin --disable-demorecog-plugin --disable-recorder-plugin --disable-cepstral-plugin
|
||||
make
|
||||
make install
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
uname -a | grep -qi bsd && MAKE=gmake || MAKE=make
|
||||
FS_DIR=`pwd`
|
||||
|
||||
cd /root
|
||||
svn co https://opalvoip.svn.sourceforge.net/svnroot/opalvoip/ptlib/trunk ptlib
|
||||
cd ptlib
|
||||
./configure --prefix=/usr
|
||||
${MAKE}
|
||||
${MAKE} install
|
||||
|
||||
cd ..
|
||||
svn co https://opalvoip.svn.sourceforge.net/svnroot/opalvoip/opal/branches/v3_6 opal
|
||||
cd opal
|
||||
export PKG_CONFIG_PATH=/usr/lib/pkgconfig
|
||||
./configure --prefix=/usr
|
||||
${MAKE}
|
||||
${MAKE} install
|
||||
cd ${FS_DIR}
|
||||
${MAKE} mod_opal-install
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
tar zxf libzrtp-0.81.514.tar.gz
|
||||
cd libzrtp-0.81.514
|
||||
patch -p1 < ../patches/zrtp_bnlib_pic.diff
|
||||
cd projects/gnu/
|
||||
./configure CFLAGS="-fPIC"
|
||||
make
|
||||
make install
|
|
@ -0,0 +1,66 @@
|
|||
##
|
||||
## config.layout -- Pre-defined Installation Path Layouts
|
||||
##
|
||||
## Hints:
|
||||
## - layouts can be loaded with configure's --enable-layout=ID option
|
||||
## - when no --enable-layout option is given, the default layout is `FreeSWITCH'
|
||||
## - a trailing plus character (`+') on paths is replaced with a
|
||||
## `/<target>' suffix where <target> is currently hardcoded to 'freeswitch'.
|
||||
## (This may become a configurable parameter at some point.)
|
||||
##
|
||||
|
||||
# Default FreeSWITCH path layout.
|
||||
<Layout FreeSWITCH>
|
||||
prefix: /usr/local/freeswitch
|
||||
exec_prefix: ${prefix}
|
||||
bindir: ${exec_prefix}/bin
|
||||
sbindir: ${exec_prefix}/bin
|
||||
libdir: ${exec_prefix}/lib
|
||||
libexecdir: ${exec_prefix}/modules
|
||||
modulesdir: ${exec_prefix}/modules
|
||||
mandir: ${prefix}/man
|
||||
sysconfdir: ${prefix}/conf
|
||||
datadir: ${prefix}
|
||||
includedir: ${prefix}/include
|
||||
localstatedir: ${prefix}
|
||||
runtimedir: ${localstatedir}/log
|
||||
logfiledir: ${localstatedir}/log
|
||||
</Layout>
|
||||
|
||||
# GNU standards conforming path layout.
|
||||
# See FSF's GNU project `make-stds' document for details.
|
||||
<Layout GNU>
|
||||
prefix: /usr/local
|
||||
exec_prefix: ${prefix}
|
||||
bindir: ${exec_prefix}/bin
|
||||
sbindir: ${exec_prefix}/sbin
|
||||
libdir: ${exec_prefix}/lib
|
||||
libexecdir: ${exec_prefix}/libexec
|
||||
modulesdir: ${libdir}/freeswitch/modules
|
||||
mandir: ${prefix}/man
|
||||
sysconfdir: ${prefix}/etc/freeswitch
|
||||
datadir: ${prefix}/share/freeswitch
|
||||
includedir: ${prefix}/include/freeswitch
|
||||
localstatedir: ${prefix}/var/freeswitch
|
||||
runtimedir: ${localstatedir}/run
|
||||
logfiledir: ${localstatedir}/log
|
||||
</Layout>
|
||||
|
||||
# Linux FHS (File Hierarchy Standard) layout
|
||||
# see
|
||||
<Layout FHS>
|
||||
prefix: /usr
|
||||
exec_prefix: ${prefix}
|
||||
bindir: ${exec_prefix}/bin
|
||||
sbindir: ${exec_prefix}/sbin
|
||||
libdir: ${exec_prefix}/lib/freeswitch
|
||||
libexecdir: ${exec_prefix}/libexec
|
||||
modulesdir: ${libdir}/modules
|
||||
mandir: ${prefix}/man
|
||||
sysconfdir: /etc/freeswitch
|
||||
datadir: ${prefix}/share/freeswitch
|
||||
includedir: ${prefix}/include/freeswitch
|
||||
localstatedir: /var/lib/freeswitch
|
||||
runtimedir: /var/run/freeswitch
|
||||
logfiledir: /var/log/freeswitch
|
||||
</Layout>
|
|
@ -0,0 +1,142 @@
|
|||
AC_DEFUN([AX_CFLAGS_GCC_OPTION_OLD], [dnl
|
||||
AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
|
||||
AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_gcc_option_$2])dnl
|
||||
AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for gcc m4_ifval($2,$2,-option)],
|
||||
VAR,[VAR="no, unknown"
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_C
|
||||
ac_save_[]FLAGS="$[]FLAGS"
|
||||
for ac_arg dnl
|
||||
in "-pedantic % m4_ifval($2,$2,-option)" dnl GCC
|
||||
#
|
||||
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
|
||||
AC_TRY_COMPILE([],[return 0;],
|
||||
[VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
|
||||
done
|
||||
FLAGS="$ac_save_[]FLAGS"
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
case ".$VAR" in
|
||||
.ok|.ok,*) m4_ifvaln($3,$3) ;;
|
||||
.|.no|.no,*) m4_ifvaln($4,$4) ;;
|
||||
*) m4_ifvaln($3,$3,[
|
||||
if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
|
||||
then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
|
||||
else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
|
||||
m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
|
||||
fi ]) ;;
|
||||
esac
|
||||
AS_VAR_POPDEF([VAR])dnl
|
||||
AS_VAR_POPDEF([FLAGS])dnl
|
||||
])
|
||||
|
||||
|
||||
dnl the only difference - the LANG selection... and the default FLAGS
|
||||
|
||||
AC_DEFUN([AX_CXXFLAGS_GCC_OPTION_OLD], [dnl
|
||||
AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
|
||||
AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_gcc_option_$2])dnl
|
||||
AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for gcc m4_ifval($2,$2,-option)],
|
||||
VAR,[VAR="no, unknown"
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_CXX
|
||||
ac_save_[]FLAGS="$[]FLAGS"
|
||||
for ac_arg dnl
|
||||
in "-pedantic % m4_ifval($2,$2,-option)" dnl GCC
|
||||
#
|
||||
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
|
||||
AC_TRY_COMPILE([],[return 0;],
|
||||
[VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
|
||||
done
|
||||
FLAGS="$ac_save_[]FLAGS"
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
case ".$VAR" in
|
||||
.ok|.ok,*) m4_ifvaln($3,$3) ;;
|
||||
.|.no|.no,*) m4_ifvaln($4,$4) ;;
|
||||
*) m4_ifvaln($3,$3,[
|
||||
if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
|
||||
then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
|
||||
else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
|
||||
m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
|
||||
fi ]) ;;
|
||||
esac
|
||||
AS_VAR_POPDEF([VAR])dnl
|
||||
AS_VAR_POPDEF([FLAGS])dnl
|
||||
])
|
||||
|
||||
dnl -------------------------------------------------------------------------
|
||||
|
||||
AC_DEFUN([AX_CFLAGS_GCC_OPTION_NEW], [dnl
|
||||
AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
|
||||
AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_gcc_option_$1])dnl
|
||||
AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for gcc m4_ifval($1,$1,-option)],
|
||||
VAR,[VAR="no, unknown"
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_C
|
||||
ac_save_[]FLAGS="$[]FLAGS"
|
||||
for ac_arg dnl
|
||||
in "-pedantic % m4_ifval($1,$1,-option)" dnl GCC
|
||||
#
|
||||
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
|
||||
AC_TRY_COMPILE([],[return 0;],
|
||||
[VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
|
||||
done
|
||||
FLAGS="$ac_save_[]FLAGS"
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
case ".$VAR" in
|
||||
.ok|.ok,*) m4_ifvaln($3,$3) ;;
|
||||
.|.no|.no,*) m4_ifvaln($4,$4) ;;
|
||||
*) m4_ifvaln($3,$3,[
|
||||
if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
|
||||
then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR])
|
||||
else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"])
|
||||
m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"
|
||||
fi ]) ;;
|
||||
esac
|
||||
AS_VAR_POPDEF([VAR])dnl
|
||||
AS_VAR_POPDEF([FLAGS])dnl
|
||||
])
|
||||
|
||||
|
||||
dnl the only difference - the LANG selection... and the default FLAGS
|
||||
|
||||
AC_DEFUN([AX_CXXFLAGS_GCC_OPTION_NEW], [dnl
|
||||
AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
|
||||
AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_gcc_option_$1])dnl
|
||||
AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for gcc m4_ifval($1,$1,-option)],
|
||||
VAR,[VAR="no, unknown"
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_CXX
|
||||
ac_save_[]FLAGS="$[]FLAGS"
|
||||
for ac_arg dnl
|
||||
in "-pedantic % m4_ifval($1,$1,-option)" dnl GCC
|
||||
#
|
||||
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
|
||||
AC_TRY_COMPILE([],[return 0;],
|
||||
[VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
|
||||
done
|
||||
FLAGS="$ac_save_[]FLAGS"
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
case ".$VAR" in
|
||||
.ok|.ok,*) m4_ifvaln($3,$3) ;;
|
||||
.|.no|.no,*) m4_ifvaln($4,$4) ;;
|
||||
*) m4_ifvaln($3,$3,[
|
||||
if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
|
||||
then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR])
|
||||
else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"])
|
||||
m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"
|
||||
fi ]) ;;
|
||||
esac
|
||||
AS_VAR_POPDEF([VAR])dnl
|
||||
AS_VAR_POPDEF([FLAGS])dnl
|
||||
])
|
||||
|
||||
AC_DEFUN([AX_CFLAGS_GCC_OPTION],[ifelse(m4_bregexp([$2],[-]),-1,
|
||||
[AX_CFLAGS_GCC_OPTION_NEW($@)],[AX_CFLAGS_GCC_OPTION_OLD($@)])])
|
||||
|
||||
AC_DEFUN([AX_CXXFLAGS_GCC_OPTION],[ifelse(m4_bregexp([$2],[-]),-1,
|
||||
[AX_CXXFLAGS_GCC_OPTION_NEW($@)],[AX_CXXFLAGS_GCC_OPTION_OLD($@)])])
|
||||
|
|
@ -0,0 +1,140 @@
|
|||
AC_DEFUN([AX_CFLAGS_SUN_OPTION_OLD], [dnl
|
||||
AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
|
||||
AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_sun_option_$2])dnl
|
||||
AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for sun/cc m4_ifval($2,$2,-option)],
|
||||
VAR,[VAR="no, unknown"
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_C
|
||||
ac_save_[]FLAGS="$[]FLAGS"
|
||||
for ac_arg dnl
|
||||
in "+xstrconst -Xc % m4_ifval($2,$2,-option)" dnl Solaris C
|
||||
#
|
||||
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
|
||||
AC_TRY_COMPILE([],[return 0;],
|
||||
[VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
|
||||
done
|
||||
FLAGS="$ac_save_[]FLAGS"
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
case ".$VAR" in
|
||||
.ok|.ok,*) m4_ifvaln($3,$3) ;;
|
||||
.|.no|.no,*) m4_ifvaln($4,$4) ;;
|
||||
*) m4_ifvaln($3,$3,[
|
||||
if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
|
||||
then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
|
||||
else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
|
||||
m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
|
||||
fi ]) ;;
|
||||
esac
|
||||
AS_VAR_POPDEF([VAR])dnl
|
||||
AS_VAR_POPDEF([FLAGS])dnl
|
||||
])
|
||||
|
||||
dnl the only difference - the LANG selection... and the default FLAGS
|
||||
|
||||
AC_DEFUN([AX_CXXFLAGS_SUN_OPTION_OLD], [dnl
|
||||
AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
|
||||
AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_sun_option_$2])dnl
|
||||
AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for sun/cc m4_ifval($2,$2,-option)],
|
||||
VAR,[VAR="no, unknown"
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_CXX
|
||||
ac_save_[]FLAGS="$[]FLAGS"
|
||||
for ac_arg dnl
|
||||
in "+xstrconst -Xc % m4_ifval($2,$2,-option)" dnl Solaris C
|
||||
#
|
||||
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
|
||||
AC_TRY_COMPILE([],[return 0;],
|
||||
[VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
|
||||
done
|
||||
FLAGS="$ac_save_[]FLAGS"
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
case ".$VAR" in
|
||||
.ok|.ok,*) m4_ifvaln($3,$3) ;;
|
||||
.|.no|.no,*) m4_ifvaln($4,$4) ;;
|
||||
*) m4_ifvaln($3,$3,[
|
||||
if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
|
||||
then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
|
||||
else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
|
||||
m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
|
||||
fi ]) ;;
|
||||
esac
|
||||
AS_VAR_POPDEF([VAR])dnl
|
||||
AS_VAR_POPDEF([FLAGS])dnl
|
||||
])
|
||||
|
||||
dnl -----------------------------------------------------------------------
|
||||
|
||||
AC_DEFUN([AX_CFLAGS_SUN_OPTION_NEW], [dnl
|
||||
AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
|
||||
AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_sun_option_$1])dnl
|
||||
AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for sun/cc m4_ifval($1,$1,-option)],
|
||||
VAR,[VAR="no, unknown"
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_C
|
||||
ac_save_[]FLAGS="$[]FLAGS"
|
||||
for ac_arg dnl
|
||||
in "+xstrconst -Xc % m4_ifval($1,$1,-option)" dnl Solaris C
|
||||
#
|
||||
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
|
||||
AC_TRY_COMPILE([],[return 0;],
|
||||
[VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
|
||||
done
|
||||
FLAGS="$ac_save_[]FLAGS"
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
case ".$VAR" in
|
||||
.ok|.ok,*) m4_ifvaln($3,$3) ;;
|
||||
.|.no|.no,*) m4_ifvaln($4,$4) ;;
|
||||
*) m4_ifvaln($3,$3,[
|
||||
if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
|
||||
then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR])
|
||||
else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"])
|
||||
m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"
|
||||
fi ]) ;;
|
||||
esac
|
||||
AS_VAR_POPDEF([VAR])dnl
|
||||
AS_VAR_POPDEF([FLAGS])dnl
|
||||
])
|
||||
|
||||
dnl the only difference - the LANG selection... and the default FLAGS
|
||||
|
||||
AC_DEFUN([AX_CXXFLAGS_SUN_OPTION_NEW], [dnl
|
||||
AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
|
||||
AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_sun_option_$1])dnl
|
||||
AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for sun/cc m4_ifval($1,$1,-option)],
|
||||
VAR,[VAR="no, unknown"
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_CXX
|
||||
ac_save_[]FLAGS="$[]FLAGS"
|
||||
for ac_arg dnl
|
||||
in "+xstrconst -Xc % m4_ifval($1,$1,-option)" dnl Solaris C
|
||||
#
|
||||
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
|
||||
AC_TRY_COMPILE([],[return 0;],
|
||||
[VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
|
||||
done
|
||||
FLAGS="$ac_save_[]FLAGS"
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
case ".$VAR" in
|
||||
.ok|.ok,*) m4_ifvaln($3,$3) ;;
|
||||
.|.no|.no,*) m4_ifvaln($4,$4) ;;
|
||||
*) m4_ifvaln($3,$3,[
|
||||
if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
|
||||
then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR])
|
||||
else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"])
|
||||
m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"
|
||||
fi ]) ;;
|
||||
esac
|
||||
AS_VAR_POPDEF([VAR])dnl
|
||||
AS_VAR_POPDEF([FLAGS])dnl
|
||||
])
|
||||
|
||||
AC_DEFUN([AX_CFLAGS_SUN_OPTION],[ifelse(m4_regexp([$2],[-]),-1,
|
||||
[AX_CFLAGS_SUN_OPTION_NEW($@)],[AX_CFLAGS_SUN_OPTION_OLD($@)])])
|
||||
|
||||
AC_DEFUN([AX_CXXFLAGS_SUN_OPTION],[ifelse(m4_regexp([$2],[-]),-1,
|
||||
[AX_CXXFLAGS_SUN_OPTION_NEW($@)],[AX_CXXFLAGS_SUN_OPTION_OLD($@)])])
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
AC_DEFUN([AX_GCC_ARCHFLAG],
|
||||
[AC_REQUIRE([AC_PROG_CC])
|
||||
|
||||
AC_ARG_WITH(gcc-arch, [AC_HELP_STRING([--with-gcc-arch=<arch>], [use architecture <arch> for gcc -march/-mtune, instead of guessing])],
|
||||
ax_gcc_arch=$withval, ax_gcc_arch=yes)
|
||||
|
||||
AC_MSG_CHECKING([for gcc architecture flag])
|
||||
AC_MSG_RESULT([])
|
||||
AC_CACHE_VAL(ax_cv_gcc_archflag,
|
||||
[
|
||||
ax_cv_gcc_archflag="unknown"
|
||||
|
||||
if test "$GCC" = yes; then
|
||||
|
||||
if test "x$ax_gcc_arch" = xyes; then
|
||||
ax_gcc_arch=""
|
||||
if test "$cross_compiling" = no; then
|
||||
case $host_cpu in
|
||||
i[[3456]]86*|x86_64*) # use cpuid codes, in part from x86info-1.7 by D. Jones
|
||||
AX_GCC_X86_CPUID(0)
|
||||
AX_GCC_X86_CPUID(1)
|
||||
case $ax_cv_gcc_x86_cpuid_0 in
|
||||
*:756e6547:*:*) # Intel
|
||||
case $ax_cv_gcc_x86_cpuid_1 in
|
||||
*5[[48]]?:*:*:*) ax_gcc_arch="pentium-mmx pentium" ;;
|
||||
*5??:*:*:*) ax_gcc_arch=pentium ;;
|
||||
*6[[3456]]?:*:*:*) ax_gcc_arch="pentium2 pentiumpro" ;;
|
||||
*6a?:*[[01]]:*:*) ax_gcc_arch="pentium2 pentiumpro" ;;
|
||||
*6a?:*[[234]]:*:*) ax_gcc_arch="pentium3 pentiumpro" ;;
|
||||
*6[[9d]]?:*:*:*) ax_gcc_arch="pentium-m pentium3 pentiumpro" ;;
|
||||
*6[[78b]]?:*:*:*) ax_gcc_arch="pentium3 pentiumpro" ;;
|
||||
*6??:*:*:*) ax_gcc_arch=pentiumpro ;;
|
||||
*f3[[347]]:*:*:*|*f4[1347]:*:*:*)
|
||||
case $host_cpu in
|
||||
x86_64*) ax_gcc_arch="nocona pentium4 pentiumpro" ;;
|
||||
*) ax_gcc_arch="prescott pentium4 pentiumpro" ;;
|
||||
esac ;;
|
||||
*f??:*:*:*) ax_gcc_arch="pentium4 pentiumpro";;
|
||||
esac ;;
|
||||
*:68747541:*:*) # AMD
|
||||
case $ax_cv_gcc_x86_cpuid_1 in
|
||||
*5[[67]]?:*:*:*) ax_gcc_arch=k6 ;;
|
||||
*5[[8d]]?:*:*:*) ax_gcc_arch="k6-2 k6" ;;
|
||||
*5[[9]]?:*:*:*) ax_gcc_arch="k6-3 k6" ;;
|
||||
*60?:*:*:*) ax_gcc_arch=k7 ;;
|
||||
*6[[12]]?:*:*:*) ax_gcc_arch="athlon k7" ;;
|
||||
*6[[34]]?:*:*:*) ax_gcc_arch="athlon-tbird k7" ;;
|
||||
*67?:*:*:*) ax_gcc_arch="athlon-4 athlon k7" ;;
|
||||
*6[[68a]]?:*:*:*)
|
||||
AX_GCC_X86_CPUID(0x80000006) # L2 cache size
|
||||
case $ax_cv_gcc_x86_cpuid_0x80000006 in
|
||||
*:*:*[[1-9a-f]]??????:*) # (L2 = ecx >> 16) >= 256
|
||||
ax_gcc_arch="athlon-xp athlon-4 athlon k7" ;;
|
||||
*) ax_gcc_arch="athlon-4 athlon k7" ;;
|
||||
esac ;;
|
||||
*f[[4cef8b]]?:*:*:*) ax_gcc_arch="athlon64 k8" ;;
|
||||
*f5?:*:*:*) ax_gcc_arch="opteron k8" ;;
|
||||
*f7?:*:*:*) ax_gcc_arch="athlon-fx opteron k8" ;;
|
||||
*f??:*:*:*) ax_gcc_arch="k8" ;;
|
||||
esac ;;
|
||||
*:746e6543:*:*) # IDT
|
||||
case $ax_cv_gcc_x86_cpuid_1 in
|
||||
*54?:*:*:*) ax_gcc_arch=winchip-c6 ;;
|
||||
*58?:*:*:*) ax_gcc_arch=winchip2 ;;
|
||||
*6[[78]]?:*:*:*) ax_gcc_arch=c3 ;;
|
||||
*69?:*:*:*) ax_gcc_arch="c3-2 c3" ;;
|
||||
esac ;;
|
||||
esac
|
||||
if test x"$ax_gcc_arch" = x; then # fallback
|
||||
case $host_cpu in
|
||||
i586*) ax_gcc_arch=pentium ;;
|
||||
i686*) ax_gcc_arch=pentiumpro ;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
|
||||
sparc*)
|
||||
AC_PATH_PROG([PRTDIAG], [prtdiag], [prtdiag], [$PATH:/usr/platform/`uname -i`/sbin/:/usr/platform/`uname -m`/sbin/])
|
||||
cputype=`(((grep cpu /proc/cpuinfo | cut -d: -f2) ; ($PRTDIAG -v |grep -i sparc) ; grep -i cpu /var/run/dmesg.boot ) | head -n 1) 2> /dev/null`
|
||||
cputype=`echo "$cputype" | tr -d ' -' |tr $as_cr_LETTERS $as_cr_letters`
|
||||
case $cputype in
|
||||
*ultrasparciv*) ax_gcc_arch="ultrasparc4 ultrasparc3 ultrasparc v9" ;;
|
||||
*ultrasparciii*) ax_gcc_arch="ultrasparc3 ultrasparc v9" ;;
|
||||
*ultrasparc*) ax_gcc_arch="ultrasparc v9" ;;
|
||||
*supersparc*|*tms390z5[[05]]*) ax_gcc_arch="supersparc v8" ;;
|
||||
*hypersparc*|*rt62[[056]]*) ax_gcc_arch="hypersparc v8" ;;
|
||||
*cypress*) ax_gcc_arch=cypress ;;
|
||||
esac ;;
|
||||
|
||||
alphaev5) ax_gcc_arch=ev5 ;;
|
||||
alphaev56) ax_gcc_arch=ev56 ;;
|
||||
alphapca56) ax_gcc_arch="pca56 ev56" ;;
|
||||
alphapca57) ax_gcc_arch="pca57 pca56 ev56" ;;
|
||||
alphaev6) ax_gcc_arch=ev6 ;;
|
||||
alphaev67) ax_gcc_arch=ev67 ;;
|
||||
alphaev68) ax_gcc_arch="ev68 ev67" ;;
|
||||
alphaev69) ax_gcc_arch="ev69 ev68 ev67" ;;
|
||||
alphaev7) ax_gcc_arch="ev7 ev69 ev68 ev67" ;;
|
||||
alphaev79) ax_gcc_arch="ev79 ev7 ev69 ev68 ev67" ;;
|
||||
|
||||
powerpc*)
|
||||
cputype=`((grep cpu /proc/cpuinfo | head -n 1 | cut -d: -f2 | cut -d, -f1 | sed 's/ //g') ; /usr/bin/machine ; /bin/machine; grep CPU /var/run/dmesg.boot | head -n 1 | cut -d" " -f2) 2> /dev/null`
|
||||
cputype=`echo $cputype | sed -e 's/ppc//g;s/ *//g'`
|
||||
case $cputype in
|
||||
*750*) ax_gcc_arch="750 G3" ;;
|
||||
*740[[0-9]]*) ax_gcc_arch="$cputype 7400 G4" ;;
|
||||
*74[[4-5]][[0-9]]*) ax_gcc_arch="$cputype 7450 G4" ;;
|
||||
*74[[0-9]][[0-9]]*) ax_gcc_arch="$cputype G4" ;;
|
||||
*970*) ax_gcc_arch="970 G5 power4";;
|
||||
*POWER4*|*power4*|*gq*) ax_gcc_arch="power4 970";;
|
||||
*POWER5*|*power5*|*gr*|*gs*) ax_gcc_arch="power5 power4 970";;
|
||||
603ev|8240) ax_gcc_arch="$cputype 603e 603";;
|
||||
*) ax_gcc_arch=$cputype ;;
|
||||
esac
|
||||
ax_gcc_arch="$ax_gcc_arch powerpc"
|
||||
;;
|
||||
esac
|
||||
fi # not cross-compiling
|
||||
fi # guess arch
|
||||
|
||||
if test "x$ax_gcc_arch" != x -a "x$ax_gcc_arch" != xno; then
|
||||
for arch in $ax_gcc_arch; do
|
||||
if test "x[]m4_default([$1],yes)" = xyes; then # if we require portable code
|
||||
flags="-mtune=$arch"
|
||||
# -mcpu=$arch and m$arch generate nonportable code on every arch except
|
||||
# x86. And some other arches (e.g. Alpha) don't accept -mtune. Grrr.
|
||||
case $host_cpu in i*86|x86_64*) flags="$flags -mcpu=$arch -m$arch";; esac
|
||||
else
|
||||
flags="-march=$arch -mcpu=$arch -m$arch"
|
||||
fi
|
||||
for flag in $flags; do
|
||||
AX_CHECK_COMPILER_FLAGS($flag, [ax_cv_gcc_archflag=$flag; break])
|
||||
done
|
||||
test "x$ax_cv_gcc_archflag" = xunknown || break
|
||||
done
|
||||
fi
|
||||
|
||||
fi # $GCC=yes
|
||||
])
|
||||
AC_MSG_CHECKING([for gcc architecture flag])
|
||||
AC_MSG_RESULT($ax_cv_gcc_archflag)
|
||||
if test "x$ax_cv_gcc_archflag" = xunknown; then
|
||||
m4_default([$3],:)
|
||||
else
|
||||
m4_default([$2], [CFLAGS="$CFLAGS $ax_cv_gcc_archflag"])
|
||||
fi
|
||||
])
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
AC_DEFUN([AX_GCC_X86_CPUID],
|
||||
[AC_REQUIRE([AC_PROG_CC])
|
||||
AC_LANG_PUSH([C])
|
||||
AC_CACHE_CHECK(for x86 cpuid $1 output, ax_cv_gcc_x86_cpuid_$1,
|
||||
[AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [
|
||||
int op = $1, eax, ebx, ecx, edx;
|
||||
FILE *f;
|
||||
__asm__("cpuid"
|
||||
: "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
|
||||
: "a" (op));
|
||||
f = fopen("conftest_cpuid", "w"); if (!f) return 1;
|
||||
fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx);
|
||||
fclose(f);
|
||||
return 0;
|
||||
])],
|
||||
[ax_cv_gcc_x86_cpuid_$1=`cat conftest_cpuid`; rm -f conftest_cpuid],
|
||||
[ax_cv_gcc_x86_cpuid_$1=unknown; rm -f conftest_cpuid],
|
||||
[ax_cv_gcc_x86_cpuid_$1=unknown])])
|
||||
AC_LANG_POP([C])
|
||||
])
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
AC_DEFUN([AC_PROG_GZIP],[
|
||||
AC_CHECK_PROGS(gzip,[gzip],no)
|
||||
export gzip;
|
||||
if test $gzip = "no" ;
|
||||
then
|
||||
AC_MSG_ERROR([Unable to find the gzip application]);
|
||||
fi
|
||||
AC_SUBST(gzip)
|
||||
])
|
|
@ -0,0 +1,9 @@
|
|||
AC_DEFUN([AC_PROG_WGET],[
|
||||
AC_CHECK_PROGS(wget,[wget],no)
|
||||
export wget;
|
||||
if test $wget = "no" ;
|
||||
then
|
||||
AC_MSG_ERROR([Unable to find the wget application]);
|
||||
fi
|
||||
AC_SUBST(wget)
|
||||
])
|
|
@ -0,0 +1,120 @@
|
|||
AC_DEFUN([AX_CC_MAXOPT],
|
||||
[
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([AX_COMPILER_VENDOR])
|
||||
|
||||
AC_ARG_ENABLE(portable-binary, [AC_HELP_STRING([--enable-portable-binary], [disable compiler optimizations that would produce unportable binaries])],
|
||||
acx_maxopt_portable=$withval, acx_maxopt_portable=no)
|
||||
|
||||
# Try to determine "good" native compiler flags if none specified via CFLAGS
|
||||
if test "$ac_test_CFLAGS" != "set"; then
|
||||
CFLAGS=""
|
||||
case $ax_cv_c_compiler_vendor in
|
||||
dec) CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host"
|
||||
if test "x$acx_maxopt_portable" = xno; then
|
||||
CFLAGS="$CFLAGS -arch host"
|
||||
fi;;
|
||||
|
||||
sun) CFLAGS="-native -fast -xO5 -dalign -xc99=all"
|
||||
if test "x$acx_maxopt_portable" = xyes; then
|
||||
CFLAGS="$CFLAGS -xarch=generic"
|
||||
fi;;
|
||||
|
||||
hp) CFLAGS="+Oall +Optrs_ansi +DSnative"
|
||||
if test "x$acx_maxopt_portable" = xyes; then
|
||||
CFLAGS="$CFLAGS +DAportable"
|
||||
fi;;
|
||||
|
||||
ibm) if test "x$acx_maxopt_portable" = xno; then
|
||||
xlc_opt="-qarch=auto -qtune=auto"
|
||||
else
|
||||
xlc_opt="-qtune=auto"
|
||||
fi
|
||||
AX_CHECK_COMPILER_FLAGS($xlc_opt,
|
||||
CFLAGS="-O3 -qansialias -w $xlc_opt",
|
||||
[CFLAGS="-O3 -qansialias -w"
|
||||
echo "******************************************************"
|
||||
echo "* You seem to have the IBM C compiler. It is *"
|
||||
echo "* recommended for best performance that you use: *"
|
||||
echo "* *"
|
||||
echo "* CFLAGS=-O3 -qarch=xxx -qtune=xxx -qansialias -w *"
|
||||
echo "* ^^^ ^^^ *"
|
||||
echo "* where xxx is pwr2, pwr3, 604, or whatever kind of *"
|
||||
echo "* CPU you have. (Set the CFLAGS environment var. *"
|
||||
echo "* and re-run configure.) For more info, man cc. *"
|
||||
echo "******************************************************"])
|
||||
;;
|
||||
|
||||
intel) CFLAGS="-O3 -ansi_alias"
|
||||
if test "x$acx_maxopt_portable" = xno; then
|
||||
icc_archflag=unknown
|
||||
icc_flags=""
|
||||
case $host_cpu in
|
||||
i686*|x86_64*)
|
||||
# icc accepts gcc assembly syntax, so these should work:
|
||||
AX_GCC_X86_CPUID(0)
|
||||
AX_GCC_X86_CPUID(1)
|
||||
case $ax_cv_gcc_x86_cpuid_0 in # see AX_GCC_ARCHFLAG
|
||||
*:756e6547:*:*) # Intel
|
||||
case $ax_cv_gcc_x86_cpuid_1 in
|
||||
*6a?:*[[234]]:*:*|*6[[789b]]?:*:*:*) icc_flags="-xK";;
|
||||
*f3[[347]]:*:*:*|*f4[1347]:*:*:*) icc_flags="-xP -xN -xW -xK";;
|
||||
*f??:*:*:*) icc_flags="-xN -xW -xK";;
|
||||
esac ;;
|
||||
esac ;;
|
||||
esac
|
||||
if test "x$icc_flags" != x; then
|
||||
for flag in $icc_flags; do
|
||||
AX_CHECK_COMPILER_FLAGS($flag, [icc_archflag=$flag; break])
|
||||
done
|
||||
fi
|
||||
AC_MSG_CHECKING([for icc architecture flag])
|
||||
AC_MSG_RESULT($icc_archflag)
|
||||
if test "x$icc_archflag" != xunknown; then
|
||||
CFLAGS="$CFLAGS $icc_archflag"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
gnu)
|
||||
# default optimization flags for gcc on all systems
|
||||
CFLAGS="-O3 -fomit-frame-pointer"
|
||||
|
||||
# -malign-double for x86 systems
|
||||
AX_CHECK_COMPILER_FLAGS(-malign-double, CFLAGS="$CFLAGS -malign-double")
|
||||
|
||||
# -fstrict-aliasing for gcc-2.95+
|
||||
AX_CHECK_COMPILER_FLAGS(-fstrict-aliasing,
|
||||
CFLAGS="$CFLAGS -fstrict-aliasing")
|
||||
|
||||
# note that we enable "unsafe" fp optimization with other compilers, too
|
||||
AX_CHECK_COMPILER_FLAGS(-ffast-math, CFLAGS="$CFLAGS -ffast-math")
|
||||
|
||||
AX_GCC_ARCHFLAG($acx_maxopt_portable)
|
||||
;;
|
||||
esac
|
||||
|
||||
if test -z "$CFLAGS"; then
|
||||
echo ""
|
||||
echo "********************************************************"
|
||||
echo "* WARNING: Don't know the best CFLAGS for this system *"
|
||||
echo "* Use ./configure CFLAGS=... to specify your own flags *"
|
||||
echo "* (otherwise, a default of CFLAGS=-O3 will be used) *"
|
||||
echo "********************************************************"
|
||||
echo ""
|
||||
CFLAGS="-O3"
|
||||
fi
|
||||
|
||||
AX_CHECK_COMPILER_FLAGS($CFLAGS, [], [
|
||||
echo ""
|
||||
echo "********************************************************"
|
||||
echo "* WARNING: The guessed CFLAGS don't seem to work with *"
|
||||
echo "* your compiler. *"
|
||||
echo "* Use ./configure CFLAGS=... to specify your own flags *"
|
||||
echo "********************************************************"
|
||||
echo ""
|
||||
CFLAGS=""
|
||||
])
|
||||
|
||||
fi
|
||||
])
|
|
@ -0,0 +1,94 @@
|
|||
AC_DEFUN([AX_CFLAGS_WARN_ALL_ANSI],[dnl
|
||||
AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
|
||||
AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_warn_all_ansi])dnl
|
||||
AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum ansi warnings],
|
||||
VAR,[VAR="no, unknown"
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_C
|
||||
ac_save_[]FLAGS="$[]FLAGS"
|
||||
# IRIX C compiler:
|
||||
# -use_readonly_const is the default for IRIX C,
|
||||
# puts them into .rodata, but they are copied later.
|
||||
# need to be "-G0 -rdatashared" for strictmode but
|
||||
# I am not sure what effect that has really. - guidod
|
||||
for ac_arg dnl
|
||||
in "-pedantic % -Wall -std=c99 -pedantic" dnl GCC
|
||||
"-xstrconst % -v -Xc -xc99=all" dnl Solaris C
|
||||
# "-std1 % -verbose -w0 -warnprotos -std1" dnl Digital Unix
|
||||
# " % -qlanglvl=ansi -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX
|
||||
# " % -ansi -ansiE -fullwarn" dnl IRIX
|
||||
# "+ESlit % +w1 -Aa" dnl HP-UX C
|
||||
# "-Xc % -pvctl[,]fullmsg -Xc" dnl NEC SX-5 (Super-UX 10)
|
||||
# "-h conform % -h msglevel 2 -h conform" dnl Cray C (Unicos)
|
||||
#
|
||||
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
|
||||
AC_TRY_COMPILE([],[return 0;],
|
||||
[VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
|
||||
done
|
||||
FLAGS="$ac_save_[]FLAGS"
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
case ".$VAR" in
|
||||
.ok|.ok,*) m4_ifvaln($3,$3) ;;
|
||||
.|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[
|
||||
AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])
|
||||
m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;;
|
||||
*) m4_ifvaln($3,$3,[
|
||||
if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
|
||||
then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
|
||||
else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
|
||||
m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
|
||||
fi ]) ;;
|
||||
esac
|
||||
AS_VAR_POPDEF([VAR])dnl
|
||||
AS_VAR_POPDEF([FLAGS])dnl
|
||||
])
|
||||
|
||||
dnl the only difference - the LANG selection... and the default FLAGS
|
||||
|
||||
AC_DEFUN([AX_CXXFLAGS_WARN_ALL_ANSI],[dnl
|
||||
AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
|
||||
AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_warn_all_ansi])dnl
|
||||
AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum ansi warnings],
|
||||
VAR,[VAR="no, unknown"
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_CXX
|
||||
ac_save_[]FLAGS="$[]FLAGS"
|
||||
# IRIX C compiler:
|
||||
# -use_readonly_const is the default for IRIX C,
|
||||
# puts them into .rodata, but they are copied later.
|
||||
# need to be "-G0 -rdatashared" for strictmode but
|
||||
# I am not sure what effect that has really. - guidod
|
||||
for ac_arg dnl
|
||||
in "-pedantic % -Wall -ansi -pedantic" dnl GCC
|
||||
"-xstrconst % -v -Xc" dnl Solaris C
|
||||
# "-std1 % -verbose -w0 -warnprotos -std1" dnl Digital Unix
|
||||
# " % -qlanglvl=ansi -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX
|
||||
# " % -ansi -ansiE -fullwarn" dnl IRIX
|
||||
# "+ESlit % +w1 -Aa" dnl HP-UX C
|
||||
# "-Xc % -pvctl[,]fullmsg -Xc" dnl NEC SX-5 (Super-UX 10)
|
||||
# "-h conform % -h msglevel 2 -h conform" dnl Cray C (Unicos)
|
||||
#
|
||||
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
|
||||
AC_TRY_COMPILE([],[return 0;],
|
||||
[VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
|
||||
done
|
||||
FLAGS="$ac_save_[]FLAGS"
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
case ".$VAR" in
|
||||
.ok|.ok,*) m4_ifvaln($3,$3) ;;
|
||||
.|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[
|
||||
AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])
|
||||
m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;;
|
||||
*) m4_ifvaln($3,$3,[
|
||||
if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
|
||||
then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
|
||||
else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
|
||||
m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
|
||||
fi ]) ;;
|
||||
esac
|
||||
AS_VAR_POPDEF([VAR])dnl
|
||||
AS_VAR_POPDEF([FLAGS])dnl
|
||||
])
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
AC_DEFUN([AX_CHECK_COMPILER_FLAGS],
|
||||
[AC_PREREQ(2.59) dnl for _AC_LANG_PREFIX
|
||||
AC_MSG_CHECKING([whether _AC_LANG compiler accepts $1])
|
||||
dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
|
||||
AS_LITERAL_IF([$1],
|
||||
[AC_CACHE_VAL(AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1), [
|
||||
ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
|
||||
_AC_LANG_PREFIX[]FLAGS="$1"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
|
||||
AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=yes,
|
||||
AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=no)
|
||||
_AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])],
|
||||
[ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
|
||||
_AC_LANG_PREFIX[]FLAGS="$1"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
|
||||
eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=yes,
|
||||
eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=no)
|
||||
_AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])
|
||||
eval ax_check_compiler_flags=$AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)
|
||||
AC_MSG_RESULT($ax_check_compiler_flags)
|
||||
if test "x$ax_check_compiler_flags" = xyes; then
|
||||
m4_default([$2], :)
|
||||
else
|
||||
m4_default([$3], :)
|
||||
fi
|
||||
])dnl AX_CHECK_COMPILER_FLAG
|
|
@ -0,0 +1,153 @@
|
|||
|
||||
dnl Usage:
|
||||
dnl AX_CHECK_JAVA
|
||||
dnl Test for java, and defines
|
||||
dnl - JAVA_CFLAGS (compiler flags)
|
||||
dnl - LIB_JAVA (linker flags, stripping and path)
|
||||
dnl prerequisites:
|
||||
|
||||
AC_DEFUN([AX_CHECK_JAVA],
|
||||
[
|
||||
AC_ARG_WITH([java],
|
||||
[AC_HELP_STRING([--with-java=PFX], [prefix where 'java' is installed.])],
|
||||
[with_java_prefix="$withval"],
|
||||
[with_java_prefix="${JAVA_INSTALL_PATH:-/usr/java/j2sdk1.4.1_01}"])
|
||||
have_java='no'
|
||||
LIB_JAVA=''
|
||||
JAVA_FLAGS=''
|
||||
JAVA_HOME=''
|
||||
if test "x$with_java" != 'xno'
|
||||
then
|
||||
AC_MSG_CHECKING([for JAVA installation at ${with_java}])
|
||||
AC_MSG_RESULT()
|
||||
|
||||
dnl these two lines should let u find most java installations
|
||||
java_dirs="/usr /usr/local /usr/lib/j2sdk1.4-sun /usr/lib/jvm/java /System/Library/Frameworks/JavaVM.framework/Versions/Current /opt /mingw"
|
||||
java_inc_dirs="include include/libgcj Headers"
|
||||
|
||||
if test "x$with_java" != 'x'
|
||||
then
|
||||
if test -d "$with_java"
|
||||
then
|
||||
JAVA_HOME="$with_java"
|
||||
for j in $java_inc_dirs
|
||||
do
|
||||
echo "configure: __oline__: checking $JAVA_HOME/$j" >&AC_FD_CC
|
||||
if test -r "$JAVA_HOME/$j/jni.h"; then
|
||||
echo "taking that" >&AC_FD_CC
|
||||
java_inc_dir="$j"
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
else
|
||||
AC_MSG_WARN([Sorry, $with_java does not exist, checking usual places])
|
||||
with_java=''
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl now find the java dirs
|
||||
|
||||
if test "x$JAVA_HOME" = 'x'
|
||||
then
|
||||
for i in $java_dirs;
|
||||
do
|
||||
for j in $java_inc_dirs
|
||||
do
|
||||
echo "configure: __oline__: checking $i/$j" >&AC_FD_CC
|
||||
if test -r "$i/$j/jni.h"; then
|
||||
echo "taking that" >&AC_FD_CC
|
||||
JAVA_HOME="$i"
|
||||
java_inc_dir="$j"
|
||||
break
|
||||
fi
|
||||
done
|
||||
done
|
||||
if test "x$JAVA_HOME" != 'x'
|
||||
then
|
||||
AC_MSG_NOTICE([java home set to $JAVA_HOME])
|
||||
else
|
||||
AC_MSG_NOTICE([cannot find the java directory, assuming it is specified in CFLAGS])
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
failed=0;
|
||||
passed=0;
|
||||
JAVA_OLD_CPPFLAGS=$CPPFLAGS
|
||||
case "${host_os}" in
|
||||
linux*)
|
||||
java_extra_inc=linux
|
||||
;;
|
||||
darwin*)
|
||||
java_extra_inc=darwin
|
||||
;;
|
||||
*mingw32*)
|
||||
java_extra_inc=win32
|
||||
;;
|
||||
*cygwin*)
|
||||
java_extra_inc=win32
|
||||
;;
|
||||
esac
|
||||
dnl Check if extra inc is required
|
||||
CPPFLAGS="$CPPFLAGS -I$JAVA_HOME/$java_inc_dir"
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_C
|
||||
AC_COMPILE_IFELSE(
|
||||
AC_LANG_SOURCE(
|
||||
[[#include <jni.h>]]
|
||||
),
|
||||
passed=`expr $passed + 1`,failed=`expr $failed + 1`
|
||||
)
|
||||
AC_LANG_RESTORE
|
||||
CPPFLAGS="$JAVA_OLD_CPPFLAGS"
|
||||
JAVA_FLAGS="-I$JAVA_HOME/$java_inc_dir -DHasJava"
|
||||
|
||||
if test $failed -gt 0
|
||||
then
|
||||
echo "configure: __oline__: checking if extra_inc required" >&AC_FD_CC
|
||||
failed=0;
|
||||
CPPFLAGS="$CPPFLAGS -I$JAVA_HOME/$java_inc_dir -I$JAVA_HOME/$java_inc_dir/$java_extra_inc"
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_C
|
||||
AC_COMPILE_IFELSE(
|
||||
AC_LANG_SOURCE(
|
||||
[[#include <jni.h>]]
|
||||
),
|
||||
passed=`expr $passed + 1`,failed=`expr $failed + 1`
|
||||
)
|
||||
AC_LANG_RESTORE
|
||||
CPPFLAGS="$JAVA_OLD_CPPFLAGS"
|
||||
JAVA_FLAGS="-I$JAVA_HOME/$java_inc_dir -I$JAVA_HOME/$java_inc_dir/$java_extra_inc -DHasJava"
|
||||
fi
|
||||
AC_MSG_CHECKING(if JAVA package is complete)
|
||||
if test $passed -gt 0
|
||||
then
|
||||
if test $failed -gt 0
|
||||
then
|
||||
AC_MSG_RESULT(no -- some components failed test)
|
||||
have_java='no (failed tests)'
|
||||
JAVA_FLAGS=
|
||||
else
|
||||
if test "x$JAVA_HOME" = 'x'
|
||||
then
|
||||
JAVA_FLAGS=
|
||||
else
|
||||
LIB_JAVA="-L$JAVA_HOME/lib"
|
||||
fi
|
||||
AC_DEFINE(HasJava,1,Define if you have Java)
|
||||
AC_MSG_RESULT(yes)
|
||||
have_java='yes'
|
||||
fi
|
||||
else
|
||||
JAVA_FLAGS=
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
fi
|
||||
AM_CONDITIONAL(HasJava, test "x$have_java" = 'xyes')
|
||||
AC_SUBST(LIB_JAVA)
|
||||
AC_SUBST(JAVA_FLAGS)
|
||||
AC_SUBST(JAVA_HOME)
|
||||
])
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
AC_DEFUN([AX_COMPILER_VENDOR],
|
||||
[
|
||||
AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
|
||||
[ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=unknown
|
||||
# note: don't check for gcc first since some other compilers define __GNUC__
|
||||
for ventest in intel:__ICC,__ECC,__INTEL_COMPILER ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC hp:__HP_cc,__HP_aCC dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland:__BORLANDC__,__TURBOC__ comeau:__COMO__ cray:_CRAYC kai:__KCC lcc:__LCC__ metrowerks:__MWERKS__ sgi:__sgi,sgi microsoft:_MSC_VER watcom:__WATCOMC__ portland:__PGI; do
|
||||
vencpp="defined("`echo $ventest | cut -d: -f2 | sed 's/,/) || defined(/g'`")"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
|
||||
#if !($vencpp)
|
||||
thisisanerror;
|
||||
#endif
|
||||
])], [ax_cv_]_AC_LANG_ABBREV[_compiler_vendor=`echo $ventest | cut -d: -f1`; break])
|
||||
done
|
||||
])
|
||||
])
|
|
@ -0,0 +1,148 @@
|
|||
##### http://autoconf-archive.cryp.to/ax_lib_mysql.html
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_LIB_MYSQL([MINIMUM-VERSION])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This macro provides tests of availability of MySQL client library
|
||||
# of particular version or newer.
|
||||
#
|
||||
# AX_LIB_MYSQL macro takes only one argument which is optional. If
|
||||
# there is no required version passed, then macro does not run
|
||||
# version test.
|
||||
#
|
||||
# The --with-mysql option takes one of three possible values:
|
||||
#
|
||||
# no - do not check for MySQL client library
|
||||
#
|
||||
# yes - do check for MySQL library in standard locations
|
||||
# (mysql_config should be in the PATH)
|
||||
#
|
||||
# path - complete path to mysql_config utility, use this option if
|
||||
# mysql_config can't be found in the PATH
|
||||
#
|
||||
# This macro calls:
|
||||
#
|
||||
# AC_SUBST(MYSQL_CFLAGS)
|
||||
# AC_SUBST(MYSQL_LDFLAGS)
|
||||
# AC_SUBST(MYSQL_VERSION)
|
||||
#
|
||||
# And sets:
|
||||
#
|
||||
# HAVE_MYSQL
|
||||
#
|
||||
# LAST MODIFICATION
|
||||
#
|
||||
# 2006-07-16
|
||||
#
|
||||
# COPYLEFT
|
||||
#
|
||||
# Copyright (c) 2006 Mateusz Loskot <mateusz@loskot.net>
|
||||
#
|
||||
# Copying and distribution of this file, with or without
|
||||
# modification, are permitted in any medium without royalty provided
|
||||
# the copyright notice and this notice are preserved.
|
||||
|
||||
AC_DEFUN([AX_LIB_MYSQL],
|
||||
[
|
||||
AC_ARG_WITH([mysql],
|
||||
AC_HELP_STRING([--with-mysql=@<:@ARG@:>@],
|
||||
[use MySQL client library @<:@default=yes@:>@, optionally specify path to mysql_config]
|
||||
),
|
||||
[
|
||||
if test "$withval" = "no"; then
|
||||
want_mysql="no"
|
||||
elif test "$withval" = "yes"; then
|
||||
want_mysql="yes"
|
||||
else
|
||||
want_mysql="yes"
|
||||
MYSQL_CONFIG="$withval"
|
||||
fi
|
||||
],
|
||||
[want_mysql="yes"]
|
||||
)
|
||||
|
||||
MYSQL_CFLAGS=""
|
||||
MYSQL_LDFLAGS=""
|
||||
MYSQL_VERSION=""
|
||||
|
||||
dnl
|
||||
dnl Check MySQL libraries (libpq)
|
||||
dnl
|
||||
|
||||
if test "$want_mysql" = "yes"; then
|
||||
|
||||
if test -z "$MYSQL_CONFIG" -o test; then
|
||||
AC_PATH_PROG([MYSQL_CONFIG], [mysql_config], [no])
|
||||
fi
|
||||
|
||||
if test "$MYSQL_CONFIG" != "no"; then
|
||||
AC_MSG_CHECKING([for MySQL libraries])
|
||||
|
||||
MYSQL_CFLAGS="`$MYSQL_CONFIG --cflags`"
|
||||
MYSQL_LDFLAGS="`$MYSQL_CONFIG --libs_r`"
|
||||
|
||||
MYSQL_VERSION=`$MYSQL_CONFIG --version`
|
||||
|
||||
AC_DEFINE([HAVE_MYSQL], [1],
|
||||
[Define to 1 if MySQL libraries are available])
|
||||
|
||||
found_mysql="yes"
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
found_mysql="no"
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl Check if required version of MySQL is available
|
||||
dnl
|
||||
|
||||
|
||||
mysql_version_req=ifelse([$1], [], [], [$1])
|
||||
|
||||
if test "$found_mysql" = "yes" -a -n "$mysql_version_req"; then
|
||||
|
||||
AC_MSG_CHECKING([if MySQL version is >= $mysql_version_req])
|
||||
|
||||
dnl Decompose required version string of MySQL
|
||||
dnl and calculate its number representation
|
||||
mysql_version_req_major=`expr $mysql_version_req : '\([[0-9]]*\)'`
|
||||
mysql_version_req_minor=`expr $mysql_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
|
||||
mysql_version_req_micro=`expr $mysql_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
|
||||
if test "x$mysql_version_req_micro" = "x"; then
|
||||
mysql_version_req_micro="0"
|
||||
fi
|
||||
|
||||
mysql_version_req_number=`expr $mysql_version_req_major \* 1000000 \
|
||||
\+ $mysql_version_req_minor \* 1000 \
|
||||
\+ $mysql_version_req_micro`
|
||||
|
||||
dnl Decompose version string of installed MySQL
|
||||
dnl and calculate its number representation
|
||||
mysql_version_major=`expr $MYSQL_VERSION : '\([[0-9]]*\)'`
|
||||
mysql_version_minor=`expr $MYSQL_VERSION : '[[0-9]]*\.\([[0-9]]*\)'`
|
||||
mysql_version_micro=`expr $MYSQL_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
|
||||
if test "x$mysql_version_micro" = "x"; then
|
||||
mysql_version_micro="0"
|
||||
fi
|
||||
|
||||
mysql_version_number=`expr $mysql_version_major \* 1000000 \
|
||||
\+ $mysql_version_minor \* 1000 \
|
||||
\+ $mysql_version_micro`
|
||||
|
||||
mysql_version_check=`expr $mysql_version_number \>\= $mysql_version_req_number`
|
||||
if test "$mysql_version_check" = "1"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_SUBST([MYSQL_VERSION])
|
||||
AC_SUBST([MYSQL_CFLAGS])
|
||||
AC_SUBST([MYSQL_LDFLAGS])
|
||||
])
|
|
@ -0,0 +1,96 @@
|
|||
AC_DEFUN([CHECK_ERLANG], [
|
||||
#
|
||||
# Erlang checks for mod_erlang_event
|
||||
#
|
||||
AC_ARG_WITH(
|
||||
[erlang],
|
||||
[AS_HELP_STRING([--with-erlang], [Use system provided version of erlang (default: try)])],
|
||||
[with_erlang="$withval"],
|
||||
[with_erlang="try"]
|
||||
)
|
||||
|
||||
if test "$with_erlang" != "no"
|
||||
then
|
||||
save_CFLAGS="$CFLAGS"
|
||||
save_LIBS="$LIBS"
|
||||
|
||||
if test "$with_erlang" != "yes" -a "$with_erlang" != "try" ; then
|
||||
AC_MSG_CHECKING([for erlang])
|
||||
if test ! -x "$with_erlang" ; then
|
||||
AC_MSG_ERROR([Specified erlang does not exist or is not executable: $with_erlang])
|
||||
fi
|
||||
AC_MSG_RESULT([$with_erlang])
|
||||
AC_SUBST([ERLANG], ["$with_erlang"])
|
||||
else
|
||||
AC_PATH_PROG([ERLANG], ["erl"], ["no"], ["$PATH:/usr/bin:/usr/local/bin"])
|
||||
fi
|
||||
|
||||
if test "$ERLANG" != "no" ; then
|
||||
AC_MSG_CHECKING([erlang version])
|
||||
ERLANG_VER="`$ERLANG -version 2>&1 | cut -d' ' -f6`"
|
||||
|
||||
if test -z "$ERLANG_VER" ; then
|
||||
AC_MSG_ERROR([Unable to detect erlang version])
|
||||
fi
|
||||
AC_MSG_RESULT([$ERLANG_VER])
|
||||
|
||||
ERLANG_LIBDIR=`$ERLANG -noshell -eval 'io:format("~n~s/lib~n", [[code:lib_dir("erl_interface")]]).' -s erlang halt | tail -n 1`
|
||||
AC_MSG_CHECKING([erlang libdir])
|
||||
if test -z "`echo $ERLANG_LIBDIR`" ; then
|
||||
AC_MSG_ERROR([failed])
|
||||
else
|
||||
ERLANG_LDFLAGS="-L$ERLANG_LIBDIR $ERLANG_LDFLAGS"
|
||||
LIBS="-L$ERLANG_LIBDIR $LIBS"
|
||||
fi
|
||||
AC_MSG_RESULT([$ERLANG_LIBDIR])
|
||||
|
||||
ERLANG_INCDIR=`$ERLANG -noshell -eval 'io:format("~n~s/include~n", [[code:lib_dir("erl_interface")]]).' -s erlang halt | tail -n 1`
|
||||
AC_MSG_CHECKING([erlang incdir])
|
||||
if test -z "`echo $ERLANG_INCDIR`" ; then
|
||||
AC_MSG_ERROR([failed])
|
||||
else
|
||||
ERLANG_CFLAGS="-I$ERLANG_INCDIR $ERLANG_CFLAGS"
|
||||
CFLAGS="-I$ERLANG_INCDIR $CFLAGS"
|
||||
fi
|
||||
AC_MSG_RESULT([$ERLANG_INCDIR])
|
||||
|
||||
AC_CHECK_HEADERS([ei.h], [has_ei_h="yes"], [has_ei_h="no"])
|
||||
|
||||
ERLANG_LIB="ei"
|
||||
|
||||
# check liei
|
||||
AC_CHECK_LIB([$ERLANG_LIB], [ei_encode_version], [has_libei="yes"], [has_libei="no"])
|
||||
# maybe someday ei will actually expose this?
|
||||
AC_CHECK_LIB([$ERLANG_LIB], [ei_link_unlink], [ERLANG_CFLAGS="$ERLANG_CFLAGS -DEI_LINK_UNLINK"])
|
||||
|
||||
if test "$has_libei" = "no" ; then
|
||||
AS_IF([test "$with_erlang" = "try"],
|
||||
[AC_MSG_WARN([$ERLANG_LIB is unusable])],
|
||||
[AC_MSG_ERROR([$ERLANG_LIB is unusable])]
|
||||
)
|
||||
elif test "$has_ei_h" = "no"; then
|
||||
AS_IF([test "$with_erlang" = "try"],
|
||||
[AC_MSG_WARN([ei.h is unusable - are the erlang development headers installed?])],
|
||||
[AC_MSG_ERROR([ei.h is unusable - are the erlang development headers installed?])]
|
||||
)
|
||||
else
|
||||
ERLANG_LDFLAGS="$ERLANG_LDFLAGS -lei"
|
||||
AC_MSG_NOTICE([Your erlang seems OK, do not forget to enable mod_erlang_event in modules.conf])
|
||||
AC_SUBST([ERLANG_CFLAGS], [$ERLANG_CFLAGS])
|
||||
AC_SUBST([ERLANG_LDFLAGS], [$ERLANG_LDFLAGS])
|
||||
fi
|
||||
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
|
||||
else
|
||||
AS_IF([test "$with_erlang" = "try"],
|
||||
[AC_MSG_WARN([Could not find erlang, mod_erlang_event will not build, use --with-erlang to specify the location])],
|
||||
[AC_MSG_ERROR([Could not find erlang, use --with-erlang to specify the location])]
|
||||
)
|
||||
fi
|
||||
else
|
||||
AC_MSG_WARN([erlang support disabled, building mod_erlang_event will fail!])
|
||||
fi
|
||||
|
||||
])
|
|
@ -0,0 +1,235 @@
|
|||
# LIBCURL_CHECK_CONFIG ([DEFAULT-ACTION], [MINIMUM-VERSION],
|
||||
# [ACTION-IF-YES], [ACTION-IF-NO])
|
||||
# ----------------------------------------------------------
|
||||
# David Shaw <dshaw@jabberwocky.com> May-09-2006
|
||||
#
|
||||
# Checks for libcurl. DEFAULT-ACTION is the string yes or no to
|
||||
# specify whether to default to --with-libcurl or --without-libcurl.
|
||||
# If not supplied, DEFAULT-ACTION is yes. MINIMUM-VERSION is the
|
||||
# minimum version of libcurl to accept. Pass the version as a regular
|
||||
# version number like 7.10.1. If not supplied, any version is
|
||||
# accepted. ACTION-IF-YES is a list of shell commands to run if
|
||||
# libcurl was successfully found and passed the various tests.
|
||||
# ACTION-IF-NO is a list of shell commands that are run otherwise.
|
||||
# Note that using --without-libcurl does run ACTION-IF-NO.
|
||||
#
|
||||
# This macro #defines HAVE_LIBCURL if a working libcurl setup is
|
||||
# found, and sets @LIBCURL@ and @LIBCURL_CPPFLAGS@ to the necessary
|
||||
# values. Other useful defines are LIBCURL_FEATURE_xxx where xxx are
|
||||
# the various features supported by libcurl, and LIBCURL_PROTOCOL_yyy
|
||||
# where yyy are the various protocols supported by libcurl. Both xxx
|
||||
# and yyy are capitalized. See the list of AH_TEMPLATEs at the top of
|
||||
# the macro for the complete list of possible defines. Shell
|
||||
# variables $libcurl_feature_xxx and $libcurl_protocol_yyy are also
|
||||
# defined to 'yes' for those features and protocols that were found.
|
||||
# Note that xxx and yyy keep the same capitalization as in the
|
||||
# curl-config list (e.g. it's "HTTP" and not "http").
|
||||
#
|
||||
# Users may override the detected values by doing something like:
|
||||
# LIBCURL="-lcurl" LIBCURL_CPPFLAGS="-I/usr/myinclude" ./configure
|
||||
#
|
||||
# For the sake of sanity, this macro assumes that any libcurl that is
|
||||
# found is after version 7.7.2, the first version that included the
|
||||
# curl-config script. Note that it is very important for people
|
||||
# packaging binary versions of libcurl to include this script!
|
||||
# Without curl-config, we can only guess what protocols are available,
|
||||
# or use curl_version_info to figure it out at runtime.
|
||||
|
||||
AC_DEFUN([LIBCURL_CHECK_CONFIG],
|
||||
[
|
||||
AH_TEMPLATE([LIBCURL_FEATURE_SSL],[Defined if libcurl supports SSL])
|
||||
AH_TEMPLATE([LIBCURL_FEATURE_KRB4],[Defined if libcurl supports KRB4])
|
||||
AH_TEMPLATE([LIBCURL_FEATURE_IPV6],[Defined if libcurl supports IPv6])
|
||||
AH_TEMPLATE([LIBCURL_FEATURE_LIBZ],[Defined if libcurl supports libz])
|
||||
AH_TEMPLATE([LIBCURL_FEATURE_ASYNCHDNS],[Defined if libcurl supports AsynchDNS])
|
||||
AH_TEMPLATE([LIBCURL_FEATURE_IDN],[Defined if libcurl supports IDN])
|
||||
AH_TEMPLATE([LIBCURL_FEATURE_SSPI],[Defined if libcurl supports SSPI])
|
||||
AH_TEMPLATE([LIBCURL_FEATURE_NTLM],[Defined if libcurl supports NTLM])
|
||||
|
||||
AH_TEMPLATE([LIBCURL_PROTOCOL_HTTP],[Defined if libcurl supports HTTP])
|
||||
AH_TEMPLATE([LIBCURL_PROTOCOL_HTTPS],[Defined if libcurl supports HTTPS])
|
||||
AH_TEMPLATE([LIBCURL_PROTOCOL_FTP],[Defined if libcurl supports FTP])
|
||||
AH_TEMPLATE([LIBCURL_PROTOCOL_FTPS],[Defined if libcurl supports FTPS])
|
||||
AH_TEMPLATE([LIBCURL_PROTOCOL_FILE],[Defined if libcurl supports FILE])
|
||||
AH_TEMPLATE([LIBCURL_PROTOCOL_TELNET],[Defined if libcurl supports TELNET])
|
||||
AH_TEMPLATE([LIBCURL_PROTOCOL_LDAP],[Defined if libcurl supports LDAP])
|
||||
AH_TEMPLATE([LIBCURL_PROTOCOL_DICT],[Defined if libcurl supports DICT])
|
||||
AH_TEMPLATE([LIBCURL_PROTOCOL_TFTP],[Defined if libcurl supports TFTP])
|
||||
|
||||
if test "$_libcurl_with" != "no" ; then
|
||||
|
||||
AC_PROG_AWK
|
||||
|
||||
_libcurl_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'"
|
||||
|
||||
_libcurl_try_link=yes
|
||||
|
||||
if test -d "$_libcurl_with" ; then
|
||||
LIBCURL_CPPFLAGS="-I$withval/include"
|
||||
_libcurl_ldflags="-L$withval/lib"
|
||||
AC_PATH_PROG([_libcurl_config],["$withval/bin/curl-config"])
|
||||
else
|
||||
AC_PATH_PROG([_libcurl_config],[curl-config])
|
||||
fi
|
||||
|
||||
if test x$_libcurl_config != "x" ; then
|
||||
AC_CACHE_CHECK([for the version of libcurl],
|
||||
[libcurl_cv_lib_curl_version],
|
||||
[libcurl_cv_lib_curl_version=`$_libcurl_config --version | $AWK '{print $[]2}'`])
|
||||
|
||||
_libcurl_version=`echo $libcurl_cv_lib_curl_version | $_libcurl_version_parse`
|
||||
_libcurl_wanted=`echo ifelse([$2],,[0],[$2]) | $_libcurl_version_parse`
|
||||
|
||||
if test $_libcurl_wanted -gt 0 ; then
|
||||
AC_CACHE_CHECK([for libcurl >= version $2],
|
||||
[libcurl_cv_lib_version_ok],
|
||||
[
|
||||
if test $_libcurl_version -ge $_libcurl_wanted ; then
|
||||
libcurl_cv_lib_version_ok=yes
|
||||
else
|
||||
libcurl_cv_lib_version_ok=no
|
||||
fi
|
||||
])
|
||||
fi
|
||||
|
||||
if test $_libcurl_wanted -eq 0 || test x$libcurl_cv_lib_version_ok = xyes ; then
|
||||
if test x"$LIBCURL_CPPFLAGS" = "x" ; then
|
||||
LIBCURL_CPPFLAGS=`$_libcurl_config --cflags`
|
||||
fi
|
||||
if test x"$LIBCURL" = "x" ; then
|
||||
LIBCURL=`$_libcurl_config --libs --static`
|
||||
|
||||
# This is so silly, but Apple actually has a bug in their
|
||||
# curl-config script. Fixed in Tiger, but there are still
|
||||
# lots of Panther installs around.
|
||||
case "${host}" in
|
||||
powerpc-apple-darwin7*)
|
||||
LIBCURL=`echo $LIBCURL | sed -e 's|-arch i386||g'`
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# All curl-config scripts support --feature
|
||||
_libcurl_features=`$_libcurl_config --feature`
|
||||
|
||||
# Is it modern enough to have --protocols? (7.12.4)
|
||||
if test $_libcurl_version -ge 461828 ; then
|
||||
_libcurl_protocols=`$_libcurl_config --protocols`
|
||||
fi
|
||||
else
|
||||
_libcurl_try_link=no
|
||||
fi
|
||||
|
||||
unset _libcurl_wanted
|
||||
fi
|
||||
|
||||
if test $_libcurl_try_link = yes ; then
|
||||
|
||||
# we didn't find curl-config, so let's see if the user-supplied
|
||||
# link line (or failing that, "-lcurl") is enough.
|
||||
LIBCURL=${LIBCURL-"$_libcurl_ldflags -lcurl"}
|
||||
|
||||
AC_CACHE_CHECK([whether libcurl is usable],
|
||||
[libcurl_cv_lib_curl_usable],
|
||||
[
|
||||
_libcurl_save_cppflags=$CPPFLAGS
|
||||
CPPFLAGS="$LIBCURL_CPPFLAGS $CPPFLAGS"
|
||||
_libcurl_save_libs=$LIBS
|
||||
LIBS="$LIBCURL $LIBS"
|
||||
|
||||
AC_LINK_IFELSE(AC_LANG_PROGRAM([#include <curl/curl.h>],[
|
||||
/* Try and use a few common options to force a failure if we are
|
||||
missing symbols or can't link. */
|
||||
int x;
|
||||
curl_easy_setopt(NULL,CURLOPT_URL,NULL);
|
||||
x=CURL_ERROR_SIZE;
|
||||
x=CURLOPT_WRITEFUNCTION;
|
||||
x=CURLOPT_FILE;
|
||||
x=CURLOPT_ERRORBUFFER;
|
||||
x=CURLOPT_STDERR;
|
||||
x=CURLOPT_VERBOSE;
|
||||
]),libcurl_cv_lib_curl_usable=yes,libcurl_cv_lib_curl_usable=no)
|
||||
|
||||
CPPFLAGS=$_libcurl_save_cppflags
|
||||
LIBS=$_libcurl_save_libs
|
||||
unset _libcurl_save_cppflags
|
||||
unset _libcurl_save_libs
|
||||
])
|
||||
|
||||
if test $libcurl_cv_lib_curl_usable = yes ; then
|
||||
|
||||
# Does curl_free() exist in this version of libcurl?
|
||||
# If not, fake it with free()
|
||||
|
||||
_libcurl_save_cppflags=$CPPFLAGS
|
||||
CPPFLAGS="$CPPFLAGS $LIBCURL_CPPFLAGS"
|
||||
_libcurl_save_libs=$LIBS
|
||||
LIBS="$LIBS $LIBCURL"
|
||||
|
||||
AC_CHECK_FUNC(curl_free,,
|
||||
AC_DEFINE(curl_free,free,
|
||||
[Define curl_free() as free() if our version of curl lacks curl_free.]))
|
||||
|
||||
CPPFLAGS=$_libcurl_save_cppflags
|
||||
LIBS=$_libcurl_save_libs
|
||||
unset _libcurl_save_cppflags
|
||||
unset _libcurl_save_libs
|
||||
|
||||
AC_DEFINE(HAVE_LIBCURL,1,
|
||||
[Define to 1 if you have a functional curl library.])
|
||||
AC_SUBST(LIBCURL_CPPFLAGS)
|
||||
AC_SUBST(LIBCURL)
|
||||
|
||||
for _libcurl_feature in $_libcurl_features ; do
|
||||
AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_feature_$_libcurl_feature),[1])
|
||||
eval AS_TR_SH(libcurl_feature_$_libcurl_feature)=yes
|
||||
done
|
||||
|
||||
if test "x$_libcurl_protocols" = "x" ; then
|
||||
|
||||
# We don't have --protocols, so just assume that all
|
||||
# protocols are available
|
||||
_libcurl_protocols="HTTP FTP FILE TELNET LDAP DICT"
|
||||
|
||||
if test x$libcurl_feature_SSL = xyes ; then
|
||||
_libcurl_protocols="$_libcurl_protocols HTTPS"
|
||||
|
||||
# FTPS wasn't standards-compliant until version
|
||||
# 7.11.0
|
||||
if test $_libcurl_version -ge 461568; then
|
||||
_libcurl_protocols="$_libcurl_protocols FTPS"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
for _libcurl_protocol in $_libcurl_protocols ; do
|
||||
AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_protocol_$_libcurl_protocol),[1])
|
||||
eval AS_TR_SH(libcurl_protocol_$_libcurl_protocol)=yes
|
||||
done
|
||||
else
|
||||
unset LIBCURL
|
||||
unset LIBCURL_CPPFLAGS
|
||||
fi
|
||||
fi
|
||||
|
||||
unset _libcurl_try_link
|
||||
unset _libcurl_version_parse
|
||||
unset _libcurl_config
|
||||
unset _libcurl_feature
|
||||
unset _libcurl_features
|
||||
unset _libcurl_protocol
|
||||
unset _libcurl_protocols
|
||||
unset _libcurl_version
|
||||
unset _libcurl_ldflags
|
||||
fi
|
||||
|
||||
if test x$_libcurl_with = xno || test x$libcurl_cv_lib_curl_usable != xyes ; then
|
||||
# This is the IF-NO path
|
||||
ifelse([$4],,:,[$4])
|
||||
else
|
||||
# This is the IF-YES path
|
||||
ifelse([$3],,:,[$3])
|
||||
fi
|
||||
|
||||
unset _libcurl_with
|
||||
])dnl
|
|
@ -0,0 +1,163 @@
|
|||
dnl Derrick Brashear
|
||||
dnl from KTH krb and Arla
|
||||
|
||||
AC_DEFUN([ODBC_INC_WHERE1], [
|
||||
ac_cv_found_odbc_inc=no
|
||||
if test -f "$1/sql.h" ; then
|
||||
ac_cv_found_odbc_inc=yes
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN([ODBC_INC_WHERE], [
|
||||
for i in $1; do
|
||||
AC_MSG_CHECKING(for odbc header in $i)
|
||||
ODBC_INC_WHERE1($i)
|
||||
if test "$ac_cv_found_odbc_inc" = "yes"; then
|
||||
ac_cv_odbc_where_inc=$i
|
||||
AC_MSG_RESULT(found)
|
||||
break
|
||||
else
|
||||
AC_MSG_RESULT(no found)
|
||||
fi
|
||||
done
|
||||
])
|
||||
|
||||
AC_DEFUN([ODBC_LIB_WHERE1], [
|
||||
saved_LIBS=$LIBS
|
||||
saved_CFLAGS=$CFLAGS
|
||||
case "$host" in
|
||||
*darwin*)
|
||||
LIBS="$saved_LIBS -L$1 -lodbc -framework CoreFoundation"
|
||||
;;
|
||||
*)
|
||||
LIBS="$saved_LIBS -L$1 -lodbc"
|
||||
;;
|
||||
esac
|
||||
CFLAGS="$saved_CFLAGS -I$ac_cv_odbc_where_inc"
|
||||
AC_TRY_LINK(
|
||||
[#include <sql.h>],
|
||||
[SQLHDBC con;
|
||||
SQLDisconnect(con);],
|
||||
[ac_cv_found_odbc_lib=yes],
|
||||
ac_cv_found_odbc_lib=no)
|
||||
LIBS=$saved_LIBS
|
||||
CFLAGS=$saved_CFLAGS
|
||||
])
|
||||
|
||||
AC_DEFUN([TEST_LIBPATH], [
|
||||
changequote(<<, >>)
|
||||
define(<<AC_CV_FOUND>>, translit(ac_cv_found_$2_lib, <<- *>>, <<__p>>))
|
||||
changequote([, ])
|
||||
if test "$AC_CV_FOUND" = "yes"; then
|
||||
if test \! -r "$1/lib$2.a" -a \! -r "$1/lib$2.so" -a \! -r "$1/lib$2.sl" -a \! -r "$1/lib$2.dylib"; then
|
||||
AC_CV_FOUND=no
|
||||
fi
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
AC_DEFUN([ODBC_LIB_WHERE], [
|
||||
for i in $1; do
|
||||
AC_MSG_CHECKING(for odbc library in $i)
|
||||
ODBC_LIB_WHERE1($i)
|
||||
TEST_LIBPATH($i, odbc)
|
||||
if test "$ac_cv_found_odbc_lib" = "yes" ; then
|
||||
ac_cv_odbc_where_lib=$i
|
||||
AC_MSG_RESULT(found)
|
||||
break
|
||||
else
|
||||
AC_MSG_RESULT(no found)
|
||||
fi
|
||||
done
|
||||
])
|
||||
|
||||
AC_DEFUN([FIND_LIB_SUBDIR],
|
||||
[dnl
|
||||
AC_ARG_WITH([lib-subdir], AC_HELP_STRING([--with-lib-subdir=DIR],[Find libraries in DIR instead of lib]))
|
||||
AC_CHECK_SIZEOF(long)
|
||||
AC_CACHE_CHECK([what directory libraries are found in], [ac_cv_cmu_lib_subdir],
|
||||
[test "X$with_lib_subdir" = "Xyes" && with_lib_subdir=
|
||||
test "X$with_lib_subdir" = "Xno" && with_lib_subdir=
|
||||
if test "X$with_lib_subdir" = "X" ; then
|
||||
ac_cv_cmu_lib_subdir=lib
|
||||
if test $ac_cv_sizeof_long -eq 4 ; then
|
||||
test -d /usr/lib32 && ac_cv_cmu_lib_subdir=lib32
|
||||
fi
|
||||
if test $ac_cv_sizeof_long -eq 8 ; then
|
||||
test -d /usr/lib64 && ac_cv_cmu_lib_subdir=lib64
|
||||
fi
|
||||
else
|
||||
ac_cv_cmu_lib_subdir=$with_lib_subdir
|
||||
fi])
|
||||
AC_SUBST(LIB_SUBDIR, $ac_cv_cmu_lib_subdir)
|
||||
])
|
||||
|
||||
|
||||
AC_DEFUN([AX_LIB_ODBC], [
|
||||
AC_REQUIRE([FIND_LIB_SUBDIR])
|
||||
AC_ARG_WITH(odbc,
|
||||
[ --with-odbc=PREFIX Compile with ODBC support],
|
||||
[if test "X$with_odbc" = "X"; then
|
||||
with_odbc=yes
|
||||
fi])
|
||||
AC_ARG_WITH(odbc-lib,
|
||||
[ --with-odbc-lib=dir use odbc libraries in dir],
|
||||
[if test "$withval" = "yes" -o "$withval" = "no"; then
|
||||
AC_MSG_ERROR([No argument for --with-odbc-lib])
|
||||
fi])
|
||||
AC_ARG_WITH(odbc-include,
|
||||
[ --with-odbc-include=dir use odbc headers in dir],
|
||||
[if test "$withval" = "yes" -o "$withval" = "no"; then
|
||||
AC_MSG_ERROR([No argument for --with-odbc-include])
|
||||
fi])
|
||||
|
||||
if test "X$with_odbc" != "X"; then
|
||||
if test "$with_odbc" != "yes"; then
|
||||
ac_cv_odbc_where_lib=$with_odbc
|
||||
ac_cv_odbc_where_inc=$with_odbc/include
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "X$with_odbc_include" != "X"; then
|
||||
ac_cv_odbc_where_inc=$with_odbc_include
|
||||
fi
|
||||
if test "X$ac_cv_odbc_where_inc" = "X"; then
|
||||
ODBC_INC_WHERE(/usr/include /usr/local/include)
|
||||
fi
|
||||
|
||||
if test "X$with_odbc_lib" != "X"; then
|
||||
ac_cv_odbc_where_lib=$with_odbc_lib
|
||||
fi
|
||||
if test "X$ac_cv_odbc_where_lib" = "X"; then
|
||||
AC_CHECK_LIB([odbc],[SQLDisconnect],[ac_cv_odbc_where_lib="yes"],[
|
||||
ODBC_LIB_WHERE(/usr/$LIB_SUBDIR /usr/local/$LIB_SUBDIR)
|
||||
])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING(whether to include odbc)
|
||||
if test "X$ac_cv_odbc_where_lib" = "X" -o "X$ac_cv_odbc_where_inc" = "X"; then
|
||||
ac_cv_found_odbc=no
|
||||
AC_MSG_RESULT(no)
|
||||
else
|
||||
ac_cv_found_odbc=yes
|
||||
AC_MSG_RESULT(yes)
|
||||
ODBC_INC_DIR=$ac_cv_odbc_where_inc
|
||||
ODBC_LIB_DIR=$ac_cv_odbc_where_lib
|
||||
ODBC_INC_FLAGS="-I$ac_cv_odbc_where_inc"
|
||||
ODBC_LIB_FLAGS="-Wl,-lodbc"
|
||||
case "$host" in
|
||||
*darwin*)
|
||||
ODBC_LIB_FLAGS="$ODBC_LIB_FLAGS -framework CoreFoundation"
|
||||
;;
|
||||
esac
|
||||
if test "$ac_cv_odbc_where_lib" != "yes"; then
|
||||
ODBC_LIB_FLAGS="-L$ac_cv_odbc_where_lib $ODBC_LIB_FLAGS"
|
||||
fi
|
||||
AC_SUBST(ODBC_INC_DIR)
|
||||
AC_SUBST(ODBC_LIB_DIR)
|
||||
AC_SUBST(ODBC_INC_FLAGS)
|
||||
AC_SUBST(ODBC_LIB_FLAGS)
|
||||
AC_DEFINE([HAVE_ODBC],[1],[libodbc])
|
||||
fi
|
||||
])
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
AC_DEFUN([AX_HAVE_CPU_SET], [
|
||||
#
|
||||
# Check for the Linux functions for controlling processor affinity.
|
||||
#
|
||||
# LINUX: sched_setaffinity
|
||||
AC_CHECK_FUNCS(sched_setaffinity sched_getaffinity)
|
||||
if test "$ac_cv_func_sched_setaffinity" = "yes" ; then
|
||||
AC_CACHE_CHECK([whether the CPU_SET and CPU_ZERO macros are defined],
|
||||
ac_cv_cpu_set_defined,[
|
||||
saved_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $SWITCH_AM_CFLAGS $SWITCH_ANSI_CFLAGS -D_GNU_SOURCE"
|
||||
AC_TRY_COMPILE( [#include <sched.h>],[ cpu_set_t t; CPU_ZERO(&t); CPU_SET(1,&t); ],
|
||||
ac_cv_cpu_set_defined=yes,ac_cv_cpu_set_defined=no)])
|
||||
if test "$ac_cv_cpu_set_defined" = "yes" ; then
|
||||
AC_DEFINE(HAVE_CPU_SET_MACROS,1,[Define if CPU_SET and CPU_ZERO defined])
|
||||
fi
|
||||
CFLAGS="$saved_CFLAGS"
|
||||
fi
|
||||
])
|
|
@ -0,0 +1,13 @@
|
|||
Index: Makefile.am
|
||||
===================================================================
|
||||
--- Makefile.am (revision 5682)
|
||||
+++ Makefile.am (working copy)
|
||||
@@ -133,7 +133,7 @@
|
||||
if ADD_LIBEDIT
|
||||
CORE_CFLAGS += -Ilibs/libedit/src -DSWITCH_HAVE_LIBEDIT
|
||||
CORE_LIBS += libs/libedit/src/.libs/libedit.a
|
||||
-freeswitch_LDADD += -lcurses
|
||||
+freeswitch_LDADD += -lncurses
|
||||
endif
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
cd /tmp
|
||||
mkdir fix_autoconf
|
||||
cd fix_autoconf
|
||||
wget http://mirrors.kernel.org/gnu/autoconf/autoconf-2.61.tar.gz
|
||||
tar -zxvf autoconf-2.61.tar.gz
|
||||
cd autoconf-2.61
|
||||
./configure --prefix=/usr
|
||||
make
|
||||
make install
|
||||
cd /tmp
|
||||
rm -fr fix_autoconf
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
cd /tmp
|
||||
mkdir fix_automake
|
||||
cd fix_automake
|
||||
wget http://mirrors.kernel.org/gnu/automake/automake-1.10.tar.gz
|
||||
tar -zxvf automake-1.10.tar.gz
|
||||
cd automake-1.10
|
||||
./configure --prefix=/usr
|
||||
make
|
||||
make install
|
||||
cd /tmp
|
||||
rm -fr fix_automake
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
cd /tmp
|
||||
mkdir fix_libtool
|
||||
cd fix_libtool
|
||||
wget http://mirrors.kernel.org/gnu/libtool/libtool-1.5.24.tar.gz
|
||||
tar -zxvf libtool-1.5.24.tar.gz
|
||||
cd libtool-1.5.24
|
||||
if test "`uname -s`" = "Darwin"; then
|
||||
./configure --prefix=/usr --program-prefix=g
|
||||
else
|
||||
./configure --prefix=/usr
|
||||
fi
|
||||
make
|
||||
make install
|
||||
cd /tmp
|
||||
rm -fr fix_libtool
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,35 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# freeswitch.sh - startup script for freeswitch
|
||||
|
||||
. /etc/rc.conf
|
||||
. /etc/rc.d/functions
|
||||
|
||||
case "$1" in
|
||||
|
||||
start)
|
||||
if [ -x /var/freeswitch/bin/freeswitch ] ; then
|
||||
stat_busy "freeswitch starting..."
|
||||
|
||||
/var/freeswitch/bin/freeswitch -nc &
|
||||
add_daemon freeswitch
|
||||
stat_done
|
||||
fi
|
||||
;;
|
||||
|
||||
stop)
|
||||
if [ -x /var/freeswitch/bin/freeswitch ] ; then
|
||||
stat_busy "freeswitch stopping..."
|
||||
|
||||
/var/freeswitch/bin/freeswitch -stop &
|
||||
rm_daemon freeswitch
|
||||
stat_done
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "usage: $0 { start | stop }" >&2
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
|
@ -0,0 +1,103 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# /etc/rc.d/init.d/freeswitch
|
||||
#
|
||||
# The FreeSwitch Open Source Voice Platform
|
||||
#
|
||||
# chkconfig: 345 89 14
|
||||
# description: Starts and stops the freeswitch server daemon
|
||||
# processname: freeswitch
|
||||
# config: /usr/local/freeswitch/conf/freeswitch.conf
|
||||
# pidfile: /usr/local/freeswitch/run/freeswitch.pid
|
||||
#
|
||||
|
||||
# Source function library.
|
||||
. /etc/init.d/functions
|
||||
|
||||
PROG_NAME=freeswitch
|
||||
PID_FILE=${PID_FILE-/var/run/freeswitch/freeswitch.pid}
|
||||
FS_USER=${FS_USER-freeswitch}
|
||||
FS_FILE=${FS_FILE-/usr/bin/freeswitch}
|
||||
FS_HOME=${FS_HOME-/var/run/freeswitch}
|
||||
LOCK_FILE=/var/lock/subsys/freeswitch
|
||||
FREESWITCH_ARGS="-nc"
|
||||
RETVAL=0
|
||||
|
||||
# Source usr/localions file
|
||||
if [ -f /etc/sysconfig/freeswitch ]; then
|
||||
. /etc/sysconfig/freeswitch
|
||||
fi
|
||||
|
||||
# <define any local shell functions used by the code that follows>
|
||||
|
||||
start() {
|
||||
echo -n "Starting $PROG_NAME: "
|
||||
if [ -e $LOCK_FILE ]; then
|
||||
if [ -e $PID_FILE ] && [ -e /proc/`cat $PID_FILE` ]; then
|
||||
echo
|
||||
echo -n $"$PROG_NAME is already running.";
|
||||
failure $"$PROG_NAME is already running.";
|
||||
echo
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
cd $FS_HOME
|
||||
daemon --user $FS_USER --pidfile $PID_FILE "$FS_FILE $FREESWITCH_ARGS $FREESWITCH_PARAMS >/dev/null 2>&1"
|
||||
RETVAL=$?
|
||||
echo
|
||||
[ $RETVAL -eq 0 ] && touch $LOCK_FILE;
|
||||
echo
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n "Shutting down $PROG_NAME: "
|
||||
if [ ! -e $LOCK_FILE ]; then
|
||||
echo
|
||||
echo -n $"cannot stop $PROG_NAME: $PROG_NAME is not running."
|
||||
failure $"cannot stop $PROG_NAME: $PROG_NAME is not running."
|
||||
echo
|
||||
return 1;
|
||||
fi
|
||||
cd $FS_HOME
|
||||
$FS_FILE -stop > /dev/null 2>&1
|
||||
killproc $PROG_NAME
|
||||
RETVAL=$?
|
||||
echo
|
||||
[ $RETVAL -eq 0 ] && rm -f $LOCK_FILE;
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
rhstatus() {
|
||||
status $PROG_NAME;
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
status)
|
||||
status $PROG_NAME
|
||||
RETVAL=$?
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
reload)
|
||||
# <cause the service configuration to be reread, either with
|
||||
# kill -HUP or by restarting the daemons, in a manner similar
|
||||
# to restart above>
|
||||
;;
|
||||
condrestart)
|
||||
[ -f $PID_FILE ] && restart || :
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $PROG_NAME {start|stop|status|reload|restart}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
exit $RETVAL
|
|
@ -0,0 +1,212 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Template SUSE system startup script for example service/daemon FREESWITCH
|
||||
# Copyright (C) 1995--2005 Kurt Garloff, SUSE / Novell Inc.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
# your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
|
||||
# USA.
|
||||
#
|
||||
# /etc/init.d/freeswitch
|
||||
# and its symbolic link
|
||||
# /(usr/)sbin/rcfreeswitch
|
||||
#
|
||||
# Template system startup script for some example service/daemon FREESWITCH
|
||||
#
|
||||
# LSB compatible service control script; see http://www.linuxbase.org/spec/
|
||||
#
|
||||
# Note: This template uses functions rc_XXX defined in /etc/rc.status on
|
||||
# UnitedLinux/SUSE/Novell based Linux distributions. If you want to base your
|
||||
# script on this template and ensure that it works on non UL based LSB
|
||||
# compliant Linux distributions, you either have to provide the rc.status
|
||||
# functions from UL or change the script to work without them.
|
||||
# See skeleton.compat for a template that works with other distros as well.
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: freeswitch
|
||||
# Required-Start: $syslog $remote_fs
|
||||
# Should-Start: $time ypbind sendmail mysql postgresql
|
||||
# Required-Stop: $syslog $remote_fs
|
||||
# Should-Stop: $time ypbind sendmail
|
||||
# Default-Start: 3 5
|
||||
# Default-Stop: 0 1 2 6
|
||||
# Short-Description: FREESWITCH XYZ daemon providing ZYX
|
||||
# Description: Start FREESWITCH the Open Source
|
||||
# Voice Platform
|
||||
### END INIT INFO
|
||||
#
|
||||
# Check for missing binaries (stale symlinks should not happen)
|
||||
# Note: Special treatment of stop for LSB conformance
|
||||
FREESWITCH_BIN=/opt/freeswitch/bin/freeswitch
|
||||
test -x $FREESWITCH_BIN || { echo "$FREESWITCH_BIN not installed";
|
||||
if [ "$1" = "stop" ]; then exit 0;
|
||||
else exit 5; fi; }
|
||||
|
||||
# Check for existence of needed config file and read it
|
||||
FREESWITCH_CONFIG=/etc/sysconfig/freeswitch
|
||||
test -r $FREESWITCH_CONFIG || { echo "$FREESWITCH_CONFIG not existing";
|
||||
if [ "$1" = "stop" ]; then exit 0;
|
||||
else exit 6; fi; }
|
||||
|
||||
# Read config
|
||||
. $FREESWITCH_CONFIG
|
||||
|
||||
# Source LSB init functions
|
||||
# providing start_daemon, killproc, pidofproc,
|
||||
# log_success_msg, log_failure_msg and log_warning_msg.
|
||||
# This is currently not used by UnitedLinux based distributions and
|
||||
# not needed for init scripts for UnitedLinux only. If it is used,
|
||||
# the functions from rc.status should not be sourced or used.
|
||||
#. /lib/lsb/init-functions
|
||||
|
||||
# Shell functions sourced from /etc/rc.status:
|
||||
# rc_check check and set local and overall rc status
|
||||
# rc_status check and set local and overall rc status
|
||||
# rc_status -v be verbose in local rc status and clear it afterwards
|
||||
# rc_status -v -r ditto and clear both the local and overall rc status
|
||||
# rc_status -s display "skipped" and exit with status 3
|
||||
# rc_status -u display "unused" and exit with status 3
|
||||
# rc_failed set local and overall rc status to failed
|
||||
# rc_failed <num> set local and overall rc status to <num>
|
||||
# rc_reset clear both the local and overall rc status
|
||||
# rc_exit exit appropriate to overall rc status
|
||||
# rc_active checks whether a service is activated by symlinks
|
||||
. /etc/rc.status
|
||||
|
||||
# Reset status of this service
|
||||
rc_reset
|
||||
|
||||
# Return values acc. to LSB for all commands but status:
|
||||
# 0 - success
|
||||
# 1 - generic or unspecified error
|
||||
# 2 - invalid or excess argument(s)
|
||||
# 3 - unimplemented feature (e.g. "reload")
|
||||
# 4 - user had insufficient privileges
|
||||
# 5 - program is not installed
|
||||
# 6 - program is not configured
|
||||
# 7 - program is not running
|
||||
# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
|
||||
#
|
||||
# Note that starting an already running service, stopping
|
||||
# or restarting a not-running service as well as the restart
|
||||
# with force-reload (in case signaling is not supported) are
|
||||
# considered a success.
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Starting FreeSWITCH "
|
||||
## Start daemon with startproc(8). If this fails
|
||||
## the return value is set appropriately by startproc.
|
||||
/sbin/startproc $FREESWITCH_BIN $FREESWITCH_PARAMS
|
||||
|
||||
# Remember status and be verbose
|
||||
rc_status -v
|
||||
;;
|
||||
stop)
|
||||
echo -n "Shutting down FreeSWITCH "
|
||||
## Stop daemon with killproc(8) and if this fails
|
||||
## killproc sets the return value according to LSB.
|
||||
|
||||
/sbin/killproc -TERM $FREESWITCH_BIN
|
||||
|
||||
# Remember status and be verbose
|
||||
rc_status -v
|
||||
;;
|
||||
try-restart|condrestart)
|
||||
## Do a restart only if the service was active before.
|
||||
## Note: try-restart is now part of LSB (as of 1.9).
|
||||
## RH has a similar command named condrestart.
|
||||
if test "$1" = "condrestart"; then
|
||||
echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
|
||||
fi
|
||||
$0 status
|
||||
if test $? = 0; then
|
||||
$0 restart
|
||||
else
|
||||
rc_reset # Not running is not a failure.
|
||||
fi
|
||||
# Remember status and be quiet
|
||||
rc_status
|
||||
;;
|
||||
restart)
|
||||
## Stop the service and regardless of whether it was
|
||||
## running or not, start it again.
|
||||
$0 stop
|
||||
$0 start
|
||||
|
||||
# Remember status and be quiet
|
||||
rc_status
|
||||
;;
|
||||
force-reload)
|
||||
## Signal the daemon to reload its config. Most daemons
|
||||
## do this on signal 1 (SIGHUP).
|
||||
## If it does not support it, restart the service if it
|
||||
## is running.
|
||||
|
||||
echo -n "Reload service FreeSWITCH "
|
||||
## if it supports it:
|
||||
/sbin/killproc -HUP $FREESWITCH_BIN
|
||||
#touch /var/run/FREESWITCH.pid
|
||||
rc_status -v
|
||||
|
||||
## Otherwise:
|
||||
#$0 try-restart
|
||||
#rc_status
|
||||
;;
|
||||
reload)
|
||||
## Like force-reload, but if daemon does not support
|
||||
## signaling, do nothing (!)
|
||||
|
||||
# If it supports signaling:
|
||||
echo -n "Reload service FreeSWITCH "
|
||||
/sbin/killproc -HUP $FREESWITCH_BIN
|
||||
#touch /var/run/FREESWITCH.pid
|
||||
rc_status -v
|
||||
|
||||
## Otherwise if it does not support reload:
|
||||
#rc_failed 3
|
||||
#rc_status -v
|
||||
;;
|
||||
status)
|
||||
echo -n "Checking for service FreeSWITCH "
|
||||
## Check status with checkproc(8), if process is running
|
||||
## checkproc will return with exit status 0.
|
||||
|
||||
# Return value is slightly different for the status command:
|
||||
# 0 - service up and running
|
||||
# 1 - service dead, but /var/run/ pid file exists
|
||||
# 2 - service dead, but /var/lock/ lock file exists
|
||||
# 3 - service not running (unused)
|
||||
# 4 - service status unknown :-(
|
||||
# 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
|
||||
|
||||
# NOTE: checkproc returns LSB compliant status values.
|
||||
/sbin/checkproc $FREESWITCH_BIN
|
||||
# NOTE: rc_status knows that we called this init script with
|
||||
# "status" option and adapts its messages accordingly.
|
||||
rc_status -v
|
||||
;;
|
||||
probe)
|
||||
## Optional: Probe for the necessity of a reload, print out the
|
||||
## argument to this init script which is required for a reload.
|
||||
## Note: probe is not (yet) part of LSB (as of 1.9)
|
||||
|
||||
test /opt/freeswitch/conf/freeswitch.xml -nt /opt/freeswitch/run/freeswitch.pid && echo reload
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
rc_exit
|
|
@ -0,0 +1 @@
|
|||
/opt/freeswitch/lib
|
|
@ -0,0 +1,21 @@
|
|||
check process freeswitch with pidfile /opt/freeswitch/run/freeswitch.pid
|
||||
group voice
|
||||
start program = "/etc/init.d/freeswitch start"
|
||||
stop program = "/etc/init.d/freeswitch stop"
|
||||
if failed port 5060 type UDP then restart
|
||||
if 5 restarts within 5 cycles then timeout
|
||||
depends on freeswitch_bin
|
||||
depends on freeswitch_rc
|
||||
|
||||
check file freeswitch_bin with path /opt/freeswitch/bin/freeswitch
|
||||
group voice
|
||||
if failed checksum then unmonitor
|
||||
if failed permission 755 then unmonitor
|
||||
if failed uid freeswitch then unmonitor
|
||||
|
||||
check file freeswitch_rc with path /etc/init.d/freeswitch
|
||||
group voice
|
||||
if failed checksum then unmonitor
|
||||
if failed permission 755 then unmonitor
|
||||
if failed uid root then unmonitor
|
||||
if failed gid root then unmonitor
|
|
@ -0,0 +1,23 @@
|
|||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
libexecdir=@libexecdir@
|
||||
includedir=@includedir@
|
||||
modulesdir=@modulesdir@
|
||||
runtimedir=@runtimedir@
|
||||
logfiledir=@logfiledir@
|
||||
sysconfdir=@sysconfdir@
|
||||
dbdir=@dbdir@
|
||||
htdocsdir=@htdocsdir@
|
||||
localstatedir=@localstatedir@
|
||||
grammardir=@grammardir@
|
||||
soundsdir=@soundsdir@
|
||||
scriptdir=@scriptdir@
|
||||
recordingsdir=@recordingsdir@
|
||||
bindir=@bindir@
|
||||
|
||||
Name: freeswitch
|
||||
Version: @PACKAGE_VERSION@
|
||||
Description: FreeSWITCH open source telephony platform
|
||||
Libs: -L${libdir} -lfreeswitch
|
||||
Cflags: -I${includedir}
|
|
@ -0,0 +1,8 @@
|
|||
## Type: string
|
||||
## Default: ""
|
||||
## Config: ""
|
||||
## ServiceRestart: freeswitch
|
||||
#
|
||||
# if not empty: parameters for freeswitch
|
||||
#
|
||||
FREESWITCH_PARAMS=""
|
|
@ -0,0 +1,102 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# /etc/rc.d/init.d/fs_ivrd
|
||||
#
|
||||
# The FreeSwitch Open Source Voice Platform
|
||||
#
|
||||
# chkconfig: 345 89 14
|
||||
# description: Starts and stops the fs_ivrd server daemon
|
||||
# processname: fs_ivrd
|
||||
# pidfile: /usr/local/fs_ivrd/run/fs_ivrd.pid
|
||||
#
|
||||
|
||||
# Source function library.
|
||||
. /etc/init.d/functions
|
||||
|
||||
PROG_NAME=fs_ivrd
|
||||
PID_FILE=${PID_FILE-/usr/local/freeswitch/run/fs_ivrd.pid}
|
||||
#FS_USER=${FS_USER-freeswitch}
|
||||
FS_USER=${FS_USER-root}
|
||||
FS_FILE=${FS_FILE-/usr/local/freeswitch/bin/fs_ivrd}
|
||||
FS_HOME=${FS_HOME-/usr/local/freeswitch}
|
||||
LOCK_FILE=/var/lock/subsys/fs_ivrd
|
||||
IVRD_ARGS="-h localhost -p 9090"
|
||||
RETVAL=0
|
||||
|
||||
# Source options file
|
||||
if [ -f /etc/sysconfig/fs_ivrd ]; then
|
||||
. /etc/sysconfig/fs_ivrd
|
||||
fi
|
||||
|
||||
# <define any local shell functions used by the code that follows>
|
||||
|
||||
start() {
|
||||
echo -n "Starting $PROG_NAME: "
|
||||
if [ -e $LOCK_FILE ]; then
|
||||
if [ -e $PID_FILE ] && [ -e /proc/`cat $PID_FILE` ]; then
|
||||
echo
|
||||
echo -n $"$PROG_NAME is already running.";
|
||||
failure $"$PROG_NAME is already running.";
|
||||
echo
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
cd $FS_HOME
|
||||
daemon --user $FS_USER --pidfile $PID_FILE "$FS_FILE $IVRD_ARGS $IVRD_PARAMS >/dev/null 2>&1 &"
|
||||
echo
|
||||
RETVAL=$?
|
||||
[ $RETVAL -eq 0 ] && touch $LOCK_FILE;
|
||||
echo
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n "Shutting down $PROG_NAME: "
|
||||
if [ ! -e $LOCK_FILE ]; then
|
||||
echo
|
||||
echo -n $"cannot stop $PROG_NAME: $PROG_NAME is not running."
|
||||
failure $"cannot stop $PROG_NAME: $PROG_NAME is not running."
|
||||
echo
|
||||
return 1;
|
||||
fi
|
||||
cd $FS_HOME
|
||||
$FS_FILE -stop > /dev/null 2>&1
|
||||
killproc $PROG_NAME
|
||||
RETVAL=$?
|
||||
echo
|
||||
[ $RETVAL -eq 0 ] && rm -f $LOCK_FILE;
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
rhstatus() {
|
||||
status $PROG_NAME;
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
status)
|
||||
status $PROG_NAME
|
||||
RETVAL=$?
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
reload)
|
||||
# <cause the service configuration to be reread, either with
|
||||
# kill -HUP or by restarting the daemons, in a manner similar
|
||||
# to restart above>
|
||||
;;
|
||||
condrestart)
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $PROG_NAME {start|stop|status|restart}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
exit $RETVAL
|
|
@ -0,0 +1,21 @@
|
|||
open O, ">.indent.pro";
|
||||
select O;
|
||||
|
||||
while (<>) {
|
||||
open I, $_;
|
||||
while(<I>) {
|
||||
if (/([\w\d]+_t)[\s\)]/) {
|
||||
##print "-T $1 ";
|
||||
$h{$1}++;
|
||||
}
|
||||
}
|
||||
close I;
|
||||
}
|
||||
|
||||
print "-brs -sai -npsl -di0 -br -ce -d0 -cli0 -npcs -nfc1 -ut -i4 -ts4 -l155 -cs ";
|
||||
|
||||
foreach (keys %h) {
|
||||
print "-T $_ ";
|
||||
}
|
||||
|
||||
close O;
|
|
@ -0,0 +1,34 @@
|
|||
#!/bin/sh
|
||||
|
||||
TAR=@TAR@
|
||||
ZCAT=@ZCAT@
|
||||
WGET=@WGET@
|
||||
CURL=@CURL@
|
||||
|
||||
if [ -f "$WGET" ] ; then
|
||||
DOWNLOAD_CMD=$WGET
|
||||
else
|
||||
if [ -f "$CURL" ] ; then
|
||||
DOWNLOAD_CMD="$CURL -O"
|
||||
fi
|
||||
fi
|
||||
|
||||
base=http://files.freeswitch.org/g729/
|
||||
tarfile=$1
|
||||
url=`echo $tarfile | grep "://"`
|
||||
|
||||
if [ ! -z $url ] ; then
|
||||
base=$tarfile/
|
||||
tarfile=$2
|
||||
fi
|
||||
|
||||
if [ ! -f $tarfile ] ; then
|
||||
$DOWNLOAD_CMD $base$tarfile
|
||||
if [ ! -f $tarfile ] ; then
|
||||
echo cannot find $tarfile
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
#!/bin/sh
|
||||
|
||||
TAR=@TAR@
|
||||
ZCAT=@ZCAT@
|
||||
BZIP=@BZIP@
|
||||
XZ=@XZ@
|
||||
WGET=@WGET@
|
||||
CURL=@CURL@
|
||||
|
||||
if [ -f "$WGET" ]; then
|
||||
DOWNLOAD_CMD=$WGET
|
||||
elif [ -f "$CURL" ]; then
|
||||
DOWNLOAD_CMD="$CURL -O"
|
||||
fi
|
||||
|
||||
if [ -n "`echo $1 | grep '://'`" ]; then
|
||||
base=$1/
|
||||
tarfile=$2
|
||||
else
|
||||
base=http://files.freeswitch.org/downloads/libs/
|
||||
tarfile=$1
|
||||
fi
|
||||
|
||||
uncompressed=`echo $tarfile | sed 's/\(\(\.tar\.gz\|\.tar\.bz2\|\.tar\.xz\)\|\(\.tgz\|\.tbz2\)\)$//'`
|
||||
|
||||
case `echo $tarfile | sed 's/^.*\.//'` in
|
||||
bz2|tbz2) UNZIPPER=$BZIP ;;
|
||||
xz) UNZIPPER=$XZ ;;
|
||||
gz|tgz|*) UNZIPPER=$ZCAT ;;
|
||||
esac
|
||||
|
||||
if [ ! -d $tarfile ]; then
|
||||
if [ ! -f $tarfile ]; then
|
||||
rm -fr $uncompressed
|
||||
$DOWNLOAD_CMD $base$tarfile
|
||||
if [ ! -f $tarfile ]; then
|
||||
echo cannot find $tarfile
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
if [ ! -d $uncompressed ]; then
|
||||
$UNZIPPER -c -d $tarfile | $TAR -xf -
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,38 @@
|
|||
#!/bin/sh
|
||||
|
||||
TAR=@TAR@
|
||||
ZCAT=@ZCAT@
|
||||
WGET=@WGET@
|
||||
CURL=@CURL@
|
||||
|
||||
DIR=`pwd`
|
||||
|
||||
if [ -x "$WGET" ] ; then
|
||||
DOWNLOAD_CMD=$WGET
|
||||
fi
|
||||
if [ "x${DOWNLOAD_CMD}" = "x" -a -x "$CURL" ] ; then
|
||||
DOWNLOAD_CMD="$CURL -O"
|
||||
fi
|
||||
|
||||
base=http://files.freeswitch.org/
|
||||
tarfile=$1
|
||||
install=$2
|
||||
|
||||
echo -n "#"
|
||||
pwd
|
||||
echo "# $0 $1 $2"
|
||||
|
||||
if [ ! -f $tarfile ] ; then
|
||||
$DOWNLOAD_CMD $base$tarfile
|
||||
if [ ! -f $tarfile ] ; then
|
||||
echo cannot find $tarfile
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -z $install ] ; then
|
||||
test -d $install || mkdir $install
|
||||
cd $install && $ZCAT -c -d $DIR/$tarfile | $TAR xf -
|
||||
fi
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,74 @@
|
|||
################################################################################
|
||||
# ignore_helper.pl
|
||||
# Copyright (c) 2007-2009 Anthony Minessale II <anthm@freeswitch.org>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person
|
||||
# obtaining a copy of this software and associated documentation
|
||||
# files (the "Software"), to deal in the Software without
|
||||
# restriction, including without limitation the rights to use,
|
||||
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the
|
||||
# Software is furnished to do so, subject to the following
|
||||
# conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
# OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# Usage: cat <file with list of things to ignore (full path from trunk root) > | ignore_helper.pl
|
||||
#
|
||||
################################################################################
|
||||
|
||||
while (<>) {
|
||||
my $path = $_;
|
||||
my ($dir, $file) = $path =~ /(.*)\/([^\/]+)$/;
|
||||
if (!$dir) {
|
||||
$dir = ".";
|
||||
$file = $path;
|
||||
}
|
||||
|
||||
my $props = $PROP_HASH{$dir};
|
||||
if (!$props) {
|
||||
my @prop_tmp = `svn propget svn:ignore $dir`;
|
||||
my @prop_tmp2;
|
||||
foreach (@prop_tmp) {
|
||||
$_ =~ s/[\r\n]//g;
|
||||
if ($_) {
|
||||
push @prop_tmp2, $_;
|
||||
}
|
||||
}
|
||||
$props = \@prop_tmp2;
|
||||
|
||||
$PROP_HASH{$dir} = $props;
|
||||
}
|
||||
if ($props) {
|
||||
push @{$props}, "$file";
|
||||
}
|
||||
}
|
||||
|
||||
foreach (keys %PROP_HASH) {
|
||||
my $dir = $_;
|
||||
my @list = @{$PROP_HASH{$dir}};
|
||||
my $path = $dir;
|
||||
$path =~ s/\//_/g;
|
||||
$path = "/tmp/$path.tmp";
|
||||
|
||||
print "Setting Properties on $dir\n";
|
||||
|
||||
open O, ">$path";
|
||||
foreach (@list) {
|
||||
print O "$_\n";
|
||||
}
|
||||
close O;
|
||||
my $cmd = "svn propset svn:ignore -F $path $dir";
|
||||
system($cmd);
|
||||
unlink($path);
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
echo -n "-brs -npsl -di0 -br -ce -d0 -cli0 -npcs -nfc1 -ut -i4 -ts4 -l155 -cs -T size_t " > ./.indent.pro
|
||||
|
||||
for i in `find src/ -name \*.c` ; do cat $i | perl -ne 'print "-T $1 " if (/([0-9A-Za-z_-]+_t)/)' ; done | sort | uniq >> ./.indent.pro
|
||||
for i in `find src/ -name \*.h` ; do cat $i | perl -ne 'print "-T $1 " if (/([0-9A-Za-z_-]+_t)/)' ; done | sort | uniq >> ./.indent.pro
|
||||
|
||||
|
|
@ -0,0 +1,284 @@
|
|||
@SET_MAKE@
|
||||
|
||||
switch_builddir=@switch_builddir@
|
||||
switch_srcdir=@switch_srcdir@
|
||||
|
||||
build=@build@
|
||||
host=@host@
|
||||
target=$(host)
|
||||
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
libexecdir=@libexecdir@
|
||||
includedir=@includedir@
|
||||
modulesdir=@modulesdir@
|
||||
runtimedir=@runtimedir@
|
||||
logfiledir=@logfiledir@
|
||||
sysconfdir=@sysconfdir@
|
||||
localstatedir=@localstatedir@
|
||||
grammardir=@grammardir@
|
||||
|
||||
CC=@CC@
|
||||
CXX=@CXX@
|
||||
AWK=@AWK@
|
||||
SHELL=@SHELL@
|
||||
INSTALL=@INSTALL@
|
||||
GETLIB=@GETLIB@
|
||||
LIBTOOL=@LIBTOOL@
|
||||
AR=@AR@
|
||||
LIBGNUTLS_LIBS=@LIBGNUTLS_LIBS@
|
||||
LTINSTALL=$(LIBTOOL) --quiet --mode=install $(INSTALL)
|
||||
LTUNINSTALL=$(LIBTOOL) --mode=uninstall rm -f
|
||||
CCLD = $(CC)
|
||||
CXXLD = $(CXX)
|
||||
|
||||
LIBCURL_DEPS=@LIBCURL_DEPS@
|
||||
LIBCURL=@LIBCURL@
|
||||
LIBCURL_CPPFLAGS=@LIBCURL_CPPFLAGS@
|
||||
CURL_DIR=$(switch_srcdir)/libs/curl
|
||||
CURLLA=$(switch_builddir)/libs/curl/lib/libcurl.la
|
||||
|
||||
OPENSSL_LIBS=@openssl_LIBS@
|
||||
OPENSSL_CFLAGS=@openssl_CFLAGS@
|
||||
|
||||
LIBS=$(switch_builddir)/libfreeswitch.la
|
||||
DEFS=@DEFS@
|
||||
|
||||
DYLD_LIBRARY_PATH=@libdir@:$DYLD_LIBRARY_PATH
|
||||
LD_LIBRARY_PATH=@libdir@:$LD_LIBRARY_PATH
|
||||
OSARCH=`uname -s`
|
||||
DYNAMIC_LIB_EXTEN = @DYNAMIC_LIB_EXTEN@
|
||||
LIBTOOL_LIB_EXTEN = @LIBTOOL_LIB_EXTEN@
|
||||
SOLINK = @SOLINK@
|
||||
|
||||
CFLAGS=@CFLAGS@
|
||||
CXXFLAGS=@CXXFLAGS@
|
||||
LDFLAGS=@SWITCH_AM_LDFLAGS@ @LDFLAGS@ $(OUR_LDFLAGS)
|
||||
|
||||
ALL_CFLAGS = $(LOCAL_CFLAGS) $(MOD_CFLAGS) @SWITCH_AM_CFLAGS@ @CFLAGS@ @SWITCH_ANSI_CFLAGS@ -D_GNU_SOURCE $(OUR_CFLAGS)
|
||||
ALL_CXXFLAGS = $(LOCAL_CFLAGS) $(MOD_CFLAGS) @SWITCH_AM_CXXFLAGS@ @CXXFLAGS@ -D_GNU_SOURCE $(OUR_CFLAGS)
|
||||
|
||||
DEFAULT_VARS:= CFLAGS="$(CFLAGS)" CPPFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" CC="$(CC)" CXX="$(CXX)"
|
||||
DEFAULT_ARGS:= --build=$(build) --host=$(host) --target=$(target) \
|
||||
--prefix="$(prefix)" --exec_prefix="$(exec_prefix)" --libdir="$(libdir)" \
|
||||
--disable-shared --with-pic
|
||||
|
||||
COMPILE = $(CC) $(ALL_CFLAGS) $(DEFS)
|
||||
LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(COMPILE)
|
||||
LINK = $(LIBTOOL) --mode=link --tag=CC $(CCLD) $(ALL_CFLAGS) $(LDFLAGS) -shared -module -avoid-version -rpath $(modulesdir) -o $@
|
||||
|
||||
CXXCOMPILE = $(CXX) $(ALL_CXXFLAGS) $(DEFS)
|
||||
LTCXXCOMPILE = $(LIBTOOL) --mode=compile --tag=CXX $(CXXCOMPILE)
|
||||
CXXLINK = $(LIBTOOL) --mode=link --tag=CXX $(CXXLD) $(ALL_CXXFLAGS) $(LDFLAGS) -shared -module -avoid-version -rpath $(modulesdir) -o $@
|
||||
|
||||
CSOURCEFILE=$(MODNAME).c
|
||||
CXXSOURCEFILE=$(MODNAME).cpp
|
||||
TOUCH_TARGET=@TOUCH_TARGET@
|
||||
|
||||
#MAKE_OPTS = `if test -z "$(VERBOSE)" ; then $(MAKE) --help | grep silent | grep "\-s" 2>&1 >/dev/null && echo -s;fi`
|
||||
MAKE_OPTS = `test -n "$(VERBOSE)" || echo -s`
|
||||
RECURSE_MODNAME=`pwd | sed -e 's|^.*/||'`
|
||||
RECURSE_SOURCEFILE=`if test -f "$$modname.cpp" -o -f "$(MODDIR)/$$modname.cpp"; then echo "$$modname.cpp"; else echo "$$modname.c"; fi`
|
||||
RECURSE_OUR_CFLAGS=` $(LOCAL_INSERT_CFLAGS) `
|
||||
RECURSE_OUR_LDFLAGS=` $(LOCAL_INSERT_LDFLAGS) `
|
||||
RECURSE_MODDIR=`if test -z $(MODDIR); then pwd | sed -e 's|$(switch_builddir)|$(switch_srcdir)|'; else echo $(MODDIR); fi`
|
||||
RECURSE_MAKE=+modname="$(RECURSE_MODNAME)" ; \
|
||||
sourcefile="$(RECURSE_SOURCEFILE)" ; \
|
||||
osarch=`uname -s` ; \
|
||||
ourcflags="$(RECURSE_OUR_CFLAGS)" ; \
|
||||
ourldflags="$(RECURSE_OUR_LDFLAGS)" ; \
|
||||
insertobjs="`$(LOCAL_INSERT_OBJS)`" ; \
|
||||
moddir="$(RECURSE_MODDIR)" ; \
|
||||
$(MAKE) $(MAKE_OPTS) MODNAME="$$modname" SOURCEFILE="$$sourcefile" MODDIR="$$moddir" \
|
||||
OUR_CFLAGS="$$ourcflags" OUR_LDFLAGS="$$ourldflags" OUR_OBJS="$$insertobjs"
|
||||
|
||||
all: Makefile
|
||||
@$(RECURSE_MAKE) all-modules || exit 1
|
||||
depend: Makefile
|
||||
@$(RECURSE_MAKE) depend-modules || exit 1
|
||||
clean: Makefile
|
||||
@$(RECURSE_MAKE) clean-modules || exit 1
|
||||
install: Makefile
|
||||
@$(RECURSE_MAKE) install-modules || exit 1
|
||||
uninstall: Makefile
|
||||
@$(RECURSE_MAKE) uninstall-modules || exit 1
|
||||
distclean: Makefile
|
||||
@$(RECURSE_MAKE) distclean-modules || exit 1
|
||||
extraclean: Makefile
|
||||
@$(RECURSE_MAKE) extraclean-modules || exit 1
|
||||
|
||||
all-modules: local_depend $(MODNAME).$(LIBTOOL_LIB_EXTEN) local_all Makefile
|
||||
depend-modules: local_depend
|
||||
clean-modules: local_clean mod_clean
|
||||
install-modules: all-modules depend_install local_install mod_install
|
||||
uninstall-modules: local_uninstall mod_uninstall
|
||||
distclean-modules: clean-modules local_distclean
|
||||
extraclean-modules: distclean local_extraclean
|
||||
|
||||
Makefile:
|
||||
@if test ! -f $@; then \
|
||||
if ! pwd | grep $(switch_builddir)/src/mod ; then rulesdir=$(switch_builddir) ; else rulesdir=../../../.. ; fi ; \
|
||||
echo BASE=$$rulesdir > Makefile ; \
|
||||
echo 'include $$(BASE)/build/modmake.rules' >> Makefile ; \
|
||||
fi ;
|
||||
|
||||
$(CURLLA):
|
||||
@cd $(CURL_DIR) && $(MAKE)
|
||||
|
||||
LINK_OUTPUT_REDIR=> .libs/$(MODNAME).log || error="yes" ; \
|
||||
if test -n "$(VERBOSE)" -o "$$error" = "yes"; then \
|
||||
cat .libs/$(MODNAME).log ; \
|
||||
fi ;\
|
||||
if test "$$error" = "yes"; then \
|
||||
exit 1 ;\
|
||||
fi
|
||||
|
||||
$(MODNAME).$(LIBTOOL_LIB_EXTEN): $(LIBS) $(LOCAL_LIBADD) $(LOCAL_OBJS) $(OUR_OBJS) $(MODDIR)/$(SOURCEFILE) $(MODNAME).lo
|
||||
@echo Creating $@...
|
||||
@test -d .libs || mkdir .libs
|
||||
@error="";\
|
||||
if test -f "$(CSOURCEFILE)" -o -f "$(MODDIR)/$(CSOURCEFILE)"; then \
|
||||
$(LINK) $(SOLINK) $(MODNAME).lo $(LIBS) $(LOCAL_LDFLAGS) $(LOCAL_OBJS) $(OUR_OBJS) $(LOCAL_LIBADD) $(LOCAL_LDFLAGS_POST) $(LINK_OUTPUT_REDIR) ;\
|
||||
else \
|
||||
$(CXXLINK) $(SOLINK) $(MODNAME).lo $(LIBS) $(LOCAL_LDFLAGS) $(LOCAL_OBJS) $(OUR_OBJS) $(LOCAL_LIBADD) $(LOCAL_LDFLAGS_POST) $(LINK_OUTPUT_REDIR) ;\
|
||||
fi;
|
||||
|
||||
mod_clean:
|
||||
@rm -fr *.$(LIBTOOL_LIB_EXTEN) *.o *.lo *~ .libs $(LOCAL_OBJS)
|
||||
|
||||
mod_install: $(DESTDIR)$(modulesdir)/$(MODNAME).$(LIBTOOL_LIB_EXTEN)
|
||||
|
||||
$(DESTDIR)$(modulesdir)/$(MODNAME).$(LIBTOOL_LIB_EXTEN):$(MODNAME).$(LIBTOOL_LIB_EXTEN)
|
||||
@echo installing $<
|
||||
@$(LTINSTALL) $(MODNAME).$(LIBTOOL_LIB_EXTEN) $(DESTDIR)$(modulesdir) >/dev/null
|
||||
|
||||
mod_uninstall:
|
||||
@$(LTUNINSTALL) $(DESTDIR)$(modulesdir)/$(MODNAME).$(LIBTOOL_LIB_EXTEN)
|
||||
|
||||
# define these in your makefile if you wish
|
||||
local_all local_depend local_clean depend_install local_install local_distclean local_extraclean local_uninstall:
|
||||
|
||||
#
|
||||
# Implicit rules for creating outputs from input files
|
||||
#
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .lo .o .cpp
|
||||
|
||||
.c.o:
|
||||
@echo Compiling $<...
|
||||
@if test ! -z $(VERBOSE) ; then echo $(COMPILE) -c -o $@ `test -f '$<' || echo '$(MODDIR)/'`$< ; fi
|
||||
@$(COMPILE) -c -o $@ `test -f '$<' || echo '$(MODDIR)/'`$< || exit 1
|
||||
|
||||
.c.lo:
|
||||
@echo Compiling $<...
|
||||
@if test ! -z $(VERBOSE) ; then echo $(LTCOMPILE) -c -o $@ `test -f '$<' || echo '$(MODDIR)/'`$< ; fi
|
||||
@$(LTCOMPILE) -c -o $@ `test -f '$<' || echo '$(MODDIR)/'`$< || exit 1
|
||||
|
||||
.cpp.o:
|
||||
@echo Compiling $<...
|
||||
@if test ! -z $(VERBOSE) ; then echo $(CXXCOMPILE) -c -o $@ `test -f '$<' || echo '$(MODDIR)/'`$< ; fi
|
||||
@$(CXXCOMPILE) -c -o $@ `test -f '$<' || echo '$(MODDIR)/'`$< || exit 1
|
||||
|
||||
.cpp.lo:
|
||||
@echo Compiling $<...
|
||||
@if test ! -z $(VERBOSE) ; then echo $(LTCXXCOMPILE) -c -o $@ `test -f '$<' || echo '$(MODDIR)/'`$< ; fi
|
||||
@$(LTCXXCOMPILE) -c -o $@ `test -f '$<' || echo '$(MODDIR)/'`$< || exit 1
|
||||
|
||||
$(MODNAME).o: $(MODDIR)/$(SOURCEFILE) \
|
||||
$(switch_srcdir)/src/include/switch.h \
|
||||
$(switch_builddir)/src/include/switch_am_config.h \
|
||||
$(switch_srcdir)/src/include/switch_types.h $(switch_srcdir)/src/include/switch_apr.h \
|
||||
$(switch_srcdir)/src/include/switch_core_db.h $(switch_srcdir)/src/include/switch_regex.h \
|
||||
$(switch_srcdir)/src/include/switch_core.h $(switch_srcdir)/src/include/switch_loadable_module.h \
|
||||
$(switch_srcdir)/src/include/switch_console.h $(switch_srcdir)/src/include/switch_utils.h \
|
||||
$(switch_srcdir)/src/include/switch_caller.h $(switch_srcdir)/src/include/switch_config.h \
|
||||
$(switch_srcdir)/src/include/switch_frame.h $(switch_srcdir)/src/include/switch_module_interfaces.h \
|
||||
$(switch_srcdir)/src/include/switch_channel.h $(switch_srcdir)/src/include/switch_buffer.h \
|
||||
$(switch_srcdir)/src/include/switch_event.h $(switch_srcdir)/src/include/switch_resample.h \
|
||||
$(switch_srcdir)/src/include/switch_ivr.h $(switch_srcdir)/src/include/switch_rtp.h \
|
||||
$(switch_srcdir)/src/include/switch_stun.h $(switch_srcdir)/src/include/switch_log.h \
|
||||
$(switch_srcdir)/src/include/switch_xml.h
|
||||
@echo Compiling $<...
|
||||
if test -f "$(CSOURCEFILE)" -o -f "$(MODDIR)/$(CSOURCEFILE)"; then \
|
||||
if test ! -z $(VERBOSE) ; then echo $(COMPILE) -c -o $@ `test -f '$<' || echo '$(MODDIR)/'`$< ; fi ;\
|
||||
$(COMPILE) -c -o $@ `test -f '$<' || echo '$(MODDIR)/'`$< ; \
|
||||
else \
|
||||
if test ! -z $(VERBOSE) ; then echo $(CXXCOMPILE) -c -o $@ `test -f '$<' || echo '$(MODDIR)/'`$< ; fi ;\
|
||||
$(CXXCOMPILE) -c -o $@ `test -f '$<' || echo '$(MODDIR)/'`$< ; \
|
||||
fi;
|
||||
|
||||
$(MODNAME).lo: $(MODDIR)/$(SOURCEFILE) \
|
||||
$(switch_srcdir)/src/include/switch.h \
|
||||
$(switch_builddir)/src/include/switch_am_config.h \
|
||||
$(switch_srcdir)/src/include/switch_types.h $(switch_srcdir)/src/include/switch_apr.h \
|
||||
$(switch_srcdir)/src/include/switch_core_db.h $(switch_srcdir)/src/include/switch_regex.h \
|
||||
$(switch_srcdir)/src/include/switch_core.h $(switch_srcdir)/src/include/switch_loadable_module.h \
|
||||
$(switch_srcdir)/src/include/switch_console.h $(switch_srcdir)/src/include/switch_utils.h \
|
||||
$(switch_srcdir)/src/include/switch_caller.h $(switch_srcdir)/src/include/switch_config.h \
|
||||
$(switch_srcdir)/src/include/switch_frame.h $(switch_srcdir)/src/include/switch_module_interfaces.h \
|
||||
$(switch_srcdir)/src/include/switch_channel.h $(switch_srcdir)/src/include/switch_buffer.h \
|
||||
$(switch_srcdir)/src/include/switch_event.h $(switch_srcdir)/src/include/switch_resample.h \
|
||||
$(switch_srcdir)/src/include/switch_ivr.h $(switch_srcdir)/src/include/switch_rtp.h \
|
||||
$(switch_srcdir)/src/include/switch_stun.h $(switch_srcdir)/src/include/switch_log.h \
|
||||
$(switch_srcdir)/src/include/switch_xml.h
|
||||
@echo Compiling $<...
|
||||
if test -f "$(CSOURCEFILE)" -o -f "$(MODDIR)/$(CSOURCEFILE)"; then \
|
||||
if test ! -z $(VERBOSE) ; then echo $(LTCOMPILE) -c -o $@ `test -f '$<' || echo '$(MODDIR)/'`$< ; fi ;\
|
||||
$(LTCOMPILE) -c -o $@ `test -f '$<' || echo '$(MODDIR)/'`$< ; \
|
||||
else \
|
||||
if test ! -z $(VERBOSE) ; then echo $(LTCXXCOMPILE) -c -o $@ `test -f '$<' || echo '$(MODDIR)/'`$< ; fi ;\
|
||||
$(LTCXXCOMPILE) -c -o $@ `test -f '$<' || echo '$(MODDIR)/'`$< ; \
|
||||
fi;
|
||||
|
||||
$(switch_srcdir)/src/include/switch.h:
|
||||
|
||||
$(switch_builddir)/src/include/switch_am_config.h: $(switch_srcdir)/src/include/switch_am_config.h.in
|
||||
|
||||
$(switch_srcdir)/src/include/switch_types.h:
|
||||
|
||||
$(switch_srcdir)/src/include/switch_apr.h:
|
||||
|
||||
$(switch_srcdir)/src/include/switch_core_db.h:
|
||||
|
||||
$(switch_srcdir)/src/include/switch_regex.h:
|
||||
|
||||
$(switch_srcdir)/src/include/switch_core.h:
|
||||
|
||||
$(switch_srcdir)/src/include/switch_loadable_module.h:
|
||||
|
||||
$(switch_srcdir)/src/include/switch_console.h:
|
||||
|
||||
$(switch_srcdir)/src/include/switch_utils.h:
|
||||
|
||||
$(switch_srcdir)/src/include/switch_caller.h:
|
||||
|
||||
$(switch_srcdir)/src/include/switch_config.h:
|
||||
|
||||
$(switch_srcdir)/src/include/switch_frame.h:
|
||||
|
||||
$(switch_srcdir)/src/include/switch_module_interfaces.h:
|
||||
|
||||
$(switch_srcdir)/src/include/switch_channel.h:
|
||||
|
||||
$(switch_srcdir)/src/include/switch_buffer.h:
|
||||
|
||||
$(switch_srcdir)/src/include/switch_event.h:
|
||||
|
||||
$(switch_srcdir)/src/include/switch_resample.h:
|
||||
|
||||
$(switch_srcdir)/src/include/switch_ivr.h:
|
||||
|
||||
$(switch_srcdir)/src/include/switch_rtp.h:
|
||||
|
||||
$(switch_srcdir)/src/include/switch_stun.h:
|
||||
|
||||
$(switch_srcdir)/src/include/switch_log.h:
|
||||
|
||||
$(switch_srcdir)/src/include/switch_xml.h:
|
||||
|
||||
|
||||
.PHONY: all clean depend install distclean extraclean \
|
||||
all-modules clean-modules depend-modules install-modules distclean-modules extraclean-modules \
|
||||
local_all local_clean local_depend local_install local_distclean local_extraclean \
|
||||
mod_clean mod_install mod_uninstall depend_install
|
|
@ -0,0 +1,19 @@
|
|||
AM_CFLAGS = $(SWITCH_AM_CFLAGS) $(SWITCH_ANSI_CFLAGS)
|
||||
AM_CPPFLAGS = $(SWITCH_AM_CXXFLAGS)
|
||||
AM_LDFLAGS = $(SWITCH_AM_LDFLAGS)
|
||||
#we should set all these vars from configure, no reason to have these in each Makefile.am
|
||||
LIBTOOL = echo "`link=\`echo $@|grep .la;echo $@|grep .so;echo $@|grep .dll\`;if test -n "$$link"; then echo Creating $@;fi`";`if test -z "$(VERBOSE)" ; \
|
||||
then echo $(SHELL) $(switch_builddir)/quiet_libtool ;else echo $(SHELL) $(switch_builddir)/libtool; fi`
|
||||
AM_MAKEFLAGS=`test -n "$(VERBOSE)" || echo -s`
|
||||
# Dirty trick to override the link output
|
||||
LIBS+=> $(MODNAME).log || error="yes";if test -n "$(VERBOSE)" -o "$$error" = "yes";then cat $(MODNAME).log;fi;if test "$$error" = "yes";then exit 1;fi
|
||||
|
||||
moddir=@modulesdir@
|
||||
|
||||
all-modules: all
|
||||
depend-modules: depend
|
||||
clean-modules: clean
|
||||
install-modules: install
|
||||
uninstall-modules: uninstall
|
||||
distclean-modules: distclean
|
||||
extraclean-modules: extraclean
|
|
@ -0,0 +1,132 @@
|
|||
#applications/mod_abstraction
|
||||
#applications/mod_avmd
|
||||
#applications/mod_blacklist
|
||||
#applications/mod_callcenter
|
||||
#applications/mod_cidlookup
|
||||
applications/mod_cluechoo
|
||||
applications/mod_commands
|
||||
applications/mod_conference
|
||||
#applications/mod_curl
|
||||
applications/mod_db
|
||||
#applications/mod_directory
|
||||
#applications/mod_distributor
|
||||
applications/mod_dptools
|
||||
#applications/mod_easyroute
|
||||
applications/mod_enum
|
||||
applications/mod_esf
|
||||
#applications/mod_esl
|
||||
applications/mod_expr
|
||||
applications/mod_fifo
|
||||
#applications/mod_fsk
|
||||
applications/mod_fsv
|
||||
applications/mod_hash
|
||||
applications/mod_httapi
|
||||
#applications/mod_http_cache
|
||||
#applications/mod_ladspa
|
||||
#applications/mod_lcr
|
||||
#applications/mod_memcache
|
||||
#applications/mod_mongo
|
||||
#applications/mod_nibblebill
|
||||
#applications/mod_osp
|
||||
#applications/mod_redis
|
||||
#applications/mod_rss
|
||||
applications/mod_sms
|
||||
#applications/mod_snapshot
|
||||
#applications/mod_snipe_hunt
|
||||
#applications/mod_snom
|
||||
#applications/mod_soundtouch
|
||||
applications/mod_spandsp
|
||||
#applications/mod_spy
|
||||
#applications/mod_stress
|
||||
applications/mod_valet_parking
|
||||
#applications/mod_vmd
|
||||
applications/mod_voicemail
|
||||
#applications/mod_voicemail_ivr
|
||||
#asr_tts/mod_cepstral
|
||||
#asr_tts/mod_flite
|
||||
#asr_tts/mod_pocketsphinx
|
||||
#asr_tts/mod_tts_commandline
|
||||
#asr_tts/mod_unimrcp
|
||||
codecs/mod_amr
|
||||
#codecs/mod_amrwb
|
||||
codecs/mod_bv
|
||||
#codecs/mod_celt
|
||||
#codecs/mod_codec2
|
||||
#codecs/mod_com_g729
|
||||
#codecs/mod_dahdi_codec
|
||||
codecs/mod_g723_1
|
||||
codecs/mod_g729
|
||||
codecs/mod_h26x
|
||||
codecs/mod_ilbc
|
||||
#codecs/mod_isac
|
||||
#codecs/mod_opus
|
||||
#codecs/mod_sangoma_codec
|
||||
#codecs/mod_silk
|
||||
codecs/mod_siren
|
||||
codecs/mod_speex
|
||||
dialplans/mod_dialplan_asterisk
|
||||
#dialplans/mod_dialplan_directory
|
||||
dialplans/mod_dialplan_xml
|
||||
#directories/mod_ldap
|
||||
#endpoints/mod_alsa
|
||||
#endpoints/mod_dingaling
|
||||
#endpoints/mod_h323
|
||||
#endpoints/mod_khomp
|
||||
endpoints/mod_loopback
|
||||
#endpoints/mod_opal
|
||||
#endpoints/mod_portaudio
|
||||
#endpoints/mod_rtmp
|
||||
#endpoints/mod_skinny
|
||||
#endpoints/mod_skypopen
|
||||
endpoints/mod_sofia
|
||||
event_handlers/mod_cdr_csv
|
||||
#event_handlers/mod_cdr_mongodb
|
||||
#event_handlers/mod_cdr_pg_csv
|
||||
event_handlers/mod_cdr_sqlite
|
||||
#event_handlers/mod_erlang_event
|
||||
#event_handlers/mod_event_multicast
|
||||
event_handlers/mod_event_socket
|
||||
#event_handlers/mod_event_zmq
|
||||
#event_handlers/mod_radius_cdr
|
||||
#event_handlers/mod_snmp
|
||||
formats/mod_local_stream
|
||||
formats/mod_native_file
|
||||
#formats/mod_portaudio_stream
|
||||
#formats/mod_shell_stream
|
||||
#formats/mod_shout
|
||||
formats/mod_sndfile
|
||||
formats/mod_tone_stream
|
||||
#languages/mod_java
|
||||
languages/mod_lua
|
||||
#languages/mod_managed
|
||||
#languages/mod_perl
|
||||
#languages/mod_python
|
||||
languages/mod_spidermonkey
|
||||
#languages/mod_yaml
|
||||
loggers/mod_console
|
||||
loggers/mod_logfile
|
||||
loggers/mod_syslog
|
||||
#say/mod_say_de
|
||||
say/mod_say_en
|
||||
#say/mod_say_es
|
||||
#say/mod_say_fr
|
||||
#say/mod_say_he
|
||||
#say/mod_say_hu
|
||||
#say/mod_say_it
|
||||
#say/mod_say_nl
|
||||
#say/mod_say_pt
|
||||
#say/mod_say_ru
|
||||
#say/mod_say_th
|
||||
#say/mod_say_zh
|
||||
#timers/mod_posix_timer
|
||||
#timers/mod_timerfd
|
||||
xml_int/mod_xml_cdr
|
||||
#xml_int/mod_xml_curl
|
||||
#xml_int/mod_xml_ldap
|
||||
xml_int/mod_xml_rpc
|
||||
|
||||
#../../libs/freetdm/mod_freetdm
|
||||
#../../libs/openzap/mod_openzap
|
||||
|
||||
## Experimental Modules (don't cry if they're broken)
|
||||
#../../contrib/mod/xml_int/mod_xml_odbc
|
|
@ -0,0 +1 @@
|
|||
1.0.8
|
|
@ -0,0 +1,3 @@
|
|||
en-us-callie 1.0.18
|
||||
ru-RU-elena 1.0.13
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/perl
|
||||
while(<>) {
|
||||
s/SWITCH_DECLARE_CONSTRUCTOR//g;
|
||||
s/SWITCH_DECLARE[^\(]*\((.*?)\)/$1/g;
|
||||
print;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
cd src/mod/languages/mod_lua
|
||||
make swigclean
|
||||
make lua_wrap
|
||||
cd ../../../..
|
||||
|
||||
cd src/mod/languages/mod_perl
|
||||
make swigclean
|
||||
make mod_perl_wrap.cpp
|
||||
cd ../../../..
|
||||
|
||||
cd src/mod/languages/mod_python
|
||||
make swigclean
|
||||
make mod_python_wrap.cpp
|
||||
cd ../../../..
|
||||
|
||||
cd src/mod/languages/mod_java
|
||||
make reswig
|
||||
cd ../../../..
|
||||
|
||||
cd src/mod/languages/mod_managed
|
||||
make reswig
|
||||
cd ../../../..
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
arg=$1 ; shift
|
||||
prefix=`cat config.log | grep ^prefix=\' | awk -F \' '{print $2}'`
|
||||
if [ -z $prefix ] ; then
|
||||
prefix="/usr/local/freeswitch"
|
||||
fi
|
||||
unset VERBOSE
|
||||
switch_srcdir=`pwd`
|
||||
if [ -z $MAKE ] ; then
|
||||
MAKE=make
|
||||
fi
|
||||
|
||||
if [ -z $arg ] ; then
|
||||
echo "Cleaning tree...."
|
||||
$MAKE clean modwipe 2>&1 > /dev/null
|
||||
echo "Building core...."
|
||||
$MAKE -j freeswitch 2>&1 > /dev/null
|
||||
MODS=`cat modules.conf | grep -v \#`
|
||||
for i in $MODS ; do
|
||||
MOD_NAME=`echo $i | sed -e 's|^.*/||'`
|
||||
MOD_DIR=`if test -d $switch_srcdir/src/mod/$i ; then echo $switch_srcdir/src/mod/$i ; else echo $i ; fi;`
|
||||
touch /tmp/$MOD_NAME.tmp
|
||||
$0 $MOD_NAME $MOD_DIR
|
||||
done
|
||||
echo "Building mods...."
|
||||
while [ 1 = 1 ] ; do
|
||||
x=0
|
||||
for i in $MODS ; do
|
||||
if [ -f /tmp/$MOD_NAME.tmp ] ; then
|
||||
x=$[$x+1];
|
||||
fi
|
||||
done
|
||||
if [ $x = 0 ] ; then
|
||||
echo Build finished. Making install
|
||||
$MAKE -j install 2>&1 > /dev/null
|
||||
echo done
|
||||
exit;
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! $arg = "bg" ] ; then
|
||||
$0 bg $arg $@ &
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
MOD_NAME=$1 ; shift
|
||||
MOD_DIR=$1 ; shift
|
||||
|
||||
#echo "Making module in $MOD_NAME..."
|
||||
if [ -f $MOD_DIR/Makefile ] ; then
|
||||
cd $MOD_DIR && BASE=$switch_srcdir $MAKE -j 2>&1 > /dev/null
|
||||
else
|
||||
cd $MOD_DIR && BASE=$switch_srcdir $MAKE -j -f $switch_srcdir/build/modmake.rules 2>&1 > /dev/null
|
||||
fi
|
||||
|
||||
#echo "Finished making module in $MOD_NAME"
|
||||
sleep 1
|
||||
rm /tmp/$MOD_NAME.tmp
|
||||
|
||||
|
Binary file not shown.
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
mxmlc -static-link-runtime-shared-libraries freeswitch.mxml
|
|
@ -0,0 +1,313 @@
|
|||
/*
|
||||
Copyright (c) 2009, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.adobe.air.crypto
|
||||
{
|
||||
import com.adobe.crypto.SHA256;
|
||||
|
||||
import flash.data.EncryptedLocalStore;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
/**
|
||||
* The EncryptionKeyGenerator class generates an encryption key value, such as you would use
|
||||
* to encrypt files or data. For example, the encryption key is suitable to use as
|
||||
* an encryption key for an encrypted AIR local SQL (SQLite) database.
|
||||
*
|
||||
* <p>This class uses techniques and algorithms that are designed for maximum
|
||||
* data privacy and security. Use this class to generate an encryption key if your
|
||||
* application requires data to be encrypted on a per-user level (in other words,
|
||||
* if only one user of the application should be able to access his or her data).
|
||||
* In some situations you may also want to use per-user encryption for data even
|
||||
* if the application design specifies that other users can access the data. For more
|
||||
* information, see
|
||||
* "<a href="http://help.adobe.com/en_US/AIR/1.5/devappsflex/WS34990ABF-C893-47ec-B813-9C9D9587A398.html">Considerations for using encryption with a database</a>"
|
||||
* in the guide
|
||||
* "<a href="http://help.adobe.com/en_US/AIR/1.5/devappsflex/">Developing Adobe AIR Applications with Flex</a>."</p>
|
||||
*
|
||||
* <p>The generated encryption key is based on a password that you provide. For any given
|
||||
* password, in the same AIR application
|
||||
* running in the same user account on the same machine, the encryption key result is
|
||||
* the same.</p>
|
||||
*
|
||||
* <p>To generate an encryption key from a password, use the <code>getEncryptionKey()</code>
|
||||
* method. To confirm that a password is a "strong" password before calling the
|
||||
* <code>getEncryptionKey()</code> method, use the <code>validateStrongPassword()</code>
|
||||
* method.</p>
|
||||
*
|
||||
* <p>In addition, the EncryptionKeyGenerator includes a utility constant,
|
||||
* <code>ENCRYPTED_DB_PASSWORD_ERROR_ID</code>. This constant matches the error ID of
|
||||
* the SQLError error that occurs when code that is attempting to open an encrypted database
|
||||
* provides the wrong encryption key.</p>
|
||||
*
|
||||
* <p>This class is designed to create an encryption key suitable for providing the highest
|
||||
* level of data privacy and security. In order to achieve that level of security, a few
|
||||
* security principles must be followed:</p>
|
||||
*
|
||||
* <ul>
|
||||
* <li>Your application should never store the user-entered password</li>
|
||||
* <li>Your application should never store the encryption key returned by the
|
||||
* <code>getEncryptionKey()</code> method.</li>
|
||||
* <li>Instead, each time the user runs the application and attempts to access the database,
|
||||
* your application code should call the <code>getEncryptionKey()</code> method to
|
||||
* regenerate the encryption key.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>For more information about data security, and an explanation of the security techniques
|
||||
* used in the EncryptionKeyGenerator class, see
|
||||
* "<a href="http://help.adobe.com/en_US/AIR/1.5/devappsflex/WS61068DCE-9499-4d40-82B8-B71CC35D832C.html">Example: Generating and using an encryption key</a>"
|
||||
* in the guide
|
||||
* "<a href="http://help.adobe.com/en_US/AIR/1.5/devappsflex/">Developing Adobe AIR Applications with Flex</a>."</p>
|
||||
*/
|
||||
public class EncryptionKeyGenerator
|
||||
{
|
||||
// ------- Constants -------
|
||||
/**
|
||||
* This constant matches the error ID (3138) of the SQLError error that occurs when
|
||||
* code that is attempting to open an encrypted database provides the wrong
|
||||
* encryption key.
|
||||
*/
|
||||
public static const ENCRYPTED_DB_PASSWORD_ERROR_ID:uint = 3138;
|
||||
|
||||
private static const STRONG_PASSWORD_PATTERN:RegExp = /(?=^.{8,32}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/;
|
||||
private static const SALT_ELS_KEY:String = "com.adobe.air.crypto::EncryptedDBSalt$$$";
|
||||
|
||||
|
||||
// ------- Constructor -------
|
||||
|
||||
/**
|
||||
* Creates a new EncryptionKeyGenerator instance.
|
||||
*/
|
||||
public function EncryptionKeyGenerator() {}
|
||||
|
||||
|
||||
// ------- Public methods -------
|
||||
|
||||
/**
|
||||
* Checks a password and returns a value indicating whether the password is a "strong"
|
||||
* password. The criteria for a strong password are:
|
||||
*
|
||||
* <ul>
|
||||
* <li>Minimum 8 characters</li>
|
||||
* <li>Maxmium 32 characters</li>
|
||||
* <li>Contains at least one lowercase letter</li>
|
||||
* <li>Contains at least one uppercase letter</li>
|
||||
* <li>Contains at least one number or symbol character</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param password The password to check
|
||||
*
|
||||
* @return A value indicating whether the password is a strong password (<code>true</code>)
|
||||
* or not (<code>false</code>).
|
||||
*/
|
||||
public function validateStrongPassword(password:String):Boolean
|
||||
{
|
||||
if (password == null || password.length <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return STRONG_PASSWORD_PATTERN.test(password);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Uses a password to generate a 16-byte encryption key. The return value is suitable
|
||||
* to use as an encryption key for an encrypted AIR local SQL (SQLite) database.
|
||||
*
|
||||
* <p>For any given
|
||||
* password, calling the <code>getEncryptionKey()</code> method from the same AIR application
|
||||
* running in the same user account on the same machine, the encryption key result is
|
||||
* the same.
|
||||
*
|
||||
* <p>This method is designed to create an encryption key suitable for providing the highest
|
||||
* level of data privacy and security. In order to achieve that level of security, your
|
||||
* application must follow several security principles:</p>
|
||||
*
|
||||
* <ul>
|
||||
* <li>Your application can never store the user-entered password</li>
|
||||
* <li>Your application can never store the encryption key returned by the
|
||||
* <code>getEncryptionKey()</code> method.</li>
|
||||
* <li>Instead, each time the user runs the application and attempts to access the database,
|
||||
* call the <code>getEncryptionKey()</code> method to regenerate the encryption key.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>For more information about data security, and an explanation of the security techniques
|
||||
* used in the EncryptionKeyGenerator class, see
|
||||
* "<a href="http://help.adobe.com/en_US/AIR/1.5/devappsflex/WS61068DCE-9499-4d40-82B8-B71CC35D832C.html">Example: Generating and using an encryption key</a>"
|
||||
* in the guide
|
||||
* "<a href="http://help.adobe.com/en_US/AIR/1.5/devappsflex/">Developing Adobe AIR Applications with Flex</a>."</p>
|
||||
*
|
||||
* @param password The password to use to generate the encryption key.
|
||||
* @param overrideSaltELSKey The EncryptionKeyGenerator creates and stores a random value
|
||||
* (known as a <i>salt</i>) as part of the process of
|
||||
* generating the encryption key. The first time an application
|
||||
* calls the <code>getEncryptionKey()</code> method, the salt
|
||||
* value is created and stored in the AIR application's encrypted
|
||||
* local store (ELS). From then on, the salt value is loaded from the
|
||||
* ELS.
|
||||
* <p>If you wish to provide a custom String ELS key for storing
|
||||
* the salt value, specify a value for the <code>overrideSaltELSKey</code>
|
||||
* parameter. If the parameter is <code>null</code> (the default)
|
||||
* a default key name is used.</p>
|
||||
*
|
||||
* @return The generated encryption key, a 16-byte ByteArray object.
|
||||
*
|
||||
* @throws ArgumentError If the specified password is not a "strong" password according to the
|
||||
* criteria explained in the <code>validateStrongPassword()</code>
|
||||
* method description
|
||||
*
|
||||
* @throws ArgumentError If a non-<code>null</code> value is specified for the <code>overrideSaltELSKey</code>
|
||||
* parameter, and the value is an empty String (<code>""</code>)
|
||||
*/
|
||||
public function getEncryptionKey(password:String, overrideSaltELSKey:String=null):ByteArray
|
||||
{
|
||||
if (!validateStrongPassword(password))
|
||||
{
|
||||
throw new ArgumentError("The password must be a strong password. It must be 8-32 characters long. It must contain at least one uppercase letter, at least one lowercase letter, and at least one number or symbol.");
|
||||
}
|
||||
|
||||
if (overrideSaltELSKey != null && overrideSaltELSKey.length <= 0)
|
||||
{
|
||||
throw new ArgumentError("If an overrideSaltELSKey parameter value is specified, it can't be an empty String.");
|
||||
}
|
||||
|
||||
var concatenatedPassword:String = concatenatePassword(password);
|
||||
|
||||
var saltKey:String;
|
||||
if (overrideSaltELSKey == null)
|
||||
{
|
||||
saltKey = SALT_ELS_KEY;
|
||||
}
|
||||
else
|
||||
{
|
||||
saltKey = overrideSaltELSKey;
|
||||
}
|
||||
|
||||
var salt:ByteArray = EncryptedLocalStore.getItem(saltKey);
|
||||
if (salt == null)
|
||||
{
|
||||
salt = makeSalt();
|
||||
EncryptedLocalStore.setItem(saltKey, salt);
|
||||
}
|
||||
|
||||
var unhashedKey:ByteArray = xorBytes(concatenatedPassword, salt);
|
||||
|
||||
var hashedKey:String = SHA256.hashBytes(unhashedKey);
|
||||
|
||||
var encryptionKey:ByteArray = generateEncryptionKey(hashedKey);
|
||||
|
||||
return encryptionKey;
|
||||
}
|
||||
|
||||
|
||||
// ------- Creating encryption key -------
|
||||
|
||||
private function concatenatePassword(pwd:String):String
|
||||
{
|
||||
var len:int = pwd.length;
|
||||
var targetLength:int = 32;
|
||||
|
||||
if (len == targetLength)
|
||||
{
|
||||
return pwd;
|
||||
}
|
||||
|
||||
var repetitions:int = Math.floor(targetLength / len);
|
||||
var excess:int = targetLength % len;
|
||||
|
||||
var result:String = "";
|
||||
|
||||
for (var i:uint = 0; i < repetitions; i++)
|
||||
{
|
||||
result += pwd;
|
||||
}
|
||||
|
||||
result += pwd.substr(0, excess);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private function makeSalt():ByteArray
|
||||
{
|
||||
var result:ByteArray = new ByteArray;
|
||||
|
||||
for (var i:uint = 0; i < 8; i++)
|
||||
{
|
||||
result.writeUnsignedInt(Math.round(Math.random() * uint.MAX_VALUE));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private function xorBytes(passwordString:String, salt:ByteArray):ByteArray
|
||||
{
|
||||
var result:ByteArray = new ByteArray();
|
||||
|
||||
for (var i:uint = 0; i < 32; i += 4)
|
||||
{
|
||||
// Extract 4 bytes from the password string and convert to a uint
|
||||
var o1:uint = passwordString.charCodeAt(i) << 24;
|
||||
o1 += passwordString.charCodeAt(i + 1) << 16;
|
||||
o1 += passwordString.charCodeAt(i + 2) << 8;
|
||||
o1 += passwordString.charCodeAt(i + 3);
|
||||
|
||||
salt.position = i;
|
||||
var o2:uint = salt.readUnsignedInt();
|
||||
|
||||
var xor:uint = o1 ^ o2;
|
||||
result.writeUnsignedInt(xor);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private function generateEncryptionKey(hash:String):ByteArray
|
||||
{
|
||||
var result:ByteArray = new ByteArray();
|
||||
|
||||
// select a range of 128 bits (32 hex characters) from the hash
|
||||
// In this case, we'll use the bits starting from position 17
|
||||
for (var i:uint = 0; i < 32; i += 2)
|
||||
{
|
||||
var position:uint = i + 17;
|
||||
var hex:String = hash.substr(position, 2);
|
||||
var byte:int = parseInt(hex, 16);
|
||||
result.writeByte(byte);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,245 @@
|
|||
/*
|
||||
Copyright (c) 2009, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.adobe.air.filesystem
|
||||
{
|
||||
import flash.filesystem.File;
|
||||
import flash.utils.Timer;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.events.Event;
|
||||
import flash.events.EventDispatcher;
|
||||
import com.adobe.air.filesystem.events.FileMonitorEvent;
|
||||
|
||||
/*
|
||||
Todo:
|
||||
|
||||
-Cmonitor changes in multiple attributes
|
||||
-add support for monitoring multiple files
|
||||
*/
|
||||
|
||||
/**
|
||||
* Dispatched when the modified date of the file being modified changes.
|
||||
*
|
||||
* @eventType com.adobe.air.filesystem.events.FileMonitor.CHANGE
|
||||
*/
|
||||
[Event(name="CHANGE", type="com.adobe.air.filesystem.events.FileMonitor")]
|
||||
|
||||
/**
|
||||
* Dispatched when the file being monitored is moved or deleted. The file
|
||||
* will be unwatched.
|
||||
*
|
||||
* @eventType com.adobe.air.filesystem.events.FileMonitor.MOVE
|
||||
*/
|
||||
[Event(name="MOVE", type="com.adobe.air.filesystem.events.FileMonitor")]
|
||||
|
||||
/**
|
||||
* Dispatched when the file being monitored is created.
|
||||
*
|
||||
* @eventType com.adobe.air.filesystem.events.FileMonitor.CREATE
|
||||
*/
|
||||
[Event(name="CREATE", type="com.adobe.air.filesystem.events.FileMonitor")]
|
||||
|
||||
/**
|
||||
* Class that monitors files for changes.
|
||||
*/
|
||||
public class FileMonitor extends EventDispatcher
|
||||
{
|
||||
private var _file:File;
|
||||
private var timer:Timer;
|
||||
public static const DEFAULT_MONITOR_INTERVAL:Number = 1000;
|
||||
private var _interval:Number;
|
||||
private var fileExists:Boolean = false;
|
||||
|
||||
private var lastModifiedTime:Number;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @parameter file The File that will be monitored for changes.
|
||||
*
|
||||
* @param interval How often in milliseconds the file is polled for
|
||||
* change events. Default value is 1000, minimum value is 1000
|
||||
*/
|
||||
public function FileMonitor(file:File = null, interval:Number = -1)
|
||||
{
|
||||
this.file = file;
|
||||
|
||||
if(interval != -1)
|
||||
{
|
||||
if(interval < 1000)
|
||||
{
|
||||
_interval = 1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
_interval = interval;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_interval = DEFAULT_MONITOR_INTERVAL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* File being monitored for changes.
|
||||
*
|
||||
* Setting the property will result in unwatch() being called.
|
||||
*/
|
||||
public function get file():File
|
||||
{
|
||||
return _file;
|
||||
}
|
||||
|
||||
public function set file(file:File):void
|
||||
{
|
||||
if(timer && timer.running)
|
||||
{
|
||||
unwatch();
|
||||
}
|
||||
|
||||
_file = file;
|
||||
|
||||
if(!_file)
|
||||
{
|
||||
fileExists = false;
|
||||
return;
|
||||
}
|
||||
|
||||
//note : this will throw an error if new File() is passed in.
|
||||
fileExists = _file.exists;
|
||||
if(fileExists)
|
||||
{
|
||||
lastModifiedTime = _file.modificationDate.getTime();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* How often the system is polled for Volume change events.
|
||||
*/
|
||||
public function get interval():Number
|
||||
{
|
||||
return _interval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Begins monitoring the specified file for changes.
|
||||
*
|
||||
* Broadcasts Event.CHANGE event when the file's modification date has changed.
|
||||
*/
|
||||
public function watch():void
|
||||
{
|
||||
if(!file)
|
||||
{
|
||||
//should we throw an error?
|
||||
return;
|
||||
}
|
||||
|
||||
if(timer && timer.running)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//check and see if timer is active. if it is, return
|
||||
if(!timer)
|
||||
{
|
||||
timer = new Timer(_interval);
|
||||
timer.addEventListener(TimerEvent.TIMER, onTimerEvent, false, 0, true);
|
||||
}
|
||||
|
||||
timer.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops watching the specified file for changes.
|
||||
*/
|
||||
public function unwatch():void
|
||||
{
|
||||
if(!timer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
timer.stop();
|
||||
timer.removeEventListener(TimerEvent.TIMER, onTimerEvent);
|
||||
}
|
||||
|
||||
private function onTimerEvent(e:TimerEvent):void
|
||||
{
|
||||
var outEvent:FileMonitorEvent;
|
||||
|
||||
if(fileExists != _file.exists)
|
||||
{
|
||||
if(_file.exists)
|
||||
{
|
||||
//file was created
|
||||
outEvent = new FileMonitorEvent(FileMonitorEvent.CREATE);
|
||||
lastModifiedTime = _file.modificationDate.getTime();
|
||||
}
|
||||
else
|
||||
{
|
||||
//file was moved / deleted
|
||||
outEvent = new FileMonitorEvent(FileMonitorEvent.MOVE);
|
||||
unwatch();
|
||||
}
|
||||
fileExists = _file.exists;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!_file.exists)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var modifiedTime:Number = _file.modificationDate.getTime();
|
||||
|
||||
if(modifiedTime == lastModifiedTime)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lastModifiedTime = modifiedTime;
|
||||
|
||||
//file modified
|
||||
outEvent = new FileMonitorEvent(FileMonitorEvent.CHANGE);
|
||||
}
|
||||
|
||||
if(outEvent)
|
||||
{
|
||||
outEvent.file = _file;
|
||||
dispatchEvent(outEvent);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
Copyright (c) 2009, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.adobe.air.filesystem
|
||||
{
|
||||
import flash.system.Capabilities;
|
||||
import flash.filesystem.File;
|
||||
|
||||
|
||||
public class FileUtil
|
||||
{
|
||||
/**
|
||||
* @return An Array of Files representing the root directories of the
|
||||
* operating system.
|
||||
*/
|
||||
public static function getRootDirectories():Array
|
||||
{
|
||||
var v:Array = File.getRootDirectories();
|
||||
var os:String = Capabilities.os;
|
||||
|
||||
if(os.indexOf("Mac") > -1)
|
||||
{
|
||||
v = File(v[0]).resolvePath("Volumes").getDirectoryListing();
|
||||
}
|
||||
else if(os.indexOf("Linux") > -1)
|
||||
{
|
||||
//todo: need to impliment Linux
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,184 @@
|
|||
/*
|
||||
Copyright (c) 2009, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.adobe.air.filesystem
|
||||
{
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.utils.Timer;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.filesystem.File;
|
||||
import flash.utils.Dictionary;
|
||||
import com.adobe.air.filesystem.events.FileMonitorEvent;
|
||||
import com.adobe.utils.ArrayUtil;
|
||||
|
||||
/**
|
||||
* Dispatched when a volume is added to the system.
|
||||
*
|
||||
* @eventType com.adobe.air.filesystem.events.FileMonitor.ADD_VOLUME
|
||||
*/
|
||||
[Event(name="ADD_VOLUME", type="com.adobe.air.filesystem.events.FileMonitor")]
|
||||
|
||||
/**
|
||||
* Dispatched when a volume is removed from the system.
|
||||
*
|
||||
* @eventType com.adobe.air.filesystem.events.FileMonitor.REMOVE_VOLUME
|
||||
*/
|
||||
[Event(name="REMOVE_VOLUME", type="com.adobe.air.filesystem.events.FileMonitor")]
|
||||
|
||||
/**
|
||||
* Class that monitors changes to the File volumes attached to the operating
|
||||
* system.
|
||||
*/
|
||||
public class VolumeMonitor extends EventDispatcher
|
||||
{
|
||||
private var timer:Timer;
|
||||
private var _interval:Number;
|
||||
private static const DEFAULT_MONITOR_INTERVAL:Number = 2000;
|
||||
|
||||
private var volumes:Dictionary;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param interval How often in milliseconds the system is polled for
|
||||
* volume change events. Default value is 2000, minimum value is 1000
|
||||
*/
|
||||
public function VolumeMonitor(interval:Number = -1)
|
||||
{
|
||||
if(interval != -1)
|
||||
{
|
||||
if(interval < 1000)
|
||||
{
|
||||
_interval = 1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
_interval = interval;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_interval = DEFAULT_MONITOR_INTERVAL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* How often the system is polled for Volume change events.
|
||||
*/
|
||||
public function get interval():Number
|
||||
{
|
||||
return _interval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Begins the monitoring of changes to the attached File volumes.
|
||||
*/
|
||||
public function watch():void
|
||||
{
|
||||
if(!timer)
|
||||
{
|
||||
timer = new Timer(_interval);
|
||||
timer.addEventListener(TimerEvent.TIMER, onTimerEvent,false,0, true);
|
||||
}
|
||||
|
||||
//we reinitialize the hash everytime we start watching
|
||||
volumes = new Dictionary();
|
||||
|
||||
var v:Array = FileUtil.getRootDirectories();
|
||||
for each(var f:File in v)
|
||||
{
|
||||
//null or undefined
|
||||
if(volumes[f.url] == null)
|
||||
{
|
||||
volumes[f.url] = f;
|
||||
}
|
||||
}
|
||||
|
||||
timer.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops monitoring for changes to the attached File volumes.
|
||||
*/
|
||||
public function unwatch():void
|
||||
{
|
||||
timer.stop();
|
||||
timer.removeEventListener(TimerEvent.TIMER, onTimerEvent);
|
||||
}
|
||||
|
||||
private function onTimerEvent(e:TimerEvent):void
|
||||
{
|
||||
var v:Array = FileUtil.getRootDirectories();
|
||||
|
||||
var outEvent:FileMonitorEvent;
|
||||
var found:Boolean = false;
|
||||
for(var key:String in volumes)
|
||||
{
|
||||
for each(var f:File in v)
|
||||
{
|
||||
//trace("--\n" + key);
|
||||
//trace(f.url);
|
||||
if(f.url == key)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!found)
|
||||
{
|
||||
outEvent = new FileMonitorEvent(FileMonitorEvent.REMOVE_VOLUME);
|
||||
outEvent.file = volumes[key];
|
||||
dispatchEvent(outEvent);
|
||||
delete volumes[key];
|
||||
}
|
||||
|
||||
found = false;
|
||||
}
|
||||
|
||||
for each(var f2:File in v)
|
||||
{
|
||||
//null or undefined
|
||||
if(volumes[f2.url] == null)
|
||||
{
|
||||
volumes[f2.url] = f2;
|
||||
outEvent = new FileMonitorEvent(FileMonitorEvent.ADD_VOLUME);
|
||||
outEvent.file = f2;
|
||||
|
||||
dispatchEvent(outEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
Copyright (c) 2009, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.adobe.air.filesystem.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.filesystem.File;
|
||||
|
||||
public class FileMonitorEvent extends Event
|
||||
{
|
||||
public static const CHANGE:String = "onFileChange";
|
||||
public static const MOVE:String = "onFileMove";
|
||||
public static const CREATE:String = "onFileCreate";
|
||||
public static const ADD_VOLUME:String = "onVolumeAdd";
|
||||
public static const REMOVE_VOLUME:String = "onVolumeRemove";
|
||||
|
||||
public var file:File;
|
||||
public function FileMonitorEvent(type:String, bubbles:Boolean=false,
|
||||
cancelable:Boolean=false)
|
||||
{
|
||||
super(type, bubbles, cancelable);
|
||||
}
|
||||
|
||||
public override function clone():Event
|
||||
{
|
||||
var out:FileMonitorEvent = new FileMonitorEvent(type, bubbles, cancelable);
|
||||
out.file = file;
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
Copyright (c) 2008, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.adobe.air.logging
|
||||
{
|
||||
import flash.filesystem.File;
|
||||
import flash.filesystem.FileMode;
|
||||
import flash.filesystem.FileStream;
|
||||
|
||||
import mx.core.mx_internal;
|
||||
import mx.logging.targets.LineFormattedTarget;
|
||||
|
||||
use namespace mx_internal;
|
||||
|
||||
/**
|
||||
* An Adobe AIR only class that provides a log target for the Flex logging
|
||||
* framework, that logs files to a file on the user's system.
|
||||
*
|
||||
* This class will only work when running within Adobe AIR>
|
||||
*/
|
||||
public class FileTarget extends LineFormattedTarget
|
||||
{
|
||||
private const DEFAULT_LOG_PATH:String = "app-storage:/application.log";
|
||||
|
||||
private var log:File;
|
||||
|
||||
public function FileTarget(logFile:File = null)
|
||||
{
|
||||
if(logFile != null)
|
||||
{
|
||||
log = logFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
log = new File(DEFAULT_LOG_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
public function get logURI():String
|
||||
{
|
||||
return log.url;
|
||||
}
|
||||
|
||||
mx_internal override function internalLog(message:String):void
|
||||
{
|
||||
write(message);
|
||||
}
|
||||
|
||||
private function write(msg:String):void
|
||||
{
|
||||
var fs:FileStream = new FileStream();
|
||||
fs.open(log, FileMode.APPEND);
|
||||
fs.writeUTFBytes(msg + File.lineEnding);
|
||||
fs.close();
|
||||
}
|
||||
|
||||
public function clear():void
|
||||
{
|
||||
var fs:FileStream = new FileStream();
|
||||
fs.open(log, FileMode.WRITE);
|
||||
fs.writeUTFBytes("");
|
||||
fs.close();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,165 @@
|
|||
/*
|
||||
Copyright (c) 2009, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.adobe.air.net
|
||||
{
|
||||
import com.adobe.crypto.MD5;
|
||||
import com.adobe.net.DynamicURLLoader;
|
||||
|
||||
import flash.events.Event;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.filesystem.File;
|
||||
import flash.filesystem.FileMode;
|
||||
import flash.filesystem.FileStream;
|
||||
import flash.net.URLLoaderDataFormat;
|
||||
import flash.net.URLRequest;
|
||||
import flash.utils.ByteArray;
|
||||
import com.adobe.air.net.events.ResourceCacheEvent;
|
||||
|
||||
//todo: add event metadata
|
||||
|
||||
public class ResourceCache extends EventDispatcher
|
||||
{
|
||||
private var _cacheName:String;
|
||||
//maybe rename to make it clearer it loads data
|
||||
public function ResourceCache(cacheName:String)
|
||||
{
|
||||
_cacheName = cacheName;
|
||||
}
|
||||
|
||||
public function get cacheName():String
|
||||
{
|
||||
return _cacheName;
|
||||
}
|
||||
|
||||
private function getStorageDir():File
|
||||
{
|
||||
return File.applicationStorageDirectory.resolvePath(_cacheName);
|
||||
}
|
||||
|
||||
public function itemExists(key:String):Boolean
|
||||
{
|
||||
return getItemFile(key).exists;
|
||||
}
|
||||
|
||||
public function clearCache():void
|
||||
{
|
||||
var cacheDir:File = getStorageDir();
|
||||
try
|
||||
{
|
||||
cacheDir.deleteDirectory(true);
|
||||
}
|
||||
catch (e:IOErrorEvent)
|
||||
{
|
||||
// we tried!
|
||||
}
|
||||
}
|
||||
|
||||
public function getItemFile(key:String):File
|
||||
{
|
||||
var dir:File = getStorageDir();
|
||||
var fName:String = generateKeyHash(key);
|
||||
var file:File = dir.resolvePath(fName);
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
public function retrieve(url:String):void
|
||||
{
|
||||
|
||||
var key:String = generateKeyHash(url);
|
||||
var file:File = getItemFile(key);
|
||||
|
||||
//todo: do we need to check if the dir exists?
|
||||
|
||||
if(file.exists)
|
||||
{
|
||||
var e:ResourceCacheEvent = new ResourceCacheEvent(ResourceCacheEvent.ITEM_READY);
|
||||
e.key = key;
|
||||
e.file = file;
|
||||
|
||||
dispatchEvent(e);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var loader:DynamicURLLoader = new DynamicURLLoader();
|
||||
loader.file = file;
|
||||
loader.key = key;
|
||||
|
||||
loader.addEventListener(Event.COMPLETE, onDataLoad);
|
||||
loader.addEventListener(IOErrorEvent.IO_ERROR, onLoadError);
|
||||
|
||||
loader.dataFormat = URLLoaderDataFormat.BINARY;
|
||||
|
||||
loader.load(new URLRequest(url));
|
||||
|
||||
}
|
||||
|
||||
private function onLoadError(event:IOErrorEvent):void
|
||||
{
|
||||
trace("onLoadError : could not cache item");
|
||||
}
|
||||
|
||||
private function onDataLoad(event:Event):void
|
||||
{
|
||||
var loader:DynamicURLLoader = DynamicURLLoader(event.target);
|
||||
|
||||
var f:File = File(loader.file);
|
||||
var key:String = String(loader.key);
|
||||
|
||||
var fileStream:FileStream = new FileStream();
|
||||
fileStream.open(f, FileMode.WRITE);
|
||||
fileStream.writeBytes(loader.data as ByteArray);
|
||||
fileStream.close();
|
||||
|
||||
var g:ResourceCacheEvent = new ResourceCacheEvent(ResourceCacheEvent.ITEM_CACHED);
|
||||
g.key = key;
|
||||
g.file = f;
|
||||
|
||||
dispatchEvent(g);
|
||||
|
||||
var e:ResourceCacheEvent = new ResourceCacheEvent(ResourceCacheEvent.ITEM_READY);
|
||||
e.key = key;
|
||||
e.file = f;
|
||||
|
||||
dispatchEvent(e);
|
||||
}
|
||||
|
||||
|
||||
private function generateKeyHash(key:String):String
|
||||
{
|
||||
return MD5.hash(key);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
Copyright (c) 2009, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.adobe.air.net.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.filesystem.File;
|
||||
|
||||
public class ResourceCacheEvent extends Event
|
||||
{
|
||||
|
||||
public static const ITEM_READY:String = "onPathReady";
|
||||
public static const ITEM_CACHED:String = "onItemCached";
|
||||
|
||||
[Bindable]
|
||||
public var key:String;
|
||||
|
||||
[Bindable]
|
||||
public var file:File;
|
||||
|
||||
public function ResourceCacheEvent(type:String,
|
||||
bubbles:Boolean=false,
|
||||
cancelable:Boolean=false)
|
||||
{
|
||||
super(type, bubbles, cancelable);
|
||||
}
|
||||
|
||||
public override function clone():Event
|
||||
{
|
||||
var out:ResourceCacheEvent = new ResourceCacheEvent(type,
|
||||
bubbles,
|
||||
cancelable);
|
||||
|
||||
out.key = key;
|
||||
out.file = file;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
Copyright (c) 2008, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.adobe.crypto {
|
||||
import flash.utils.ByteArray;
|
||||
import flash.utils.Endian;
|
||||
import flash.utils.describeType;
|
||||
/**
|
||||
* Keyed-Hashing for Message Authentication
|
||||
* Implementation based on algorithm description at
|
||||
* http://www.faqs.org/rfcs/rfc2104.html
|
||||
*/
|
||||
public class HMAC
|
||||
{
|
||||
/**
|
||||
* Performs the HMAC hash algorithm using byte arrays.
|
||||
*
|
||||
* @param secret The secret key
|
||||
* @param message The message to hash
|
||||
* @param algorithm Hash object to use
|
||||
* @return A string containing the hash value of message
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion Flash 8.5
|
||||
* @tiptext
|
||||
*/
|
||||
public static function hash( secret:String, message:String, algorithm:Object = null ):String
|
||||
{
|
||||
var text:ByteArray = new ByteArray();
|
||||
var k_secret:ByteArray = new ByteArray();
|
||||
|
||||
text.writeUTFBytes(message);
|
||||
k_secret.writeUTFBytes(secret);
|
||||
|
||||
return hashBytes(k_secret, text, algorithm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the HMAC hash algorithm using string.
|
||||
*
|
||||
* @param secret The secret key
|
||||
* @param message The message to hash
|
||||
* @param algorithm Hash object to use
|
||||
* @return A string containing the hash value of message
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion Flash 8.5
|
||||
* @tiptext
|
||||
*/
|
||||
public static function hashBytes( secret:ByteArray, message:ByteArray, algorithm:Object = null ):String
|
||||
{
|
||||
var ipad:ByteArray = new ByteArray();
|
||||
var opad:ByteArray = new ByteArray();
|
||||
var endian:String = Endian.BIG_ENDIAN;
|
||||
|
||||
if(algorithm == null){
|
||||
algorithm = MD5;
|
||||
}
|
||||
|
||||
if ( describeType(algorithm).@name.toString() == "com.adobe.crypto::MD5" ) {
|
||||
endian = Endian.LITTLE_ENDIAN;
|
||||
}
|
||||
|
||||
if ( secret.length > 64 ) {
|
||||
algorithm.hashBytes(secret);
|
||||
secret = new ByteArray();
|
||||
secret.endian = endian;
|
||||
|
||||
while ( algorithm.digest.bytesAvailable != 0 ) {
|
||||
secret.writeInt(algorithm.digest.readInt());
|
||||
}
|
||||
}
|
||||
|
||||
secret.length = 64
|
||||
secret.position = 0;
|
||||
for ( var x:int = 0; x < 64; x++ ) {
|
||||
var byte:int = secret.readByte();
|
||||
ipad.writeByte(0x36 ^ byte);
|
||||
opad.writeByte(0x5c ^ byte);
|
||||
}
|
||||
|
||||
ipad.writeBytes(message);
|
||||
algorithm.hashBytes(ipad);
|
||||
var tmp:ByteArray = new ByteArray();
|
||||
tmp.endian = endian;
|
||||
|
||||
while ( algorithm.digest.bytesAvailable != 0 ) {
|
||||
tmp.writeInt(algorithm.digest.readInt());
|
||||
}
|
||||
tmp.position = 0;
|
||||
|
||||
while ( tmp.bytesAvailable != 0 ) {
|
||||
opad.writeByte(tmp.readUnsignedByte());
|
||||
}
|
||||
return algorithm.hashBytes( opad );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
Copyright (c) 2008, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package com.adobe.crypto {
|
||||
|
||||
import flash.utils.Endian;
|
||||
|
||||
/**
|
||||
* Contains reusable methods for operations pertaining
|
||||
* to int values.
|
||||
*/
|
||||
public class IntUtil {
|
||||
|
||||
/**
|
||||
* Rotates x left n bits
|
||||
*
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion Flash 9.0
|
||||
* @tiptext
|
||||
*/
|
||||
public static function rol ( x:int, n:int ):int {
|
||||
return ( x << n ) | ( x >>> ( 32 - n ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotates x right n bits
|
||||
*
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion Flash 9.0
|
||||
* @tiptext
|
||||
*/
|
||||
public static function ror ( x:int, n:int ):uint {
|
||||
var nn:int = 32 - n;
|
||||
return ( x << nn ) | ( x >>> ( 32 - nn ) );
|
||||
}
|
||||
|
||||
/** String for quick lookup of a hex character based on index */
|
||||
private static var hexChars:String = "0123456789abcdef";
|
||||
|
||||
/**
|
||||
* Outputs the hex value of a int, allowing the developer to specify
|
||||
* the endinaness in the process. Hex output is lowercase.
|
||||
*
|
||||
* @param n The int value to output as hex
|
||||
* @param bigEndian Flag to output the int as big or little endian
|
||||
* @return A string of length 8 corresponding to the
|
||||
* hex representation of n ( minus the leading "0x" )
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion Flash 9.0
|
||||
* @tiptext
|
||||
*/
|
||||
public static function toHex( n:int, bigEndian:Boolean = false ):String {
|
||||
var s:String = "";
|
||||
|
||||
if ( bigEndian ) {
|
||||
for ( var i:int = 0; i < 4; i++ ) {
|
||||
s += hexChars.charAt( ( n >> ( ( 3 - i ) * 8 + 4 ) ) & 0xF )
|
||||
+ hexChars.charAt( ( n >> ( ( 3 - i ) * 8 ) ) & 0xF );
|
||||
}
|
||||
} else {
|
||||
for ( var x:int = 0; x < 4; x++ ) {
|
||||
s += hexChars.charAt( ( n >> ( x * 8 + 4 ) ) & 0xF )
|
||||
+ hexChars.charAt( ( n >> ( x * 8 ) ) & 0xF );
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,281 @@
|
|||
/*
|
||||
Copyright (c) 2008, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.adobe.crypto {
|
||||
|
||||
import com.adobe.crypto.IntUtil;
|
||||
import flash.utils.ByteArray;
|
||||
/**
|
||||
* The MD5 Message-Digest Algorithm
|
||||
*
|
||||
* Implementation based on algorithm description at
|
||||
* http://www.faqs.org/rfcs/rfc1321.html
|
||||
*/
|
||||
public class MD5 {
|
||||
|
||||
public static var digest:ByteArray;
|
||||
/**
|
||||
* Performs the MD5 hash algorithm on a string.
|
||||
*
|
||||
* @param s The string to hash
|
||||
* @return A string containing the hash value of s
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion Flash 8.5
|
||||
* @tiptext
|
||||
*/
|
||||
|
||||
public static function hash(s:String) :String{
|
||||
//Convert to byteArray and send through hashBinary function
|
||||
// so as to only have complex code in one location
|
||||
var ba:ByteArray = new ByteArray();
|
||||
ba.writeUTFBytes(s);
|
||||
return hashBinary(ba);
|
||||
}
|
||||
|
||||
public static function hashBytes(s:ByteArray) :String{
|
||||
return hashBinary(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the MD5 hash algorithm on a ByteArray.
|
||||
*
|
||||
* @param s The string to hash
|
||||
* @return A string containing the hash value of s
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion Flash 8.5
|
||||
* @tiptext
|
||||
*/
|
||||
public static function hashBinary( s:ByteArray ):String {
|
||||
// initialize the md buffers
|
||||
var a:int = 1732584193;
|
||||
var b:int = -271733879;
|
||||
var c:int = -1732584194;
|
||||
var d:int = 271733878;
|
||||
|
||||
// variables to store previous values
|
||||
var aa:int;
|
||||
var bb:int;
|
||||
var cc:int;
|
||||
var dd:int;
|
||||
|
||||
// create the blocks from the string and
|
||||
// save the length as a local var to reduce
|
||||
// lookup in the loop below
|
||||
var x:Array = createBlocks( s );
|
||||
var len:int = x.length;
|
||||
|
||||
// loop over all of the blocks
|
||||
for ( var i:int = 0; i < len; i += 16) {
|
||||
// save previous values
|
||||
aa = a;
|
||||
bb = b;
|
||||
cc = c;
|
||||
dd = d;
|
||||
|
||||
// Round 1
|
||||
a = ff( a, b, c, d, x[int(i+ 0)], 7, -680876936 ); // 1
|
||||
d = ff( d, a, b, c, x[int(i+ 1)], 12, -389564586 ); // 2
|
||||
c = ff( c, d, a, b, x[int(i+ 2)], 17, 606105819 ); // 3
|
||||
b = ff( b, c, d, a, x[int(i+ 3)], 22, -1044525330 ); // 4
|
||||
a = ff( a, b, c, d, x[int(i+ 4)], 7, -176418897 ); // 5
|
||||
d = ff( d, a, b, c, x[int(i+ 5)], 12, 1200080426 ); // 6
|
||||
c = ff( c, d, a, b, x[int(i+ 6)], 17, -1473231341 ); // 7
|
||||
b = ff( b, c, d, a, x[int(i+ 7)], 22, -45705983 ); // 8
|
||||
a = ff( a, b, c, d, x[int(i+ 8)], 7, 1770035416 ); // 9
|
||||
d = ff( d, a, b, c, x[int(i+ 9)], 12, -1958414417 ); // 10
|
||||
c = ff( c, d, a, b, x[int(i+10)], 17, -42063 ); // 11
|
||||
b = ff( b, c, d, a, x[int(i+11)], 22, -1990404162 ); // 12
|
||||
a = ff( a, b, c, d, x[int(i+12)], 7, 1804603682 ); // 13
|
||||
d = ff( d, a, b, c, x[int(i+13)], 12, -40341101 ); // 14
|
||||
c = ff( c, d, a, b, x[int(i+14)], 17, -1502002290 ); // 15
|
||||
b = ff( b, c, d, a, x[int(i+15)], 22, 1236535329 ); // 16
|
||||
|
||||
// Round 2
|
||||
a = gg( a, b, c, d, x[int(i+ 1)], 5, -165796510 ); // 17
|
||||
d = gg( d, a, b, c, x[int(i+ 6)], 9, -1069501632 ); // 18
|
||||
c = gg( c, d, a, b, x[int(i+11)], 14, 643717713 ); // 19
|
||||
b = gg( b, c, d, a, x[int(i+ 0)], 20, -373897302 ); // 20
|
||||
a = gg( a, b, c, d, x[int(i+ 5)], 5, -701558691 ); // 21
|
||||
d = gg( d, a, b, c, x[int(i+10)], 9, 38016083 ); // 22
|
||||
c = gg( c, d, a, b, x[int(i+15)], 14, -660478335 ); // 23
|
||||
b = gg( b, c, d, a, x[int(i+ 4)], 20, -405537848 ); // 24
|
||||
a = gg( a, b, c, d, x[int(i+ 9)], 5, 568446438 ); // 25
|
||||
d = gg( d, a, b, c, x[int(i+14)], 9, -1019803690 ); // 26
|
||||
c = gg( c, d, a, b, x[int(i+ 3)], 14, -187363961 ); // 27
|
||||
b = gg( b, c, d, a, x[int(i+ 8)], 20, 1163531501 ); // 28
|
||||
a = gg( a, b, c, d, x[int(i+13)], 5, -1444681467 ); // 29
|
||||
d = gg( d, a, b, c, x[int(i+ 2)], 9, -51403784 ); // 30
|
||||
c = gg( c, d, a, b, x[int(i+ 7)], 14, 1735328473 ); // 31
|
||||
b = gg( b, c, d, a, x[int(i+12)], 20, -1926607734 ); // 32
|
||||
|
||||
// Round 3
|
||||
a = hh( a, b, c, d, x[int(i+ 5)], 4, -378558 ); // 33
|
||||
d = hh( d, a, b, c, x[int(i+ 8)], 11, -2022574463 ); // 34
|
||||
c = hh( c, d, a, b, x[int(i+11)], 16, 1839030562 ); // 35
|
||||
b = hh( b, c, d, a, x[int(i+14)], 23, -35309556 ); // 36
|
||||
a = hh( a, b, c, d, x[int(i+ 1)], 4, -1530992060 ); // 37
|
||||
d = hh( d, a, b, c, x[int(i+ 4)], 11, 1272893353 ); // 38
|
||||
c = hh( c, d, a, b, x[int(i+ 7)], 16, -155497632 ); // 39
|
||||
b = hh( b, c, d, a, x[int(i+10)], 23, -1094730640 ); // 40
|
||||
a = hh( a, b, c, d, x[int(i+13)], 4, 681279174 ); // 41
|
||||
d = hh( d, a, b, c, x[int(i+ 0)], 11, -358537222 ); // 42
|
||||
c = hh( c, d, a, b, x[int(i+ 3)], 16, -722521979 ); // 43
|
||||
b = hh( b, c, d, a, x[int(i+ 6)], 23, 76029189 ); // 44
|
||||
a = hh( a, b, c, d, x[int(i+ 9)], 4, -640364487 ); // 45
|
||||
d = hh( d, a, b, c, x[int(i+12)], 11, -421815835 ); // 46
|
||||
c = hh( c, d, a, b, x[int(i+15)], 16, 530742520 ); // 47
|
||||
b = hh( b, c, d, a, x[int(i+ 2)], 23, -995338651 ); // 48
|
||||
|
||||
// Round 4
|
||||
a = ii( a, b, c, d, x[int(i+ 0)], 6, -198630844 ); // 49
|
||||
d = ii( d, a, b, c, x[int(i+ 7)], 10, 1126891415 ); // 50
|
||||
c = ii( c, d, a, b, x[int(i+14)], 15, -1416354905 ); // 51
|
||||
b = ii( b, c, d, a, x[int(i+ 5)], 21, -57434055 ); // 52
|
||||
a = ii( a, b, c, d, x[int(i+12)], 6, 1700485571 ); // 53
|
||||
d = ii( d, a, b, c, x[int(i+ 3)], 10, -1894986606 ); // 54
|
||||
c = ii( c, d, a, b, x[int(i+10)], 15, -1051523 ); // 55
|
||||
b = ii( b, c, d, a, x[int(i+ 1)], 21, -2054922799 ); // 56
|
||||
a = ii( a, b, c, d, x[int(i+ 8)], 6, 1873313359 ); // 57
|
||||
d = ii( d, a, b, c, x[int(i+15)], 10, -30611744 ); // 58
|
||||
c = ii( c, d, a, b, x[int(i+ 6)], 15, -1560198380 ); // 59
|
||||
b = ii( b, c, d, a, x[int(i+13)], 21, 1309151649 ); // 60
|
||||
a = ii( a, b, c, d, x[int(i+ 4)], 6, -145523070 ); // 61
|
||||
d = ii( d, a, b, c, x[int(i+11)], 10, -1120210379 ); // 62
|
||||
c = ii( c, d, a, b, x[int(i+ 2)], 15, 718787259 ); // 63
|
||||
b = ii( b, c, d, a, x[int(i+ 9)], 21, -343485551 ); // 64
|
||||
|
||||
a += aa;
|
||||
b += bb;
|
||||
c += cc;
|
||||
d += dd;
|
||||
}
|
||||
digest = new ByteArray()
|
||||
digest.writeInt(a);
|
||||
digest.writeInt(b);
|
||||
digest.writeInt(c);
|
||||
digest.writeInt(d);
|
||||
digest.position = 0;
|
||||
// Finish up by concatening the buffers with their hex output
|
||||
return IntUtil.toHex( a ) + IntUtil.toHex( b ) + IntUtil.toHex( c ) + IntUtil.toHex( d );
|
||||
}
|
||||
|
||||
/**
|
||||
* Auxiliary function f as defined in RFC
|
||||
*/
|
||||
private static function f( x:int, y:int, z:int ):int {
|
||||
return ( x & y ) | ( (~x) & z );
|
||||
}
|
||||
|
||||
/**
|
||||
* Auxiliary function g as defined in RFC
|
||||
*/
|
||||
private static function g( x:int, y:int, z:int ):int {
|
||||
return ( x & z ) | ( y & (~z) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Auxiliary function h as defined in RFC
|
||||
*/
|
||||
private static function h( x:int, y:int, z:int ):int {
|
||||
return x ^ y ^ z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Auxiliary function i as defined in RFC
|
||||
*/
|
||||
private static function i( x:int, y:int, z:int ):int {
|
||||
return y ^ ( x | (~z) );
|
||||
}
|
||||
|
||||
/**
|
||||
* A generic transformation function. The logic of ff, gg, hh, and
|
||||
* ii are all the same, minus the function used, so pull that logic
|
||||
* out and simplify the method bodies for the transoformation functions.
|
||||
*/
|
||||
private static function transform( func:Function, a:int, b:int, c:int, d:int, x:int, s:int, t:int):int {
|
||||
var tmp:int = a + int( func( b, c, d ) ) + x + t;
|
||||
return IntUtil.rol( tmp, s ) + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* ff transformation function
|
||||
*/
|
||||
private static function ff ( a:int, b:int, c:int, d:int, x:int, s:int, t:int ):int {
|
||||
return transform( f, a, b, c, d, x, s, t );
|
||||
}
|
||||
|
||||
/**
|
||||
* gg transformation function
|
||||
*/
|
||||
private static function gg ( a:int, b:int, c:int, d:int, x:int, s:int, t:int ):int {
|
||||
return transform( g, a, b, c, d, x, s, t );
|
||||
}
|
||||
|
||||
/**
|
||||
* hh transformation function
|
||||
*/
|
||||
private static function hh ( a:int, b:int, c:int, d:int, x:int, s:int, t:int ):int {
|
||||
return transform( h, a, b, c, d, x, s, t );
|
||||
}
|
||||
|
||||
/**
|
||||
* ii transformation function
|
||||
*/
|
||||
private static function ii ( a:int, b:int, c:int, d:int, x:int, s:int, t:int ):int {
|
||||
return transform( i, a, b, c, d, x, s, t );
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string to a sequence of 16-word blocks
|
||||
* that we'll do the processing on. Appends padding
|
||||
* and length in the process.
|
||||
*
|
||||
* @param s The string to split into blocks
|
||||
* @return An array containing the blocks that s was
|
||||
* split into.
|
||||
*/
|
||||
private static function createBlocks( s:ByteArray ):Array {
|
||||
var blocks:Array = new Array();
|
||||
var len:int = s.length * 8;
|
||||
var mask:int = 0xFF; // ignore hi byte of characters > 0xFF
|
||||
for( var i:int = 0; i < len; i += 8 ) {
|
||||
blocks[ int(i >> 5) ] |= ( s[ i / 8 ] & mask ) << ( i % 32 );
|
||||
}
|
||||
|
||||
// append padding and length
|
||||
blocks[ int(len >> 5) ] |= 0x80 << ( len % 32 );
|
||||
blocks[ int(( ( ( len + 64 ) >>> 9 ) << 4 ) + 14) ] = len;
|
||||
return blocks;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,402 @@
|
|||
/*
|
||||
Copyright (c) 2008, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.adobe.crypto
|
||||
{
|
||||
import com.adobe.utils.IntUtil;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
/**
|
||||
* Perform MD5 hash of an input stream in chunks. This class is
|
||||
* based on com.adobe.crypto.MD5 and can process data in
|
||||
* chunks. Both block creation and hash computation are done
|
||||
* together for whatever input is available so that the memory
|
||||
* overhead at a time is always fixed. Memory usage is governed by
|
||||
* two parameters: one is the amount of data passed in to update()
|
||||
* and the other is memoryBlockSize. The latter comes into play
|
||||
* only when the memory window exceeds the pre allocated memory
|
||||
* window of flash player. Usage: create an instance, call
|
||||
* update(data) repeatedly for all chunks and finally complete()
|
||||
* which will return the md5 hash.
|
||||
*/
|
||||
public class MD5Stream
|
||||
{
|
||||
private static var mask:int = 0xFF;
|
||||
|
||||
private var arr:Array = [];
|
||||
|
||||
/* running count of length */
|
||||
private var arrLen:int;
|
||||
|
||||
// initialize the md buffers
|
||||
private var a:int = 1732584193;
|
||||
private var b:int = -271733879;
|
||||
private var c:int = -1732584194;
|
||||
private var d:int = 271733878;
|
||||
|
||||
// variables to store previous values
|
||||
private var aa:int;
|
||||
private var bb:int;
|
||||
private var cc:int;
|
||||
private var dd:int;
|
||||
|
||||
/* index for data read */
|
||||
private var arrIndexLen:int = 0;
|
||||
/* index for hash computation */
|
||||
private var arrProcessIndex:int = 0;
|
||||
/* index for removing stale arr values */
|
||||
private var cleanIndex:int = 0;
|
||||
|
||||
/**
|
||||
* Change this value from the default (16384) in the range of
|
||||
* MBs to actually affect GC as GC allocates in pools of
|
||||
* memory */
|
||||
public var memoryBlockSize:int = 16384;
|
||||
|
||||
|
||||
public function MD5Stream()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pass in chunks of the input data with update(), call
|
||||
* complete() with an optional chunk which will return the
|
||||
* final hash. Equivalent to the way
|
||||
* java.security.MessageDigest works.
|
||||
*
|
||||
* @param input The optional bytearray chunk which is the final part of the input
|
||||
* @return A string containing the hash value
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion Flash 8.5
|
||||
* @tiptext
|
||||
*/
|
||||
public function complete(input:ByteArray=null):String
|
||||
{
|
||||
if ( arr.length == 0 )
|
||||
{
|
||||
if ( input == null )
|
||||
{
|
||||
throw new Error("null input to complete without prior call to update. At least an empty bytearray must be passed.");
|
||||
}
|
||||
}
|
||||
|
||||
if ( input != null )
|
||||
{
|
||||
readIntoArray(input);
|
||||
}
|
||||
|
||||
//pad, append length
|
||||
padArray(arrLen);
|
||||
|
||||
hashRemainingChunks(false);
|
||||
|
||||
var res:String = IntUtil.toHex( a ) + IntUtil.toHex( b ) +
|
||||
IntUtil.toHex( c ) + IntUtil.toHex( d );
|
||||
resetFields();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass in chunks of the input data with update(), call
|
||||
* complete() with an optional chunk which will return the
|
||||
* final hash. Equivalent to the way
|
||||
* java.security.MessageDigest works.
|
||||
*
|
||||
* @param input The bytearray chunk to perform the hash on
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion Flash 8.5
|
||||
* @tiptext
|
||||
*/
|
||||
public function update(input:ByteArray):void
|
||||
{
|
||||
readIntoArray(input);
|
||||
hashRemainingChunks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-initialize this instance for use to perform hashing on
|
||||
* another input stream. This is called automatically by
|
||||
* complete().
|
||||
*
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion Flash 8.5
|
||||
* @tiptext
|
||||
*/
|
||||
public function resetFields():void
|
||||
{
|
||||
//truncate array
|
||||
arr.length = 0;
|
||||
arrLen = 0;
|
||||
|
||||
// initialize the md buffers
|
||||
a = 1732584193;
|
||||
b = -271733879;
|
||||
c = -1732584194;
|
||||
d = 271733878;
|
||||
|
||||
// variables to store previous values
|
||||
aa = 0;
|
||||
bb = 0;
|
||||
cc = 0;
|
||||
dd = 0;
|
||||
|
||||
arrIndexLen = 0;
|
||||
arrProcessIndex = 0;
|
||||
cleanIndex = 0;
|
||||
}
|
||||
|
||||
/** read into arr and free up used blocks of arr */
|
||||
private function readIntoArray(input:ByteArray):void
|
||||
{
|
||||
var closestChunkLen:int = input.length * 8;
|
||||
arrLen += closestChunkLen;
|
||||
|
||||
/* clean up memory. if there are entries in the array that
|
||||
* are already processed and the amount is greater than
|
||||
* memoryBlockSize, create a new array, copy the last
|
||||
* block into it and let the old one get picked up by
|
||||
* GC. */
|
||||
if ( arrProcessIndex - cleanIndex > memoryBlockSize )
|
||||
{
|
||||
var newarr:Array= new Array();
|
||||
|
||||
/* AS Arrays in sparse arrays. arr[2002] can exist
|
||||
* without values for arr[0] - arr[2001] */
|
||||
for ( var j:int = arrProcessIndex; j < arr.length; j++ )
|
||||
{
|
||||
newarr[j] = arr[j];
|
||||
}
|
||||
|
||||
cleanIndex = arrProcessIndex;
|
||||
arr = null;
|
||||
arr = newarr;
|
||||
}
|
||||
|
||||
for ( var k:int = 0; k < closestChunkLen; k+=8 )
|
||||
{
|
||||
//discard high bytes (convert to uint)
|
||||
arr[ int(arrIndexLen >> 5) ] |= ( input[ k / 8 ] & mask ) << ( arrIndexLen % 32 );
|
||||
arrIndexLen += 8;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function hashRemainingChunks(bUpdate:Boolean=true):void
|
||||
{
|
||||
var len:int = arr.length;
|
||||
|
||||
/* leave a 16 word block untouched if we are called from
|
||||
* update. This is because, padArray() can modify the last
|
||||
* block and this modification has to happen before we
|
||||
* compute the hash. */
|
||||
if ( bUpdate )
|
||||
{
|
||||
len -= 16;
|
||||
}
|
||||
|
||||
/* don't do anything if don't have a 16 word block. */
|
||||
if ( arrProcessIndex >= len || len - arrProcessIndex < 15 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for ( var i:int = arrProcessIndex; i < len ; i += 16, arrProcessIndex += 16)
|
||||
{
|
||||
// save previous values
|
||||
aa = a;
|
||||
bb = b;
|
||||
cc = c;
|
||||
dd = d;
|
||||
|
||||
// Round 1
|
||||
a = ff( a, b, c, d, arr[int(i+ 0)], 7, -680876936 ); // 1
|
||||
d = ff( d, a, b, c, arr[int(i+ 1)], 12, -389564586 ); // 2
|
||||
c = ff( c, d, a, b, arr[int(i+ 2)], 17, 606105819 ); // 3
|
||||
b = ff( b, c, d, a, arr[int(i+ 3)], 22, -1044525330 ); // 4
|
||||
a = ff( a, b, c, d, arr[int(i+ 4)], 7, -176418897 ); // 5
|
||||
d = ff( d, a, b, c, arr[int(i+ 5)], 12, 1200080426 ); // 6
|
||||
c = ff( c, d, a, b, arr[int(i+ 6)], 17, -1473231341 ); // 7
|
||||
b = ff( b, c, d, a, arr[int(i+ 7)], 22, -45705983 ); // 8
|
||||
a = ff( a, b, c, d, arr[int(i+ 8)], 7, 1770035416 ); // 9
|
||||
d = ff( d, a, b, c, arr[int(i+ 9)], 12, -1958414417 ); // 10
|
||||
c = ff( c, d, a, b, arr[int(i+10)], 17, -42063 ); // 11
|
||||
b = ff( b, c, d, a, arr[int(i+11)], 22, -1990404162 ); // 12
|
||||
a = ff( a, b, c, d, arr[int(i+12)], 7, 1804603682 ); // 13
|
||||
d = ff( d, a, b, c, arr[int(i+13)], 12, -40341101 ); // 14
|
||||
c = ff( c, d, a, b, arr[int(i+14)], 17, -1502002290 ); // 15
|
||||
b = ff( b, c, d, a, arr[int(i+15)], 22, 1236535329 ); // 16
|
||||
|
||||
// Round 2
|
||||
a = gg( a, b, c, d, arr[int(i+ 1)], 5, -165796510 ); // 17
|
||||
d = gg( d, a, b, c, arr[int(i+ 6)], 9, -1069501632 ); // 18
|
||||
c = gg( c, d, a, b, arr[int(i+11)], 14, 643717713 ); // 19
|
||||
b = gg( b, c, d, a, arr[int(i+ 0)], 20, -373897302 ); // 20
|
||||
a = gg( a, b, c, d, arr[int(i+ 5)], 5, -701558691 ); // 21
|
||||
d = gg( d, a, b, c, arr[int(i+10)], 9, 38016083 ); // 22
|
||||
c = gg( c, d, a, b, arr[int(i+15)], 14, -660478335 ); // 23
|
||||
b = gg( b, c, d, a, arr[int(i+ 4)], 20, -405537848 ); // 24
|
||||
a = gg( a, b, c, d, arr[int(i+ 9)], 5, 568446438 ); // 25
|
||||
d = gg( d, a, b, c, arr[int(i+14)], 9, -1019803690 ); // 26
|
||||
c = gg( c, d, a, b, arr[int(i+ 3)], 14, -187363961 ); // 27
|
||||
b = gg( b, c, d, a, arr[int(i+ 8)], 20, 1163531501 ); // 28
|
||||
a = gg( a, b, c, d, arr[int(i+13)], 5, -1444681467 ); // 29
|
||||
d = gg( d, a, b, c, arr[int(i+ 2)], 9, -51403784 ); // 30
|
||||
c = gg( c, d, a, b, arr[int(i+ 7)], 14, 1735328473 ); // 31
|
||||
b = gg( b, c, d, a, arr[int(i+12)], 20, -1926607734 ); // 32
|
||||
|
||||
// Round 3
|
||||
a = hh( a, b, c, d, arr[int(i+ 5)], 4, -378558 ); // 33
|
||||
d = hh( d, a, b, c, arr[int(i+ 8)], 11, -2022574463 ); // 34
|
||||
c = hh( c, d, a, b, arr[int(i+11)], 16, 1839030562 ); // 35
|
||||
b = hh( b, c, d, a, arr[int(i+14)], 23, -35309556 ); // 36
|
||||
a = hh( a, b, c, d, arr[int(i+ 1)], 4, -1530992060 ); // 37
|
||||
d = hh( d, a, b, c, arr[int(i+ 4)], 11, 1272893353 ); // 38
|
||||
c = hh( c, d, a, b, arr[int(i+ 7)], 16, -155497632 ); // 39
|
||||
b = hh( b, c, d, a, arr[int(i+10)], 23, -1094730640 ); // 40
|
||||
a = hh( a, b, c, d, arr[int(i+13)], 4, 681279174 ); // 41
|
||||
d = hh( d, a, b, c, arr[int(i+ 0)], 11, -358537222 ); // 42
|
||||
c = hh( c, d, a, b, arr[int(i+ 3)], 16, -722521979 ); // 43
|
||||
b = hh( b, c, d, a, arr[int(i+ 6)], 23, 76029189 ); // 44
|
||||
a = hh( a, b, c, d, arr[int(i+ 9)], 4, -640364487 ); // 45
|
||||
d = hh( d, a, b, c, arr[int(i+12)], 11, -421815835 ); // 46
|
||||
c = hh( c, d, a, b, arr[int(i+15)], 16, 530742520 ); // 47
|
||||
b = hh( b, c, d, a, arr[int(i+ 2)], 23, -995338651 ); // 48
|
||||
|
||||
// Round 4
|
||||
a = ii( a, b, c, d, arr[int(i+ 0)], 6, -198630844 ); // 49
|
||||
d = ii( d, a, b, c, arr[int(i+ 7)], 10, 1126891415 ); // 50
|
||||
c = ii( c, d, a, b, arr[int(i+14)], 15, -1416354905 ); // 51
|
||||
b = ii( b, c, d, a, arr[int(i+ 5)], 21, -57434055 ); // 52
|
||||
a = ii( a, b, c, d, arr[int(i+12)], 6, 1700485571 ); // 53
|
||||
d = ii( d, a, b, c, arr[int(i+ 3)], 10, -1894986606 ); // 54
|
||||
c = ii( c, d, a, b, arr[int(i+10)], 15, -1051523 ); // 55
|
||||
b = ii( b, c, d, a, arr[int(i+ 1)], 21, -2054922799 ); // 56
|
||||
a = ii( a, b, c, d, arr[int(i+ 8)], 6, 1873313359 ); // 57
|
||||
d = ii( d, a, b, c, arr[int(i+15)], 10, -30611744 ); // 58
|
||||
c = ii( c, d, a, b, arr[int(i+ 6)], 15, -1560198380 ); // 59
|
||||
b = ii( b, c, d, a, arr[int(i+13)], 21, 1309151649 ); // 60
|
||||
a = ii( a, b, c, d, arr[int(i+ 4)], 6, -145523070 ); // 61
|
||||
d = ii( d, a, b, c, arr[int(i+11)], 10, -1120210379 ); // 62
|
||||
c = ii( c, d, a, b, arr[int(i+ 2)], 15, 718787259 ); // 63
|
||||
b = ii( b, c, d, a, arr[int(i+ 9)], 21, -343485551 ); // 64
|
||||
|
||||
a += aa;
|
||||
b += bb;
|
||||
c += cc;
|
||||
d += dd;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function padArray(len:int):void
|
||||
{
|
||||
arr[ int(len >> 5) ] |= 0x80 << ( len % 32 );
|
||||
arr[ int(( ( ( len + 64 ) >>> 9 ) << 4 ) + 14) ] = len;
|
||||
arrLen = arr.length;
|
||||
}
|
||||
|
||||
/* Code below same as com.adobe.crypto.MD5 */
|
||||
|
||||
/**
|
||||
* Auxiliary function f as defined in RFC
|
||||
*/
|
||||
private static function f( x:int, y:int, z:int ):int {
|
||||
return ( x & y ) | ( (~x) & z );
|
||||
}
|
||||
|
||||
/**
|
||||
* Auxiliary function g as defined in RFC
|
||||
*/
|
||||
private static function g( x:int, y:int, z:int ):int {
|
||||
return ( x & z ) | ( y & (~z) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Auxiliary function h as defined in RFC
|
||||
*/
|
||||
private static function h( x:int, y:int, z:int ):int {
|
||||
return x ^ y ^ z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Auxiliary function i as defined in RFC
|
||||
*/
|
||||
private static function i( x:int, y:int, z:int ):int {
|
||||
return y ^ ( x | (~z) );
|
||||
}
|
||||
|
||||
/**
|
||||
* A generic transformation function. The logic of ff, gg, hh, and
|
||||
* ii are all the same, minus the function used, so pull that logic
|
||||
* out and simplify the method bodies for the transoformation functions.
|
||||
*/
|
||||
private static function transform( func:Function, a:int, b:int, c:int, d:int, x:int, s:int, t:int):int {
|
||||
var tmp:int = a + int( func( b, c, d ) ) + x + t;
|
||||
return IntUtil.rol( tmp, s ) + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* ff transformation function
|
||||
*/
|
||||
private static function ff ( a:int, b:int, c:int, d:int, x:int, s:int, t:int ):int {
|
||||
return transform( f, a, b, c, d, x, s, t );
|
||||
}
|
||||
|
||||
/**
|
||||
* gg transformation function
|
||||
*/
|
||||
private static function gg ( a:int, b:int, c:int, d:int, x:int, s:int, t:int ):int {
|
||||
return transform( g, a, b, c, d, x, s, t );
|
||||
}
|
||||
|
||||
/**
|
||||
* hh transformation function
|
||||
*/
|
||||
private static function hh ( a:int, b:int, c:int, d:int, x:int, s:int, t:int ):int {
|
||||
return transform( h, a, b, c, d, x, s, t );
|
||||
}
|
||||
|
||||
/**
|
||||
* ii transformation function
|
||||
*/
|
||||
private static function ii ( a:int, b:int, c:int, d:int, x:int, s:int, t:int ):int {
|
||||
return transform( i, a, b, c, d, x, s, t );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,289 @@
|
|||
/*
|
||||
Copyright (c) 2008, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.adobe.crypto
|
||||
{
|
||||
import com.adobe.utils.IntUtil;
|
||||
import flash.utils.ByteArray;
|
||||
import mx.utils.Base64Encoder;
|
||||
|
||||
/**
|
||||
* US Secure Hash Algorithm 1 (SHA1)
|
||||
*
|
||||
* Implementation based on algorithm description at
|
||||
* http://www.faqs.org/rfcs/rfc3174.html
|
||||
*/
|
||||
public class SHA1
|
||||
{
|
||||
public static var digest:ByteArray;
|
||||
|
||||
/**
|
||||
* Performs the SHA1 hash algorithm on a string.
|
||||
*
|
||||
* @param s The string to hash
|
||||
* @return A string containing the hash value of s
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion 9.0
|
||||
* @tiptext
|
||||
*/
|
||||
public static function hash( s:String ):String
|
||||
{
|
||||
var blocks:Array = createBlocksFromString( s );
|
||||
var byteArray:ByteArray = hashBlocks( blocks );
|
||||
|
||||
return IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the SHA1 hash algorithm on a ByteArray.
|
||||
*
|
||||
* @param data The ByteArray data to hash
|
||||
* @return A string containing the hash value of data
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion 9.0
|
||||
*/
|
||||
public static function hashBytes( data:ByteArray ):String
|
||||
{
|
||||
var blocks:Array = SHA1.createBlocksFromByteArray( data );
|
||||
var byteArray:ByteArray = hashBlocks(blocks);
|
||||
|
||||
return IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the SHA1 hash algorithm on a string, then does
|
||||
* Base64 encoding on the result.
|
||||
*
|
||||
* @param s The string to hash
|
||||
* @return The base64 encoded hash value of s
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion 9.0
|
||||
* @tiptext
|
||||
*/
|
||||
public static function hashToBase64( s:String ):String
|
||||
{
|
||||
var blocks:Array = SHA1.createBlocksFromString( s );
|
||||
var byteArray:ByteArray = hashBlocks(blocks);
|
||||
|
||||
// ByteArray.toString() returns the contents as a UTF-8 string,
|
||||
// which we can't use because certain byte sequences might trigger
|
||||
// a UTF-8 conversion. Instead, we convert the bytes to characters
|
||||
// one by one.
|
||||
var charsInByteArray:String = "";
|
||||
byteArray.position = 0;
|
||||
for (var j:int = 0; j < byteArray.length; j++)
|
||||
{
|
||||
var byte:uint = byteArray.readUnsignedByte();
|
||||
charsInByteArray += String.fromCharCode(byte);
|
||||
}
|
||||
|
||||
var encoder:Base64Encoder = new Base64Encoder();
|
||||
encoder.encode(charsInByteArray);
|
||||
return encoder.flush();
|
||||
}
|
||||
|
||||
private static function hashBlocks( blocks:Array ):ByteArray
|
||||
{
|
||||
// initialize the h's
|
||||
var h0:int = 0x67452301;
|
||||
var h1:int = 0xefcdab89;
|
||||
var h2:int = 0x98badcfe;
|
||||
var h3:int = 0x10325476;
|
||||
var h4:int = 0xc3d2e1f0;
|
||||
|
||||
var len:int = blocks.length;
|
||||
var w:Array = new Array( 80 );
|
||||
var temp:int;
|
||||
|
||||
// loop over all of the blocks
|
||||
for ( var i:int = 0; i < len; i += 16 ) {
|
||||
|
||||
// 6.1.c
|
||||
var a:int = h0;
|
||||
var b:int = h1;
|
||||
var c:int = h2;
|
||||
var d:int = h3;
|
||||
var e:int = h4;
|
||||
|
||||
// 80 steps to process each block
|
||||
var t:int;
|
||||
for ( t = 0; t < 20; t++ ) {
|
||||
|
||||
if ( t < 16 ) {
|
||||
// 6.1.a
|
||||
w[ t ] = blocks[ i + t ];
|
||||
} else {
|
||||
// 6.1.b
|
||||
temp = w[ t - 3 ] ^ w[ t - 8 ] ^ w[ t - 14 ] ^ w[ t - 16 ];
|
||||
w[ t ] = ( temp << 1 ) | ( temp >>> 31 )
|
||||
}
|
||||
|
||||
// 6.1.d
|
||||
temp = ( ( a << 5 ) | ( a >>> 27 ) ) + ( ( b & c ) | ( ~b & d ) ) + e + int( w[ t ] ) + 0x5a827999;
|
||||
|
||||
e = d;
|
||||
d = c;
|
||||
c = ( b << 30 ) | ( b >>> 2 );
|
||||
b = a;
|
||||
a = temp;
|
||||
}
|
||||
for ( ; t < 40; t++ )
|
||||
{
|
||||
// 6.1.b
|
||||
temp = w[ t - 3 ] ^ w[ t - 8 ] ^ w[ t - 14 ] ^ w[ t - 16 ];
|
||||
w[ t ] = ( temp << 1 ) | ( temp >>> 31 )
|
||||
|
||||
// 6.1.d
|
||||
temp = ( ( a << 5 ) | ( a >>> 27 ) ) + ( b ^ c ^ d ) + e + int( w[ t ] ) + 0x6ed9eba1;
|
||||
|
||||
e = d;
|
||||
d = c;
|
||||
c = ( b << 30 ) | ( b >>> 2 );
|
||||
b = a;
|
||||
a = temp;
|
||||
}
|
||||
for ( ; t < 60; t++ )
|
||||
{
|
||||
// 6.1.b
|
||||
temp = w[ t - 3 ] ^ w[ t - 8 ] ^ w[ t - 14 ] ^ w[ t - 16 ];
|
||||
w[ t ] = ( temp << 1 ) | ( temp >>> 31 )
|
||||
|
||||
// 6.1.d
|
||||
temp = ( ( a << 5 ) | ( a >>> 27 ) ) + ( ( b & c ) | ( b & d ) | ( c & d ) ) + e + int( w[ t ] ) + 0x8f1bbcdc;
|
||||
|
||||
e = d;
|
||||
d = c;
|
||||
c = ( b << 30 ) | ( b >>> 2 );
|
||||
b = a;
|
||||
a = temp;
|
||||
}
|
||||
for ( ; t < 80; t++ )
|
||||
{
|
||||
// 6.1.b
|
||||
temp = w[ t - 3 ] ^ w[ t - 8 ] ^ w[ t - 14 ] ^ w[ t - 16 ];
|
||||
w[ t ] = ( temp << 1 ) | ( temp >>> 31 )
|
||||
|
||||
// 6.1.d
|
||||
temp = ( ( a << 5 ) | ( a >>> 27 ) ) + ( b ^ c ^ d ) + e + int( w[ t ] ) + 0xca62c1d6;
|
||||
|
||||
e = d;
|
||||
d = c;
|
||||
c = ( b << 30 ) | ( b >>> 2 );
|
||||
b = a;
|
||||
a = temp;
|
||||
}
|
||||
|
||||
// 6.1.e
|
||||
h0 += a;
|
||||
h1 += b;
|
||||
h2 += c;
|
||||
h3 += d;
|
||||
h4 += e;
|
||||
}
|
||||
|
||||
var byteArray:ByteArray = new ByteArray();
|
||||
byteArray.writeInt(h0);
|
||||
byteArray.writeInt(h1);
|
||||
byteArray.writeInt(h2);
|
||||
byteArray.writeInt(h3);
|
||||
byteArray.writeInt(h4);
|
||||
byteArray.position = 0;
|
||||
|
||||
digest = new ByteArray();
|
||||
digest.writeBytes(byteArray);
|
||||
digest.position = 0;
|
||||
return byteArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a ByteArray to a sequence of 16-word blocks
|
||||
* that we'll do the processing on. Appends padding
|
||||
* and length in the process.
|
||||
*
|
||||
* @param data The data to split into blocks
|
||||
* @return An array containing the blocks into which data was split
|
||||
*/
|
||||
private static function createBlocksFromByteArray( data:ByteArray ):Array
|
||||
{
|
||||
var oldPosition:int = data.position;
|
||||
data.position = 0;
|
||||
|
||||
var blocks:Array = new Array();
|
||||
var len:int = data.length * 8;
|
||||
var mask:int = 0xFF; // ignore hi byte of characters > 0xFF
|
||||
for( var i:int = 0; i < len; i += 8 )
|
||||
{
|
||||
blocks[ i >> 5 ] |= ( data.readByte() & mask ) << ( 24 - i % 32 );
|
||||
}
|
||||
|
||||
// append padding and length
|
||||
blocks[ len >> 5 ] |= 0x80 << ( 24 - len % 32 );
|
||||
blocks[ ( ( ( len + 64 ) >> 9 ) << 4 ) + 15 ] = len;
|
||||
|
||||
data.position = oldPosition;
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string to a sequence of 16-word blocks
|
||||
* that we'll do the processing on. Appends padding
|
||||
* and length in the process.
|
||||
*
|
||||
* @param s The string to split into blocks
|
||||
* @return An array containing the blocks that s was split into.
|
||||
*/
|
||||
private static function createBlocksFromString( s:String ):Array
|
||||
{
|
||||
var blocks:Array = new Array();
|
||||
var len:int = s.length * 8;
|
||||
var mask:int = 0xFF; // ignore hi byte of characters > 0xFF
|
||||
for( var i:int = 0; i < len; i += 8 ) {
|
||||
blocks[ i >> 5 ] |= ( s.charCodeAt( i / 8 ) & mask ) << ( 24 - i % 32 );
|
||||
}
|
||||
|
||||
// append padding and length
|
||||
blocks[ len >> 5 ] |= 0x80 << ( 24 - len % 32 );
|
||||
blocks[ ( ( ( len + 64 ) >> 9 ) << 4 ) + 15 ] = len;
|
||||
return blocks;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,257 @@
|
|||
/*
|
||||
Copyright (c) 2008, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.adobe.crypto
|
||||
{
|
||||
import com.adobe.utils.IntUtil;
|
||||
import flash.utils.ByteArray;
|
||||
import mx.utils.Base64Encoder;
|
||||
|
||||
/**
|
||||
* The SHA-224 algorithm
|
||||
*
|
||||
* @see http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf
|
||||
*/
|
||||
public class SHA224
|
||||
{
|
||||
public static var digest:ByteArray;
|
||||
|
||||
/**
|
||||
* Performs the SHA224 hash algorithm on a string.
|
||||
*
|
||||
* @param s The string to hash
|
||||
* @return A string containing the hash value of s
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion 9.0
|
||||
* @tiptext
|
||||
*/
|
||||
public static function hash( s:String ):String {
|
||||
var blocks:Array = createBlocksFromString( s );
|
||||
var byteArray:ByteArray = hashBlocks( blocks );
|
||||
return IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the SHA224 hash algorithm on a ByteArray.
|
||||
*
|
||||
* @param data The ByteArray data to hash
|
||||
* @return A string containing the hash value of data
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion 9.0
|
||||
*/
|
||||
public static function hashBytes( data:ByteArray ):String
|
||||
{
|
||||
var blocks:Array = createBlocksFromByteArray( data );
|
||||
var byteArray:ByteArray = hashBlocks(blocks);
|
||||
return IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the SHA224 hash algorithm on a string, then does
|
||||
* Base64 encoding on the result.
|
||||
*
|
||||
* @param s The string to hash
|
||||
* @return The base64 encoded hash value of s
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion 9.0
|
||||
* @tiptext
|
||||
*/
|
||||
public static function hashToBase64( s:String ):String
|
||||
{
|
||||
var blocks:Array = createBlocksFromString( s );
|
||||
var byteArray:ByteArray = hashBlocks(blocks);
|
||||
|
||||
// ByteArray.toString() returns the contents as a UTF-8 string,
|
||||
// which we can't use because certain byte sequences might trigger
|
||||
// a UTF-8 conversion. Instead, we convert the bytes to characters
|
||||
// one by one.
|
||||
var charsInByteArray:String = "";
|
||||
byteArray.position = 0;
|
||||
for (var j:int = 0; j < byteArray.length; j++)
|
||||
{
|
||||
var byte:uint = byteArray.readUnsignedByte();
|
||||
charsInByteArray += String.fromCharCode(byte);
|
||||
}
|
||||
|
||||
var encoder:Base64Encoder = new Base64Encoder();
|
||||
encoder.encode(charsInByteArray);
|
||||
return encoder.flush();
|
||||
}
|
||||
|
||||
private static function hashBlocks( blocks:Array ):ByteArray {
|
||||
var h0:int = 0xc1059ed8;
|
||||
var h1:int = 0x367cd507;
|
||||
var h2:int = 0x3070dd17;
|
||||
var h3:int = 0xf70e5939;
|
||||
var h4:int = 0xffc00b31;
|
||||
var h5:int = 0x68581511;
|
||||
var h6:int = 0x64f98fa7;
|
||||
var h7:int = 0xbefa4fa4;
|
||||
|
||||
var k:Array = new Array(0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2);
|
||||
|
||||
var len:int = blocks.length;
|
||||
var w:Array = new Array();
|
||||
|
||||
// loop over all of the blocks
|
||||
for ( var i:int = 0; i < len; i += 16 ) {
|
||||
|
||||
var a:int = h0;
|
||||
var b:int = h1;
|
||||
var c:int = h2;
|
||||
var d:int = h3;
|
||||
var e:int = h4;
|
||||
var f:int = h5;
|
||||
var g:int = h6;
|
||||
var h:int = h7;
|
||||
|
||||
for(var t:int = 0; t < 64; t++) {
|
||||
|
||||
if ( t < 16 ) {
|
||||
w[t] = blocks[ i + t ];
|
||||
if(isNaN(w[t])) { w[t] = 0; }
|
||||
} else {
|
||||
var ws0:int = IntUtil.ror(w[t-15], 7) ^ IntUtil.ror(w[t-15], 18) ^ (w[t-15] >>> 3);
|
||||
var ws1:int = IntUtil.ror(w[t-2], 17) ^ IntUtil.ror(w[t-2], 19) ^ (w[t-2] >>> 10);
|
||||
w[t] = w[t-16] + ws0 + w[t-7] + ws1;
|
||||
}
|
||||
|
||||
var s0:int = IntUtil.ror(a, 2) ^ IntUtil.ror(a, 13) ^ IntUtil.ror(a, 22);
|
||||
var maj:int = (a & b) ^ (a & c) ^ (b & c);
|
||||
var t2:int = s0 + maj;
|
||||
var s1:int = IntUtil.ror(e, 6) ^ IntUtil.ror(e, 11) ^ IntUtil.ror(e, 25);
|
||||
var ch:int = (e & f) ^ ((~e) & g);
|
||||
var t1:int = h + s1 + ch + k[t] + w[t];
|
||||
|
||||
h = g;
|
||||
g = f;
|
||||
f = e;
|
||||
e = d + t1;
|
||||
d = c;
|
||||
c = b;
|
||||
b = a;
|
||||
a = t1 + t2;
|
||||
}
|
||||
|
||||
//Add this chunk's hash to result so far:
|
||||
h0 += a;
|
||||
h1 += b;
|
||||
h2 += c;
|
||||
h3 += d;
|
||||
h4 += e;
|
||||
h5 += f;
|
||||
h6 += g;
|
||||
h7 += h;
|
||||
}
|
||||
|
||||
var byteArray:ByteArray = new ByteArray();
|
||||
byteArray.writeInt(h0);
|
||||
byteArray.writeInt(h1);
|
||||
byteArray.writeInt(h2);
|
||||
byteArray.writeInt(h3);
|
||||
byteArray.writeInt(h4);
|
||||
byteArray.writeInt(h5);
|
||||
byteArray.writeInt(h6);
|
||||
byteArray.position = 0;
|
||||
|
||||
digest = new ByteArray();
|
||||
digest.writeBytes(byteArray);
|
||||
digest.position = 0;
|
||||
return byteArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a ByteArray to a sequence of 16-word blocks
|
||||
* that we'll do the processing on. Appends padding
|
||||
* and length in the process.
|
||||
*
|
||||
* @param data The data to split into blocks
|
||||
* @return An array containing the blocks into which data was split
|
||||
*/
|
||||
private static function createBlocksFromByteArray( data:ByteArray ):Array
|
||||
{
|
||||
var oldPosition:int = data.position;
|
||||
data.position = 0;
|
||||
|
||||
var blocks:Array = new Array();
|
||||
var len:int = data.length * 8;
|
||||
var mask:int = 0xFF; // ignore hi byte of characters > 0xFF
|
||||
for( var i:int = 0; i < len; i += 8 )
|
||||
{
|
||||
blocks[ i >> 5 ] |= ( data.readByte() & mask ) << ( 24 - i % 32 );
|
||||
}
|
||||
|
||||
// append padding and length
|
||||
blocks[ len >> 5 ] |= 0x80 << ( 24 - len % 32 );
|
||||
blocks[ ( ( ( len + 64 ) >> 9 ) << 4 ) + 15 ] = len;
|
||||
|
||||
data.position = oldPosition;
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string to a sequence of 16-word blocks
|
||||
* that we'll do the processing on. Appends padding
|
||||
* and length in the process.
|
||||
*
|
||||
* @param s The string to split into blocks
|
||||
* @return An array containing the blocks that s was split into.
|
||||
*/
|
||||
private static function createBlocksFromString( s:String ):Array
|
||||
{
|
||||
var blocks:Array = new Array();
|
||||
var len:int = s.length * 8;
|
||||
var mask:int = 0xFF; // ignore hi byte of characters > 0xFF
|
||||
for( var i:int = 0; i < len; i += 8 ) {
|
||||
blocks[ i >> 5 ] |= ( s.charCodeAt( i / 8 ) & mask ) << ( 24 - i % 32 );
|
||||
}
|
||||
|
||||
// append padding and length
|
||||
blocks[ len >> 5 ] |= 0x80 << ( 24 - len % 32 );
|
||||
blocks[ ( ( ( len + 64 ) >> 9 ) << 4 ) + 15 ] = len;
|
||||
return blocks;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,261 @@
|
|||
/*
|
||||
Copyright (c) 2008, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.adobe.crypto
|
||||
{
|
||||
import com.adobe.utils.IntUtil;
|
||||
import flash.utils.ByteArray;
|
||||
import mx.utils.Base64Encoder;
|
||||
|
||||
/**
|
||||
* The SHA-256 algorithm
|
||||
*
|
||||
* @see http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf
|
||||
*/
|
||||
public class SHA256
|
||||
{
|
||||
public static var digest:ByteArray;
|
||||
/**
|
||||
* Performs the SHA256 hash algorithm on a string.
|
||||
*
|
||||
* @param s The string to hash
|
||||
* @return A string containing the hash value of s
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion 9.0
|
||||
* @tiptext
|
||||
*/
|
||||
public static function hash( s:String ):String {
|
||||
var blocks:Array = createBlocksFromString( s );
|
||||
var byteArray:ByteArray = hashBlocks( blocks );
|
||||
|
||||
return IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the SHA256 hash algorithm on a ByteArray.
|
||||
*
|
||||
* @param data The ByteArray data to hash
|
||||
* @return A string containing the hash value of data
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion 9.0
|
||||
*/
|
||||
public static function hashBytes( data:ByteArray ):String
|
||||
{
|
||||
var blocks:Array = createBlocksFromByteArray( data );
|
||||
var byteArray:ByteArray = hashBlocks(blocks);
|
||||
|
||||
return IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true )
|
||||
+ IntUtil.toHex( byteArray.readInt(), true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the SHA256 hash algorithm on a string, then does
|
||||
* Base64 encoding on the result.
|
||||
*
|
||||
* @param s The string to hash
|
||||
* @return The base64 encoded hash value of s
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion 9.0
|
||||
* @tiptext
|
||||
*/
|
||||
public static function hashToBase64( s:String ):String
|
||||
{
|
||||
var blocks:Array = createBlocksFromString( s );
|
||||
var byteArray:ByteArray = hashBlocks(blocks);
|
||||
|
||||
// ByteArray.toString() returns the contents as a UTF-8 string,
|
||||
// which we can't use because certain byte sequences might trigger
|
||||
// a UTF-8 conversion. Instead, we convert the bytes to characters
|
||||
// one by one.
|
||||
var charsInByteArray:String = "";
|
||||
byteArray.position = 0;
|
||||
for (var j:int = 0; j < byteArray.length; j++)
|
||||
{
|
||||
var byte:uint = byteArray.readUnsignedByte();
|
||||
charsInByteArray += String.fromCharCode(byte);
|
||||
}
|
||||
|
||||
var encoder:Base64Encoder = new Base64Encoder();
|
||||
encoder.encode(charsInByteArray);
|
||||
return encoder.flush();
|
||||
}
|
||||
|
||||
private static function hashBlocks( blocks:Array ):ByteArray {
|
||||
var h0:int = 0x6a09e667;
|
||||
var h1:int = 0xbb67ae85;
|
||||
var h2:int = 0x3c6ef372;
|
||||
var h3:int = 0xa54ff53a;
|
||||
var h4:int = 0x510e527f;
|
||||
var h5:int = 0x9b05688c;
|
||||
var h6:int = 0x1f83d9ab;
|
||||
var h7:int = 0x5be0cd19;
|
||||
|
||||
var k:Array = new Array(0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2);
|
||||
|
||||
var len:int = blocks.length;
|
||||
var w:Array = new Array( 64 );
|
||||
|
||||
// loop over all of the blocks
|
||||
for ( var i:int = 0; i < len; i += 16 ) {
|
||||
|
||||
var a:int = h0;
|
||||
var b:int = h1;
|
||||
var c:int = h2;
|
||||
var d:int = h3;
|
||||
var e:int = h4;
|
||||
var f:int = h5;
|
||||
var g:int = h6;
|
||||
var h:int = h7;
|
||||
|
||||
for(var t:int = 0; t < 64; t++) {
|
||||
|
||||
if ( t < 16 ) {
|
||||
w[t] = blocks[ i + t ];
|
||||
if(isNaN(w[t])) { w[t] = 0; }
|
||||
} else {
|
||||
var ws0:int = IntUtil.ror(w[t-15], 7) ^ IntUtil.ror(w[t-15], 18) ^ (w[t-15] >>> 3);
|
||||
var ws1:int = IntUtil.ror(w[t-2], 17) ^ IntUtil.ror(w[t-2], 19) ^ (w[t-2] >>> 10);
|
||||
w[t] = w[t-16] + ws0 + w[t-7] + ws1;
|
||||
}
|
||||
|
||||
var s0:int = IntUtil.ror(a, 2) ^ IntUtil.ror(a, 13) ^ IntUtil.ror(a, 22);
|
||||
var maj:int = (a & b) ^ (a & c) ^ (b & c);
|
||||
var t2:int = s0 + maj;
|
||||
var s1:int = IntUtil.ror(e, 6) ^ IntUtil.ror(e, 11) ^ IntUtil.ror(e, 25);
|
||||
var ch:int = (e & f) ^ ((~e) & g);
|
||||
var t1:int = h + s1 + ch + k[t] + w[t];
|
||||
|
||||
h = g;
|
||||
g = f;
|
||||
f = e;
|
||||
e = d + t1;
|
||||
d = c;
|
||||
c = b;
|
||||
b = a;
|
||||
a = t1 + t2;
|
||||
}
|
||||
|
||||
//Add this chunk's hash to result so far:
|
||||
h0 += a;
|
||||
h1 += b;
|
||||
h2 += c;
|
||||
h3 += d;
|
||||
h4 += e;
|
||||
h5 += f;
|
||||
h6 += g;
|
||||
h7 += h;
|
||||
}
|
||||
|
||||
var byteArray:ByteArray = new ByteArray();
|
||||
byteArray.writeInt(h0);
|
||||
byteArray.writeInt(h1);
|
||||
byteArray.writeInt(h2);
|
||||
byteArray.writeInt(h3);
|
||||
byteArray.writeInt(h4);
|
||||
byteArray.writeInt(h5);
|
||||
byteArray.writeInt(h6);
|
||||
byteArray.writeInt(h7);
|
||||
byteArray.position = 0;
|
||||
|
||||
digest = new ByteArray();
|
||||
digest.writeBytes(byteArray);
|
||||
digest.position = 0;
|
||||
return byteArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a ByteArray to a sequence of 16-word blocks
|
||||
* that we'll do the processing on. Appends padding
|
||||
* and length in the process.
|
||||
*
|
||||
* @param data The data to split into blocks
|
||||
* @return An array containing the blocks into which data was split
|
||||
*/
|
||||
private static function createBlocksFromByteArray( data:ByteArray ):Array
|
||||
{
|
||||
var oldPosition:int = data.position;
|
||||
data.position = 0;
|
||||
|
||||
var blocks:Array = new Array();
|
||||
var len:int = data.length * 8;
|
||||
var mask:int = 0xFF; // ignore hi byte of characters > 0xFF
|
||||
for( var i:int = 0; i < len; i += 8 )
|
||||
{
|
||||
blocks[ i >> 5 ] |= ( data.readByte() & mask ) << ( 24 - i % 32 );
|
||||
}
|
||||
|
||||
// append padding and length
|
||||
blocks[ len >> 5 ] |= 0x80 << ( 24 - len % 32 );
|
||||
blocks[ ( ( ( len + 64 ) >> 9 ) << 4 ) + 15 ] = len;
|
||||
|
||||
data.position = oldPosition;
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string to a sequence of 16-word blocks
|
||||
* that we'll do the processing on. Appends padding
|
||||
* and length in the process.
|
||||
*
|
||||
* @param s The string to split into blocks
|
||||
* @return An array containing the blocks that s was split into.
|
||||
*/
|
||||
private static function createBlocksFromString( s:String ):Array
|
||||
{
|
||||
var blocks:Array = new Array();
|
||||
var len:int = s.length * 8;
|
||||
var mask:int = 0xFF; // ignore hi byte of characters > 0xFF
|
||||
for( var i:int = 0; i < len; i += 8 ) {
|
||||
blocks[ i >> 5 ] |= ( s.charCodeAt( i / 8 ) & mask ) << ( 24 - i % 32 );
|
||||
}
|
||||
|
||||
// append padding and length
|
||||
blocks[ len >> 5 ] |= 0x80 << ( 24 - len % 32 );
|
||||
blocks[ ( ( ( len + 64 ) >> 9 ) << 4 ) + 15 ] = len;
|
||||
return blocks;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
Copyright (c) 2008, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.adobe.crypto
|
||||
{
|
||||
import mx.formatters.DateFormatter;
|
||||
import mx.utils.Base64Encoder;
|
||||
|
||||
/**
|
||||
* Web Services Security Username Token
|
||||
*
|
||||
* Implementation based on algorithm description at
|
||||
* http://www.oasis-open.org/committees/wss/documents/WSS-Username-02-0223-merged.pdf
|
||||
*/
|
||||
public class WSSEUsernameToken
|
||||
{
|
||||
/**
|
||||
* Generates a WSSE Username Token.
|
||||
*
|
||||
* @param username The username
|
||||
* @param password The password
|
||||
* @param nonce A cryptographically random nonce (if null, the nonce
|
||||
* will be generated)
|
||||
* @param timestamp The time at which the token is generated (if null,
|
||||
* the time will be set to the moment of execution)
|
||||
* @return The generated token
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion Flash 9.0
|
||||
* @tiptext
|
||||
*/
|
||||
public static function getUsernameToken(username:String, password:String, nonce:String=null, timestamp:Date=null):String
|
||||
{
|
||||
if (nonce == null)
|
||||
{
|
||||
nonce = generateNonce();
|
||||
}
|
||||
nonce = base64Encode(nonce);
|
||||
|
||||
var created:String = generateTimestamp(timestamp);
|
||||
|
||||
var password64:String = getBase64Digest(nonce,
|
||||
created,
|
||||
password);
|
||||
|
||||
var token:String = new String("UsernameToken Username=\"");
|
||||
token += username + "\", " +
|
||||
"PasswordDigest=\"" + password64 + "\", " +
|
||||
"Nonce=\"" + nonce + "\", " +
|
||||
"Created=\"" + created + "\"";
|
||||
return token;
|
||||
}
|
||||
|
||||
private static function generateNonce():String
|
||||
{
|
||||
// Math.random returns a Number between 0 and 1. We don't want our
|
||||
// nonce to contain invalid characters (e.g. the period) so we
|
||||
// strip them out before returning the result.
|
||||
var s:String = Math.random().toString();
|
||||
return s.replace(".", "");
|
||||
}
|
||||
|
||||
internal static function base64Encode(s:String):String
|
||||
{
|
||||
var encoder:Base64Encoder = new Base64Encoder();
|
||||
encoder.encode(s);
|
||||
return encoder.flush();
|
||||
}
|
||||
|
||||
internal static function generateTimestamp(timestamp:Date):String
|
||||
{
|
||||
if (timestamp == null)
|
||||
{
|
||||
timestamp = new Date();
|
||||
}
|
||||
var dateFormatter:DateFormatter = new DateFormatter();
|
||||
dateFormatter.formatString = "YYYY-MM-DDTJJ:NN:SS"
|
||||
return dateFormatter.format(timestamp) + "Z";
|
||||
}
|
||||
|
||||
internal static function getBase64Digest(nonce:String, created:String, password:String):String
|
||||
{
|
||||
return SHA1.hashToBase64(nonce + created + password);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
Copyright (c) 2008, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.adobe.errors
|
||||
{
|
||||
/**
|
||||
* This class represents an Error that is thrown when a method is called when
|
||||
* the receiving instance is in an invalid state.
|
||||
*
|
||||
* For example, this may occur if a method has been called, and other properties
|
||||
* in the instance have not been initialized properly.
|
||||
*
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion Flash 9.0
|
||||
* @tiptext
|
||||
*
|
||||
*/
|
||||
public class IllegalStateError extends Error
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param message A message describing the error in detail.
|
||||
*
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion Flash 9.0
|
||||
* @tiptext
|
||||
*/
|
||||
public function IllegalStateError(message:String)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
Copyright (c) 2008, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package com.adobe.fileformats.vcard
|
||||
{
|
||||
public class Address
|
||||
{
|
||||
public var type:String;
|
||||
public var street:String;
|
||||
public var city:String;
|
||||
public var state:String;
|
||||
public var postalCode:String;
|
||||
|
||||
public function toString():String
|
||||
{
|
||||
return (street + " " + city + ", " + state + " " + postalCode);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
Copyright (c) 2008, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package com.adobe.fileformats.vcard
|
||||
{
|
||||
public class Email
|
||||
{
|
||||
public var type:String;
|
||||
public var address:String;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
Copyright (c) 2008, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package com.adobe.fileformats.vcard
|
||||
{
|
||||
public class Phone
|
||||
{
|
||||
public var type:String;
|
||||
public var number:String;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
Copyright (c) 2008, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package com.adobe.fileformats.vcard
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class VCard
|
||||
{
|
||||
public var fullName:String;
|
||||
public var orgs:Array;
|
||||
public var title:String;
|
||||
public var image:ByteArray;
|
||||
public var phones:Array;
|
||||
public var emails:Array;
|
||||
public var addresses:Array;
|
||||
|
||||
public function VCard()
|
||||
{
|
||||
orgs = new Array();
|
||||
phones = new Array();
|
||||
emails = new Array();
|
||||
addresses = new Array();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,246 @@
|
|||
/*
|
||||
Copyright (c) 2008, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package com.adobe.fileformats.vcard
|
||||
{
|
||||
import mx.utils.Base64Decoder;
|
||||
import mx.utils.StringUtil;
|
||||
|
||||
public class VCardParser
|
||||
{
|
||||
public static function parse(vcardStr:String):Array
|
||||
{
|
||||
var vcards:Array = new Array();
|
||||
var lines:Array = vcardStr.split(/\r\n/);
|
||||
var vcard:VCard;
|
||||
var type:String;
|
||||
var typeTmp:String;
|
||||
var line:String;
|
||||
|
||||
for (var i:uint = 0; i < lines.length; ++i)
|
||||
{
|
||||
line = lines[i];
|
||||
if (line == "BEGIN:VCARD")
|
||||
{
|
||||
vcard = new VCard();
|
||||
}
|
||||
else if (line == "END:VCARD")
|
||||
{
|
||||
if (vcard != null)
|
||||
{
|
||||
vcards.push(vcard);
|
||||
}
|
||||
}
|
||||
else if(line.search(/^ORG/i) != -1)
|
||||
{
|
||||
var org:String = line.substring(4, line.length);
|
||||
var orgArray:Array = org.split(";");
|
||||
for each (var orgToken:String in orgArray)
|
||||
{
|
||||
if (StringUtil.trim(orgToken).length > 0)
|
||||
{
|
||||
vcard.orgs.push(orgToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(line.search(/^TITLE/i) != -1)
|
||||
{
|
||||
var title:String = line.substring(6, line.length);
|
||||
vcard.title = title;
|
||||
}
|
||||
else if (line.search(/^FN:/i) != -1)
|
||||
{
|
||||
var fullName:String = line.substring(3, line.length);
|
||||
vcard.fullName = fullName;
|
||||
}
|
||||
else if (line.search(/^TEL/i) != -1)
|
||||
{
|
||||
type = new String();
|
||||
typeTmp = new String();
|
||||
var phone:Phone = new Phone();
|
||||
var number:String;
|
||||
var phoneTokens:Array = line.split(";");
|
||||
for each (var phoneToken:String in phoneTokens)
|
||||
{
|
||||
if (phoneToken.search(/^TYPE=/i) != -1)
|
||||
{
|
||||
if (phoneToken.indexOf(":") != -1)
|
||||
{
|
||||
typeTmp = phoneToken.substring(5, phoneToken.indexOf(":"));
|
||||
number = phoneToken.substring(phoneToken.indexOf(":")+1, phoneToken.length);
|
||||
}
|
||||
else
|
||||
{
|
||||
typeTmp = phoneToken.substring(5, phoneToken.length);
|
||||
}
|
||||
|
||||
typeTmp = typeTmp.toLocaleLowerCase();
|
||||
|
||||
if (typeTmp == "pref")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (type.length != 0)
|
||||
{
|
||||
type += (" ");
|
||||
}
|
||||
type += typeTmp;
|
||||
}
|
||||
}
|
||||
if (type.length > 0 && number != null)
|
||||
{
|
||||
phone.type = type;
|
||||
phone.number = number;
|
||||
}
|
||||
vcard.phones.push(phone);
|
||||
}
|
||||
else if (line.search(/^EMAIL/i) != -1)
|
||||
{
|
||||
type = new String();
|
||||
typeTmp = new String();
|
||||
var email:Email = new Email();
|
||||
var emailAddress:String;
|
||||
var emailTokens:Array = line.split(";");
|
||||
for each (var emailToken:String in emailTokens)
|
||||
{
|
||||
if (emailToken.search(/^TYPE=/i) != -1)
|
||||
{
|
||||
if (emailToken.indexOf(":") != -1)
|
||||
{
|
||||
typeTmp = emailToken.substring(5, emailToken.indexOf(":"));
|
||||
emailAddress = emailToken.substring(emailToken.indexOf(":")+1, emailToken.length);
|
||||
}
|
||||
else
|
||||
{
|
||||
typeTmp = emailToken.substring(5, emailToken.length);
|
||||
}
|
||||
|
||||
typeTmp = typeTmp.toLocaleLowerCase();
|
||||
|
||||
if (typeTmp == "pref" || typeTmp == "internet")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (type.length != 0)
|
||||
{
|
||||
type += (" ");
|
||||
}
|
||||
type += typeTmp;
|
||||
}
|
||||
}
|
||||
if (type.length > 0 && emailAddress != null)
|
||||
{
|
||||
email.type = type;
|
||||
email.address = emailAddress;
|
||||
}
|
||||
vcard.emails.push(email);
|
||||
}
|
||||
else if (line.indexOf("ADR;") != -1)
|
||||
{
|
||||
var addressTokens:Array = line.split(";");
|
||||
var address:Address = new Address();
|
||||
for (var j:uint = 0; j < addressTokens.length; ++j)
|
||||
{
|
||||
var addressToken:String = addressTokens[j];
|
||||
if (addressToken.search(/^home:+$/i) != -1) // For Outlook, which uses non-standard vCards.
|
||||
{
|
||||
address.type = "home";
|
||||
}
|
||||
else if (addressToken.search(/^work:+$/i) != -1) // For Outlook, which uses non-standard vCards.
|
||||
{
|
||||
address.type = "work";
|
||||
}
|
||||
if (addressToken.search(/^type=/i) != -1) // The "type" parameter is the standard way (which Address Book uses)
|
||||
{
|
||||
// First, remove the optional ":" character.
|
||||
addressToken = addressToken.replace(/:/,"");
|
||||
var addressType:String = addressToken.substring(5, addressToken.length).toLowerCase();
|
||||
if (addressType == "pref") // Not interested in which one is preferred.
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (addressType.indexOf("home") != -1) // home
|
||||
{
|
||||
addressType = "home";
|
||||
}
|
||||
else if (addressType.indexOf("work") != -1) // work
|
||||
{
|
||||
addressType = "work";
|
||||
}
|
||||
else if (addressType.indexOf(",") != -1) // if the comma technique is used, just use the first one
|
||||
{
|
||||
var typeTokens:Array = addressType.split(",");
|
||||
for each (var typeToken:String in typeTokens)
|
||||
{
|
||||
if (typeToken != "pref")
|
||||
{
|
||||
addressType = typeToken;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
address.type = addressType;
|
||||
}
|
||||
else if (addressToken.search(/^\d/) != -1 && address.street == null)
|
||||
{
|
||||
address.street = addressToken.replace(/\\n/, "");
|
||||
address.city = addressTokens[j+1];
|
||||
address.state = addressTokens[j+2];
|
||||
address.postalCode = addressTokens[j+3];
|
||||
}
|
||||
}
|
||||
if (address.type != null && address.street != null)
|
||||
{
|
||||
vcard.addresses.push(address);
|
||||
}
|
||||
|
||||
}
|
||||
else if (line.search(/^PHOTO;BASE64/i) != -1)
|
||||
{
|
||||
var imageStr:String = new String();
|
||||
for (var k:uint = i+1; k < lines.length; ++k)
|
||||
{
|
||||
imageStr += lines[k];
|
||||
//if (lines[k].search(/.+\=$/) != -1) // Very slow in Mac due to RegEx bug
|
||||
if (lines[k].indexOf('=') != -1)
|
||||
{
|
||||
var decoder:Base64Decoder = new Base64Decoder();
|
||||
decoder.decode(imageStr);
|
||||
vcard.image = decoder.flush();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return vcards;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
Copyright (c) 2008, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package com.adobe.images
|
||||
{
|
||||
public class BitString
|
||||
{
|
||||
public var len:int = 0;
|
||||
public var val:int = 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,648 @@
|
|||
/*
|
||||
Copyright (c) 2008, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package com.adobe.images
|
||||
{
|
||||
import flash.geom.*;
|
||||
import flash.display.*;
|
||||
import flash.utils.*;
|
||||
|
||||
/**
|
||||
* Class that converts BitmapData into a valid JPEG
|
||||
*/
|
||||
public class JPGEncoder
|
||||
{
|
||||
|
||||
// Static table initialization
|
||||
|
||||
private var ZigZag:Array = [
|
||||
0, 1, 5, 6,14,15,27,28,
|
||||
2, 4, 7,13,16,26,29,42,
|
||||
3, 8,12,17,25,30,41,43,
|
||||
9,11,18,24,31,40,44,53,
|
||||
10,19,23,32,39,45,52,54,
|
||||
20,22,33,38,46,51,55,60,
|
||||
21,34,37,47,50,56,59,61,
|
||||
35,36,48,49,57,58,62,63
|
||||
];
|
||||
|
||||
private var YTable:Array = new Array(64);
|
||||
private var UVTable:Array = new Array(64);
|
||||
private var fdtbl_Y:Array = new Array(64);
|
||||
private var fdtbl_UV:Array = new Array(64);
|
||||
|
||||
private function initQuantTables(sf:int):void
|
||||
{
|
||||
var i:int;
|
||||
var t:Number;
|
||||
var YQT:Array = [
|
||||
16, 11, 10, 16, 24, 40, 51, 61,
|
||||
12, 12, 14, 19, 26, 58, 60, 55,
|
||||
14, 13, 16, 24, 40, 57, 69, 56,
|
||||
14, 17, 22, 29, 51, 87, 80, 62,
|
||||
18, 22, 37, 56, 68,109,103, 77,
|
||||
24, 35, 55, 64, 81,104,113, 92,
|
||||
49, 64, 78, 87,103,121,120,101,
|
||||
72, 92, 95, 98,112,100,103, 99
|
||||
];
|
||||
for (i = 0; i < 64; i++) {
|
||||
t = Math.floor((YQT[i]*sf+50)/100);
|
||||
if (t < 1) {
|
||||
t = 1;
|
||||
} else if (t > 255) {
|
||||
t = 255;
|
||||
}
|
||||
YTable[ZigZag[i]] = t;
|
||||
}
|
||||
var UVQT:Array = [
|
||||
17, 18, 24, 47, 99, 99, 99, 99,
|
||||
18, 21, 26, 66, 99, 99, 99, 99,
|
||||
24, 26, 56, 99, 99, 99, 99, 99,
|
||||
47, 66, 99, 99, 99, 99, 99, 99,
|
||||
99, 99, 99, 99, 99, 99, 99, 99,
|
||||
99, 99, 99, 99, 99, 99, 99, 99,
|
||||
99, 99, 99, 99, 99, 99, 99, 99,
|
||||
99, 99, 99, 99, 99, 99, 99, 99
|
||||
];
|
||||
for (i = 0; i < 64; i++) {
|
||||
t = Math.floor((UVQT[i]*sf+50)/100);
|
||||
if (t < 1) {
|
||||
t = 1;
|
||||
} else if (t > 255) {
|
||||
t = 255;
|
||||
}
|
||||
UVTable[ZigZag[i]] = t;
|
||||
}
|
||||
var aasf:Array = [
|
||||
1.0, 1.387039845, 1.306562965, 1.175875602,
|
||||
1.0, 0.785694958, 0.541196100, 0.275899379
|
||||
];
|
||||
i = 0;
|
||||
for (var row:int = 0; row < 8; row++)
|
||||
{
|
||||
for (var col:int = 0; col < 8; col++)
|
||||
{
|
||||
fdtbl_Y[i] = (1.0 / (YTable [ZigZag[i]] * aasf[row] * aasf[col] * 8.0));
|
||||
fdtbl_UV[i] = (1.0 / (UVTable[ZigZag[i]] * aasf[row] * aasf[col] * 8.0));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var YDC_HT:Array;
|
||||
private var UVDC_HT:Array;
|
||||
private var YAC_HT:Array;
|
||||
private var UVAC_HT:Array;
|
||||
|
||||
private function computeHuffmanTbl(nrcodes:Array, std_table:Array):Array
|
||||
{
|
||||
var codevalue:int = 0;
|
||||
var pos_in_table:int = 0;
|
||||
var HT:Array = new Array();
|
||||
for (var k:int=1; k<=16; k++) {
|
||||
for (var j:int=1; j<=nrcodes[k]; j++) {
|
||||
HT[std_table[pos_in_table]] = new BitString();
|
||||
HT[std_table[pos_in_table]].val = codevalue;
|
||||
HT[std_table[pos_in_table]].len = k;
|
||||
pos_in_table++;
|
||||
codevalue++;
|
||||
}
|
||||
codevalue*=2;
|
||||
}
|
||||
return HT;
|
||||
}
|
||||
|
||||
private var std_dc_luminance_nrcodes:Array = [0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0];
|
||||
private var std_dc_luminance_values:Array = [0,1,2,3,4,5,6,7,8,9,10,11];
|
||||
private var std_ac_luminance_nrcodes:Array = [0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,0x7d];
|
||||
private var std_ac_luminance_values:Array = [
|
||||
0x01,0x02,0x03,0x00,0x04,0x11,0x05,0x12,
|
||||
0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07,
|
||||
0x22,0x71,0x14,0x32,0x81,0x91,0xa1,0x08,
|
||||
0x23,0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0,
|
||||
0x24,0x33,0x62,0x72,0x82,0x09,0x0a,0x16,
|
||||
0x17,0x18,0x19,0x1a,0x25,0x26,0x27,0x28,
|
||||
0x29,0x2a,0x34,0x35,0x36,0x37,0x38,0x39,
|
||||
0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,
|
||||
0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59,
|
||||
0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,
|
||||
0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,
|
||||
0x7a,0x83,0x84,0x85,0x86,0x87,0x88,0x89,
|
||||
0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,
|
||||
0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,
|
||||
0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6,
|
||||
0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,
|
||||
0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,
|
||||
0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xe1,0xe2,
|
||||
0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,
|
||||
0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,
|
||||
0xf9,0xfa
|
||||
];
|
||||
|
||||
private var std_dc_chrominance_nrcodes:Array = [0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0];
|
||||
private var std_dc_chrominance_values:Array = [0,1,2,3,4,5,6,7,8,9,10,11];
|
||||
private var std_ac_chrominance_nrcodes:Array = [0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,0x77];
|
||||
private var std_ac_chrominance_values:Array = [
|
||||
0x00,0x01,0x02,0x03,0x11,0x04,0x05,0x21,
|
||||
0x31,0x06,0x12,0x41,0x51,0x07,0x61,0x71,
|
||||
0x13,0x22,0x32,0x81,0x08,0x14,0x42,0x91,
|
||||
0xa1,0xb1,0xc1,0x09,0x23,0x33,0x52,0xf0,
|
||||
0x15,0x62,0x72,0xd1,0x0a,0x16,0x24,0x34,
|
||||
0xe1,0x25,0xf1,0x17,0x18,0x19,0x1a,0x26,
|
||||
0x27,0x28,0x29,0x2a,0x35,0x36,0x37,0x38,
|
||||
0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,
|
||||
0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,
|
||||
0x59,0x5a,0x63,0x64,0x65,0x66,0x67,0x68,
|
||||
0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,
|
||||
0x79,0x7a,0x82,0x83,0x84,0x85,0x86,0x87,
|
||||
0x88,0x89,0x8a,0x92,0x93,0x94,0x95,0x96,
|
||||
0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,
|
||||
0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,
|
||||
0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xc2,0xc3,
|
||||
0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,
|
||||
0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,
|
||||
0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,
|
||||
0xea,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,
|
||||
0xf9,0xfa
|
||||
];
|
||||
|
||||
private function initHuffmanTbl():void
|
||||
{
|
||||
YDC_HT = computeHuffmanTbl(std_dc_luminance_nrcodes,std_dc_luminance_values);
|
||||
UVDC_HT = computeHuffmanTbl(std_dc_chrominance_nrcodes,std_dc_chrominance_values);
|
||||
YAC_HT = computeHuffmanTbl(std_ac_luminance_nrcodes,std_ac_luminance_values);
|
||||
UVAC_HT = computeHuffmanTbl(std_ac_chrominance_nrcodes,std_ac_chrominance_values);
|
||||
}
|
||||
|
||||
private var bitcode:Array = new Array(65535);
|
||||
private var category:Array = new Array(65535);
|
||||
|
||||
private function initCategoryNumber():void
|
||||
{
|
||||
var nrlower:int = 1;
|
||||
var nrupper:int = 2;
|
||||
var nr:int;
|
||||
for (var cat:int=1; cat<=15; cat++) {
|
||||
//Positive numbers
|
||||
for (nr=nrlower; nr<nrupper; nr++) {
|
||||
category[32767+nr] = cat;
|
||||
bitcode[32767+nr] = new BitString();
|
||||
bitcode[32767+nr].len = cat;
|
||||
bitcode[32767+nr].val = nr;
|
||||
}
|
||||
//Negative numbers
|
||||
for (nr=-(nrupper-1); nr<=-nrlower; nr++) {
|
||||
category[32767+nr] = cat;
|
||||
bitcode[32767+nr] = new BitString();
|
||||
bitcode[32767+nr].len = cat;
|
||||
bitcode[32767+nr].val = nrupper-1+nr;
|
||||
}
|
||||
nrlower <<= 1;
|
||||
nrupper <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
// IO functions
|
||||
|
||||
private var byteout:ByteArray;
|
||||
private var bytenew:int = 0;
|
||||
private var bytepos:int = 7;
|
||||
|
||||
private function writeBits(bs:BitString):void
|
||||
{
|
||||
var value:int = bs.val;
|
||||
var posval:int = bs.len-1;
|
||||
while ( posval >= 0 ) {
|
||||
if (value & uint(1 << posval) ) {
|
||||
bytenew |= uint(1 << bytepos);
|
||||
}
|
||||
posval--;
|
||||
bytepos--;
|
||||
if (bytepos < 0) {
|
||||
if (bytenew == 0xFF) {
|
||||
writeByte(0xFF);
|
||||
writeByte(0);
|
||||
}
|
||||
else {
|
||||
writeByte(bytenew);
|
||||
}
|
||||
bytepos=7;
|
||||
bytenew=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function writeByte(value:int):void
|
||||
{
|
||||
byteout.writeByte(value);
|
||||
}
|
||||
|
||||
private function writeWord(value:int):void
|
||||
{
|
||||
writeByte((value>>8)&0xFF);
|
||||
writeByte((value )&0xFF);
|
||||
}
|
||||
|
||||
// DCT & quantization core
|
||||
|
||||
private function fDCTQuant(data:Array, fdtbl:Array):Array
|
||||
{
|
||||
var tmp0:Number, tmp1:Number, tmp2:Number, tmp3:Number, tmp4:Number, tmp5:Number, tmp6:Number, tmp7:Number;
|
||||
var tmp10:Number, tmp11:Number, tmp12:Number, tmp13:Number;
|
||||
var z1:Number, z2:Number, z3:Number, z4:Number, z5:Number, z11:Number, z13:Number;
|
||||
var i:int;
|
||||
/* Pass 1: process rows. */
|
||||
var dataOff:int=0;
|
||||
for (i=0; i<8; i++) {
|
||||
tmp0 = data[dataOff+0] + data[dataOff+7];
|
||||
tmp7 = data[dataOff+0] - data[dataOff+7];
|
||||
tmp1 = data[dataOff+1] + data[dataOff+6];
|
||||
tmp6 = data[dataOff+1] - data[dataOff+6];
|
||||
tmp2 = data[dataOff+2] + data[dataOff+5];
|
||||
tmp5 = data[dataOff+2] - data[dataOff+5];
|
||||
tmp3 = data[dataOff+3] + data[dataOff+4];
|
||||
tmp4 = data[dataOff+3] - data[dataOff+4];
|
||||
|
||||
/* Even part */
|
||||
tmp10 = tmp0 + tmp3; /* phase 2 */
|
||||
tmp13 = tmp0 - tmp3;
|
||||
tmp11 = tmp1 + tmp2;
|
||||
tmp12 = tmp1 - tmp2;
|
||||
|
||||
data[dataOff+0] = tmp10 + tmp11; /* phase 3 */
|
||||
data[dataOff+4] = tmp10 - tmp11;
|
||||
|
||||
z1 = (tmp12 + tmp13) * 0.707106781; /* c4 */
|
||||
data[dataOff+2] = tmp13 + z1; /* phase 5 */
|
||||
data[dataOff+6] = tmp13 - z1;
|
||||
|
||||
/* Odd part */
|
||||
tmp10 = tmp4 + tmp5; /* phase 2 */
|
||||
tmp11 = tmp5 + tmp6;
|
||||
tmp12 = tmp6 + tmp7;
|
||||
|
||||
/* The rotator is modified from fig 4-8 to avoid extra negations. */
|
||||
z5 = (tmp10 - tmp12) * 0.382683433; /* c6 */
|
||||
z2 = 0.541196100 * tmp10 + z5; /* c2-c6 */
|
||||
z4 = 1.306562965 * tmp12 + z5; /* c2+c6 */
|
||||
z3 = tmp11 * 0.707106781; /* c4 */
|
||||
|
||||
z11 = tmp7 + z3; /* phase 5 */
|
||||
z13 = tmp7 - z3;
|
||||
|
||||
data[dataOff+5] = z13 + z2; /* phase 6 */
|
||||
data[dataOff+3] = z13 - z2;
|
||||
data[dataOff+1] = z11 + z4;
|
||||
data[dataOff+7] = z11 - z4;
|
||||
|
||||
dataOff += 8; /* advance pointer to next row */
|
||||
}
|
||||
|
||||
/* Pass 2: process columns. */
|
||||
dataOff = 0;
|
||||
for (i=0; i<8; i++) {
|
||||
tmp0 = data[dataOff+ 0] + data[dataOff+56];
|
||||
tmp7 = data[dataOff+ 0] - data[dataOff+56];
|
||||
tmp1 = data[dataOff+ 8] + data[dataOff+48];
|
||||
tmp6 = data[dataOff+ 8] - data[dataOff+48];
|
||||
tmp2 = data[dataOff+16] + data[dataOff+40];
|
||||
tmp5 = data[dataOff+16] - data[dataOff+40];
|
||||
tmp3 = data[dataOff+24] + data[dataOff+32];
|
||||
tmp4 = data[dataOff+24] - data[dataOff+32];
|
||||
|
||||
/* Even part */
|
||||
tmp10 = tmp0 + tmp3; /* phase 2 */
|
||||
tmp13 = tmp0 - tmp3;
|
||||
tmp11 = tmp1 + tmp2;
|
||||
tmp12 = tmp1 - tmp2;
|
||||
|
||||
data[dataOff+ 0] = tmp10 + tmp11; /* phase 3 */
|
||||
data[dataOff+32] = tmp10 - tmp11;
|
||||
|
||||
z1 = (tmp12 + tmp13) * 0.707106781; /* c4 */
|
||||
data[dataOff+16] = tmp13 + z1; /* phase 5 */
|
||||
data[dataOff+48] = tmp13 - z1;
|
||||
|
||||
/* Odd part */
|
||||
tmp10 = tmp4 + tmp5; /* phase 2 */
|
||||
tmp11 = tmp5 + tmp6;
|
||||
tmp12 = tmp6 + tmp7;
|
||||
|
||||
/* The rotator is modified from fig 4-8 to avoid extra negations. */
|
||||
z5 = (tmp10 - tmp12) * 0.382683433; /* c6 */
|
||||
z2 = 0.541196100 * tmp10 + z5; /* c2-c6 */
|
||||
z4 = 1.306562965 * tmp12 + z5; /* c2+c6 */
|
||||
z3 = tmp11 * 0.707106781; /* c4 */
|
||||
|
||||
z11 = tmp7 + z3; /* phase 5 */
|
||||
z13 = tmp7 - z3;
|
||||
|
||||
data[dataOff+40] = z13 + z2; /* phase 6 */
|
||||
data[dataOff+24] = z13 - z2;
|
||||
data[dataOff+ 8] = z11 + z4;
|
||||
data[dataOff+56] = z11 - z4;
|
||||
|
||||
dataOff++; /* advance pointer to next column */
|
||||
}
|
||||
|
||||
// Quantize/descale the coefficients
|
||||
for (i=0; i<64; i++) {
|
||||
// Apply the quantization and scaling factor & Round to nearest integer
|
||||
data[i] = Math.round((data[i]*fdtbl[i]));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
// Chunk writing
|
||||
|
||||
private function writeAPP0():void
|
||||
{
|
||||
writeWord(0xFFE0); // marker
|
||||
writeWord(16); // length
|
||||
writeByte(0x4A); // J
|
||||
writeByte(0x46); // F
|
||||
writeByte(0x49); // I
|
||||
writeByte(0x46); // F
|
||||
writeByte(0); // = "JFIF",'\0'
|
||||
writeByte(1); // versionhi
|
||||
writeByte(1); // versionlo
|
||||
writeByte(0); // xyunits
|
||||
writeWord(1); // xdensity
|
||||
writeWord(1); // ydensity
|
||||
writeByte(0); // thumbnwidth
|
||||
writeByte(0); // thumbnheight
|
||||
}
|
||||
|
||||
private function writeSOF0(width:int, height:int):void
|
||||
{
|
||||
writeWord(0xFFC0); // marker
|
||||
writeWord(17); // length, truecolor YUV JPG
|
||||
writeByte(8); // precision
|
||||
writeWord(height);
|
||||
writeWord(width);
|
||||
writeByte(3); // nrofcomponents
|
||||
writeByte(1); // IdY
|
||||
writeByte(0x11); // HVY
|
||||
writeByte(0); // QTY
|
||||
writeByte(2); // IdU
|
||||
writeByte(0x11); // HVU
|
||||
writeByte(1); // QTU
|
||||
writeByte(3); // IdV
|
||||
writeByte(0x11); // HVV
|
||||
writeByte(1); // QTV
|
||||
}
|
||||
|
||||
private function writeDQT():void
|
||||
{
|
||||
writeWord(0xFFDB); // marker
|
||||
writeWord(132); // length
|
||||
writeByte(0);
|
||||
var i:int;
|
||||
for (i=0; i<64; i++) {
|
||||
writeByte(YTable[i]);
|
||||
}
|
||||
writeByte(1);
|
||||
for (i=0; i<64; i++) {
|
||||
writeByte(UVTable[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private function writeDHT():void
|
||||
{
|
||||
writeWord(0xFFC4); // marker
|
||||
writeWord(0x01A2); // length
|
||||
var i:int;
|
||||
|
||||
writeByte(0); // HTYDCinfo
|
||||
for (i=0; i<16; i++) {
|
||||
writeByte(std_dc_luminance_nrcodes[i+1]);
|
||||
}
|
||||
for (i=0; i<=11; i++) {
|
||||
writeByte(std_dc_luminance_values[i]);
|
||||
}
|
||||
|
||||
writeByte(0x10); // HTYACinfo
|
||||
for (i=0; i<16; i++) {
|
||||
writeByte(std_ac_luminance_nrcodes[i+1]);
|
||||
}
|
||||
for (i=0; i<=161; i++) {
|
||||
writeByte(std_ac_luminance_values[i]);
|
||||
}
|
||||
|
||||
writeByte(1); // HTUDCinfo
|
||||
for (i=0; i<16; i++) {
|
||||
writeByte(std_dc_chrominance_nrcodes[i+1]);
|
||||
}
|
||||
for (i=0; i<=11; i++) {
|
||||
writeByte(std_dc_chrominance_values[i]);
|
||||
}
|
||||
|
||||
writeByte(0x11); // HTUACinfo
|
||||
for (i=0; i<16; i++) {
|
||||
writeByte(std_ac_chrominance_nrcodes[i+1]);
|
||||
}
|
||||
for (i=0; i<=161; i++) {
|
||||
writeByte(std_ac_chrominance_values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private function writeSOS():void
|
||||
{
|
||||
writeWord(0xFFDA); // marker
|
||||
writeWord(12); // length
|
||||
writeByte(3); // nrofcomponents
|
||||
writeByte(1); // IdY
|
||||
writeByte(0); // HTY
|
||||
writeByte(2); // IdU
|
||||
writeByte(0x11); // HTU
|
||||
writeByte(3); // IdV
|
||||
writeByte(0x11); // HTV
|
||||
writeByte(0); // Ss
|
||||
writeByte(0x3f); // Se
|
||||
writeByte(0); // Bf
|
||||
}
|
||||
|
||||
// Core processing
|
||||
private var DU:Array = new Array(64);
|
||||
|
||||
private function processDU(CDU:Array, fdtbl:Array, DC:Number, HTDC:Array, HTAC:Array):Number
|
||||
{
|
||||
var EOB:BitString = HTAC[0x00];
|
||||
var M16zeroes:BitString = HTAC[0xF0];
|
||||
var i:int;
|
||||
|
||||
var DU_DCT:Array = fDCTQuant(CDU, fdtbl);
|
||||
//ZigZag reorder
|
||||
for (i=0;i<64;i++) {
|
||||
DU[ZigZag[i]]=DU_DCT[i];
|
||||
}
|
||||
var Diff:int = DU[0] - DC; DC = DU[0];
|
||||
//Encode DC
|
||||
if (Diff==0) {
|
||||
writeBits(HTDC[0]); // Diff might be 0
|
||||
} else {
|
||||
writeBits(HTDC[category[32767+Diff]]);
|
||||
writeBits(bitcode[32767+Diff]);
|
||||
}
|
||||
//Encode ACs
|
||||
var end0pos:int = 63;
|
||||
for (; (end0pos>0)&&(DU[end0pos]==0); end0pos--) {
|
||||
};
|
||||
//end0pos = first element in reverse order !=0
|
||||
if ( end0pos == 0) {
|
||||
writeBits(EOB);
|
||||
return DC;
|
||||
}
|
||||
i = 1;
|
||||
while ( i <= end0pos ) {
|
||||
var startpos:int = i;
|
||||
for (; (DU[i]==0) && (i<=end0pos); i++) {
|
||||
}
|
||||
var nrzeroes:int = i-startpos;
|
||||
if ( nrzeroes >= 16 ) {
|
||||
for (var nrmarker:int=1; nrmarker <= nrzeroes/16; nrmarker++) {
|
||||
writeBits(M16zeroes);
|
||||
}
|
||||
nrzeroes = int(nrzeroes&0xF);
|
||||
}
|
||||
writeBits(HTAC[nrzeroes*16+category[32767+DU[i]]]);
|
||||
writeBits(bitcode[32767+DU[i]]);
|
||||
i++;
|
||||
}
|
||||
if ( end0pos != 63 ) {
|
||||
writeBits(EOB);
|
||||
}
|
||||
return DC;
|
||||
}
|
||||
|
||||
private var YDU:Array = new Array(64);
|
||||
private var UDU:Array = new Array(64);
|
||||
private var VDU:Array = new Array(64);
|
||||
|
||||
private function RGB2YUV(img:BitmapData, xpos:int, ypos:int):void
|
||||
{
|
||||
var pos:int=0;
|
||||
for (var y:int=0; y<8; y++) {
|
||||
for (var x:int=0; x<8; x++) {
|
||||
var P:uint = img.getPixel32(xpos+x,ypos+y);
|
||||
var R:Number = Number((P>>16)&0xFF);
|
||||
var G:Number = Number((P>> 8)&0xFF);
|
||||
var B:Number = Number((P )&0xFF);
|
||||
YDU[pos]=((( 0.29900)*R+( 0.58700)*G+( 0.11400)*B))-128;
|
||||
UDU[pos]=(((-0.16874)*R+(-0.33126)*G+( 0.50000)*B));
|
||||
VDU[pos]=((( 0.50000)*R+(-0.41869)*G+(-0.08131)*B));
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for JPEGEncoder class
|
||||
*
|
||||
* @param quality The quality level between 1 and 100 that detrmines the
|
||||
* level of compression used in the generated JPEG
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion Flash 9.0
|
||||
* @tiptext
|
||||
*/
|
||||
public function JPGEncoder(quality:Number = 50)
|
||||
{
|
||||
if (quality <= 0) {
|
||||
quality = 1;
|
||||
}
|
||||
if (quality > 100) {
|
||||
quality = 100;
|
||||
}
|
||||
var sf:int = 0;
|
||||
if (quality < 50) {
|
||||
sf = int(5000 / quality);
|
||||
} else {
|
||||
sf = int(200 - quality*2);
|
||||
}
|
||||
// Create tables
|
||||
initHuffmanTbl();
|
||||
initCategoryNumber();
|
||||
initQuantTables(sf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Created a JPEG image from the specified BitmapData
|
||||
*
|
||||
* @param image The BitmapData that will be converted into the JPEG format.
|
||||
* @return a ByteArray representing the JPEG encoded image data.
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion Flash 9.0
|
||||
* @tiptext
|
||||
*/
|
||||
public function encode(image:BitmapData):ByteArray
|
||||
{
|
||||
// Initialize bit writer
|
||||
byteout = new ByteArray();
|
||||
bytenew=0;
|
||||
bytepos=7;
|
||||
|
||||
// Add JPEG headers
|
||||
writeWord(0xFFD8); // SOI
|
||||
writeAPP0();
|
||||
writeDQT();
|
||||
writeSOF0(image.width,image.height);
|
||||
writeDHT();
|
||||
writeSOS();
|
||||
|
||||
|
||||
// Encode 8x8 macroblocks
|
||||
var DCY:Number=0;
|
||||
var DCU:Number=0;
|
||||
var DCV:Number=0;
|
||||
bytenew=0;
|
||||
bytepos=7;
|
||||
for (var ypos:int=0; ypos<image.height; ypos+=8) {
|
||||
for (var xpos:int=0; xpos<image.width; xpos+=8) {
|
||||
RGB2YUV(image, xpos, ypos);
|
||||
DCY = processDU(YDU, fdtbl_Y, DCY, YDC_HT, YAC_HT);
|
||||
DCU = processDU(UDU, fdtbl_UV, DCU, UVDC_HT, UVAC_HT);
|
||||
DCV = processDU(VDU, fdtbl_UV, DCV, UVDC_HT, UVAC_HT);
|
||||
}
|
||||
}
|
||||
|
||||
// Do the bit alignment of the EOI marker
|
||||
if ( bytepos >= 0 ) {
|
||||
var fillbits:BitString = new BitString();
|
||||
fillbits.len = bytepos+1;
|
||||
fillbits.val = (1<<(bytepos+1))-1;
|
||||
writeBits(fillbits);
|
||||
}
|
||||
|
||||
writeWord(0xFFD9); //EOI
|
||||
return byteout;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
Copyright (c) 2008, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems Incorporated nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package com.adobe.images
|
||||
{
|
||||
import flash.geom.*;
|
||||
import flash.display.Bitmap;
|
||||
import flash.display.BitmapData;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
/**
|
||||
* Class that converts BitmapData into a valid PNG
|
||||
*/
|
||||
public class PNGEncoder
|
||||
{
|
||||
/**
|
||||
* Created a PNG image from the specified BitmapData
|
||||
*
|
||||
* @param image The BitmapData that will be converted into the PNG format.
|
||||
* @return a ByteArray representing the PNG encoded image data.
|
||||
* @langversion ActionScript 3.0
|
||||
* @playerversion Flash 9.0
|
||||
* @tiptext
|
||||
*/
|
||||
public static function encode(img:BitmapData):ByteArray {
|
||||
// Create output byte array
|
||||
var png:ByteArray = new ByteArray();
|
||||
// Write PNG signature
|
||||
png.writeUnsignedInt(0x89504e47);
|
||||
png.writeUnsignedInt(0x0D0A1A0A);
|
||||
// Build IHDR chunk
|
||||
var IHDR:ByteArray = new ByteArray();
|
||||
IHDR.writeInt(img.width);
|
||||
IHDR.writeInt(img.height);
|
||||
IHDR.writeUnsignedInt(0x08060000); // 32bit RGBA
|
||||
IHDR.writeByte(0);
|
||||
writeChunk(png,0x49484452,IHDR);
|
||||
// Build IDAT chunk
|
||||
var IDAT:ByteArray= new ByteArray();
|
||||
for(var i:int=0;i < img.height;i++) {
|
||||
// no filter
|
||||
IDAT.writeByte(0);
|
||||
var p:uint;
|
||||
var j:int;
|
||||
if ( !img.transparent ) {
|
||||
for(j=0;j < img.width;j++) {
|
||||
p = img.getPixel(j,i);
|
||||
IDAT.writeUnsignedInt(
|
||||
uint(((p&0xFFFFFF) << 8)|0xFF));
|
||||
}
|
||||
} else {
|
||||
for(j=0;j < img.width;j++) {
|
||||
p = img.getPixel32(j,i);
|
||||
IDAT.writeUnsignedInt(
|
||||
uint(((p&0xFFFFFF) << 8)|
|
||||
(p>>>24)));
|
||||
}
|
||||
}
|
||||
}
|
||||
IDAT.compress();
|
||||
writeChunk(png,0x49444154,IDAT);
|
||||
// Build IEND chunk
|
||||
writeChunk(png,0x49454E44,null);
|
||||
// return PNG
|
||||
return png;
|
||||
}
|
||||
|
||||
private static var crcTable:Array;
|
||||
private static var crcTableComputed:Boolean = false;
|
||||
|
||||
private static function writeChunk(png:ByteArray,
|
||||
type:uint, data:ByteArray):void {
|
||||
if (!crcTableComputed) {
|
||||
crcTableComputed = true;
|
||||
crcTable = [];
|
||||
var c:uint;
|
||||
for (var n:uint = 0; n < 256; n++) {
|
||||
c = n;
|
||||
for (var k:uint = 0; k < 8; k++) {
|
||||
if (c & 1) {
|
||||
c = uint(uint(0xedb88320) ^
|
||||
uint(c >>> 1));
|
||||
} else {
|
||||
c = uint(c >>> 1);
|
||||
}
|
||||
}
|
||||
crcTable[n] = c;
|
||||
}
|
||||
}
|
||||
var len:uint = 0;
|
||||
if (data != null) {
|
||||
len = data.length;
|
||||
}
|
||||
png.writeUnsignedInt(len);
|
||||
var p:uint = png.position;
|
||||
png.writeUnsignedInt(type);
|
||||
if ( data != null ) {
|
||||
png.writeBytes(data);
|
||||
}
|
||||
var e:uint = png.position;
|
||||
png.position = p;
|
||||
c = 0xffffffff;
|
||||
for (var i:int = 0; i < (e-p); i++) {
|
||||
c = uint(crcTable[
|
||||
(c ^ png.readUnsignedByte()) &
|
||||
uint(0xff)] ^ uint(c >>> 8));
|
||||
}
|
||||
c = uint(c^uint(0xffffffff));
|
||||
png.position = e;
|
||||
png.writeUnsignedInt(c);
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue