diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/bootstrap /tmp/2JlptO5AlS/cmake-2.3.4-20060317/bootstrap --- /tmp/107n8sR4i4/cmake-2.2.3/bootstrap 2005-10-17 20:49:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/bootstrap 2006-03-07 04:41:56.000000000 +0800 @@ -5,8 +5,8 @@ # Program: CMake - Cross-Platform Makefile Generator # Module: $RCSfile: bootstrap,v $ # Language: Bourne Shell -# Date: $Date: 2005/10/17 12:49:39 $ -# Version: $Revision: 1.66.2.3 $ +# Date: $Date: 2006/03/06 20:41:56 $ +# Version: $Revision: 1.78 $ # # Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. # See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -17,6 +17,56 @@ # #========================================================================= +# Detect system and directory information. +cmake_system=`uname` +cmake_source_dir=`echo $0 | sed -n '/\//{s/\/[^\/]*$//;p;}'` +cmake_source_dir=`(cd "${cmake_source_dir}";pwd)` +cmake_binary_dir=`pwd` +cmake_bootstrap_dir="${cmake_binary_dir}/Bootstrap.cmk" +cmake_data_dir="/share/CMake" +cmake_doc_dir="/doc/CMake" +cmake_man_dir="/man" +cmake_init_file="" + +# Determine whether this is a MinGW environment. +if echo "${cmake_system}" | grep MINGW >/dev/null 2>&1; then + cmake_system_mingw=true +else + cmake_system_mingw=false +fi + +# Choose the generator to use for bootstrapping. +if ${cmake_system_mingw}; then + # Bootstrapping from an MSYS prompt. + cmake_bootstrap_generator="MSYS Makefiles" +else + # Bootstrapping from a standard UNIX prompt. + cmake_bootstrap_generator="Unix Makefiles" +fi + +# Helper function to fix windows paths. +cmake_fix_slashes () +{ + echo "$1" | sed 's/\\/\//g' +} + +# Choose the default install prefix. +if ${cmake_system_mingw}; then + if [ "x${PROGRAMFILES}" != "x" ]; then + cmake_default_prefix=`cmake_fix_slashes "${PROGRAMFILES}/CMake"` + elif [ "x${ProgramFiles}" != "x" ]; then + cmake_default_prefix=`cmake_fix_slashes "${ProgramFiles}/CMake"` + elif [ "x${SYSTEMDRIVE}" != "x" ]; then + cmake_default_prefix=`cmake_fix_slashes "${SYSTEMDRIVE}/Program Files/CMake"` + elif [ "x${SystemDrive}" != "x" ]; then + cmake_default_prefix=`cmake_fix_slashes "${SystemDrive}/Program Files/CMake"` + else + cmake_default_prefix="c:/Program Files/CMake" + fi +else + cmake_default_prefix="/usr/local" +fi + CMAKE_KNOWN_C_COMPILERS="cc gcc xlc icc tcc" CMAKE_KNOWN_CXX_COMPILERS="aCC xlC CC g++ c++ icc como " CMAKE_KNOWN_MAKE_PROCESSORS="gmake make" @@ -47,6 +97,10 @@ cmGlobalGenerator \ cmGlob \ cmLocalGenerator \ + cmInstallGenerator \ + cmInstallFilesGenerator \ + cmInstallScriptGenerator \ + cmInstallTargetGenerator \ cmSourceFile \ cmSystemTools \ cmFileTimeComparison \ @@ -56,6 +110,10 @@ cmXCodeObject \ cmXCode21Object \ cmLocalUnixMakefileGenerator3 \ + cmMakefileExecutableTargetGenerator \ + cmMakefileLibraryTargetGenerator \ + cmMakefileTargetGenerator \ + cmMakefileUtilityTargetGenerator \ cmBootstrapCommands \ cmCommands \ cmTarget \ @@ -66,22 +124,44 @@ cmOrderLinkDirectories \ cmSourceGroup" +if ${cmake_system_mingw}; then + CMAKE_CXX_SOURCES="${CMAKE_CXX_SOURCES}\ + cmGlobalMSYSMakefileGenerator \ + cmGlobalMinGWMakefileGenerator \ + cmWin32ProcessExecution" +fi + CMAKE_C_SOURCES="\ cmListFileLexer \ " -KWSYS_C_SOURCES="\ - ProcessUNIX" +if ${cmake_system_mingw}; then + KWSYS_C_SOURCES="\ + ProcessWin32" + KWSYS_C_MINGW_SOURCES="\ + ProcessFwd9x \ + EncodeExecutable" + KWSYS_C_GENERATED_SOURCES="\ + cmsysProcessFwd9xEnc" +else + KWSYS_C_SOURCES="\ + ProcessUNIX" + KWSYS_C_MINGW_SOURCES="" + KWSYS_C_GENERATED_SOURCES="" +fi KWSYS_CXX_SOURCES="\ Directory \ + Glob \ RegularExpression \ SystemTools" KWSYS_FILES="\ Directory.hxx \ + Glob.hxx \ Process.h \ RegularExpression.hxx \ + String.hxx \ SystemTools.hxx" KWSYS_IOS_FILES=" @@ -90,17 +170,6 @@ iostream \ sstream" -cmake_system=`uname` - -cmake_source_dir=`echo $0 | sed -n '/\//{s/\/[^\/]*$//;p;}'` -cmake_source_dir=`(cd "${cmake_source_dir}";pwd)` -cmake_binary_dir=`pwd` -cmake_bootstrap_dir="${cmake_binary_dir}/Bootstrap.cmk" -cmake_data_dir="/share/CMake" -cmake_doc_dir="/doc/CMake" -cmake_man_dir="/man" -cmake_init_file="" - # Display CMake bootstrap usage cmake_usage() { @@ -117,7 +186,7 @@ Directory and file names: --prefix=PREFIX install files in tree rooted at PREFIX - [/usr/local] + [${cmake_default_prefix}] --datadir=DIR install data files in PREFIX/DIR [/share/CMake] --docdir=DIR install documentation files in PREFIX/DIR @@ -330,10 +399,11 @@ # Parse arguments cmake_verbose= cmake_parallel_make= -cmake_prefix_dir="/usr/local" +cmake_prefix_dir="${cmake_default_prefix}" for a in "$@"; do if echo $a | grep "^--prefix=" > /dev/null 2> /dev/null; then cmake_prefix_dir=`echo $a | sed "s/^--prefix=//"` + cmake_prefix_dir=`cmake_fix_slashes "${cmake_prefix_dir}"` fi if echo $a | grep "^--parallel=" > /dev/null 2> /dev/null; then cmake_parallel_make=`echo $a | sed "s/^--parallel=//" | grep "[0-9][0-9]*"` @@ -949,7 +1019,7 @@ # Just to be safe, let us store compiler and flags to the header file -cmake_bootstrap_version='$Revision: 1.66.2.3 $' +cmake_bootstrap_version='$Revision: 1.78 $' cmake_compiler_settings_comment="/* * Generated by ${cmake_source_dir}/bootstrap * Version: ${cmake_bootstrap_version} @@ -968,7 +1038,7 @@ * Sources: * ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} * kwSys Sources: - * ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} + * ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} ${KWSYS_C_MINGW_SOURCES} */ " @@ -1003,13 +1073,21 @@ echo "${cmake_cxx_compiler} does not have ANSI for scoping" fi +# When bootstrapping on MinGW with MSYS we must convert the source +# directory to a windows path. +if ${cmake_system_mingw}; then + cmake_root_dir=`cd "${cmake_source_dir}"; pwd -W` +else + cmake_root_dir="${cmake_source_dir}" +fi + # Write CMake version for a in MAJOR MINOR PATCH; do CMake_VERSION=`cat "${cmake_source_dir}/CMakeLists.txt" | \ grep "SET(CMake_VERSION_${a} *[0-9]*)" | sed "s/SET(CMake_VERSION_${a} *\([0-9]*\))/\1/"` cmake_report cmConfigure.h.tmp "#define CMake_VERSION_${a} ${CMake_VERSION}" done -cmake_report cmConfigure.h.tmp "#define CMAKE_ROOT_DIR \"${cmake_source_dir}\"" +cmake_report cmConfigure.h.tmp "#define CMAKE_ROOT_DIR \"${cmake_root_dir}\"" cmake_report cmConfigure.h.tmp "#define CMAKE_DATA_DIR \"${cmake_data_dir}\"" cmake_report cmConfigure.h.tmp "#define CMAKE_BOOTSTRAP" @@ -1052,9 +1130,9 @@ done # Generate Makefile -dep="cmConfigure.h cmsys/Configure.hxx cmsys/Configure.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h" +dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h" objs="" -for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}; do +for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} ${KWSYS_C_GENERATED_SOURCES}; do objs="${objs} ${a}.o" done @@ -1093,7 +1171,7 @@ echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile" echo " ${cmake_c_compiler} ${cmake_c_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile" done -for a in ${KWSYS_C_SOURCES}; do +for a in ${KWSYS_C_SOURCES} ${KWSYS_C_MINGW_SOURCES}; do src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.c"` echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile" echo " ${cmake_c_compiler} ${cmake_c_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile" @@ -1103,6 +1181,20 @@ echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile" echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile" done +if ${cmake_system_mingw}; then + src=`cmake_escape "${cmake_bootstrap_dir}/cmsysProcessFwd9xEnc.c"` + in=`cmake_escape "${cmake_bootstrap_dir}/cmsysProcessFwd9x.exe"` + cmd=`cmake_escape "${cmake_bootstrap_dir}/cmsysEncodeExecutable.exe"` + a="cmsysProcessFwd9xEnc" + echo "${cmd} : EncodeExecutable.o" >> "${cmake_bootstrap_dir}/Makefile" + echo " ${cmake_c_compiler} ${LDFLAGS} ${cmake_c_flags} EncodeExecutable.o -o ${cmd}" >> "${cmake_bootstrap_dir}/Makefile" + echo "${in} : ProcessFwd9x.o" >> "${cmake_bootstrap_dir}/Makefile" + echo " ${cmake_c_compiler} ${LDFLAGS} ${cmake_c_flags} ProcessFwd9x.o -o ${in}" >> "${cmake_bootstrap_dir}/Makefile" + echo "${src} : ${cmd} ${in}" >> "${cmake_bootstrap_dir}/Makefile" + echo " ${cmd} ${in} ${src} cmsys ProcessFwd9x" >> "${cmake_bootstrap_dir}/Makefile" + echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile" + echo " ${cmake_c_compiler} ${cmake_c_flags} -I`cmake_escape \"${cmake_source_dir}/Source/kwsys\"` -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile" +fi cat>>"${cmake_bootstrap_dir}/Makefile"< Wed, 22 Mar 2006 22:10:41 +0800 + cmake (2.2.3-1) unstable; urgency=low * New upstream release (Closes: #338324) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/debian/rules /tmp/2JlptO5AlS/cmake-2.3.4-20060317/debian/rules --- /tmp/107n8sR4i4/cmake-2.2.3/debian/rules 2006-03-23 23:35:26.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/debian/rules 2006-03-23 23:35:27.000000000 +0800 @@ -54,7 +54,7 @@ echo CMAKE_CXX_FLAGS:STRING=$(CFLAGS) >> Build/CMakeCache.txt (if [[ $(DARTP) == "USE_DART" ]]; then echo BUILDNAME:STRING=cmake_2.2.3-1_$(DARCH).deb >> Build/CMakeCache.txt; fi) (cd Build ; ../bootstrap --prefix=/usr --docdir=/share/doc/cmake --mandir=/share/man) - chmod -x ChangeLog.manual + #chmod -x ChangeLog.manual chmod -x Modules/*.cmake Modules/*.cxx Modules/Platform/Windows-gcc.cmake Modules/Platform/Windows-icl.cmake chmod -x Modules/Platform/CYGWIN-g77.cmake Modules/CMakeRCCompiler.cmake.in Modules/CMakeFortranCompiler.cmake.in chmod -x Modules/Platform/* @@ -114,7 +114,7 @@ dh_installman dh_installinfo # dh_undocumented - dh_installchangelogs ChangeLog.txt ChangeLog.manual + dh_installchangelogs ChangeLog.txt dh_link dh_strip dh_compress -XCMake.pdf diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Docs/cmake-mode.el /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Docs/cmake-mode.el --- /tmp/107n8sR4i4/cmake-2.2.3/Docs/cmake-mode.el 2005-09-16 04:38:36.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Docs/cmake-mode.el 2006-02-11 03:15:58.000000000 +0800 @@ -3,7 +3,7 @@ ; Program: CMake - Cross-Platform Makefile Generator ; Module: $RCSfile: cmake-mode.el,v $ ; -; Copyright (c) 2000-$Date: 2005/09/15 20:38:36 $ Kitware, Inc., Insight Consortium. All rights reserved. +; Copyright (c) 2000-$Date: 2006/02/10 19:15:58 $ Kitware, Inc., Insight Consortium. All rights reserved. ; See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. ; ; This software is distributed WITHOUT ANY WARRANTY; without even @@ -134,15 +134,16 @@ ) ) -; (regexp-opt '("ADD_CUSTOM_COMMAND" "ADD_CUSTOM_TARGET" "ADD_DEFINITIONS" "ADD_DEPENDENCIES" "ADD_SUBDIRECTORY" "ADD_EXECUTABLE" "ADD_LIBRARY" "ADD_TEST" "AUX_SOURCE_DIRECTORY" "BUILD_COMMAND" "BUILD_NAME" "CMAKE_MINIMUM_REQUIRED" "CONFIGURE_FILE" "CREATE_TEST_SOURCELIST" "CREATE_TEST_SOURCELIST " "ELSE" "ENABLE_TESTING" "ENABLE_TESTING " "ENDFOREACH" "ENDIF" "ENDMACRO" "ENDWHILE" "EXEC_PROGRAM" "EXPORT_LIBRARY_DEPENDENCIES" "FIND_FILE" "FIND_LIBRARY" "FIND_PACKAGE" "FIND_PATH" "FIND_PROGRAM" "FLTK_WRAP_UI" "FOREACH" "GET_CMAKE_PROPERTY" "GET_DIRECTORY_PROPERTY" "GET_FILENAME_COMPONENT" "GET_SOURCE_FILE_PROPERTY" "GET_TARGET_PROPERTY" "IF" "INCLUDE" "INCLUDE_DIRECTORIES" "INCLUDE_EXTERNAL_MSPROJECT" "INCLUDE_REGULAR_EXPRESSION" "INSTALL_FILES" "INSTALL_PROGRAMS" "INSTALL_TARGETS" "ITK_WRAP_TCL" "LINK_DIRECTORIES" "LINK_LIBRARIES" "LOAD_CACHE" "LOAD_COMMAND" "MACRO" "MAKE_DIRECTORY" "MARK_AS_ADVANCED" "MESSAGE" "OPTION" "OUTPUT_REQUIRED_FILES" "PROJECT" "QT_WRAP_CPP" "QT_WRAP_UI" "REMOVE" "SEPARATE_ARGUMENTS" "SET" "SET_DIRECTORY_PROPERTIES" "SET_SOURCE_FILES_PROPERTIES" "SET_TARGET_PROPERTIES" "SITE_NAME" "SOURCE_GROUP" "STRING" "SUBDIRS" "SUBDIR_DEPENDS" "TARGET_LINK_LIBRARIES" "TRY_COMPILE" "TRY_RUN" "USE_MANGLED_MESA" "UTILITY_SOURCE" "VARIABLE_REQUIRES" "VTK_MAKE_INSTANTIATOR" "VTK_MAKE_INSTANTIATOR " "VTK_WRAP_JAVA" "VTK_WRAP_PYTHON" "VTK_WRAP_TCL" "WHILE" "WRITE_FILE" "add_custom_command" "add_custom_target" "add_definitions" "add_dependencies" "add_subdirectory" "add_executable" "add_library" "add_test" "aux_source_directory" "build_command" "build_name" "cmake_minimum_required" "configure_file" "create_test_sourcelist" "create_test_sourcelist " "else" "enable_testing" "enable_testing " "endforeach" "endif" "endmacro" "endwhile" "exec_program" "export_library_dependencies" "find_file" "find_library" "find_package" "find_path" "find_program" "fltk_wrap_ui" "foreach" "get_cmake_property" "get_directory_property" "get_filename_component" "get_source_file_property" "get_target_property" "if" "include" "include_directories" "include_external_msproject" "include_regular_expression" "install_files" "install_programs" "install_targets" "itk_wrap_tcl" "link_directories" "link_libraries" "load_cache" "load_command" "macro" "make_directory" "mark_as_advanced" "message" "option" "output_required_files" "project" "qt_wrap_cpp" "qt_wrap_ui" "remove" "separate_arguments" "set" "set_directory_properties" "set_source_files_properties" "set_target_properties" "site_name" "source_group" "string" "subdirs" "subdir_depends" "target_link_libraries" "try_compile" "try_run" "use_mangled_mesa" "utility_source" "variable_requires" "vtk_make_instantiator" "vtk_make_instantiator " "vtk_wrap_java" "vtk_wrap_python" "vtk_wrap_tcl" "while" "write_file") t)g +; (regexp-opt '("ADD_CUSTOM_COMMAND" "ADD_CUSTOM_TARGET" "ADD_DEFINITIONS" "ADD_DEPENDENCIES" "ADD_SUBDIRECTORY" "ADD_EXECUTABLE" "ADD_LIBRARY" "ADD_TEST" "AUX_SOURCE_DIRECTORY" "BUILD_COMMAND" "BUILD_NAME" "CMAKE_MINIMUM_REQUIRED" "CONFIGURE_FILE" "CREATE_TEST_SOURCELIST" "CREATE_TEST_SOURCELIST " "ELSE" "ENABLE_TESTING" "ENABLE_TESTING " "ENDFOREACH" "ENDIF" "ENDMACRO" "ENDWHILE" "EXEC_PROGRAM" "EXECUTE_PROCESS" "EXPORT_LIBRARY_DEPENDENCIES" "FIND_FILE" "FIND_LIBRARY" "FIND_PACKAGE" "FIND_PATH" "FIND_PROGRAM" "FLTK_WRAP_UI" "FOREACH" "GET_CMAKE_PROPERTY" "GET_DIRECTORY_PROPERTY" "GET_FILENAME_COMPONENT" "GET_SOURCE_FILE_PROPERTY" "GET_TARGET_PROPERTY" "IF" "INCLUDE" "INCLUDE_DIRECTORIES" "INCLUDE_EXTERNAL_MSPROJECT" "INCLUDE_REGULAR_EXPRESSION" "INSTALL" "INSTALL_FILES" "INSTALL_PROGRAMS" "INSTALL_TARGETS" "ITK_WRAP_TCL" "LINK_DIRECTORIES" "LINK_LIBRARIES" "LIST" "LOAD_CACHE" "LOAD_COMMAND" "MACRO" "MAKE_DIRECTORY" "MARK_AS_ADVANCED" "MESSAGE" "OPTION" "OUTPUT_REQUIRED_FILES" "PROJECT" "QT_WRAP_CPP" "QT_WRAP_UI" "REMOVE" "SEPARATE_ARGUMENTS" "SET" "SET_DIRECTORY_PROPERTIES" "SET_SOURCE_FILES_PROPERTIES" "SET_TARGET_PROPERTIES" "SITE_NAME" "SOURCE_GROUP" "STRING" "SUBDIRS" "SUBDIR_DEPENDS" "TARGET_LINK_LIBRARIES" "TRY_COMPILE" "TRY_RUN" "USE_MANGLED_MESA" "UTILITY_SOURCE" "VARIABLE_REQUIRES" "VTK_MAKE_INSTANTIATOR" "VTK_MAKE_INSTANTIATOR " "VTK_WRAP_JAVA" "VTK_WRAP_PYTHON" "VTK_WRAP_TCL" "WHILE" "WRITE_FILE" "add_custom_command" "add_custom_target" "add_definitions" "add_dependencies" "add_subdirectory" "add_executable" "add_library" "add_test" "aux_source_directory" "build_command" "build_name" "cmake_minimum_required" "configure_file" "create_test_sourcelist" "create_test_sourcelist " "else" "enable_testing" "enable_testing " "endforeach" "endif" "endmacro" "endwhile" "exec_program" "export_library_dependencies" "find_file" "find_library" "find_package" "find_path" "find_program" "fltk_wrap_ui" "foreach" "get_cmake_property" "get_directory_property" "get_filename_component" "get_source_file_property" "get_target_property" "if" "include" "include_directories" "include_external_msproject" "include_regular_expression" "install_files" "install_programs" "install_targets" "itk_wrap_tcl" "link_directories" "link_libraries" "load_cache" "load_command" "macro" "make_directory" "mark_as_advanced" "message" "option" "output_required_files" "project" "qt_wrap_cpp" "qt_wrap_ui" "remove" "separate_arguments" "set" "set_directory_properties" "set_source_files_properties" "set_target_properties" "site_name" "source_group" "string" "subdirs" "subdir_depends" "target_link_libraries" "try_compile" "try_run" "use_mangled_mesa" "utility_source" "variable_requires" "vtk_make_instantiator" "vtk_make_instantiator " "vtk_wrap_java" "vtk_wrap_python" "vtk_wrap_tcl" "while" "write_file") t) ; run the above in the scatch buffer to generate the string that ; goes in (list '("the regexp string" . font-lock-function-name-face) +; the string will be available in the *Messages* buffer ; Define keyword highlighting. (defconst cmake-font-lock-defaults (list ;; '("(" . font-lock-keyword-face) - '("\\(A\\(?:DD_\\(?:CUSTOM_\\(?:COMMAND\\|TARGET\\)\\|DE\\(?:\\(?:FINITION\\|PENDENCIE\\)S\\)\\|EXECUTABLE\\|LIBRARY\\|SUBDIRECTORY\\|TEST\\)\\|UX_SOURCE_DIRECTORY\\)\\|BUILD_\\(?:COMMAND\\|NAME\\)\\|C\\(?:MAKE_MINIMUM_REQUIRED\\|ONFIGURE_FILE\\|REATE_TEST_SOURCELIST ?\\)\\|E\\(?:LSE\\|N\\(?:ABLE_TESTING ?\\|D\\(?:FOREACH\\|IF\\|MACRO\\|WHILE\\)\\)\\|X\\(?:EC_PROGRAM\\|PORT_LIBRARY_DEPENDENCIES\\)\\)\\|F\\(?:IND_\\(?:FILE\\|LIBRARY\\|P\\(?:A\\(?:CKAGE\\|TH\\)\\|ROGRAM\\)\\)\\|LTK_WRAP_UI\\|OREACH\\)\\|GET_\\(?:CMAKE_PROPERTY\\|DIRECTORY_PROPERTY\\|FILENAME_COMPONENT\\|\\(?:SOURCE_FILE\\|TARGET\\)_PROPERTY\\)\\|I\\(?:F\\|N\\(?:CLUDE\\(?:_\\(?:DIRECTORIES\\|EXTERNAL_MSPROJECT\\|REGULAR_EXPRESSION\\)\\)?\\|STALL_\\(?:\\(?:FILE\\|PROGRAM\\|TARGET\\)S\\)\\)\\|TK_WRAP_TCL\\)\\|L\\(?:INK_\\(?:\\(?:DIRECTO\\|LIBRA\\)RIES\\)\\|OAD_C\\(?:ACHE\\|OMMAND\\)\\)\\|M\\(?:A\\(?:CRO\\|KE_DIRECTORY\\|RK_AS_ADVANCED\\)\\|ESSAGE\\)\\|O\\(?:PTION\\|UTPUT_REQUIRED_FILES\\)\\|PROJECT\\|QT_WRAP_\\(?:CPP\\|UI\\)\\|REMOVE\\|S\\(?:E\\(?:PARATE_ARGUMENTS\\|T\\(?:_\\(?:\\(?:DIRECTORY\\|SOURCE_FILES\\|TARGET\\)_PROPERTIES\\)\\)?\\)\\|ITE_NAME\\|OURCE_GROUP\\|TRING\\|UBDIR\\(?:\\(?:_DEPEND\\)?S\\)\\)\\|T\\(?:ARGET_LINK_LIBRARIES\\|RY_\\(?:COMPILE\\|RUN\\)\\)\\|U\\(?:SE_MANGLED_MESA\\|TILITY_SOURCE\\)\\|V\\(?:ARIABLE_REQUIRES\\|TK_\\(?:MAKE_INSTANTIATOR ?\\|WRAP_\\(?:JAVA\\|PYTHON\\|TCL\\)\\)\\)\\|W\\(?:\\(?:H\\|RITE_F\\)ILE\\)\\|a\\(?:dd_\\(?:custom_\\(?:command\\|target\\)\\|de\\(?:\\(?:finition\\|pendencie\\)s\\)\\|executable\\|library\\|subdirectory\\|test\\)\\|ux_source_directory\\)\\|build_\\(?:command\\|name\\)\\|c\\(?:make_minimum_required\\|onfigure_file\\|reate_test_sourcelist ?\\)\\|e\\(?:lse\\|n\\(?:able_testing ?\\|d\\(?:foreach\\|if\\|macro\\|while\\)\\)\\|x\\(?:ec_program\\|port_library_dependencies\\)\\)\\|f\\(?:ind_\\(?:file\\|library\\|p\\(?:a\\(?:ckage\\|th\\)\\|rogram\\)\\)\\|ltk_wrap_ui\\|oreach\\)\\|get_\\(?:cmake_property\\|directory_property\\|filename_component\\|\\(?:source_file\\|target\\)_property\\)\\|i\\(?:f\\|n\\(?:clude\\(?:_\\(?:directories\\|external_msproject\\|regular_expression\\)\\)?\\|stall_\\(?:\\(?:file\\|program\\|target\\)s\\)\\)\\|tk_wrap_tcl\\)\\|l\\(?:ink_\\(?:\\(?:directo\\|libra\\)ries\\)\\|oad_c\\(?:ache\\|ommand\\)\\)\\|m\\(?:a\\(?:cro\\|ke_directory\\|rk_as_advanced\\)\\|essage\\)\\|o\\(?:ption\\|utput_required_files\\)\\|project\\|qt_wrap_\\(?:cpp\\|ui\\)\\|remove\\|s\\(?:e\\(?:parate_arguments\\|t\\(?:_\\(?:\\(?:directory\\|source_files\\|target\\)_properties\\)\\)?\\)\\|ite_name\\|ource_group\\|tring\\|ubdir\\(?:\\(?:_depend\\)?s\\)\\)\\|t\\(?:arget_link_libraries\\|ry_\\(?:compile\\|run\\)\\)\\|u\\(?:se_mangled_mesa\\|tility_source\\)\\|v\\(?:ariable_requires\\|tk_\\(?:make_instantiator ?\\|wrap_\\(?:java\\|python\\|tcl\\)\\)\\)\\|w\\(?:\\(?:h\\|rite_f\\)ile\\)\\)" . font-lock-function-name-face) + '("\\(A\\(?:DD_\\(?:CUSTOM_\\(?:COMMAND\\|TARGET\\)\\|DE\\(?:\\(?:FINITION\\|PENDENCIE\\)S\\)\\|EXECUTABLE\\|LIBRARY\\|SUBDIRECTORY\\|TEST\\)\\|UX_SOURCE_DIRECTORY\\)\\|BUILD_\\(?:COMMAND\\|NAME\\)\\|C\\(?:MAKE_MINIMUM_REQUIRED\\|ONFIGURE_FILE\\|REATE_TEST_SOURCELIST ?\\)\\|E\\(?:LSE\\|N\\(?:ABLE_TESTING ?\\|D\\(?:FOREACH\\|IF\\|MACRO\\|WHILE\\)\\)\\|X\\(?:EC\\(?:UTE_PROCESS\\|_PROGRAM\\)\\|PORT_LIBRARY_DEPENDENCIES\\)\\)\\|F\\(?:IND_\\(?:FILE\\|LIBRARY\\|P\\(?:A\\(?:CKAGE\\|TH\\)\\|ROGRAM\\)\\)\\|LTK_WRAP_UI\\|OREACH\\)\\|GET_\\(?:CMAKE_PROPERTY\\|DIRECTORY_PROPERTY\\|FILENAME_COMPONENT\\|\\(?:SOURCE_FILE\\|TARGET\\)_PROPERTY\\)\\|I\\(?:F\\|N\\(?:CLUDE\\(?:_\\(?:DIRECTORIES\\|EXTERNAL_MSPROJECT\\|REGULAR_EXPRESSION\\)\\)?\\|STALL\\(?:_\\(?:\\(?:FILE\\|PROGRAM\\|TARGET\\)S\\)\\)?\\)\\|TK_WRAP_TCL\\)\\|L\\(?:I\\(?:NK_\\(?:\\(?:DIRECTO\\|LIBRA\\)RIES\\)\\|ST\\)\\|OAD_C\\(?:ACHE\\|OMMAND\\)\\)\\|M\\(?:A\\(?:CRO\\|KE_DIRECTORY\\|RK_AS_ADVANCED\\)\\|ESSAGE\\)\\|O\\(?:PTION\\|UTPUT_REQUIRED_FILES\\)\\|PROJECT\\|QT_WRAP_\\(?:CPP\\|UI\\)\\|REMOVE\\|S\\(?:E\\(?:PARATE_ARGUMENTS\\|T\\(?:_\\(?:\\(?:DIRECTORY\\|SOURCE_FILES\\|TARGET\\)_PROPERTIES\\)\\)?\\)\\|ITE_NAME\\|OURCE_GROUP\\|TRING\\|UBDIR\\(?:\\(?:_DEPEND\\)?S\\)\\)\\|T\\(?:ARGET_LINK_LIBRARIES\\|RY_\\(?:COMPILE\\|RUN\\)\\)\\|U\\(?:SE_MANGLED_MESA\\|TILITY_SOURCE\\)\\|V\\(?:ARIABLE_REQUIRES\\|TK_\\(?:MAKE_INSTANTIATOR ?\\|WRAP_\\(?:JAVA\\|PYTHON\\|TCL\\)\\)\\)\\|W\\(?:\\(?:H\\|RITE_F\\)ILE\\)\\|a\\(?:dd_\\(?:custom_\\(?:command\\|target\\)\\|de\\(?:\\(?:finition\\|pendencie\\)s\\)\\|executable\\|library\\|subdirectory\\|test\\)\\|ux_source_directory\\)\\|build_\\(?:command\\|name\\)\\|c\\(?:make_minimum_required\\|onfigure_file\\|reate_test_sourcelist ?\\)\\|e\\(?:lse\\|n\\(?:able_testing ?\\|d\\(?:foreach\\|if\\|macro\\|while\\)\\)\\|x\\(?:ec_program\\|port_library_dependencies\\)\\)\\|f\\(?:ind_\\(?:file\\|library\\|p\\(?:a\\(?:ckage\\|th\\)\\|rogram\\)\\)\\|ltk_wrap_ui\\|oreach\\)\\|get_\\(?:cmake_property\\|directory_property\\|filename_component\\|\\(?:source_file\\|target\\)_property\\)\\|i\\(?:f\\|n\\(?:clude\\(?:_\\(?:directories\\|external_msproject\\|regular_expression\\)\\)?\\|stall_\\(?:\\(?:file\\|program\\|target\\)s\\)\\)\\|tk_wrap_tcl\\)\\|l\\(?:ink_\\(?:\\(?:directo\\|libra\\)ries\\)\\|oad_c\\(?:ache\\|ommand\\)\\)\\|m\\(?:a\\(?:cro\\|ke_directory\\|rk_as_advanced\\)\\|essage\\)\\|o\\(?:ption\\|utput_required_files\\)\\|project\\|qt_wrap_\\(?:cpp\\|ui\\)\\|remove\\|s\\(?:e\\(?:parate_arguments\\|t\\(?:_\\(?:\\(?:directory\\|source_files\\|target\\)_properties\\)\\)?\\)\\|ite_name\\|ource_group\\|tring\\|ubdir\\(?:\\(?:_depend\\)?s\\)\\)\\|t\\(?:arget_link_libraries\\|ry_\\(?:compile\\|run\\)\\)\\|u\\(?:se_mangled_mesa\\|tility_source\\)\\|v\\(?:ariable_requires\\|tk_\\(?:make_instantiator ?\\|wrap_\\(?:java\\|python\\|tcl\\)\\)\\)\\|w\\(?:\\(?:h\\|rite_f\\)ile\\)\\)" . font-lock-function-name-face) "Highlighting expressions for CMAKE mode.") ) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CheckCSourceCompiles.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CheckCSourceCompiles.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CheckCSourceCompiles.cmake 2005-08-12 02:02:18.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CheckCSourceCompiles.cmake 2006-02-10 08:23:17.000000000 +0800 @@ -1,14 +1,16 @@ +# - Check if the source code provided in the SOURCE argument compiles. +# CHECK_C_SOURCE_COMPILES(SOURCE VAR) +# - macro which checks if the source code compiles +# SOURCE - source code to try to compile +# VAR - variable to store size if the type exists. # -# Check if the source code provided in the SOURCE argument compiles. -# -# CHECK_C_SOURCE_COMPILES - macro which checks if the source code compiles\ -# SOURCE - source code to try to compile -# VARIABLE - variable to store size if the type exists. -# -# Checks the following optional VARIABLES (not arguments) -# CMAKE_REQUIRED_LIBRARIES - Link to extra libraries -# CMAKE_REQUIRED_FLAGS - Extra flags to C compiler +# The following variables may be set before calling this macro to +# modify the way the check is run: # +# CMAKE_REQUIRED_FLAGS = string of compile command line flags +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_INCLUDES = list of include directories +# CMAKE_REQUIRED_LIBRARIES = list of libraries to link MACRO(CHECK_C_SOURCE_COMPILES SOURCE VAR) IF("${VAR}" MATCHES "^${VAR}$") @@ -17,18 +19,23 @@ IF(CMAKE_REQUIRED_LIBRARIES) SET(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + ELSE(CMAKE_REQUIRED_LIBRARIES) + SET(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES) ENDIF(CMAKE_REQUIRED_LIBRARIES) IF(CMAKE_REQUIRED_INCLUDES) SET(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") + ELSE(CMAKE_REQUIRED_INCLUDES) + SET(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES) ENDIF(CMAKE_REQUIRED_INCLUDES) - FILE(WRITE "${CMAKE_BINARY_DIR}/CMakeTmp/src.c" + FILE(WRITE "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/src.c" "${SOURCE}") MESSAGE(STATUS "Performing Test ${VAR}") TRY_COMPILE(${VAR} ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/CMakeTmp/src.c + ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/src.c + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} CMAKE_FLAGS "${CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}" "${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}" diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CheckCXXSourceCompiles.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CheckCXXSourceCompiles.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CheckCXXSourceCompiles.cmake 2005-08-12 02:02:18.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CheckCXXSourceCompiles.cmake 2006-02-10 08:23:17.000000000 +0800 @@ -1,14 +1,16 @@ +# - Check if the source code provided in the SOURCE argument compiles. +# CHECK_CXX_SOURCE_COMPILES(SOURCE VAR) +# - macro which checks if the source code compiles\ +# SOURCE - source code to try to compile +# VAR - variable to store size if the type exists. # -# Check if the source code provided in the SOURCE argument compiles. -# -# CHECK_CXX_SOURCE_COMPILES - macro which checks if the source code compiles\ -# SOURCE - source code to try to compile -# VARIABLE - variable to store size if the type exists. -# -# Checks the following optional VARIABLES (not arguments) -# CMAKE_REQUIRED_LIBRARIES - Link to extra libraries -# CMAKE_REQUIRED_FLAGS - Extra flags to C compiler +# The following variables may be set before calling this macro to +# modify the way the check is run: # +# CMAKE_REQUIRED_FLAGS = string of compile command line flags +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_INCLUDES = list of include directories +# CMAKE_REQUIRED_LIBRARIES = list of libraries to link MACRO(CHECK_CXX_SOURCE_COMPILES SOURCE VAR) IF("${VAR}" MATCHES "^${VAR}$") @@ -17,18 +19,23 @@ IF(CMAKE_REQUIRED_LIBRARIES) SET(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + ELSE(CMAKE_REQUIRED_LIBRARIES) + SET(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES) ENDIF(CMAKE_REQUIRED_LIBRARIES) IF(CMAKE_REQUIRED_INCLUDES) SET(CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") + ELSE(CMAKE_REQUIRED_INCLUDES) + SET(CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES) ENDIF(CMAKE_REQUIRED_INCLUDES) - FILE(WRITE "${CMAKE_BINARY_DIR}/CMakeTmp/src.c" + FILE(WRITE "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/src.cxx" "${SOURCE}") MESSAGE(STATUS "Performing Test ${VAR}") TRY_COMPILE(${VAR} ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/CMakeTmp/src.cxx + ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/src.cxx + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} CMAKE_FLAGS "${CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES}" "${CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES}" @@ -36,14 +43,14 @@ IF(${VAR}) SET(${VAR} 1 CACHE INTERNAL "Test ${FUNCTION}") MESSAGE(STATUS "Performing Test ${VAR} - Success") - WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeOutput.log + WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log "Performing C++ SOURCE FILE Test ${VAR} succeded with the following output:\n" "${OUTPUT}\n" "Source file was:\n${SOURCE}\n" APPEND) ELSE(${VAR}) MESSAGE(STATUS "Performing Test ${VAR} - Failed") SET(${VAR} "" CACHE INTERNAL "Test ${FUNCTION}") - WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeError.log + WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log "Performing C++ SOURCE FILE Test ${VAR} failed with the following output:\n" "${OUTPUT}\n" "Source file was:\n${SOURCE}\n" APPEND) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CheckFunctionExists.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CheckFunctionExists.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CheckFunctionExists.cmake 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CheckFunctionExists.cmake 2006-02-10 08:23:17.000000000 +0800 @@ -1,14 +1,16 @@ +# - Check if the function exists. +# CHECK_FUNCTION_EXISTS(FUNCTION VARIABLE) +# - macro which checks if the function exists +# FUNCTION - the name of the function +# VARIABLE - variable to store the result # -# Check if the function exists. -# -# CHECK_FUNCTION_EXISTS - macro which checks if the function exists -# FUNCTION - the name of the function -# VARIABLE - variable to store the result -# -# If CMAKE_REQUIRED_FLAGS is set then those flags will be passed into the -# compile of the program likewise if CMAKE_REQUIRED_LIBRARIES is set then -# those libraries will be linked against the test program +# The following variables may be set before calling this macro to +# modify the way the check is run: # +# CMAKE_REQUIRED_FLAGS = string of compile command line flags +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_INCLUDES = list of include directories +# CMAKE_REQUIRED_LIBRARIES = list of libraries to link MACRO(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE) IF("${VARIABLE}" MATCHES "^${VARIABLE}$") @@ -16,14 +18,24 @@ "-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}") MESSAGE(STATUS "Looking for ${FUNCTION}") IF(CMAKE_REQUIRED_LIBRARIES) - SET(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES + SET(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + ELSE(CMAKE_REQUIRED_LIBRARIES) + SET(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES) ENDIF(CMAKE_REQUIRED_LIBRARIES) + IF(CMAKE_REQUIRED_INCLUDES) + SET(CHECK_FUNCTION_EXISTS_ADD_INCLUDES + "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") + ELSE(CMAKE_REQUIRED_INCLUDES) + SET(CHECK_FUNCTION_EXISTS_ADD_INCLUDES) + ENDIF(CMAKE_REQUIRED_INCLUDES) TRY_COMPILE(${VARIABLE} ${CMAKE_BINARY_DIR} ${CMAKE_ROOT}/Modules/CheckFunctionExists.c + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} "${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}" + "${CHECK_FUNCTION_EXISTS_ADD_INCLUDES}" OUTPUT_VARIABLE OUTPUT) IF(${VARIABLE}) SET(${VARIABLE} 1 CACHE INTERNAL "Have function ${FUNCTION}") diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CheckIncludeFile.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CheckIncludeFile.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CheckIncludeFile.cmake 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CheckIncludeFile.cmake 2006-02-10 08:23:17.000000000 +0800 @@ -1,19 +1,30 @@ -# -# Check if the include file exists. -# -# CHECK_INCLUDE_FILE - macro which checks the include file exists. -# INCLUDE - name of include file -# VARIABLE - variable to return result -# +# - Check if the include file exists. +# CHECK_INCLUDE_FILE(INCLUDE VARIABLE) +# - macro which checks the include file exists. +# INCLUDE - name of include file +# VARIABLE - variable to return result +# # an optional third argument is the CFlags to add to the compile line # or you can use CMAKE_REQUIRED_FLAGS # +# The following variables may be set before calling this macro to +# modify the way the check is run: +# +# CMAKE_REQUIRED_FLAGS = string of compile command line flags +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_INCLUDES = list of include directories +# MACRO(CHECK_INCLUDE_FILE INCLUDE VARIABLE) IF("${VARIABLE}" MATCHES "^${VARIABLE}$") + IF(CMAKE_REQUIRED_INCLUDES) + SET(CHECK_INCLUDE_FILE_C_INCLUDE_DIRS "-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}") + ELSE(CMAKE_REQUIRED_INCLUDES) + SET(CHECK_INCLUDE_FILE_C_INCLUDE_DIRS) + ENDIF(CMAKE_REQUIRED_INCLUDES) SET(MACRO_CHECK_INCLUDE_FILE_FLAGS ${CMAKE_REQUIRED_FLAGS}) SET(CHECK_INCLUDE_FILE_VAR ${INCLUDE}) CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CheckIncludeFile.c.in - ${CMAKE_BINARY_DIR}/CMakeTmp/CheckIncludeFile.c IMMEDIATE) + ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckIncludeFile.c IMMEDIATE) MESSAGE(STATUS "Looking for ${INCLUDE}") IF(${ARGC} EQUAL 3) SET(CMAKE_C_FLAGS_SAVE ${CMAKE_C_FLAGS}) @@ -22,9 +33,11 @@ TRY_COMPILE(${VARIABLE} ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/CMakeTmp/CheckIncludeFile.c + ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckIncludeFile.c + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILE_FLAGS} + "${CHECK_INCLUDE_FILE_C_INCLUDE_DIRS}" OUTPUT_VARIABLE OUTPUT) IF(${ARGC} EQUAL 3) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CheckIncludeFileCXX.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CheckIncludeFileCXX.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CheckIncludeFileCXX.cmake 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CheckIncludeFileCXX.cmake 2006-02-10 08:23:17.000000000 +0800 @@ -1,19 +1,30 @@ +# - Check if the include file exists. +# CHECK_INCLUDE_FILE_CXX(INCLUDE VARIABLE) # -# Check if the include file exists. +# INCLUDE - name of include file +# VARIABLE - variable to return result +# +# An optional third argument is the CFlags to add to the compile line +# or you can use CMAKE_REQUIRED_FLAGS. # -# CHECK_INCLUDE_FILE - macro which checks the include file exists. -# INCLUDE - name of include file -# VARIABLE - variable to return result +# The following variables may be set before calling this macro to +# modify the way the check is run: # -# an optional third argument is the CFlags to add to the compile line -# or you can use CMAKE_REQUIRED_FLAGS +# CMAKE_REQUIRED_FLAGS = string of compile command line flags +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_INCLUDES = list of include directories # MACRO(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE) IF("${VARIABLE}" MATCHES "^${VARIABLE}$") + IF(CMAKE_REQUIRED_INCLUDES) + SET(CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS "-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}") + ELSE(CMAKE_REQUIRED_INCLUDES) + SET(CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS) + ENDIF(CMAKE_REQUIRED_INCLUDES) SET(MACRO_CHECK_INCLUDE_FILE_FLAGS ${CMAKE_REQUIRED_FLAGS}) SET(CHECK_INCLUDE_FILE_VAR ${INCLUDE}) CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in - ${CMAKE_BINARY_DIR}/CMakeTmp/CheckIncludeFile.cxx IMMEDIATE) + ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckIncludeFile.cxx IMMEDIATE) MESSAGE(STATUS "Looking for C++ include ${INCLUDE}") IF(${ARGC} EQUAL 3) SET(CMAKE_CXX_FLAGS_SAVE ${CMAKE_CXX_FLAGS}) @@ -22,10 +33,12 @@ TRY_COMPILE(${VARIABLE} ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/CMakeTmp/CheckIncludeFile.cxx + ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckIncludeFile.cxx + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILE_FLAGS} - OUTPUT_VARIABLE OUTPUT) + "${CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS}" + OUTPUT_VARIABLE OUTPUT) IF(${ARGC} EQUAL 3) SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_SAVE}) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CheckIncludeFiles.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CheckIncludeFiles.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CheckIncludeFiles.cmake 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CheckIncludeFiles.cmake 2006-02-24 22:08:03.000000000 +0800 @@ -1,38 +1,49 @@ +# - Check if the files can be included # -# Check if the files can be included +# CHECK_INCLUDE_FILES(INCLUDE VARIABLE) # -# CHECK_INCLUDE_FILES - macro which checks the include file exists. -# INCLUDE - list of files to include -# VARIABLE - variable to return result +# INCLUDE - list of files to include +# VARIABLE - variable to return result # -# If CMAKE_REQUIRED_FLAGS is set then those flags will be passed into the -# compile of the program - +# The following variables may be set before calling this macro to +# modify the way the check is run: +# +# CMAKE_REQUIRED_FLAGS = string of compile command line flags +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_INCLUDES = list of include directories MACRO(CHECK_INCLUDE_FILES INCLUDE VARIABLE) IF("${VARIABLE}" MATCHES "^${VARIABLE}$") + SET(CMAKE_CONFIGURABLE_FILE_CONTENT "/* */\n") + IF(CMAKE_REQUIRED_INCLUDES) + SET(CHECK_INCLUDE_FILES_INCLUDE_DIRS "-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}") + ELSE(CMAKE_REQUIRED_INCLUDES) + SET(CHECK_INCLUDE_FILES_INCLUDE_DIRS) + ENDIF(CMAKE_REQUIRED_INCLUDES) SET(CHECK_INCLUDE_FILES_CONTENT "/* */\n") SET(MACRO_CHECK_INCLUDE_FILES_FLAGS ${CMAKE_REQUIRED_FLAGS}) FOREACH(FILE ${INCLUDE}) - SET(CHECK_INCLUDE_FILES_CONTENT - "${CHECK_INCLUDE_FILES_CONTENT}#include <${FILE}>\n") + SET(CMAKE_CONFIGURABLE_FILE_CONTENT + "${CMAKE_CONFIGURABLE_FILE_CONTENT}#include <${FILE}>\n") ENDFOREACH(FILE) - SET(CHECK_INCLUDE_FILES_CONTENT - "${CHECK_INCLUDE_FILES_CONTENT}\n\nint main(){return 0;}\n") - FILE(WRITE ${CMAKE_BINARY_DIR}/CMakeTmp/CheckIncludeFiles.c - "${CHECK_INCLUDE_FILES_CONTENT}") + SET(CMAKE_CONFIGURABLE_FILE_CONTENT + "${CMAKE_CONFIGURABLE_FILE_CONTENT}\n\nint main(){return 0;}\n") + CONFIGURE_FILE("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in" + "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckIncludeFiles.c" @ONLY IMMEDIATE) MESSAGE(STATUS "Looking for include files ${VARIABLE}") TRY_COMPILE(${VARIABLE} ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/CMakeTmp/CheckIncludeFiles.c + ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckIncludeFiles.c + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILES_FLAGS} + "${CHECK_INCLUDE_FILES_INCLUDE_DIRS}" OUTPUT_VARIABLE OUTPUT) IF(${VARIABLE}) MESSAGE(STATUS "Looking for include files ${VARIABLE} - found") SET(${VARIABLE} 1 CACHE INTERNAL "Have include ${VARIABLE}") - FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log + FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeFiles/CMakeOutput.log "Determining if files ${INCLUDE} " "exist passed with the following output:\n" "${OUTPUT}\n\n") @@ -42,7 +53,7 @@ FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log "Determining if files ${INCLUDE} " "exist failed with the following output:\n" - "${OUTPUT}\nSource:\n${CHECK_INCLUDE_FILES_CONTENT}\n") + "${OUTPUT}\nSource:\n${CMAKE_CONFIGURABLE_FILE_CONTENT}\n") ENDIF(${VARIABLE}) ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$") ENDMACRO(CHECK_INCLUDE_FILES) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CheckLibraryExists.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CheckLibraryExists.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CheckLibraryExists.cmake 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CheckLibraryExists.cmake 2006-02-10 22:46:40.000000000 +0800 @@ -1,16 +1,17 @@ +# - Check if the function exists. +# CHECK_LIBRARY_EXISTS (LIBRARY FUNCTION LOCATION VARIABLE) # -# Check if the function exists. +# LIBRARY - the name of the library you are looking for +# FUNCTION - the name of the function +# LOCATION - location where the library should be found +# VARIABLE - variable to store the result # -# CHECK_LIBRARY_EXISTS - macro which checks if the function exists -# LIBRARY - the name of the library you are looking for -# FUNCTION - the name of the function -# LOCATION - location where the library should be found -# VARIABLE - variable to store the result +# The following variables may be set before calling this macro to +# modify the way the check is run: # -# If CMAKE_REQUIRED_FLAGS is set then those flags will be passed into the -# compile of the program likewise if CMAKE_REQUIRED_LIBRARIES is set then -# those libraries will be linked against the test program - +# CMAKE_REQUIRED_FLAGS = string of compile command line flags +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_LIBRARIES = list of libraries to link MACRO(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE) IF("${VARIABLE}" MATCHES "^${VARIABLE}$") @@ -25,6 +26,7 @@ TRY_COMPILE(${VARIABLE} ${CMAKE_BINARY_DIR} ${CMAKE_ROOT}/Modules/CheckFunctionExists.c + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_LIBRARY_EXISTS_DEFINITION} -DLINK_DIRECTORIES:STRING=${LOCATION} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CheckSymbolExists.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CheckSymbolExists.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CheckSymbolExists.cmake 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CheckSymbolExists.cmake 2006-02-23 22:58:07.000000000 +0800 @@ -1,41 +1,53 @@ +# - Check if the symbol exists in include files +# CHECK_SYMBOL_EXISTS(SYMBOL FILES VARIABLE) # -# Check if the symbol exists in include files +# SYMBOL - symbol +# FILES - include files to check +# VARIABLE - variable to return result # -# CHECK_SYMBOL_EXISTS - macro which checks the symbol exists in include files. -# SYMBOL - symbol -# FILES - include files to check -# VARIABLE - variable to return result +# The following variables may be set before calling this macro to +# modify the way the check is run: # -# If CMAKE_REQUIRED_FLAGS is set then those flags will be passed into the -# compile of the program likewise if CMAKE_REQUIRED_LIBRARIES is set then -# those libraries will be linked against the test program - +# CMAKE_REQUIRED_FLAGS = string of compile command line flags +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_INCLUDES = list of include directories +# CMAKE_REQUIRED_LIBRARIES = list of libraries to link MACRO(CHECK_SYMBOL_EXISTS SYMBOL FILES VARIABLE) IF("${VARIABLE}" MATCHES "^${VARIABLE}$") - SET(CHECK_SYMBOL_EXISTS_CONTENT "/* */\n") + SET(CMAKE_CONFIGURABLE_FILE_CONTENT "/* */\n") SET(MACRO_CHECK_SYMBOL_EXISTS_FLAGS ${CMAKE_REQUIRED_FLAGS}) IF(CMAKE_REQUIRED_LIBRARIES) SET(CHECK_SYMBOL_EXISTS_LIBS "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + ELSE(CMAKE_REQUIRED_LIBRARIES) + SET(CHECK_SYMBOL_EXISTS_LIBS) ENDIF(CMAKE_REQUIRED_LIBRARIES) + IF(CMAKE_REQUIRED_INCLUDES) + SET(CMAKE_SYMBOL_EXISTS_INCLUDES + "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") + ELSE(CMAKE_REQUIRED_INCLUDES) + SET(CMAKE_SYMBOL_EXISTS_INCLUDES) + ENDIF(CMAKE_REQUIRED_INCLUDES) FOREACH(FILE ${FILES}) - SET(CHECK_SYMBOL_EXISTS_CONTENT - "${CHECK_SYMBOL_EXISTS_CONTENT}#include <${FILE}>\n") + SET(CMAKE_CONFIGURABLE_FILE_CONTENT + "${CMAKE_CONFIGURABLE_FILE_CONTENT}#include <${FILE}>\n") ENDFOREACH(FILE) - SET(CHECK_SYMBOL_EXISTS_CONTENT - "${CHECK_SYMBOL_EXISTS_CONTENT}\nvoid cmakeRequireSymbol(int dummy,...){(void)dummy;}\nint main()\n{\n#ifndef ${SYMBOL}\n cmakeRequireSymbol(0,&${SYMBOL});\n#endif\n return 0;\n}\n") + SET(CMAKE_CONFIGURABLE_FILE_CONTENT + "${CMAKE_CONFIGURABLE_FILE_CONTENT}\nvoid cmakeRequireSymbol(int dummy,...){(void)dummy;}\nint main()\n{\n#ifndef ${SYMBOL}\n cmakeRequireSymbol(0,&${SYMBOL});\n#endif\n return 0;\n}\n") - FILE(WRITE ${CMAKE_BINARY_DIR}/CMakeTmp/CheckSymbolExists.c - "${CHECK_SYMBOL_EXISTS_CONTENT}") + CONFIGURE_FILE("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in" + "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckSymbolExists.c" @ONLY) MESSAGE(STATUS "Looking for ${SYMBOL}") TRY_COMPILE(${VARIABLE} ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/CMakeTmp/CheckSymbolExists.c + ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckSymbolExists.c + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_SYMBOL_EXISTS_FLAGS} "${CHECK_SYMBOL_EXISTS_LIBS}" + "${CMAKE_SYMBOL_EXISTS_INCLUDES}" OUTPUT_VARIABLE OUTPUT) IF(${VARIABLE}) MESSAGE(STATUS "Looking for ${SYMBOL} - found") @@ -43,16 +55,16 @@ FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log "Determining if the ${SYMBOL} " "exist passed with the following output:\n" - "${OUTPUT}\nFile ${CMAKE_BINARY_DIR}/CMakeTmp/CheckSymbolExists.c:\n" - "${CHECK_SYMBOL_EXISTS_CONTENT}\n") + "${OUTPUT}\nFile ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckSymbolExists.c:\n" + "${CMAKE_CONFIGURABLE_FILE_CONTENT}\n") ELSE(${VARIABLE}) MESSAGE(STATUS "Looking for ${SYMBOL} - not found.") SET(${VARIABLE} "" CACHE INTERNAL "Have symbol ${SYMBOL}") FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log "Determining if the ${SYMBOL} " "exist failed with the following output:\n" - "${OUTPUT}\nFile ${CMAKE_BINARY_DIR}/CMakeTmp/CheckSymbolExists.c:\n" - "${CHECK_SYMBOL_EXISTS_CONTENT}\n") + "${OUTPUT}\nFile ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckSymbolExists.c:\n" + "${CMAKE_CONFIGURABLE_FILE_CONTENT}\n") ENDIF(${VARIABLE}) ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$") ENDMACRO(CHECK_SYMBOL_EXISTS) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CheckTypeSize.c.in /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CheckTypeSize.c.in --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CheckTypeSize.c.in 2004-10-05 20:33:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CheckTypeSize.c.in 2006-01-13 22:57:15.000000000 +0800 @@ -1,7 +1,7 @@ +#cmakedefine CHECK_TYPE_SIZE_TYPE @CHECK_TYPE_SIZE_TYPE@ #ifdef CHECK_TYPE_SIZE_TYPE @CHECK_TYPE_SIZE_PREINCLUDE@ - #ifdef HAVE_SYS_TYPES_H # include #endif /* HAVE_SYS_TYPES_H */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CheckTypeSize.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CheckTypeSize.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CheckTypeSize.cmake 2005-08-12 02:02:18.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CheckTypeSize.cmake 2006-02-15 04:29:13.000000000 +0800 @@ -1,41 +1,58 @@ -# +# - Check sizeof a type +# CHECK_TYPE_SIZE(TYPE VARIABLE) # Check if the type exists and determine size of type. if the type # exists, the size will be stored to the variable. +# VARIABLE - variable to store size if the type exists. +# HAVE_${VARIABLE} - does the variable exists or not +# The following variables may be set before calling this macro to +# modify the way the check is run: # -# CHECK_TYPE_SIZE - macro which checks the size of type -# VARIABLE - variable to store size if the type exists. -# HAVE_${VARIABLE} - does the variable exists or not -# +# CMAKE_REQUIRED_FLAGS = string of compile command line flags +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_INCLUDES = list of include directories +# CMAKE_REQUIRED_LIBRARIES = list of libraries to link MACRO(CHECK_TYPE_SIZE TYPE VARIABLE) SET(CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS 1) IF("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$") + SET(CHECK_TYPE_SIZE_TYPE "${TYPE}") SET(MACRO_CHECK_TYPE_SIZE_FLAGS - "-DCHECK_TYPE_SIZE_TYPE=\"${TYPE}\" ${CMAKE_REQUIRED_FLAGS}") + "${CMAKE_REQUIRED_FLAGS}") FOREACH(def HAVE_SYS_TYPES_H HAVE_STDINT_H HAVE_STDDEF_H) IF("${def}") SET(MACRO_CHECK_TYPE_SIZE_FLAGS "${MACRO_CHECK_TYPE_SIZE_FLAGS} -D${def}") ENDIF("${def}") ENDFOREACH(def) + SET(CHECK_TYPE_SIZE_PREINCLUDE) SET(CHECK_TYPE_SIZE_PREMAIN) FOREACH(def ${CMAKE_EXTRA_INCLUDE_FILES}) SET(CHECK_TYPE_SIZE_PREMAIN "${CHECK_TYPE_SIZE_PREMAIN}#include \"${def}\"\n") ENDFOREACH(def) CONFIGURE_FILE("${CMAKE_ROOT}/Modules/CheckTypeSize.c.in" - "${CMAKE_BINARY_DIR}/CMakeTmp/CheckTypeSize.c" IMMEDIATE @ONLY) - FILE(READ "${CMAKE_BINARY_DIR}/CMakeTmp/CheckTypeSize.c" + "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckTypeSize.c" IMMEDIATE @ONLY) + FILE(READ "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckTypeSize.c" CHECK_TYPE_SIZE_FILE_CONTENT) MESSAGE(STATUS "Check size of ${TYPE}") IF(CMAKE_REQUIRED_LIBRARIES) SET(CHECK_TYPE_SIZE_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + ELSE(CMAKE_REQUIRED_LIBRARIES) + SET(CHECK_TYPE_SIZE_ADD_LIBRARIES) ENDIF(CMAKE_REQUIRED_LIBRARIES) + IF(CMAKE_REQUIRED_INCLUDES) + SET(CHECK_TYPE_SIZE_ADD_INCLUDES + "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") + ELSE(CMAKE_REQUIRED_INCLUDES) + SET(CHECK_TYPE_SIZE_ADD_INCLUDES) + ENDIF(CMAKE_REQUIRED_INCLUDES) TRY_RUN(${VARIABLE} HAVE_${VARIABLE} ${CMAKE_BINARY_DIR} - "${CMAKE_BINARY_DIR}/CMakeTmp/CheckTypeSize.c" + "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckTypeSize.c" + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_TYPE_SIZE_FLAGS} "${CHECK_TYPE_SIZE_ADD_LIBRARIES}" + "${CHECK_TYPE_SIZE_ADD_INCLUDES}" OUTPUT_VARIABLE OUTPUT) IF(HAVE_${VARIABLE}) MESSAGE(STATUS "Check size of ${TYPE} - done") diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CheckVariableExists.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CheckVariableExists.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CheckVariableExists.cmake 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CheckVariableExists.cmake 2006-02-10 08:23:18.000000000 +0800 @@ -1,27 +1,33 @@ +# - Check if the variable exists. +# CHECK_VARIABLE_EXISTS(VAR VARIABLE) +# +# VAR - the name of the variable +# VARIABLE - variable to store the result # -# Check if the variable exists. -# # CHECK_VARIABLE_EXISTS - macro which checks if the variable exists -# VAR - the name of the variable -# VARIABLE - variable to store the result +# This macro is only for C variables. # -# If CMAKE_REQUIRED_FLAGS is set then those flags will be passed into the -# compile of the program likewise if CMAKE_REQUIRED_LIBRARIES is set then -# those libraries will be linked against the test program -# -# only for C variables +# The following variables may be set before calling this macro to +# modify the way the check is run: # +# CMAKE_REQUIRED_FLAGS = string of compile command line flags +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_LIBRARIES = list of libraries to link + MACRO(CHECK_VARIABLE_EXISTS VAR VARIABLE) IF("${VARIABLE}" MATCHES "^${VARIABLE}$") SET(MACRO_CHECK_VARIABLE_DEFINITIONS "-DCHECK_VARIABLE_EXISTS=${VAR} ${CMAKE_REQUIRED_FLAGS}") MESSAGE(STATUS "Looking for ${VAR}") IF(CMAKE_REQUIRED_LIBRARIES) - SET(CHECK_VARIABLE_EXISTS_ADD_LIBRARIES + SET(CHECK_VARIABLE_EXISTS_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + ELSE(CMAKE_REQUIRED_LIBRARIES) + SET(CHECK_VARIABLE_EXISTS_ADD_LIBRARIES) ENDIF(CMAKE_REQUIRED_LIBRARIES) TRY_COMPILE(${VARIABLE} ${CMAKE_BINARY_DIR} ${CMAKE_ROOT}/Modules/CheckVariableExists.c + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_VARIABLE_DEFINITIONS} "${CHECK_VARIABLE_EXISTS_ADD_LIBRARIES}" OUTPUT_VARIABLE OUTPUT) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeBackwardCompatibilityC.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeBackwardCompatibilityC.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeBackwardCompatibilityC.cmake 2005-04-27 05:11:48.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeBackwardCompatibilityC.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,3 +1,4 @@ + # Nothing here yet IF(CMAKE_GENERATOR MATCHES "Visual Studio 7") INCLUDE(CMakeVS7BackwardCompatibility) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeBackwardCompatibilityCXX.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeBackwardCompatibilityCXX.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeBackwardCompatibilityCXX.cmake 2004-08-27 10:52:53.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeBackwardCompatibilityCXX.cmake 2006-01-17 23:21:44.000000000 +0800 @@ -1,4 +1,10 @@ -# +# - define a bunch of backwards compatibility variables +# CMAKE_ANSI_CXXFLAGS - flag for ansi c++ +# CMAKE_HAS_ANSI_STRING_STREAM - has +# INCLUDE(TestForANSIStreamHeaders) +# INCLUDE(CheckIncludeFileCXX) +# INCLUDE(TestForSTDNamespace) +# INCLUDE(TestForANSIForScope) IF(NOT CMAKE_SKIP_COMPATIBILITY_TESTS) # check for some ANSI flags in the CXX compiler if it is not gnu IF(NOT CMAKE_COMPILER_IS_GNUCXX) @@ -28,10 +34,7 @@ INCLUDE(CheckIncludeFileCXX) INCLUDE(TestForSTDNamespace) INCLUDE(TestForANSIForScope) - CHECK_INCLUDE_FILE_CXX("sstream" CMAKE_HAS_ANSI_STRING_STREAM) + INCLUDE(TestForSSTREAM) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_SAVE}") - IF(NOT CMAKE_HAS_ANSI_STRING_STREAM) - SET( CMAKE_NO_ANSI_STRING_STREAM 1 CACHE INTERNAL - "Does the compiler support sstream or stringstream.") - ENDIF(NOT CMAKE_HAS_ANSI_STRING_STREAM) ENDIF(NOT CMAKE_SKIP_COMPATIBILITY_TESTS) + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeCCompiler.cmake.in /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeCCompiler.cmake.in --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeCCompiler.cmake.in 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeCCompiler.cmake.in 2006-01-26 00:41:05.000000000 +0800 @@ -1,5 +1,5 @@ SET(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@") -SET(CMAKE_C_COMPILER_ARG1 @CMAKE_C_COMPILER_ARG1@) +SET(CMAKE_C_COMPILER_ARG1 "@CMAKE_C_COMPILER_ARG1@") SET(CMAKE_AR "@CMAKE_AR@") SET(CMAKE_RANLIB "@CMAKE_RANLIB@") SET(CMAKE_COMPILER_IS_GNUCC @CMAKE_COMPILER_IS_GNUCC@) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeCInformation.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeCInformation.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeCInformation.cmake 2005-09-09 02:59:57.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeCInformation.cmake 2006-03-07 04:14:23.000000000 +0800 @@ -1,3 +1,4 @@ + # This file sets the basic flags for the C language in CMake. # It also loads the available platform file for the system-compiler # if it exists. @@ -10,6 +11,21 @@ ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake) INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL) +# This should be included before the _INIT variables are +# used to initialize the cache. Since the rule variables +# have if blocks on them, users can still define them here. +# But, it should still be after the platform file so changes can +# be made to those values. + +IF(CMAKE_USER_MAKE_RULES_OVERRIDE) + INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE}) +ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE) + +IF(CMAKE_USER_MAKE_RULES_OVERRIDE_C) + INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE_C}) +ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE_C) + + # for most systems a module is the same as a shared library # so unless the variable CMAKE_MODULE_EXISTS is set just # copy the values from the LIBRARY variables @@ -70,7 +86,7 @@ # create a C shared library IF(NOT CMAKE_C_CREATE_SHARED_LIBRARY) SET(CMAKE_C_CREATE_SHARED_LIBRARY - " -o ") + " -o ") ENDIF(NOT CMAKE_C_CREATE_SHARED_LIBRARY) # create a C shared module just copy the shared library rule @@ -103,6 +119,6 @@ CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO ) -SET(CMAKE_C_INFOMATION_LOADED 1) +SET(CMAKE_C_INFORMATION_LOADED 1) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMake.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMake.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMake.cmake 2004-08-27 02:55:53.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMake.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,3 +1,4 @@ + # This file is used by cmake.cxx to compute the CMAKE_ROOT location. # Do not remove this file from cvs without updating cmake.cxx to look # for a different file. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeCommonLanguageInclude.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeCommonLanguageInclude.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeCommonLanguageInclude.cmake 2004-09-23 02:42:05.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeCommonLanguageInclude.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,3 +1,4 @@ + # this file has flags that are shared across languages and sets # cache values that can be initialized in the platform-compiler.cmake file # it may be included by more than one language. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeConfigurableFile.in /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeConfigurableFile.in --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeConfigurableFile.in 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeConfigurableFile.in 2006-02-23 22:58:07.000000000 +0800 @@ -0,0 +1,2 @@ +@CMAKE_CONFIGURABLE_FILE_CONTENT@ + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeCXXCompiler.cmake.in /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeCXXCompiler.cmake.in --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeCXXCompiler.cmake.in 2005-08-12 02:02:18.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeCXXCompiler.cmake.in 2006-02-10 02:48:09.000000000 +0800 @@ -1,9 +1,22 @@ SET(CMAKE_CXX_COMPILER "@CMAKE_CXX_COMPILER@") -SET(CMAKE_CXX_COMPILER_ARG1 @CMAKE_CXX_COMPILER_ARG1@) +SET(CMAKE_CXX_COMPILER_ARG1 "@CMAKE_CXX_COMPILER_ARG1@") +SET(CMAKE_AR "@CMAKE_AR@") +SET(CMAKE_RANLIB "@CMAKE_RANLIB@") SET(CMAKE_COMPILER_IS_GNUCXX @CMAKE_COMPILER_IS_GNUCXX@) SET(CMAKE_CXX_COMPILER_LOADED 1) -SET(CMAKE_COMPILER_IS_GNUCXX_RUN 1) +SET(CMAKE_COMPILER_IS_MINGW @CMAKE_COMPILER_IS_MINGW@) +SET(CMAKE_COMPILER_IS_CYGWIN @CMAKE_COMPILER_IS_CYGWIN@) +IF(CMAKE_COMPILER_IS_CYGWIN) + SET(CYGWIN 1) + SET(UNIX 1) +ENDIF(CMAKE_COMPILER_IS_CYGWIN) + +SET(CMAKE_CXX_COMPILER_ENV_VAR "CXX") +IF(CMAKE_COMPILER_IS_MINGW) + SET(MINGW 1) +ENDIF(CMAKE_COMPILER_IS_MINGW) +SET(CMAKE_COMPILER_IS_GNUCXX_RUN 1) SET(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;H;o;O;obj;OBJ;def;DEF;rc;RC) SET(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm) SET(CMAKE_CXX_LINKER_PREFERENCE Prefered) @@ -12,4 +25,6 @@ ELSE(UNIX) SET(CMAKE_CXX_OUTPUT_EXTENSION .obj) ENDIF(UNIX) -SET(CMAKE_CXX_COMPILER_ENV_VAR "CXX") +# save the size of void* in case where cache is removed +# and the this file is still around +SET(CMAKE_SIZEOF_VOID_P @CMAKE_SIZEOF_VOID_P@) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeCXXInformation.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeCXXInformation.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeCXXInformation.cmake 2005-10-17 20:49:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeCXXInformation.cmake 2006-03-07 04:14:23.000000000 +0800 @@ -1,8 +1,8 @@ + # This file sets the basic flags for the C++ language in CMake. # It also loads the available platform file for the system-compiler # if it exists. - GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_CXX_COMPILER} NAME_WE) # since the gnu compiler has several names force g++ IF(CMAKE_COMPILER_IS_GNUCXX) @@ -11,6 +11,20 @@ SET(CMAKE_SYSTEM_AND_CXX_COMPILER_INFO_FILE ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake) INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL) +# This should be included before the _INIT variables are +# used to initialize the cache. Since the rule variables +# have if blocks on them, users can still define them here. +# But, it should still be after the platform file so changes can +# be made to those values. + +IF(CMAKE_USER_MAKE_RULES_OVERRIDE) + INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE}) +ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE) + +IF(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX) + INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE_CXX}) +ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX) + # for most systems a module is the same as a shared library # so unless the variable CMAKE_MODULE_EXISTS is set just @@ -123,7 +137,7 @@ # create a shared C++ library IF(NOT CMAKE_CXX_CREATE_SHARED_LIBRARY) SET(CMAKE_CXX_CREATE_SHARED_LIBRARY - " -o ") + " -o ") ENDIF(NOT CMAKE_CXX_CREATE_SHARED_LIBRARY) # create a c++ shared module copy the shared library rule by default @@ -159,5 +173,5 @@ CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_DEBUG) -SET(CMAKE_CXX_INFOMATION_LOADED 1) +SET(CMAKE_CXX_INFORMATION_LOADED 1) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeDetermineCCompiler.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeDetermineCCompiler.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeDetermineCCompiler.cmake 2005-08-12 02:02:18.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeDetermineCCompiler.cmake 2006-02-21 12:08:12.000000000 +0800 @@ -1,3 +1,4 @@ + # determine the compiler to use for C programs # NOTE, a generator may set CMAKE_C_COMPILER before # loading this file to force a compiler. @@ -12,7 +13,7 @@ IF($ENV{CC} MATCHES ".+") GET_FILENAME_COMPONENT(CMAKE_C_COMPILER_INIT $ENV{CC} PROGRAM PROGRAM_ARGS CMAKE_C_FLAGS_ENV_INIT) IF(CMAKE_C_FLAGS_ENV_INIT) - SET(CMAKE_C_COMPILER_ARG1 ${CMAKE_C_FLAGS_ENV_INIT} CACHE STRING "First argument to C compiler") + SET(CMAKE_C_COMPILER_ARG1 "${CMAKE_C_FLAGS_ENV_INIT}" CACHE STRING "First argument to C compiler") ENDIF(CMAKE_C_FLAGS_ENV_INIT) IF(EXISTS ${CMAKE_C_COMPILER_INIT}) ELSE(EXISTS ${CMAKE_C_COMPILER_INIT}) @@ -40,7 +41,10 @@ SET(CMAKE_C_COMPILER ${CMAKE_C_COMPILER_INIT} CACHE STRING "C compiler") ENDIF(NOT CMAKE_C_COMPILER) MARK_AS_ADVANCED(CMAKE_C_COMPILER) -FIND_PROGRAM(CMAKE_AR NAMES ar ) +GET_FILENAME_COMPONENT(COMPILER_LOCATION "${CMAKE_C_COMPILER}" + PATH) + +FIND_PROGRAM(CMAKE_AR NAMES ar PATHS ${COMPILER_LOCATION} ) FIND_PROGRAM(CMAKE_RANLIB NAMES ranlib) IF(NOT CMAKE_RANLIB) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeDetermineCXXCompiler.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeDetermineCXXCompiler.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeDetermineCXXCompiler.cmake 2005-08-12 02:02:18.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeDetermineCXXCompiler.cmake 2006-01-26 00:41:05.000000000 +0800 @@ -1,3 +1,4 @@ + # determine the compiler to use for C++ programs # NOTE, a generator may set CMAKE_CXX_COMPILER before # loading this file to force a compiler. @@ -12,7 +13,7 @@ IF($ENV{CXX} MATCHES ".+") GET_FILENAME_COMPONENT(CMAKE_CXX_COMPILER_INIT $ENV{CXX} PROGRAM PROGRAM_ARGS CMAKE_CXX_FLAGS_ENV_INIT) IF(CMAKE_CXX_FLAGS_ENV_INIT) - SET(CMAKE_CXX_COMPILER_ARG1 ${CMAKE_CXX_FLAGS_ENV_INIT} CACHE STRING "First argument to CXX compiler") + SET(CMAKE_CXX_COMPILER_ARG1 "${CMAKE_CXX_FLAGS_ENV_INIT}" CACHE STRING "First argument to CXX compiler") ENDIF(CMAKE_CXX_FLAGS_ENV_INIT) IF(EXISTS ${CMAKE_CXX_COMPILER_INIT}) ELSE(EXISTS ${CMAKE_CXX_COMPILER_INIT}) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeDetermineFortranCompiler.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeDetermineFortranCompiler.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeDetermineFortranCompiler.cmake 2005-08-12 02:02:18.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeDetermineFortranCompiler.cmake 2006-01-26 00:41:05.000000000 +0800 @@ -1,3 +1,4 @@ + # determine the compiler to use for C programs # NOTE, a generator may set CMAKE_C_COMPILER before # loading this file to force a compiler. @@ -9,7 +10,7 @@ IF($ENV{FC} MATCHES ".+") GET_FILENAME_COMPONENT(CMAKE_Fortran_COMPILER_INIT $ENV{FC} PROGRAM PROGRAM_ARGS CMAKE_Fortran_FLAGS_ENV_INIT) IF(CMAKE_Fortran_FLAGS_ENV_INIT) - SET(CMAKE_Fortran_COMPILER_ARG1 ${CMAKE_Fortran_FLAGS_ENV_INIT} CACHE STRING "First argument to Fortran compiler") + SET(CMAKE_Fortran_COMPILER_ARG1 "${CMAKE_Fortran_FLAGS_ENV_INIT}" CACHE STRING "First argument to Fortran compiler") ENDIF(CMAKE_Fortran_FLAGS_ENV_INIT) IF(EXISTS ${CMAKE_Fortran_COMPILER_INIT}) ELSE(EXISTS ${CMAKE_Fortran_COMPILER_INIT}) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeDetermineJavaCompiler.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeDetermineJavaCompiler.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeDetermineJavaCompiler.cmake 2005-09-09 02:59:57.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeDetermineJavaCompiler.cmake 2006-01-26 00:41:05.000000000 +0800 @@ -1,3 +1,4 @@ + # determine the compiler to use for Java programs # NOTE, a generator may set CMAKE_Java_COMPILER before # loading this file to force a compiler. @@ -7,7 +8,7 @@ IF($ENV{JAVA_COMPILER} MATCHES ".+") GET_FILENAME_COMPONENT(CMAKE_Java_COMPILER_INIT $ENV{JAVA_COMPILER} PROGRAM PROGRAM_ARGS CMAKE_Java_FLAGS_ENV_INIT) IF(CMAKE_Java_FLAGS_ENV_INIT) - SET(CMAKE_Java_COMPILER_ARG1 ${CMAKE_Java_FLAGS_ENV_INIT} CACHE STRING "First argument to Java compiler") + SET(CMAKE_Java_COMPILER_ARG1 "${CMAKE_Java_FLAGS_ENV_INIT}" CACHE STRING "First argument to Java compiler") ENDIF(CMAKE_Java_FLAGS_ENV_INIT) IF(EXISTS ${CMAKE_Java_COMPILER_INIT}) ELSE(EXISTS ${CMAKE_Java_COMPILER_INIT}) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeDetermineRCCompiler.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeDetermineRCCompiler.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeDetermineRCCompiler.cmake 2005-08-12 02:02:18.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeDetermineRCCompiler.cmake 2006-01-26 00:41:05.000000000 +0800 @@ -1,3 +1,4 @@ + # determine the compiler to use for C programs # NOTE, a generator may set CMAKE_C_COMPILER before # loading this file to force a compiler. @@ -9,7 +10,7 @@ IF($ENV{RC} MATCHES ".+") GET_FILENAME_COMPONENT(CMAKE_RC_COMPILER_INIT $ENV{RC} PROGRAM PROGRAM_ARGS CMAKE_RC_FLAGS_ENV_INIT) IF(CMAKE_RC_FLAGS_ENV_INIT) - SET(CMAKE_RC_COMPILER_ARG1 ${CMAKE_RC_FLAGS_ENV_INIT} CACHE STRING "First argument to RC compiler") + SET(CMAKE_RC_COMPILER_ARG1 "${CMAKE_RC_FLAGS_ENV_INIT}" CACHE STRING "First argument to RC compiler") ENDIF(CMAKE_RC_FLAGS_ENV_INIT) IF(EXISTS ${CMAKE_RC_COMPILER_INIT}) ELSE(EXISTS ${CMAKE_RC_COMPILER_INIT}) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeDetermineSystem.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeDetermineSystem.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeDetermineSystem.cmake 2006-03-23 23:35:26.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeDetermineSystem.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,3 +1,4 @@ + # This module is used by the Makefile generator to determin the following variables: # CMAKE_SYSTEM_NAME - on unix this is uname -s, for windows it is Windows # CMAKE_SYSTEM_VERSION - on unix this is uname -r, for windows it is empty @@ -11,7 +12,6 @@ # HP-UX HP-UX # IRIX IRIX # Linux Linux -# GNU/kFreeBSD GNU/kFreeBSD # NetBSD NetBSD # OpenBSD OpenBSD # OFS/1 (Digital Unix) OSF1 @@ -58,11 +58,6 @@ SET(CMAKE_SYSTEM_NAME BSDOS) ENDIF(CMAKE_SYSTEM_NAME MATCHES BSD.OS) -# fix for GNU/kFreeBSD , remove the GNU/ -IF(CMAKE_SYSTEM_NAME MATCHES GNU.kFreeBSD) - SET(CMAKE_SYSTEM_NAME kFreeBSD) -ENDIF(CMAKE_SYSTEM_NAME MATCHES GNU.kFreeBSD) - # fix for CYGWIN which has windows version in it IF(CMAKE_SYSTEM_NAME MATCHES CYGWIN) SET(CMAKE_SYSTEM_NAME CYGWIN) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeExportBuildSettings.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeExportBuildSettings.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeExportBuildSettings.cmake 2002-12-05 22:46:30.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeExportBuildSettings.cmake 2005-12-15 23:41:19.000000000 +0800 @@ -1,6 +1,7 @@ -# Macro to export the build settings for use by another project. -# Provide as an argument the file into which the settings are to be -# stored. +# - export build settings from a project. +# CMAKE_EXPORT_BUILD_SETTINGS(SETTINGS_FILE) +# macro defined to export the build settings for use by another project. +# SETTINGS_FILE - the file into which the settings are to be stored. MACRO(CMAKE_EXPORT_BUILD_SETTINGS SETTINGS_FILE) IF(${SETTINGS_FILE} MATCHES ".+") CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeBuildSettings.cmake.in diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeFindFrameworks.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeFindFrameworks.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeFindFrameworks.cmake 2003-12-30 05:18:18.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeFindFrameworks.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,3 +1,5 @@ +# - helper module to find OSX frameworks + IF(NOT CMAKE_FIND_FRAMEWORKS_INCLUDED) SET(CMAKE_FIND_FRAMEWORKS_INCLUDED 1) MACRO(CMAKE_FIND_FRAMEWORKS fwk) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeFindWMake.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeFindWMake.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeFindWMake.cmake 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeFindWMake.cmake 2006-01-17 23:21:44.000000000 +0800 @@ -0,0 +1,3 @@ +SET (CMAKE_MAKE_PROGRAM "wmake" CACHE STRING + "Program used to build from makefiles.") +MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeFortranInformation.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeFortranInformation.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeFortranInformation.cmake 2005-09-09 02:59:57.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeFortranInformation.cmake 2006-03-07 04:14:23.000000000 +0800 @@ -1,3 +1,4 @@ + # This file sets the basic flags for the Fortran language in CMake. # It also loads the available platform file for the system-compiler # if it exists. @@ -11,6 +12,21 @@ ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake) INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL) +# This should be included before the _INIT variables are +# used to initialize the cache. Since the rule variables +# have if blocks on them, users can still define them here. +# But, it should still be after the platform file so changes can +# be made to those values. + +IF(CMAKE_USER_MAKE_RULES_OVERRIDE) + INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE}) +ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE) + +IF(CMAKE_USER_MAKE_RULES_OVERRIDE_Fortran) + INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE_Fortran}) +ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE_Fortran) + + # Fortran needs cmake to do a requires step during its build process to # catch any modules SET(CMAKE_NEEDS_REQUIRES_STEP_Fortran_FLAG 1) @@ -86,7 +102,7 @@ # create a Fortran shared library IF(NOT CMAKE_Fortran_CREATE_SHARED_LIBRARY) SET(CMAKE_Fortran_CREATE_SHARED_LIBRARY - " -o ") + " -o ") ENDIF(NOT CMAKE_Fortran_CREATE_SHARED_LIBRARY) # create a Fortran shared module just copy the shared library rule @@ -114,6 +130,17 @@ ENDIF(NOT CMAKE_Fortran_LINK_EXECUTABLE) +IF(NOT CMAKE_NOT_USING_CONFIG_FLAGS) + SET (CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG_INIT}" CACHE STRING + "Flags used by the compiler during debug builds.") + SET (CMAKE_Fortran_FLAGS_MINSIZEREL "${CMAKE_Fortran_FLAGS_MINSIZEREL_INIT}" CACHE STRING + "Flags used by the compiler during release minsize builds.") + SET (CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE_INIT}" CACHE STRING + "Flags used by the compiler during release builds (/MD /Ob1 /Oi /Ot /Oy /Gs will produce slightly less optimized but smaller files).") + SET (CMAKE_Fortran_FLAGS_RELWITHDEBINFO "${CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING + "Flags used by the compiler during Release with Debug Info builds.") + +ENDIF(NOT CMAKE_NOT_USING_CONFIG_FLAGS) MARK_AS_ADVANCED( CMAKE_Fortran_FLAGS @@ -123,4 +150,4 @@ CMAKE_Fortran_FLAGS_RELWITHDEBINFO) # set this variable so we can avoid loading this more than once. -SET(CMAKE_Fortran_INFOMATION_LOADED 1) +SET(CMAKE_Fortran_INFORMATION_LOADED 1) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeGenericSystem.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeGenericSystem.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeGenericSystem.cmake 2005-09-07 00:55:12.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeGenericSystem.cmake 2006-02-10 04:05:13.000000000 +0800 @@ -4,6 +4,7 @@ SET(CMAKE_STATIC_LIBRARY_SUFFIX ".a") SET(CMAKE_SHARED_LIBRARY_PREFIX "lib") # lib SET(CMAKE_SHARED_LIBRARY_SUFFIX ".so") # .so +SET(CMAKE_EXECUTABLE_SUFFIX "") # .exe SET(CMAKE_DL_LIBS "-ldl") SET(CMAKE_SHARED_LIBRARY_C_FLAGS "") # -pic SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared @@ -21,6 +22,9 @@ SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-fPIC") # -pic ENDIF(CMAKE_COMPILER_IS_GNUCXX) +SET(CMAKE_FIND_LIBRARY_PREFIXES "lib") +SET(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a") + SET (CMAKE_SKIP_RPATH "NO" CACHE BOOL "If set, runtime paths are not added when using shared libraries.") @@ -36,11 +40,11 @@ CACHE PATH "Install path prefix, prepended onto install directories.") ELSE(UNIX) IF("$ENV{ProgramFiles}" MATCHES "^$") - IF("$ENV{SystemDrive}" MATCHES "^$") + IF("$ENV{SystemDrive}" MATCHES "^$") SET(CMAKE_GENERIC_PROGRAM_FILES "C:/Program Files") - ELSE("$ENV{SystemDrive}" MATCHES "^$") + ELSE("$ENV{SystemDrive}" MATCHES "^$") SET(CMAKE_GENERIC_PROGRAM_FILES "$ENV{SystemDrive}/Program Files") - ENDIF("$ENV{SystemDrive}" MATCHES "^$") + ENDIF("$ENV{SystemDrive}" MATCHES "^$") ELSE("$ENV{ProgramFiles}" MATCHES "^$") SET(CMAKE_GENERIC_PROGRAM_FILES "$ENV{ProgramFiles}") ENDIF("$ENV{ProgramFiles}" MATCHES "^$") @@ -48,6 +52,10 @@ "${CMAKE_GENERIC_PROGRAM_FILES}/${PROJECT_NAME}" CACHE PATH "Install path prefix, prepended onto install directories.") SET(CMAKE_GENERIC_PROGRAM_FILES) + + # Make sure the prefix uses forward slashes. + STRING(REGEX REPLACE "\\\\" "/" + CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") ENDIF(UNIX) MARK_AS_ADVANCED( diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeImportBuildSettings.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeImportBuildSettings.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeImportBuildSettings.cmake 2004-05-25 23:20:13.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeImportBuildSettings.cmake 2005-12-15 23:41:19.000000000 +0800 @@ -1,6 +1,8 @@ -# Macro to import the build settings from another project. Provide as -# an argument the file created by the other project's -# CMAKE_EXPORT_BUILD_SETTINGS command. +# - import build settings from another project +# CMAKE_IMPORT_BUILD_SETTINGS(SETTINGS_FILE) +# macro defined to import the build settings from another project. +# SETTINGS_FILE is a file created by the other project's call to the +# CMAKE_EXPORT_BUILD_SETTINGS macro, see CMakeExportBuildSettings. MACRO(CMAKE_IMPORT_BUILD_SETTINGS SETTINGS_FILE) IF(${SETTINGS_FILE} MATCHES ".+") # Load the settings. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeJavaInformation.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeJavaInformation.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeJavaInformation.cmake 2004-09-27 23:36:29.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeJavaInformation.cmake 2006-03-02 20:52:52.000000000 +0800 @@ -1,3 +1,17 @@ +# This should be included before the _INIT variables are +# used to initialize the cache. Since the rule variables +# have if blocks on them, users can still define them here. +# But, it should still be after the platform file so changes can +# be made to those values. + +IF(CMAKE_USER_MAKE_RULES_OVERRIDE) + INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE}) +ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE) + +IF(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX) + INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE_CXX}) +ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX) + # this is a place holder if java needed flags for javac they would go here. IF(NOT CMAKE_Java_CREATE_STATIC_LIBRARY) SET(CMAKE_Java_CREATE_STATIC_LIBRARY diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeMinGWFindMake.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeMinGWFindMake.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeMinGWFindMake.cmake 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeMinGWFindMake.cmake 2006-02-16 10:26:47.000000000 +0800 @@ -0,0 +1,10 @@ +FIND_PROGRAM(CMAKE_MAKE_PROGRAM mingw32-make.exe PATHS + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MinGW;InstallLocation]/bin" + c:/MinGW/bin /MinGW/bin) +FIND_PROGRAM(CMAKE_SH sh.exe ) +IF(CMAKE_SH) + MESSAGE(FATAL_ERROR "sh.exe was found in your PATH, here:\n${CMAKE_SH}\nFor MinGW make to work correctly sh.exe must NOT be in your path.\nRun cmake from a shell that does not have sh.exe in your PATH.\nIf you want to use a UNIX shell, then use MSYS Makefiles.\n") + SET(CMAKE_MAKE_PROGRAM NOTFOUND) +ENDIF(CMAKE_SH) + +MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM CMAKE_SH) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeMSYSFindMake.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeMSYSFindMake.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeMSYSFindMake.cmake 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeMSYSFindMake.cmake 2006-02-16 10:26:47.000000000 +0800 @@ -0,0 +1,6 @@ +FIND_PROGRAM(CMAKE_MAKE_PROGRAM make + PATHS + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MSYS-1.0_is1;Inno Setup: App Path]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MinGW;InstallLocation]/bin" + c:/msys/1.0/bin /msys/1.0/bin) +MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakePrintSystemInformation.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakePrintSystemInformation.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakePrintSystemInformation.cmake 2002-11-09 04:46:08.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakePrintSystemInformation.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,6 +1,7 @@ -# this file can be used for diagnostic purposes -# just include it in a project to see various internal cmake -# variables +# - print system information +# This file can be used for diagnostic purposes +# just include it in a project to see various internal CMake +# variables. MESSAGE("CMAKE_SYSTEM is ${CMAKE_SYSTEM} ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION}") MESSAGE("CMAKE_SYSTEM file is ${CMAKE_SYSTEM_INFO_FILE}") diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeRCInformation.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeRCInformation.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeRCInformation.cmake 2005-08-12 02:02:18.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeRCInformation.cmake 2006-02-28 01:14:10.000000000 +0800 @@ -1,3 +1,4 @@ + # This file sets the basic flags for the Fortran language in CMake. # It also loads the available platform file for the system-compiler # if it exists. @@ -26,4 +27,4 @@ CMAKE_RC_FLAGS ) # set this variable so we can avoid loading this more than once. -SET(CMAKE_RC_INFOMATION_LOADED 1) +SET(CMAKE_RC_INFORMATION_LOADED 1) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeSystemSpecificInformation.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeSystemSpecificInformation.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeSystemSpecificInformation.cmake 2004-09-25 02:37:58.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeSystemSpecificInformation.cmake 2006-03-17 06:07:36.000000000 +0800 @@ -1,3 +1,4 @@ + # This file is included by cmGlobalGenerator::EnableLanguage. # It is included after the compiler has been determined, so # we know things like the compiler name and if the compiler is gnu. @@ -27,8 +28,8 @@ # copy the values from the LIBRARY variables # this has to be done after the system information has been loaded IF(NOT CMAKE_MODULE_EXISTS) - SET(CMAKE_SHARED_MODULE_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX}) - SET(CMAKE_SHARED_MODULE_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX}) + SET(CMAKE_SHARED_MODULE_PREFIX "${CMAKE_SHARED_LIBRARY_PREFIX}") + SET(CMAKE_SHARED_MODULE_SUFFIX "${CMAKE_SHARED_LIBRARY_SUFFIX}") SET(CMAKE_SHARED_MODULE_LINK_C_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS}) SET(CMAKE_SHARED_MODULE_RUNTIME_C_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG}) SET(CMAKE_SHARED_MODULE_RUNTIME_C_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP}) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeTestCCompiler.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeTestCCompiler.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeTestCCompiler.cmake 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeTestCCompiler.cmake 2006-01-13 02:48:36.000000000 +0800 @@ -1,3 +1,4 @@ + # This file is used by EnableLanguage in cmGlobalGenerator to # determine that that selected C compiler can actually compile # and link the most basic of programs. If not, a fatal error @@ -5,13 +6,13 @@ # any makefiles or projects. IF(NOT CMAKE_C_COMPILER_WORKS) MESSAGE(STATUS "Check for working C compiler: ${CMAKE_C_COMPILER}") - FILE(WRITE ${CMAKE_BINARY_DIR}/CMakeTmp/testCCompiler.c + FILE(WRITE ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/testCCompiler.c "#ifdef __cplusplus\n" "# error \"The CMAKE_C_COMPILER is set to a C++ compiler\"\n" "#endif\n" "int main(){return 0;}\n") TRY_COMPILE(CMAKE_C_COMPILER_WORKS ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/CMakeTmp/testCCompiler.c + ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/testCCompiler.c OUTPUT_VARIABLE OUTPUT) SET(C_TEST_WAS_RUN 1) ENDIF(NOT CMAKE_C_COMPILER_WORKS) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeTestCXXCompiler.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeTestCXXCompiler.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeTestCXXCompiler.cmake 2005-08-12 02:02:18.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeTestCXXCompiler.cmake 2006-01-13 02:48:36.000000000 +0800 @@ -1,3 +1,4 @@ + # This file is used by EnableLanguage in cmGlobalGenerator to # determine that that selected C++ compiler can actually compile # and link the most basic of programs. If not, a fatal error @@ -5,13 +6,13 @@ # any makefiles or projects. IF(NOT CMAKE_CXX_COMPILER_WORKS) MESSAGE(STATUS "Check for working CXX compiler: ${CMAKE_CXX_COMPILER}") - FILE(WRITE ${CMAKE_BINARY_DIR}/CMakeTmp/testCXXCompiler.cxx + FILE(WRITE ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/testCXXCompiler.cxx "#ifndef __cplusplus\n" "# error \"The CMAKE_CXX_COMPILER is set to a C compiler\"\n" "#endif\n" "int main(){return 0;}\n") TRY_COMPILE(CMAKE_CXX_COMPILER_WORKS ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/CMakeTmp/testCXXCompiler.cxx + ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/testCXXCompiler.cxx OUTPUT_VARIABLE OUTPUT) SET(CXX_TEST_WAS_RUN 1) ENDIF(NOT CMAKE_CXX_COMPILER_WORKS) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeTestFortranCompiler.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeTestFortranCompiler.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeTestFortranCompiler.cmake 2005-08-12 02:02:18.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeTestFortranCompiler.cmake 2006-01-13 02:48:36.000000000 +0800 @@ -1,3 +1,4 @@ + # This file is used by EnableLanguage in cmGlobalGenerator to # determine that that selected Fortran compiler can actually compile # and link the most basic of programs. If not, a fatal error @@ -5,13 +6,13 @@ # any makefiles or projects. IF(NOT CMAKE_Fortran_COMPILER_WORKS) MESSAGE(STATUS "Check for working Fortran compiler: ${CMAKE_Fortran_COMPILER}") - FILE(WRITE ${CMAKE_BINARY_DIR}/CMakeTmp/testFortranCompiler.f " + FILE(WRITE ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/testFortranCompiler.f " PROGRAM TESTFortran PRINT *, 'Hello' END ") TRY_COMPILE(CMAKE_Fortran_COMPILER_WORKS ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/CMakeTmp/testFortranCompiler.f + ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/testFortranCompiler.f OUTPUT_VARIABLE OUTPUT) SET(FORTRAN_TEST_WAS_RUN 1) ENDIF(NOT CMAKE_Fortran_COMPILER_WORKS) @@ -40,13 +41,13 @@ IF(DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F90) ELSE(DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F90) MESSAGE(STATUS "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90") - FILE(WRITE ${CMAKE_BINARY_DIR}/CMakeTmp/testFortranCompilerF90.f90 " + FILE(WRITE ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/testFortranCompilerF90.f90 " PROGRAM TESTFortran90 stop = 1 ; do while ( stop .eq. 0 ) ; end do END PROGRAM TESTFortran90 ") TRY_COMPILE(CMAKE_Fortran_COMPILER_SUPPORTS_F90 ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/CMakeTmp/testFortranCompilerF90.f90 + ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/testFortranCompilerF90.f90 OUTPUT_VARIABLE OUTPUT) IF(CMAKE_Fortran_COMPILER_SUPPORTS_F90) MESSAGE(STATUS "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90 -- yes") diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeTestJavaCompiler.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeTestJavaCompiler.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeTestJavaCompiler.cmake 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeTestJavaCompiler.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,3 +1,4 @@ + # This file is used by EnableLanguage in cmGlobalGenerator to # determine that that selected Fortran compiler can actually compile # and link the most basic of programs. If not, a fatal error diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeTestRCCompiler.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeTestRCCompiler.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeTestRCCompiler.cmake 2005-09-16 04:38:36.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeTestRCCompiler.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,3 +1,4 @@ + # This file is used by EnableLanguage in cmGlobalGenerator to # determine that that selected RC compiler can actually compile # and link the most basic of programs. If not, a fatal error diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeVS6BackwardCompatibility.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeVS6BackwardCompatibility.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeVS6BackwardCompatibility.cmake 2003-01-09 21:50:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeVS6BackwardCompatibility.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,3 +1,4 @@ + # hard code these for fast backwards compatibility tests SET (CMAKE_SIZEOF_INT 4 CACHE INTERNAL "Size of int data type") SET (CMAKE_SIZEOF_LONG 4 CACHE INTERNAL "Size of long data type") diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeVS71FindMake.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeVS71FindMake.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeVS71FindMake.cmake 2003-08-08 23:59:07.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeVS71FindMake.cmake 2006-02-28 23:27:30.000000000 +0800 @@ -2,6 +2,7 @@ NAMES devenv PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\7.1\\Setup\\VS;EnvironmentDirectory] + "$ENV{ProgramFiles}/Microsoft Visual Studio .NET/Common7/IDE" "c:/Program Files/Microsoft Visual Studio .NET/Common7/IDE" "c:/Program Files/Microsoft Visual Studio.NET/Common7/IDE" "/Program Files/Microsoft Visual Studio .NET/Common7/IDE/" diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeVS7BackwardCompatibility.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeVS7BackwardCompatibility.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeVS7BackwardCompatibility.cmake 2003-01-09 21:50:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeVS7BackwardCompatibility.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,3 +1,4 @@ + # hard code these for fast backwards compatibility tests SET (CMAKE_SIZEOF_INT 4 CACHE INTERNAL "Size of int data type") SET (CMAKE_SIZEOF_LONG 4 CACHE INTERNAL "Size of long data type") diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeVS8FindMake.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeVS8FindMake.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CMakeVS8FindMake.cmake 2005-05-27 05:30:13.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CMakeVS8FindMake.cmake 2006-03-04 00:59:59.000000000 +0800 @@ -1,8 +1,9 @@ FIND_PROGRAM(CMAKE_MAKE_PROGRAM - NAMES devenv VCExpress + NAMES VCExpress devenv PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup\\VS;EnvironmentDirectory] [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup;Dbghelp_path] + "$ENV{ProgramFiles}/Microsoft Visual Studio .NET/Common7/IDE" "c:/Program Files/Microsoft Visual Studio 8/Common7/IDE" "c:/Program Files/Microsoft Visual Studio8/Common7/IDE" "/Program Files/Microsoft Visual Studio 8/Common7/IDE/" diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CPack.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CPack.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CPack.cmake 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CPack.cmake 2006-03-02 04:00:07.000000000 +0800 @@ -0,0 +1,81 @@ +# Pick a configuration file +SET(cpack_input_file "${CMAKE_ROOT}/Templates/CPackConfig.cmake.in") +IF(EXISTS "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in") + SET(cpack_input_file "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in") +ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in") + +# Macro for setting values if a user did not overwrite them +MACRO(cpack_set_if_not_set name value) + IF(NOT DEFINED "${name}") + SET(${name} "${value}") + ENDIF(NOT DEFINED "${name}") +ENDMACRO(cpack_set_if_not_set) + +# Set the package name +cpack_set_if_not_set(CPACK_PACKAGE_NAME "${PROJECT_NAME}") +cpack_set_if_not_set(CPACK_PACKAGE_VERSION_MAJOR "0") +cpack_set_if_not_set(CPACK_PACKAGE_VERSION_MINOR "1") +cpack_set_if_not_set(CPACK_PACKAGE_VERSION_PATCH "1") +cpack_set_if_not_set(CPACK_PACKAGE_VERSION + "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") +cpack_set_if_not_set(CPACK_PACKAGE_VENDOR "Humanity") +cpack_set_if_not_set(CPACK_PACKAGE_DESCRIPTION_SUMMARY + "${PROJECT_NAME} built using CMake") + +cpack_set_if_not_set(CPACK_PACKAGE_DESCRIPTION_FILE + "${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt") +cpack_set_if_not_set(CPACK_RESOURCE_FILE_LICENSE + "${CMAKE_ROOT}/Templates/CPack.GenericLicense.txt") +cpack_set_if_not_set(CPACK_RESOURCE_FILE_README + "${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt") +cpack_set_if_not_set(CPACK_RESOURCE_FILE_WELCOME + "${CMAKE_ROOT}/Templates/CPack.GenericWelcome.txt") + +IF(CPACK_NSIS_MODIFY_PATH) + SET(CPACK_NSIS_MODIFY_PATH ON) +ENDIF(CPACK_NSIS_MODIFY_PATH) + +# -..--. +cpack_set_if_not_set(CPACK_PACKAGE_FILE_NAME + "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${CMAKE_SYSTEM_NAME}") +cpack_set_if_not_set(CPACK_PACKAGE_INSTALL_DIRECTORY + "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}") +cpack_set_if_not_set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY + "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}") + +MACRO(cpack_check_file_exists file description) +IF(NOT EXISTS "${file}") + MESSAGE(SEND_ERROR "CPack ${description} file: \"${file}\" could not be found.") +ENDIF(NOT EXISTS "${file}") +ENDMACRO(cpack_check_file_exists) +cpack_check_file_exists("${CPACK_PACKAGE_DESCRIPTION_FILE}" "package description") +cpack_check_file_exists("${CPACK_RESOURCE_FILE_LICENSE}" "license resource") +cpack_check_file_exists("${CPACK_RESOURCE_FILE_README}" "readme resource") +cpack_check_file_exists("${CPACK_RESOURCE_FILE_WELCOME}" "welcome resource") + +# Pick a generator +IF(NOT CPACK_GENERATOR) + IF(UNIX) + IF(APPLE) + SET(CPACK_GENERATOR "PackageMaker") + ELSE(APPLE) + SET(CPACK_GENERATOR "STGZ") + ENDIF(APPLE) + ELSE(UNIX) + SET(CPACK_GENERATOR "NSIS") + ENDIF(UNIX) +ENDIF(NOT CPACK_GENERATOR) + +# Set some other variables +SET(CPACK_BINARY_DIR "${CMAKE_BINARY_DIR}") + +SET(_CPACK_UNUSED_VARIABLES_) +GET_CMAKE_PROPERTY(res VARIABLES) +FOREACH(var ${res}) + IF("xxx${var}" MATCHES "xxxCPACK") + SET(_CPACK_OTHER_VARIABLES_ + "${_CPACK_OTHER_VARIABLES_}\nSET(${var} \"${${var}}\")") + ENDIF("xxx${var}" MATCHES "xxxCPACK") +ENDFOREACH(var ${res}) + +CONFIGURE_FILE("${cpack_input_file}" "${CMAKE_BINARY_DIR}/CPackConfig.cmake" @ONLY IMMEDIATE) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CPack.Description.plist.in /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CPack.Description.plist.in --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CPack.Description.plist.in 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CPack.Description.plist.in 2006-01-05 04:13:38.000000000 +0800 @@ -0,0 +1,12 @@ + + + + + IFPkgDescriptionTitle + @CPACK_PACKAGE_NAME@ + IFPkgDescriptionVersion + @CPACK_PACKAGE_VERSION@ + IFPkgDescriptionDescription + @CPACK_PACKAGE_DESCRIPTION@ + + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CPack.Info.plist.in /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CPack.Info.plist.in --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CPack.Info.plist.in 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CPack.Info.plist.in 2006-03-03 23:52:26.000000000 +0800 @@ -0,0 +1,37 @@ + + + + + +IFMajorVersion +@CPACK_PACKAGE_VERSION_MAJOR@ +IFMinorVersion +@CPACK_PACKAGE_VERSION_MINOR@ +IFPkgFlagAllowBackRev + +IFPkgFlagAuthorizationAction +AdminAuthorization +IFPkgFlagDefaultLocation +/ +IFPkgFlagInstallFat + +IFPkgFlagIsRequired + +IFPkgFlagOverwritePermissions + +IFPkgFlagRelocatable + +IFPkgFlagRestartAction +NoRestart +IFPkgFlagRootVolumeOnly + +IFPkgFlagUpdateInstalledLanguages + +IFPkgFlagUseUserMask + +IFPkgFormatVersion +0.10000000149011612 +CFBundleIdentifier +com.@CPACK_PACKAGE_VENDOR@.@CPACK_PACKAGE_NAME@.@CPACK_PACKAGE_VERSION@ + + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/CTest.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CTest.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/CTest.cmake 2005-08-12 02:02:18.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/CTest.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,5 +1,4 @@ -# CTest.cmake -# +# - setup CTest # This file configures a project to use the CTest/Dart testing/dashboard process. # OPTION(BUILD_TESTING "Build the testing tree." ON) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/Dart.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Dart.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/Dart.cmake 2005-08-12 02:02:18.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Dart.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,11 +1,11 @@ -# Dart.cmake -# +# - setup for using Dart. # This file configures a project to use the Dart testing/dashboard process. # It is broken into 3 sections. + # -# Section #1: Locate programs on the client and determine site and build name -# Section #2: Configure or copy Tcl scripts from the source tree to build tree -# Section #3: Custom targets for performing dashboard builds. +# Section #1: Locate programs on the client and determine site and build name +# Section #2: Configure or copy Tcl scripts from the source tree to build tree +# Section #3: Custom targets for performing dashboard builds. # # OPTION(BUILD_TESTING "Build the testing tree." ON) @@ -24,8 +24,8 @@ INCLUDE(CTest) SET(RUN_FROM_DART) - # Project Home Page - SET (PROJECT_URL "http://www.kitware.com") + # Project Home Page + SET (PROJECT_URL "http://www.kitware.com") FIND_PROGRAM(COMPRESSIONCOMMAND NAMES gzip compress zip DOC "Path to program used to compress files for transfer to the dart server") diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/Documentation.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Documentation.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/Documentation.cmake 2004-09-27 21:49:55.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Documentation.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,5 +1,4 @@ -# DocumentationVTK.cmake -# +# - DocumentationVTK.cmake # This file provides support for the VTK documentation framework. # It relies on several tools (Doxygen, Perl, etc). diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindAVIFile.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindAVIFile.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindAVIFile.cmake 2005-04-08 02:27:01.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindAVIFile.cmake 2005-12-15 23:41:19.000000000 +0800 @@ -1,14 +1,13 @@ -# Locate AVIFILE library and include paths - -# AVIFILE (http://avifile.sourceforge.net/ )is a set of library for i386 machines +# - Locate AVIFILE library and include paths +# AVIFILE (http://avifile.sourceforge.net/)is a set of libraries for +# i386 machines # to use various AVI codecs. Support is limited beyond Linux. Windows # provides native AVI support, and so doesn't need this library. - # This module defines -# AVIFILE_INCLUDE_DIR, where to find avifile.h , etc. -# AVIFILE_LIBRARIES, the libraries to link against to use AVIFILE -# AVIFILE_DEFINITIONS, definitions to use when compiling code that uses AVIFILE. -# AVIFILE_FOUND, If false, don't try to use AVIFILE. +# AVIFILE_INCLUDE_DIR, where to find avifile.h , etc. +# AVIFILE_LIBRARIES, the libraries to link against +# AVIFILE_DEFINITIONS, definitions to use when compiling +# AVIFILE_FOUND, If false, don't try to use AVIFILE IF (UNIX) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindCABLE.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindCABLE.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindCABLE.cmake 2003-04-23 04:10:18.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindCABLE.cmake 2005-12-15 23:41:19.000000000 +0800 @@ -1,15 +1,14 @@ -# +# - Find CABLE # This module finds if CABLE is installed and determines where the # include files and libraries are. This code sets the following variables: # -# CABLE = the full path to the cable executable -# CABLE_TCL_LIBRARY = the full path to the Tcl wrapper facility library -# CABLE_INCLUDE_DIR = the full path to the cable include directory -# -# To build Tcl wrappers, you should add shared library and link it to -# ${CABLE_TCL_LIBRARY}. You should also add ${CABLE_INCLUDE_DIR} as -# an include directory. +# CABLE the path to the cable executable +# CABLE_TCL_LIBRARY the path to the Tcl wrapper library +# CABLE_INCLUDE_DIR the path to the include directory # +# To build Tcl wrappers, you should add shared library and link it to +# ${CABLE_TCL_LIBRARY}. You should also add ${CABLE_INCLUDE_DIR} as +# an include directory. IF(NOT CABLE) FIND_PATH(CABLE_BUILD_DIR cableVersion.h) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindCurses.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindCurses.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindCurses.cmake 2005-09-09 02:59:57.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindCurses.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,5 +1,4 @@ -# -# Find the curses include file and library +# - Find the curses include file and library # FIND_PATH(CURSES_INCLUDE_PATH diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindCygwin.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindCygwin.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindCygwin.cmake 2001-12-04 23:55:17.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindCygwin.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,5 +1,4 @@ -# -# this module looks for Cygwin +# - this module looks for Cygwin # IF (WIN32) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindDart.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindDart.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindDart.cmake 2002-02-26 02:20:48.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindDart.cmake 2006-02-28 23:27:30.000000000 +0800 @@ -1,13 +1,14 @@ -# -# this module looks for the dart testing software and sets DART_ROOT -# to point to where it found it +# - Find DART +# This module looks for the dart testing software and sets DART_ROOT +# to point to where it found it. # FIND_PATH(DART_ROOT README.INSTALL $ENV{DART_ROOT} ${PROJECT_SOURCE_DIR}/Dart /usr/share/Dart - C:/Dart + C:/Dart + "$ENV{ProgramFiles}/Dart" "C:/Program Files/Dart" ${PROJECT_SOURCE_DIR}/../Dart [HKEY_LOCAL_MACHINE\\SOFTWARE\\Dart\\InstallPath] diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindDCMTK.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindDCMTK.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindDCMTK.cmake 2005-07-05 23:17:58.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindDCMTK.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,11 +1,10 @@ -# -# try to find DCMTK libraries +# - find DCMTK libraries # -# DCMTK_INCLUDE_DIR - Directories to include to use DCMTK -# DCMTK_LIBRARIES - Files to link against to use DCMTK -# DCMTK_FOUND - If false, don't try to use DCMTK -# DCMTK_DIR - (optional) Source directory for DCMTK +# DCMTK_INCLUDE_DIR - Directories to include to use DCMTK +# DCMTK_LIBRARIES - Files to link against to use DCMTK +# DCMTK_FOUND - If false, don't try to use DCMTK +# DCMTK_DIR - (optional) Source directory for DCMTK # # DCMTK_DIR can be used to make it simpler to find the various include # directories and compiled libraries if you've just compiled it in the diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindDoxygen.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindDoxygen.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindDoxygen.cmake 2005-08-12 02:02:18.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindDoxygen.cmake 2006-02-28 23:27:30.000000000 +0800 @@ -1,7 +1,4 @@ -# -# this module looks for Doxygen and the path to Graphiz's dot -# - +# - this module looks for Doxygen and the path to Graphiz's dot # With the OS X GUI version, it likes to be installed to /Applications and # it contains the doxygen executable in the bundle. In the versions I've # seen, it is located in Resources, but in general, more often binaries are @@ -18,6 +15,7 @@ # which contains dot in its bundle. FIND_PROGRAM(DOT dot + "$ENV{ProgramFiles}/ATT/Graphviz/bin" "C:/Program Files/ATT/Graphviz/bin" [HKEY_LOCAL_MACHINE\\SOFTWARE\\ATT\\Graphviz;InstallPath]/bin /Applications/Graphviz.app/Contents/MacOS diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindFLTK.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindFLTK.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindFLTK.cmake 2005-07-07 03:25:21.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindFLTK.cmake 2005-12-15 23:41:19.000000000 +0800 @@ -1,20 +1,17 @@ -# -# Find the native FLTK includes and library -# +# - Find the native FLTK includes and library # The following settings are defined -# FLTK_FLUID_EXECUTABLE, where to find the Fluid tool -# FLTK_WRAP_UI, This allows the FLTK_WRAP_UI command to work. -# FLTK_INCLUDE_DIR, where to find include files -# FLTK_LIBRARIES, list of fltk libraries -# FLTK_FOUND, Don't use FLTK if false. - +# FLTK_FLUID_EXECUTABLE, where to find the Fluid tool +# FLTK_WRAP_UI, This enables the FLTK_WRAP_UI command +# FLTK_INCLUDE_DIR, where to find include files +# FLTK_LIBRARIES, list of fltk libraries +# FLTK_FOUND, Don't use FLTK if false. # The following settings should not be used in general. -# FLTK_BASE_LIBRARY = the full path to fltk.lib -# FLTK_GL_LIBRARY = the full path to fltk_gl.lib -# FLTK_FORMS_LIBRARY = the full path to fltk_forms.lib -# FLTK_IMAGES_LIBRARY = the full path to fltk_images.lib +# FLTK_BASE_LIBRARY = the full path to fltk.lib +# FLTK_GL_LIBRARY = the full path to fltk_gl.lib +# FLTK_FORMS_LIBRARY = the full path to fltk_forms.lib +# FLTK_IMAGES_LIBRARY = the full path to fltk_images.lib -# Platform dependent libraries required by FLTK +# Platform dependent libraries required by FLTK IF(WIN32) IF(NOT CYGWIN) IF(BORLAND) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindGCCXML.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindGCCXML.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindGCCXML.cmake 2002-04-18 02:51:58.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindGCCXML.cmake 2006-02-28 23:27:30.000000000 +0800 @@ -1,7 +1,8 @@ -# Find the GCC-XML front-end executable. +# - Find the GCC-XML front-end executable. FIND_PROGRAM(GCCXML NAMES gccxml ../GCC_XML/gccxml PATHS [HKEY_CURRENT_USER\\Software\\Kitware\\GCC_XML;loc] - "C:/Program Files/GCC_XML" + "$ENV{ProgramFiles}/GCC_XML" + "C:/Program Files/GCC_XML" ) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindGLU.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindGLU.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindGLU.cmake 2004-08-27 10:52:53.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindGLU.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,4 +1,5 @@ -# + + # Use of this file is deprecated, and is here for backwards compatibility with CMake 1.4 # GLU library is now found by FindOpenGL.cmake # diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindGLUT.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindGLUT.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindGLUT.cmake 2005-08-12 02:02:18.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindGLUT.cmake 2005-12-15 23:41:19.000000000 +0800 @@ -1,14 +1,11 @@ -# -# try to find glut library and include files -# -# GLUT_INCLUDE_DIR, where to find GL/glut.h, etc. -# GLUT_LIBRARIES, the libraries to link against to use GLUT. -# GLUT_FOUND, If false, do not try to use GLUT. - -# also defined, but not for general use are -# GLUT_glut_LIBRARY = the full path to the glut library. -# GLUT_Xmu_LIBRARY = the full path to the Xmu library if available. -# GLUT_Xi_LIBRARY = the full path to the Xi Library if available. +# - try to find glut library and include files +# GLUT_INCLUDE_DIR, where to find GL/glut.h, etc. +# GLUT_LIBRARIES, the libraries to link against +# GLUT_FOUND, If false, do not try to use GLUT. +# Also defined, but not for general use are: +# GLUT_glut_LIBRARY = the full path to the glut library. +# GLUT_Xmu_LIBRARY = the full path to the Xmu library. +# GLUT_Xi_LIBRARY = the full path to the Xi Library. IF (WIN32) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindGnuplot.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindGnuplot.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindGnuplot.cmake 2004-08-27 10:52:53.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindGnuplot.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,5 +1,4 @@ -# -# this module looks for gnuplot +# - this module looks for gnuplot # INCLUDE(FindCygwin) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindGTK.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindGTK.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindGTK.cmake 2005-04-08 02:27:01.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindGTK.cmake 2005-12-15 23:41:19.000000000 +0800 @@ -1,11 +1,8 @@ -# -# try to find GTK (and glib) and GTKGLArea -# - -# GTK_INCLUDE_DIR - Directories to include to use GTK -# GTK_LIBRARIES - Files to link against to use GTK -# GTK_FOUND - If false, don't try to use GTK -# GTK_GL_FOUND - If false, don't try to use GTK's GL features +# - try to find GTK (and glib) and GTKGLArea +# GTK_INCLUDE_DIR - Directories to include to use GTK +# GTK_LIBRARIES - Files to link against to use GTK +# GTK_FOUND - GTK was found +# GTK_GL_FOUND - GTK's GL features were found # don't even bother under WIN32 IF(UNIX) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindHTMLHelp.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindHTMLHelp.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindHTMLHelp.cmake 2003-08-08 23:59:07.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindHTMLHelp.cmake 2006-02-28 23:27:30.000000000 +0800 @@ -1,9 +1,8 @@ -# -# This module looks for Microsoft HTML Help Compiler +# - This module looks for Microsoft HTML Help Compiler # It defines: -# HTML_HELP_COMPILER : full path to the HTML Help Compiler (hhc.exe) -# HTML_HELP_INCLUDE_PATH : include path to the HTML Help API (htmlhelp.h) -# HTML_HELP_LIBRARY : full path to the HTML Help library (htmlhelp.lib) +# HTML_HELP_COMPILER : full path to the Compiler (hhc.exe) +# HTML_HELP_INCLUDE_PATH : include path to the API (htmlhelp.h) +# HTML_HELP_LIBRARY : full path to the library (htmlhelp.lib) # IF (WIN32) @@ -11,6 +10,7 @@ FIND_PROGRAM (HTML_HELP_COMPILER hhc "[HKEY_CURRENT_USER\\Software\\Microsoft\\HTML Help Workshop;InstallDir]" + "$ENV{ProgramFiles}/HTML Help Workshop" "C:/Program Files/HTML Help Workshop" ) @@ -20,6 +20,7 @@ htmlhelp.h "${HTML_HELP_COMPILER_PATH}/include" "[HKEY_CURRENT_USER\\Software\\Microsoft\\HTML Help Workshop;InstallDir]/include" + "$ENV{ProgramFiles}/HTML Help Workshop/include" "C:/Program Files/HTML Help Workshop/include" ) @@ -27,6 +28,7 @@ htmlhelp "${HTML_HELP_COMPILER_PATH}/lib" "[HKEY_CURRENT_USER\\Software\\Microsoft\\HTML Help Workshop;InstallDir]/lib" + "$ENV{ProgramFiles}/HTML Help Workshop/lib" "C:/Program Files/HTML Help Workshop/lib" ) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindImageMagick.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindImageMagick.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindImageMagick.cmake 2003-01-21 23:59:48.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindImageMagick.cmake 2005-12-15 23:41:19.000000000 +0800 @@ -1,12 +1,17 @@ -# +# - Find Image Magick # This module finds if ImageMagick tools are installed and determines # where the executables are. This code sets the following variables: # -# IMAGEMAGICK_CONVERT_EXECUTABLE = the full path to the 'convert' utility -# IMAGEMAGICK_MOGRIFY_EXECUTABLE = the full path to the 'mogrify' utility -# IMAGEMAGICK_IMPORT_EXECUTABLE = the full path to the 'import' utility -# IMAGEMAGICK_MONTAGE_EXECUTABLE = the full path to the 'montage' utility -# IMAGEMAGICK_COMPOSITE_EXECUTABLE = the full path to the 'composite' utility +# IMAGEMAGICK_CONVERT_EXECUTABLE = +# the full path to the 'convert' utility +# IMAGEMAGICK_MOGRIFY_EXECUTABLE = +# the full path to the 'mogrify' utility +# IMAGEMAGICK_IMPORT_EXECUTABLE = +# the full path to the 'import' utility +# IMAGEMAGICK_MONTAGE_EXECUTABLE = +# the full path to the 'montage' utility +# IMAGEMAGICK_COMPOSITE_EXECUTABLE = +# the full path to the 'composite' utility # IF (WIN32) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindITK.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindITK.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindITK.cmake 2004-04-26 23:00:41.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindITK.cmake 2005-12-15 23:41:19.000000000 +0800 @@ -1,27 +1,25 @@ -# -# Find an ITK installation or build tree. -# +# - Find an ITK installation or build tree. + # When ITK is found, the ITKConfig.cmake file is sourced to setup the # location and configuration of ITK. Please read this file, or # ITKConfig.cmake.in from the ITK source tree for the full list of -# definitions. Of particular interest is -# -# ITK_USE_FILE - A CMake source file that can be included -# to set the include directories, library -# directories, and preprocessor macros. -# -# In addition to the variables read from ITKConfig.cmake, this find -# module also defines -# -# ITK_DIR - The directory containing ITKConfig.cmake. This is either -# the root of the build tree, or the lib/InsightToolkit -# directory. This is the only cache entry. -# -# ITK_FOUND - Whether ITK was found. If this is true, ITK_DIR is okay. -# -# USE_ITK_FILE - The full path to the UseITK.cmake file. This is provided -# for backward compatability. Use ITK_USE_FILE instead. -# +# definitions. Of particular interest is ITK_USE_FILE, a CMake source file +# that can be included to set the include directories, library directories, +# and preprocessor macros. In addition to the variables read from +# ITKConfig.cmake, this find module also defines +# ITK_DIR - The directory containing ITKConfig.cmake. +# This is either the root of the build tree, +# or the lib/InsightToolkit directory. +# This is the only cache entry. +# +# ITK_FOUND - Whether ITK was found. If this is true, +# ITK_DIR is okay. +# +# USE_ITK_FILE - The full path to the UseITK.cmake file. +# This is provided for backward +# compatability. Use ITK_USE_FILE +# instead. + SET(ITK_DIR_STRING "directory containing ITKConfig.cmake. This is either the root of the build tree, or PREFIX/lib/InsightToolkit for an installation.") diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindJava.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindJava.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindJava.cmake 2005-10-17 20:49:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindJava.cmake 2005-12-15 23:41:19.000000000 +0800 @@ -1,11 +1,11 @@ -# +# - Find Java # This module finds if Java is installed and determines where the # include files and libraries are. This code sets the following # variables: # -# JAVA_RUNTIME = the full path to the Java runtime -# JAVA_COMPILE = the full path to the Java compiler -# JAVA_ARCHIVE = the full path to the Java archiver +# JAVA_RUNTIME = the full path to the Java runtime +# JAVA_COMPILE = the full path to the Java compiler +# JAVA_ARCHIVE = the full path to the Java archiver # SET(JAVA_BIN_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\2.0;JavaHome]/bin" diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindJNI.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindJNI.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindJNI.cmake 2005-10-17 20:49:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindJNI.cmake 2005-12-15 23:41:19.000000000 +0800 @@ -1,11 +1,11 @@ -# +# - Find JNI java libraries. # This module finds if Java is installed and determines where the # include files and libraries are. It also determines what the name of # the library is. This code sets the following variables: -# -# JAVA_AWT_LIB_PATH = the path to where the jawt library is -# JAVA_INCLUDE_PATH = the path to where jni.h can be found -# JAVA_AWT_INCLUDE_PATH = the path to where jawt.h can be found +# +# JAVA_AWT_LIB_PATH = the path to the jawt library +# JAVA_INCLUDE_PATH = the include path to jni.h +# JAVA_AWT_INCLUDE_PATH = the include path to jawt.h # SET(JAVA_AWT_LIBRARY_DIRECTORIES diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindJPEG.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindJPEG.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindJPEG.cmake 2005-09-09 02:59:57.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindJPEG.cmake 2006-02-10 04:08:16.000000000 +0800 @@ -1,23 +1,22 @@ -# +# - Find JPEG # Find the native JPEG includes and library -# # This module defines -# JPEG_INCLUDE_DIR, where to find jpeglib.h, etc. -# JPEG_LIBRARIES, the libraries to link against to use JPEG. -# JPEG_FOUND, If false, do not try to use JPEG. - +# JPEG_INCLUDE_DIR, where to find jpeglib.h, etc. +# JPEG_LIBRARIES, the libraries needed to use JPEG. +# JPEG_FOUND, If false, do not try to use JPEG. # also defined, but not for general use are -# JPEG_LIBRARY, where to find the JPEG library. +# JPEG_LIBRARY, where to find the JPEG library. FIND_PATH(JPEG_INCLUDE_DIR jpeglib.h /usr/local/include /usr/include ) -FIND_LIBRARY(JPEG_LIBRARY jpeg -/usr/lib -/usr/local/lib -) +SET(JPEG_NAMES ${JPEG_NAMES} jpeg) +FIND_LIBRARY(JPEG_LIBRARY + NAMES ${JPEG_NAMES} + PATHS /usr/lib /usr/local/lib + ) IF (JPEG_LIBRARY) IF (JPEG_INCLUDE_DIR) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindKDE3.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindKDE3.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindKDE3.cmake 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindKDE3.cmake 2006-03-10 03:10:59.000000000 +0800 @@ -0,0 +1,211 @@ +# - Find the KDE3 include and library dirs, KDE preprocessors and define a some macros +# +# This module defines the following variables: +# KDE3_DEFINITIONS - compiler definitions required for compiling KDE software +# KDE3_INCLUDE_DIR - the KDE include directory +# KDE3_INCLUDE_DIRS - the KDE and the Qt include directory, for use with INCLUDE_DIRECTORIES() +# KDE3_LIB_DIR - the directory where the KDE libraries are installed, for use with LINK_DIR() +# QT_AND_KDECORE_LIBRARIES - this contains both the Qt and the kdecore library +# KDE3_DCOPIDL_EXECUTABLE - the dcopidl executable +# KDE3_DCOPIDL2CPP_EXECUTABLE - the dcopidl2cpp executable +# KDE3_KCFGC_EXECUTABLE - the kconfig_compiler executable +# KDE3_FOUND - set to TRUE if all of the above has been found +# +# The following user adjustable options are provided: +# +# KDE3_ENABLE_FINAL - enable this for KDE-style enable-final all-in-one compilation +# KDE3_BUILD_TESTS - enable this to build KDE testcases +# +# +# It also adds the following macros (from KDE3Macros.cmake) +# SRCS_VAR is always the variable which contains the list of source files for your application or library. +# +# KDE3_AUTOMOC(file1 ... fileN) +# Call this if you want to have automatic moc file handling. +# This means if you include "foo.moc" in the source file foo.cpp +# a moc file for the header foo.h will be created automatically. +# You can set the property SKIP_AUTOMAKE using SET_SOURCE_FILES_PROPERTIES() +# to exclude some files in the list from being processed. +# +# KDE3_ADD_MOC_FILES(SRCS_VAR file1 ... fileN ) +# If you don't use the KDE3_AUTOMOC() macro, for the files +# listed here moc files will be created (named "foo.moc.cpp") +# +# KDE3_ADD_DCOP_SKELS(SRCS_VAR header1.h ... headerN.h ) +# Use this to generate DCOP skeletions from the listed headers. +# +# KDE3_ADD_DCOP_STUBS(SRCS_VAR header1.h ... headerN.h ) +# Use this to generate DCOP stubs from the listed headers. +# +# KDE3_ADD_UI_FILES(SRCS_VAR file1.ui ... fileN.ui ) +# Use this to add the Qt designer ui files to your application/library. +# +# KDE3_ADD_KCFG_FILES(SRCS_VAR file1.kcfgc ... fileN.kcfgc ) +# Use this to add KDE kconfig compiler files to your application/library. +# +# KDE3_INSTALL_LIBTOOL_FILE(target) +# This will create and install a simple libtool file for the given target. +# +# KDE3_ADD_EXECUTABLE(name file1 ... fileN ) +# Equivalent to ADD_EXECUTABLE(), but additionally supports KDE3_ENABLE_FINAL +# +# KDE3_ADD_KPART(name [WITH_PREFIX] file1 ... fileN ) +# Create a KDE plugin (KPart, kioslave, etc.) from the given source files. +# It supports KDE3_ENABLE_FINAL +# If WITH_PREFIX is given, the resulting plugin will have the prefix "lib", otherwise it won't. +# It creates and install an appropriate libtool la-file. +# +# KDE3_ADD_KDEINIT_EXECUTABLE(name file1 ... fileN ) +# Create a KDE application in the form of a module loadable via kdeinit. +# It supports KDE3_ENABLE_FINAL. +# A library named kdeinit_ will be created and a small executable which links to it. +# Supports KDE3_ENABLE_FINAL +# +# Author: Alexander Neundorf + +IF(NOT UNIX) + MESSAGE(FATAL_ERROR "Compiling KDE3 applications and libraries under Windows is not supported") +ENDIF(NOT UNIX) + + +SET(QT_MT_REQUIRED TRUE) +#SET(QT_MIN_VERSION "3.0.0") + +#this line includes FindQt.cmake, which searches the Qt library and headers +FIND_PACKAGE(Qt3 REQUIRED) +FIND_PACKAGE(X11 REQUIRED) + + +SET(QT_AND_KDECORE_LIBS ${QT_LIBRARIES} kdecore) + +#add some KDE specific stuff +SET(KDE3_DEFINITIONS -DQT_CLEAN_NAMESPACE -D_GNU_SOURCE) + +#only on linux, but NOT e.g. on FreeBSD: +IF(CMAKE_SYSTEM_NAME MATCHES "Linux") + SET (KDE3_DEFINITIONS ${KDE3_DEFINITIONS} -D_XOPEN_SOURCE=500 -D_BSD_SOURCE) + SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -ansi -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -O2 -Wformat-security -Wmissing-format-attribute -fno-common") + SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -O2 -Wformat-security -fno-exceptions -fno-check-new -fno-common") +ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux") + +# works on FreeBSD, NOT tested on NetBSD and OpenBSD +IF (CMAKE_SYSTEM_NAME MATCHES BSD) + SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -ansi -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -O2 -Wformat-security -Wmissing-format-attribute -fno-common") + SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -O2 -Wformat-security -Wmissing-format-attribute -fno-exceptions -fno-check-new -fno-common") +ENDIF (CMAKE_SYSTEM_NAME MATCHES BSD) + + +#SET(CMAKE_SHARED_LINKER_FLAGS "-avoid-version -module -Wl,--no-undefined -Wl,--allow-shlib-undefined") +#SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings -avoid-version -Wl,--no-undefined -lc") +#SET(CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings -avoid-version -Wl,--no-undefined -lc") + +#now try to find some kde stuff + +#at first the KDE include direcory +# kpassdlg.h comes from kdeui and doesn't exist in KDE4 anymore +FIND_PATH(KDE3_INCLUDE_DIR kpassdlg.h + $ENV{KDEDIR}/include + /opt/kde/include + /opt/kde3/include + /usr/local/include + /usr/include/ + /usr/include/kde + /usr/local/include/kde +) + +#now the KDE library directory +FIND_LIBRARY(KDE3_LIB_DIR NAMES kdecore + PATHS + $ENV{KDEDIR}/lib + /opt/kde/lib + /opt/kde3/lib + /usr/lib + /usr/local/lib +) + +#now the KDE service types directory +#FIND_PATH(KDE3_SERVICETYPES_DIR ktexteditor.desktop +# $ENV{KDEDIR}/share/servicetypes/ +# /opt/kde/share/servicetypes/ +# /opt/kde3/share/servicetypes/ +#) + +#now search for the dcop utilities +FIND_PROGRAM(KDE3_DCOPIDL_EXECUTABLE NAME dcopidl PATHS + $ENV{KDEDIR}/bin + /opt/kde/bin + /opt/kde3/bin + ) + +FIND_PROGRAM(KDE3_DCOPIDL2CPP_EXECUTABLE NAME dcopidl2cpp PATHS + $ENV{KDEDIR}/bin + /opt/kde/bin + /opt/kde3/bin) + +FIND_PROGRAM(KDE3_KCFGC_EXECUTABLE NAME kconfig_compiler PATHS + $ENV{KDEDIR}/bin + /opt/kde/bin + /opt/kde3/bin) + + +# KDE3Macros.cmake contains all the KDE specific macros +INCLUDE(KDE3Macros) + + +#SET KDE3_FOUND +IF (KDE3_INCLUDE_DIR AND KDE3_LIB_DIR AND KDE3_DCOPIDL_EXECUTABLE AND KDE3_DCOPIDL2CPP_EXECUTABLE AND KDE3_KCFGC_EXECUTABLE) + SET(KDE3_FOUND TRUE) +ELSE (KDE3_INCLUDE_DIR AND KDE3_LIB_DIR AND KDE3_DCOPIDL_EXECUTABLE AND KDE3_DCOPIDL2CPP_EXECUTABLE AND KDE3_KCFGC_EXECUTABLE) + SET(KDE3_FOUND FALSE) +ENDIF (KDE3_INCLUDE_DIR AND KDE3_LIB_DIR AND KDE3_DCOPIDL_EXECUTABLE AND KDE3_DCOPIDL2CPP_EXECUTABLE AND KDE3_KCFGC_EXECUTABLE) + + +MACRO (KDE3_PRINT_RESULTS) + IF(KDE3_INCLUDE_DIR) + MESSAGE(STATUS "Found KDE3 include dir: ${KDE3_INCLUDE_DIR}") + ELSE(KDE3_INCLUDE_DIR) + MESSAGE(STATUS "Didn't find KDE3 headers") + ENDIF(KDE3_INCLUDE_DIR) + + IF(KDE3_LIB_DIR) + MESSAGE(STATUS "Found KDE3 library dir: ${KDE3_LIB_DIR}") + ELSE(KDE3_LIB_DIR) + MESSAGE(STATUS "Didn't find KDE3 core library") + ENDIF(KDE3_LIB_DIR) + + IF(KDE3_DCOPIDL_EXECUTABLE) + MESSAGE(STATUS "Found KDE3 dcopidl preprocessor: ${KDE3_DCOPIDL_EXECUTABLE}") + ELSE(KDE3_DCOPIDL_EXECUTABLE) + MESSAGE(STATUS "Didn't find the KDE3 dcopidl preprocessor") + ENDIF(KDE3_DCOPIDL_EXECUTABLE) + + IF(KDE3_DCOPIDL2CPP_EXECUTABLE) + MESSAGE(STATUS "Found KDE3 dcopidl2cpp preprocessor: ${KDE3_DCOPIDL2CPP_EXECUTABLE}") + ELSE(KDE3_DCOPIDL2CPP_EXECUTABLE) + MESSAGE(STATUS "Didn't find the KDE3 dcopidl2cpp preprocessor") + ENDIF(KDE3_DCOPIDL2CPP_EXECUTABLE) + + IF(KDE3_KCFGC_EXECUTABLE) + MESSAGE(STATUS "Found KDE3 kconfig_compiler preprocessor: ${KDE3_KCFGC_EXECUTABLE}") + ELSE(KDE3_KCFGC_EXECUTABLE) + MESSAGE(STATUS "Didn't find the KDE3 kconfig_compiler preprocessor") + ENDIF(KDE3_KCFGC_EXECUTABLE) + +ENDMACRO (KDE3_PRINT_RESULTS) + + +IF (KDE3_FIND_REQUIRED AND NOT KDE3_FOUND) + #bail out if something wasn't found + KDE3_PRINT_RESULTS() + MESSAGE(FATAL_ERROR "Could NOT find everything required for compiling KDE 3 programs") + +ENDIF (KDE3_FIND_REQUIRED AND NOT KDE3_FOUND) + + +IF (NOT KDE3_FIND_QUIETLY) + KDE3_PRINT_RESULTS() +ENDIF (NOT KDE3_FIND_QUIETLY) + +#add the found Qt and KDE include directories to the current include path +SET(KDE3_INCLUDE_DIRS ${QT_INCLUDE_DIR} ${KDE3_INCLUDE_DIR}) + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindKDE4.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindKDE4.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindKDE4.cmake 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindKDE4.cmake 2006-03-17 04:53:11.000000000 +0800 @@ -0,0 +1,72 @@ +# Find KDE4 and provide all necessary variables and macros to compile software for it. +# It looks for KDE 4 in the following directories in the given order: +# - CMAKE_INSTALL_PREFIX +# - KDEDIR +# - /opt/kde4 +# - /opt/kde +# +# Please look in FindKDE4Internal.cmake and KDE4Macros.cmake for more information. +# They are installed with the KDE 4 libraries in $KDEDIR/share/apps/cmake/modules/. +# +# Author: Alexander Neundorf + +# First try to find kde-config +FIND_PROGRAM(KDE4_KDECONFIG_EXECUTABLE NAMES kde-config + PATHS + ${CMAKE_INSTALL_PREFIX}/bin + $ENV{KDEDIR}/bin + /opt/kde4/bin + /opt/kde + /bin + /usr/bin + /usr/local/bin + NO_SYSTEM_PATH + NO_CMAKE_SYSTEM_PATH + ) + + +IF (NOT KDE4_KDECONFIG_EXECUTABLE) + FIND_PROGRAM(KDE4_KDECONFIG_EXECUTABLE NAMES kde-config ) +ENDIF (NOT KDE4_KDECONFIG_EXECUTABLE) + +IF (KDE4_KDECONFIG_EXECUTABLE) + # then ask kde-config for the kde data dirs + EXEC_PROGRAM(${KDE4_KDECONFIG_EXECUTABLE} ARGS --path data OUTPUT_VARIABLE _data_DIR ) + + + IF(WIN32) + # cmake can't handle paths with '\' correct :-( + STRING(REGEX REPLACE "\\\\" "/" _data_DIR "${_data_DIR}") + ELSE(WIN32) + # replace the ":" with ";" so that it becomes a valid cmake list + STRING(REGEX REPLACE ":" ";" _data_DIR "${_data_DIR}") + ENDIF(WIN32) + + # then check the data dirs for FindKDE4Internal.cmake + FIND_PATH(KDE4_DATA_DIR cmake/modules/FindKDE4Internal.cmake ${_data_DIR}) + + # if it has been found... + IF (KDE4_DATA_DIR) + + SET(CMAKE_MODULE_PATH ${KDE4_DATA_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) + + IF (KDE4_FIND_QUIETLY) + SET(_quiet QUIET) + ENDIF (KDE4_FIND_QUIETLY) + + IF (KDE4_FIND_REQUIRED) + SET(_req REQUIRED) + ENDIF (KDE4_FIND_REQUIRED) + + # use FindKDE4Internal.cmake to do the rest + FIND_PACKAGE(KDE4Internal ${_req} ${_quiet}) + + ENDIF (KDE4_DATA_DIR) + +ENDIF (KDE4_KDECONFIG_EXECUTABLE) + + +IF (KDE4_FIND_REQUIRED AND NOT KDE4_FOUND) + MESSAGE(FATAL_ERROR "Could not find KDE4") +ENDIF (KDE4_FIND_REQUIRED AND NOT KDE4_FOUND) + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindKDE.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindKDE.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindKDE.cmake 2004-06-14 22:46:46.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindKDE.cmake 2006-03-10 03:10:59.000000000 +0800 @@ -1,151 +1,9 @@ -# Locate KDE include paths and libraries -# KDE_INCLUDE_DIR -# KDE_LIB_DIR -# KDE_KDE_CONFIG -# KDE_DCOP_IDL -# KDE_VERSION - -#the macro ADD_DCOP_SOURCES(src_headers dest_srcs) +# I don't think anybody actually used this file +# at least not in any large scale +# so it should be safe to obsolete it now # -#usage: -#SET(MY_APP_SOURCES main.cpp kfoo.cpp) -#SET(MY_DCOP_SOURCES kfooiface.h) -#ADD_DCOP_SOURCES(MY_DCOP_SOURCES MY_APP_SOURCES) -#and then it should work :-) - -#uses KDE_MIN_VERSION - -CMAKE_MINIMUM_REQUIRED(VERSION 2.0.0) - -FIND_PATH(KDE_INCLUDE_DIR kurl.h - $ENV{KDEDIR}/include - /opt/kde/include - /opt/kde3/include - /usr/local/include - /usr/include/ - /usr/include/kde - /usr/local/include/kde - ) - -IF(KDE_INCLUDE_DIR) - MESSAGE(STATUS "Found KDE header files in ${KDE_INCLUDE_DIR}") -ELSE(KDE_INCLUDE_DIR) - MESSAGE(FATAL_ERROR "Didn't find KDE headers") -ENDIF(KDE_INCLUDE_DIR) - -FIND_PROGRAM(KDE_CONFIG NAME kde-config PATHS - $ENV{KDEDIR}/bin - /opt/kde/bin - /opt/kde3/bin) - -IF(NOT KDE_CONFIG) - MESSAGE(FATAL_ERROR "Didn't find the kde-config utility") -ENDIF(NOT KDE_CONFIG) - -FIND_PATH(KDE_LIB_DIR libkdecore.so - $ENV{KDEDIR}/lib - /opt/kde/lib - /opt/kde3/lib - ) - -IF(KDE_LIB_DIR) - MESSAGE(STATUS "Found KDE libraries in ${KDE_LIB_DIR}") -ELSE(KDE_LIB_DIR) - MESSAGE(FATAL_ERROR "Didn't find KDE core library") -ENDIF(KDE_LIB_DIR) - -IF (KDE_MIN_VERSION) - #extract the version from kdeversion.h - - FILE(READ ${KDE_INCLUDE_DIR}/kdeversion.h KDE_VERSION_H) - - STRING(REGEX REPLACE ".*#define[\\t\\ ]+KDE_VERSION_STRING[\\t\\ ]+\"([0-9]+\\.[0-9]+\\.[0-9]+)\".*" "\\1" KDE_VERSION "${KDE_VERSION_H}") - STRING(REGEX REPLACE ".*#define[\\t\\ ]+KDE_VERSION_MAJOR[\\t\\ ]+([0-9]+).*" "\\1" kde_major_vers "${KDE_VERSION_H}") - STRING(REGEX REPLACE ".*#define[\\t\\ ]+KDE_VERSION_MINOR[\\t\\ ]+([0-9]+).*" "\\1" kde_minor_vers "${KDE_VERSION_H}") - STRING(REGEX REPLACE ".*#define[\\t\\ ]+KDE_VERSION_RELEASE[\\t\\ ]+([0-9]+).*" "\\1" kde_vers_release "${KDE_VERSION_H}") - -#now parse the parts of the user given version string into variables - STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+$" req_kde_major_vers "${KDE_MIN_VERSION}") - IF (NOT req_kde_major_vers) - MESSAGE( FATAL_ERROR "Invalid KDE version string given: \"${KDE_MIN_VERSION}\", expected e.g. \"3.1.5\"") - ENDIF (NOT req_kde_major_vers) - - STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_kde_major_vers "${KDE_MIN_VERSION}") - STRING(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_kde_minor_vers "${KDE_MIN_VERSION}") - STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_kde_patch_vers "${KDE_MIN_VERSION}") - -# req = "6.5.4", qt = "3.2.1" - - IF (req_kde_major_vers GREATER kde_major_vers) # (6 > 3) ? - MESSAGE( FATAL_ERROR "KDE major version not matched (required: ${KDE_MIN_VERSION}, found: ${KDE_VERSION})") # yes - ELSE (req_kde_major_vers GREATER kde_major_vers) # no - IF (req_kde_major_vers LESS kde_major_vers) # (6 < 3) ? - SET( QT_VERSION_BIG_ENOUGH "YES" ) # yes - ELSE (req_kde_major_vers LESS kde_major_vers) # ( 6==3) ? - IF (req_kde_minor_vers GREATER kde_minor_vers) # (5>2) ? - MESSAGE( FATAL_ERROR "KDE minor version not matched (required: ${KDE_MIN_VERSION}, found: ${KDE_VERSION})") # yes - ELSE (req_kde_minor_vers GREATER kde_minor_vers) # no - IF (req_kde_minor_vers LESS kde_minor_vers) # (5<2) ? - SET( QT_VERSION_BIG_ENOUGH "YES" ) # yes - ELSE (req_kde_minor_vers LESS kde_minor_vers) # (5==2) - IF (req_kde_patch_vers GREATER kde_vers_release) # (4>1) ? - MESSAGE( FATAL_ERROR "KDE release version not matched (required: ${KDE_MIN_VERSION}, found: ${KDE_VERSION})") # yes - ELSE (req_kde_patch_vers GREATER kde_patch_vers) # (4>1) ? - SET( QT_VERSION_BIG_ENOUGH "YES" ) # yes - ENDIF (req_kde_patch_vers GREATER kde_vers_release) # (4>1) ? - ENDIF (req_kde_minor_vers LESS kde_minor_vers) - ENDIF (req_kde_minor_vers GREATER kde_minor_vers) - ENDIF (req_kde_major_vers LESS kde_major_vers) - ENDIF (req_kde_major_vers GREATER kde_major_vers) - MESSAGE(STATUS "KDE version ok (required: ${KDE_MIN_VERSION}, found: ${KDE_VERSION})") -ENDIF (KDE_MIN_VERSION) - -#now search for the dcop utilities -FIND_PROGRAM(KDE_DCOPIDL NAME dcopidl PATHS - $ENV{KDEDIR}/bin - /opt/kde/bin - /opt/kde3/bin) - -IF(NOT KDE_DCOPIDL) - MESSAGE(FATAL_ERROR "Didn't find the dcopidl preprocessor") -ENDIF(NOT KDE_DCOPIDL) - -FIND_PROGRAM(KDE_DCOPIDL2CPP NAME dcopidl2cpp PATHS - $ENV{KDEDIR}/bin - /opt/kde/bin - /opt/kde3/bin) - -IF(NOT KDE_DCOPIDL2CPP) - MESSAGE(FATAL_ERROR "Didn't find the dcopidl2cpp preprocessor") -ENDIF(NOT KDE_DCOPIDL2CPP) - -MACRO(DCOP_WRAP SKEL_SOURCES) - FOREACH(dcop_source ${ARGN}) - - GET_FILENAME_COMPONENT(dcop_source_basename ${dcop_source} NAME_WE) - - SET(idl_file ${CMAKE_BINARY_DIR}/${dcop_source_basename}.kidl) - SET(skel_file ${CMAKE_BINARY_DIR}/${dcop_source_basename}_skel.cpp) - - ADD_CUSTOM_COMMAND( - OUTPUT ${idl_file} - COMMAND ${KDE_DCOPIDL} - ARGS ${CMAKE_SOURCE_DIR}/${dcop_source} > ${idl_file} - DEPENDS ${CMAKE_SOURCE_DIR}/${dcop_source}) - - ADD_CUSTOM_COMMAND( - OUTPUT ${skel_file} - COMMAND ${KDE_DCOPIDL2CPP} - ARGS --c++-suffix cpp --no-signals --no-stub ${idl_file} - DEPENDS ${idl_file}) +# Alex - SET( SKEL_SOURCES ${${SKEL_SOURCES}} - ${skel_file}) - ENDFOREACH(dcop_source) -ENDMACRO (DCOP_WRAP) +MESSAGE(FATAL_ERROR "FindKDE.cmake is obsolete, please use FindKDE3.cmake or FindKDE4.cmake instead.") -MARK_AS_ADVANCED( - KDE_INCLUDE_DIR - KDE_LIB_DIR - ) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindLATEX.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindLATEX.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindLATEX.cmake 2003-10-31 02:33:51.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindLATEX.cmake 2005-12-15 23:41:19.000000000 +0800 @@ -1,14 +1,14 @@ -# +# - Find Latex # This module finds if Latex is installed and determines where the # executables are. This code sets the following variables: -# -# LATEX_COMPILER = the full path to the LaTeX compiler -# PDFLATEX_COMPILER = the full path to the PdfLaTeX compiler -# BIBTEX_COMPILER = the full path to the BibTeX compiler -# MAKEINDEX_COMPILER = the full path to the MakeIndex compiler -# DVIPS_CONVERTER = the full path to the DVIPS converter -# PS2PDF_CONVERTER = the full path to the PS2PDF converter -# LATEX2HTML_CONVERTER = the full path to the LaTeX2Html converter +# +# LATEX_COMPILER: path to the LaTeX compiler +# PDFLATEX_COMPILER: path to the PdfLaTeX compiler +# BIBTEX_COMPILER: path to the BibTeX compiler +# MAKEINDEX_COMPILER: path to the MakeIndex compiler +# DVIPS_CONVERTER: path to the DVIPS converter +# PS2PDF_CONVERTER: path to the PS2PDF converter +# LATEX2HTML_CONVERTER: path to the LaTeX2Html converter # IF (WIN32) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindMatlab.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindMatlab.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindMatlab.cmake 2005-09-09 02:59:57.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindMatlab.cmake 2005-12-15 23:41:19.000000000 +0800 @@ -1,12 +1,10 @@ -# -# this module looks for Matlab -# -# Define -# MATLAB_INCLUDE_DIR points to the include path for mex.h, engine.h -# MATLAB_LIBRARIES list of libraries need: libmex.lib, libmx.lib and libeng.lib -# MATLAB_MEX_LIBRARY point to libmex.lib -# MATLAB_MX_LIBRARY point to libmx.lib -# MATLAB_ENG_LIBRARY point to libeng.lib +# - this module looks for Matlab +# Defines: +# MATLAB_INCLUDE_DIR: include path for mex.h, engine.h +# MATLAB_LIBRARIES: required libraries: libmex, etc +# MATLAB_MEX_LIBRARY: path to libmex.lib +# MATLAB_MX_LIBRARY: path to libmx.lib +# MATLAB_ENG_LIBRARY: path to libeng.lib SET(MATLAB_FOUND 0) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindMFC.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindMFC.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindMFC.cmake 2004-04-15 23:55:29.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindMFC.cmake 2005-12-16 03:17:42.000000000 +0800 @@ -1,7 +1,6 @@ -# +# - Find MFC on Windows # Find the native MFC - i.e. decide if this is an MS VC box. -# -# MFC_FOUND - Do not attempt to use MFC if "no" or undefined. +# MFC_FOUND - Was MFC support found # You don't need to include anything or link anything to use it. # Assume no MFC support diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindMotif.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindMotif.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindMotif.cmake 2005-09-09 02:59:57.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindMotif.cmake 2005-12-16 03:17:42.000000000 +0800 @@ -1,9 +1,8 @@ -# Try to find Motif (or lesstif) -# Once done this will define -# -# MOTIF_FOUND - system has MOTIF -# MOTIF_INCLUDE_DIR - where the Motif include directory can be found -# MOTIF_LIBRARIES - Link these to use Motif +# - Try to find Motif (or lesstif) +# Once done this will define: +# MOTIF_FOUND - system has MOTIF +# MOTIF_INCLUDE_DIR - incude paths to use Motif +# MOTIF_LIBRARIES - Link these to use Motif SET(MOTIF_FOUND 0) IF(UNIX) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindMPEG2.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindMPEG2.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindMPEG2.cmake 2005-04-08 02:27:01.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindMPEG2.cmake 2005-12-16 03:17:42.000000000 +0800 @@ -1,14 +1,11 @@ -# -# Find the native MPEG2 includes and library -# +# - Find the native MPEG2 includes and library # This module defines -# MPEG2_INCLUDE_DIR, where to find mpeg2dec/mpeg2.h, etc. -# MPEG2_LIBRARIES, the libraries to link against to use MPEG2. -# MPEG2_FOUND, If false, do not try to use MPEG2. - +# MPEG2_INCLUDE_DIR, path to mpeg2dec/mpeg2.h, etc. +# MPEG2_LIBRARIES, the libraries required to use MPEG2. +# MPEG2_FOUND, If false, do not try to use MPEG2. # also defined, but not for general use are -# MPEG2_mpeg2_LIBRARY, where to find the MPEG2 library. -# MPEG2_vo_LIBRARY, where to find the vo library. +# MPEG2_mpeg2_LIBRARY, where to find the MPEG2 library. +# MPEG2_vo_LIBRARY, where to find the vo library. FIND_PATH(MPEG2_INCLUDE_DIR mpeg2.h /usr/local/include diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindMPEG.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindMPEG.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindMPEG.cmake 2005-04-08 02:27:01.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindMPEG.cmake 2005-12-16 03:17:42.000000000 +0800 @@ -1,14 +1,11 @@ -# -# Find the native MPEG includes and library -# +# - Find the native MPEG includes and library # This module defines -# MPEG_INCLUDE_DIR, where to find MPEG.h, etc. -# MPEG_LIBRARIES, the libraries to link against to use MPEG. -# MPEG_FOUND, If false, do not try to use MPEG. - +# MPEG_INCLUDE_DIR, where to find MPEG.h, etc. +# MPEG_LIBRARIES, the libraries required to use MPEG. +# MPEG_FOUND, If false, do not try to use MPEG. # also defined, but not for general use are -# MPEG_mpeg2_LIBRARY, where to find the MPEG library. -# MPEG_vo_LIBRARY, where to find the vo library. +# MPEG_mpeg2_LIBRARY, where to find the MPEG library. +# MPEG_vo_LIBRARY, where to find the vo library. FIND_PATH(MPEG_INCLUDE_DIR mpeg2dec/include/video_out.h /usr/local/include diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindMPI.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindMPI.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindMPI.cmake 2003-08-07 21:19:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindMPI.cmake 2006-02-28 23:27:30.000000000 +0800 @@ -1,29 +1,30 @@ -# -# this module look sfor MPI (Message Passing Interface) support +# - Find MPI +# This module looks for MPI (Message Passing Interface) support # it will define the following values -# -# MPI_INCLUDE_PATH = where mpi.h can be found -# MPI_LIBRARY = the library to link against (mpi mpich etc) -# +# MPI_INCLUDE_PATH = where mpi.h can be found +# MPI_LIBRARY = the library to link in (mpi mpich etc) FIND_PATH(MPI_INCLUDE_PATH mpi.h /usr/local/include /usr/include /usr/include/mpi /usr/local/mpi/include + "$ENV{ProgramFiles}/MPICH/SDK/Include" "C:/Program Files/MPICH/SDK/Include" ) FIND_LIBRARY(MPI_LIBRARY NAMES mpi mpich PATHS /usr/lib /usr/local/lib /usr/local/mpi/lib + "$ENV{ProgramFiles}/MPICH/SDK/Lib" "C:/Program Files/MPICH/SDK/Lib" ) FIND_LIBRARY(MPI_EXTRA_LIBRARY NAMES mpi++ - PATHS /usr/lib /usr/local/lib /usr/local/mpi/lib + PATHS /usr/lib /usr/local/lib /usr/local/mpi/lib + "$ENV{ProgramFiles}/MPICH/SDK/Lib" "C:/Program Files/MPICH/SDK/Lib" - DOC "If a second mpi library is necessary, specify it here.") + DOC "If a second mpi library is necessary, specify it here.") MARK_AS_ADVANCED(MPI_INCLUDE_PATH MPI_LIBRARY MPI_EXTRA_LIBRARY) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindOpenAL.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindOpenAL.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindOpenAL.cmake 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindOpenAL.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,15 +1,14 @@ -# Locate OpenAL +# - Locate OpenAL # This module defines -# OPENAL_LIBRARY -# OPENAL_FOUND, if false, do not try to link to OpenAL -# OPENAL_INCLUDE_DIR, where to find the headers -# +# OPENAL_LIBRARY +# OPENAL_FOUND, if false, do not try to link to OpenAL +# OPENAL_INCLUDE_DIR, where to find the headers +# # $OPENALDIR is an environment variable that would # correspond to the ./configure --prefix=$OPENALDIR # used in building OpenAL. -# +# # Created by Eric Wing. This was influenced by the FindSDL.cmake module. - # On OSX, this will prefer the Framework version (if found) over others. # People will have to manually change the cache values of # OPENAL_LIBRARY to override this selection. @@ -50,7 +49,7 @@ OR "${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks" ) # String is in default search path, don't need to use -F - SET (OPENAL_LIBRARY "-framework OpenAL" CACHE STRING "OpenAL framework for OSX") + SET (OPENAL_LIBRARY "-framework OpenAL" CACHE STRING "OpenAL framework for OSX") ELSE("${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks" OR "${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks" ) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindOpenGL.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindOpenGL.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindOpenGL.cmake 2005-04-08 02:27:01.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindOpenGL.cmake 2006-03-15 05:38:52.000000000 +0800 @@ -1,23 +1,23 @@ -# Try to find OpenGL +# - Try to find OpenGL # Once done this will define -# -# OPENGL_FOUND - system has OpenGL and it should be used -# OPENGL_XMESA_FOUND - system has XMESA, and it should be used. -# OPENGL_GLU_FOUND - system has GLU and it should be used. -# OPENGL_INCLUDE_DIR - where the GL include directory can be found -# OPENGL_LIBRARIES - Link these to use OpenGL and GLU -# +# +# OPENGL_FOUND - system has OpenGL +# OPENGL_XMESA_FOUND - system has XMESA +# OPENGL_GLU_FOUND - system has GLU +# OPENGL_INCLUDE_DIR - the GL include directory +# OPENGL_LIBRARIES - Link these to use OpenGL and GLU +# # If you want to use just GL you can use these values -# OPENGL_gl_LIBRARY - Path to OpenGL Library -# OPENGL_glu_LIBRARY - Path to GLU Library -# - +# OPENGL_gl_LIBRARY - Path to OpenGL Library +# OPENGL_glu_LIBRARY - Path to GLU Library +# # On OSX default to using the framework version of opengl # People will have to change the cache values of OPENGL_glu_LIBRARY # and OPENGL_gl_LIBRARY to use OpenGL with X11 on OSX IF (APPLE) - SET (OPENGL_gl_LIBRARY "-framework OpenGL" CACHE STRING "OpenGL lib for OSX") - SET (OPENGL_glu_LIBRARY "-framework AGL" CACHE STRING "AGL lib for OSX") + FIND_LIBRARY(OPENGL_gl_LIBRARY OpenGL DOC "OpenGL lib for OSX") + FIND_LIBRARY(OPENGL_glu_LIBRARY AGL DOC "AGL lib for OSX") + FIND_PATH(OPENGL_INCLUDE_DIR OpenGL/gl.h DOC "Include for OpenGL on OSX") ENDIF (APPLE) IF (WIN32) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindPerl.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindPerl.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindPerl.cmake 2004-08-27 10:52:53.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindPerl.cmake 2005-12-16 03:17:42.000000000 +0800 @@ -1,8 +1,8 @@ -# +# - Find perl # this module looks for Perl # -# PERL_EXECUTABLE - the full path to the Perl interpreter -# PERL_FOUND - If false, don't attempt to use perl. +# PERL_EXECUTABLE - the full path to perl +# PERL_FOUND - If false, don't attempt to use perl. INCLUDE(FindCygwin) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindPerlLibs.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindPerlLibs.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindPerlLibs.cmake 2005-04-08 02:27:01.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindPerlLibs.cmake 2005-12-16 03:17:42.000000000 +0800 @@ -1,10 +1,10 @@ -# +# - Find Perl libraries # This module finds if PERL is installed and determines where the include files # and libraries are. It also determines what the name of the library is. This # code sets the following variables: # -# PERL_INCLUDE_PATH = path to where object.h can be found -# PERL_EXECUTABLE = full path to the perl binary +# PERL_INCLUDE_PATH = path to where perl.h is found +# PERL_EXECUTABLE = full path to the perl binary # SET(PERL_POSSIBLE_INCLUDE_PATHS diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindPHP4.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindPHP4.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindPHP4.cmake 2005-04-08 02:27:01.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindPHP4.cmake 2005-12-16 03:17:42.000000000 +0800 @@ -1,9 +1,9 @@ -# +# - Find PHP4 # This module finds if PHP4 is installed and determines where the include files # and libraries are. It also determines what the name of the library is. This # code sets the following variables: # -# PHP4_INCLUDE_PATH = path to where object.h can be found +# PHP4_INCLUDE_PATH = path to where php.h can be found # PHP4_EXECUTABLE = full path to the php4 binary # diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindPhysFS.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindPhysFS.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindPhysFS.cmake 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindPhysFS.cmake 2005-12-16 03:17:42.000000000 +0800 @@ -1,8 +1,8 @@ -# Locate PhysFS library +# - Locate PhysFS library # This module defines -# PHYSFS_LIBRARY, the name of the library to link against -# PHYSFS_FOUND, if false, do not try to link to PHYSFS -# PHYSFS_INCLUDE_DIR, where to find PHYSFS/PHYSFS.h +# PHYSFS_LIBRARY, the name of the library to link with +# PHYSFS_FOUND, if false, do not try to link to PHYSFS +# PHYSFS_INCLUDE_DIR, where to find PHYSFS/PHYSFS.h # # $PHYSFSDIR is an environment variable that would # correspond to the ./configure --prefix=$PHYSFSDIR diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindPike.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindPike.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindPike.cmake 2004-05-01 00:11:02.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindPike.cmake 2005-12-16 03:17:42.000000000 +0800 @@ -1,9 +1,9 @@ -# +# - Find Pike # This module finds if PIKE is installed and determines where the include files # and libraries are. It also determines what the name of the library is. This # code sets the following variables: # -# PIKE_INCLUDE_PATH = path to where object.h can be found +# PIKE_INCLUDE_PATH = path to where program.h is found # PIKE_EXECUTABLE = full path to the pike binary # diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindPNG.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindPNG.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindPNG.cmake 2005-04-08 02:27:01.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindPNG.cmake 2006-02-10 04:33:58.000000000 +0800 @@ -1,18 +1,14 @@ -# -# Find the native PNG includes and library +# - Find the native PNG includes and library # # This module defines -# PNG_INCLUDE_DIR, where to find png.h, etc. -# PNG_LIBRARIES, the libraries to link against to use PNG. -# PNG_DEFINITIONS - You should ADD_DEFINITONS(${PNG_DEFINITIONS}) before compiling code that includes png library files. -# PNG_FOUND, If false, do not try to use PNG. - +# PNG_INCLUDE_DIR, where to find png.h, etc. +# PNG_LIBRARIES, the libraries to link against to use PNG. +# PNG_DEFINITIONS - You should ADD_DEFINITONS(${PNG_DEFINITIONS}) before compiling code that includes png library files. +# PNG_FOUND, If false, do not try to use PNG. # also defined, but not for general use are -# PNG_LIBRARY, where to find the PNG library. - +# PNG_LIBRARY, where to find the PNG library. # None of the above will be defined unles zlib can be found. - # PNG depends on Zlib INCLUDE(FindZLIB) @@ -22,9 +18,10 @@ /usr/include ) - FIND_LIBRARY(PNG_LIBRARY png - /usr/lib - /usr/local/lib + SET(PNG_NAMES ${PNG_NAMES} png libpng) + FIND_LIBRARY(PNG_LIBRARY + NAMES ${PNG_NAMES} + PATHS /usr/lib /usr/local/lib ) IF (PNG_LIBRARY) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindPythonInterp.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindPythonInterp.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindPythonInterp.cmake 2005-08-12 02:02:18.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindPythonInterp.cmake 2005-12-16 03:17:42.000000000 +0800 @@ -1,9 +1,9 @@ -# +# - Find python interpreter # This module finds if Python interpreter is installed and determines where the # executables are. This code sets the following variables: # -# PYTHONINTERP_FOUND - Set to true when Python executable is found -# PYTHON_EXECUTABLE - The full path to the Python interpreter +# PYTHONINTERP_FOUND - Was the Python executable found +# PYTHON_EXECUTABLE - path to the Python interpreter # FIND_PROGRAM(PYTHON_EXECUTABLE diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindPythonLibs.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindPythonLibs.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindPythonLibs.cmake 2005-04-08 02:27:01.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindPythonLibs.cmake 2005-12-16 03:17:42.000000000 +0800 @@ -1,11 +1,11 @@ -# +# - Find python libraries # This module finds if Python is installed and determines where the # include files and libraries are. It also determines what the name of # the library is. This code sets the following variables: # -# PYTHON_LIBRARIES = the full path to the library found -# PYTHON_INCLUDE_PATH = the path to where Python.h can be found -# PYTHON_DEBUG_LIBRARIES = the full path to the debug library found +# PYTHON_LIBRARIES = path to the python library +# PYTHON_INCLUDE_PATH = path to where Python.h is found +# PYTHON_DEBUG_LIBRARIES = path to the debug library # INCLUDE(CMakeFindFrameworks) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindQt3.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindQt3.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindQt3.cmake 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindQt3.cmake 2006-03-07 03:08:15.000000000 +0800 @@ -1,23 +1,24 @@ -# Locate Qt include paths and libraries - -# This module defines -# QT_INCLUDE_DIR, where to find qt.h, etc. -# QT_LIBRARIES, the libraries to link against to use Qt. -# QT_DEFINITIONS, definitions to use when compiling code that uses Qt. -# QT_FOUND, If false, don't try to use Qt. - -#if you need the multithreaded version of Qt, set QT_MT_REQUIRED to TRUE - -# also defined, but not for general use are -# QT_MOC_EXECUTABLE, where to find the moc tool. -# QT_UIC_EXECUTABLE, where to find the uic tool. -# QT_QT_LIBRARY, where to find the Qt library. -# QT_QTMAIN_LIBRARY, where to find the qtmain library. This is only required by Qt3 on Windows. +# - Locate Qt include paths and libraries +# This module defines: +# QT_INCLUDE_DIR - where to find qt.h, etc. +# QT_LIBRARIES - the libraries to link against to use Qt. +# QT_DEFINITIONS - definitions to use when +# compiling code that uses Qt. +# QT_FOUND - If false, don't try to use Qt. +# +# If you need the multithreaded version of Qt, set QT_MT_REQUIRED to TRUE +# +# Also defined, but not for general use are: +# QT_MOC_EXECUTABLE, where to find the moc tool. +# QT_UIC_EXECUTABLE, where to find the uic tool. +# QT_QT_LIBRARY, where to find the Qt library. +# QT_QTMAIN_LIBRARY, where to find the qtmain +# library. This is only required by Qt3 on Windows. # These are around for backwards compatibility # they will be set -# QT_WRAP_CPP, set true if QT_MOC_EXECUTABLE is found -# QT_WRAP_UI set true if QT_UIC_EXECUTABLE is found +# QT_WRAP_CPP, set true if QT_MOC_EXECUTABLE is found +# QT_WRAP_UI set true if QT_UIC_EXECUTABLE is found FILE(GLOB GLOB_PATHS_BIN /usr/lib/qt-3*/bin/) FIND_PATH(QT_INCLUDE_DIR qt.h @@ -37,6 +38,12 @@ /usr/X11R6/include ) +# if qglobal.h is not in the qt_include_dir then set +# QT_INCLUDE_DIR to NOTFOUND +IF(NOT EXISTS ${QT_INCLUDE_DIR}/qglobal.h) + SET(QT_INCLUDE_DIR QT_INCLUDE_DIR-NOTFOUND CACHE PATH "path to qt3 include directory" FORCE) +ENDIF(NOT EXISTS ${QT_INCLUDE_DIR}/qglobal.h) + IF(QT_INCLUDE_DIR) #extract the version string from qglobal.h FILE(READ ${QT_INCLUDE_DIR}/qglobal.h QGLOBAL_H) @@ -115,7 +122,7 @@ FIND_PROGRAM(QT_MOC_EXECUTABLE NAMES moc moc-qt3 - PATHS + PATHS "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.1;InstallDir]/include/Qt" "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/include/Qt" "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/include/Qt" @@ -153,9 +160,10 @@ IF (WIN32) FIND_LIBRARY(QT_QTMAIN_LIBRARY qtmain - "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.1;InstallDir]/lib" - "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/lib" - "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/lib" + "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.1;InstallDir]/lib" + "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/lib" + "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/lib" + "$ENV{ProgramFiles}/qt/lib" $ENV{QTDIR}/lib "C:/Program Files/qt/lib" DOC "This Library is only needed by and included with Qt3 on MSWindows. It should be NOTFOUND, undefined or IGNORE otherwise." ) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindQt4.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindQt4.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindQt4.cmake 2005-09-20 00:33:35.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindQt4.cmake 2006-03-01 00:14:16.000000000 +0800 @@ -1,115 +1,111 @@ -######################################################################## -# -# Locates Qt4 include paths and libraries -# -######################################################################## - -# This module defines -# QT_USE_FILE A CMake file that can be included to compile -# Qt 4 applications and libraries. By default, -# the QtCore and QtGui libraries are loaded. -# This behavior can be changed by setting one -# or more of the following variables to true: -# QT_DONT_USE_QTCORE -# QT_DONT_USE_QTGUI -# QT_USE_QT3SUPPORT -# QT_USE_QTASSISTANT -# QT_USE_QTDESIGNER -# QT_USE_QTMOTIF -# QT_USE_QTNETWORK -# QT_USE_QTNSPLUGIN -# QT_USE_QTOPENGL -# QT_USE_QTSQL -# QT_USE_QTXML -# All the libraries required are stored in a -# variable called QT_LIBRARIES. Add this variable -# to your TARGET_LINK_LIBRARIES. -# -# macro QT4_WRAP_CPP(outfiles inputfile ... ) -# macro QT4_WRAP_UI(outfiles inputfile ... ) -# macro QT4_ADD_RESOURCE(outfiles inputfile ... ) -# -# QT_FOUND If false, don't try to use Qt. -# QT4_FOUND If false, don't try to use Qt 4. -# -# QT_QTCORE_FOUND True if QtCore includes and library found. -# QT_QTGUI_FOUND True if QtGui includes and library found. -# QT_QT3SUPPORT_FOUND True if Qt3Support includes and library found. -# QT_QTASSISTANT_FOUND True if QtAssistant includes and library found. -# QT_QTDESIGNER_FOUND True if QtDesigner includes and library found. -# QT_QTMOTIF_FOUND True if QtMotif includes and library found. -# QT_QTNETWORK_FOUND True if QtNetwork includes and library found. -# QT_QTNSPLUGIN_FOUND True if QtNsPlugin includes and library found. -# QT_QTOPENGL_FOUND True if QtOpenGL includes and library found. -# QT_QTSQL_FOUND True if QtSql includes and library found. -# QT_QTXML_FOUND True if QtXml includes and library found. -# -# QT_DEFINITIONS Definitions to use when compiling code that -# uses Qt. -# -# QT_INCLUDES List of paths to all include directories of -# Qt4 QT_INCLUDE_DIR, QT_QT_INCLUDE_DIR, and QT_QTGUI_INCLUDE_DIR are -# always in this variable even if NOTFOUND, all other INCLUDE_DIRS are -# only added if they are found. -# -# QT_INCLUDE_DIR Path to "include" of Qt4 -# QT_QT_INCLUDE_DIR Path to "include/Qt" of Qt4 -# QT_QT3SUPPORT_INCLUDE_DIR Path to "include/Qt3Support" of Qt -# QT_QTASSISTANT_INCLUDE_DIR Path to "include/QtAssistant" of Qt4 -# QT_QTCORE_INCLUDE_DIR Path to "include/QtCore" of Qt4 -# QT_QTDESIGNER_INCLUDE_DIR Path to "include/QtDesigner" of Qt4 -# QT_QTGUI_INCLUDE_DIR Path to "include/QtGui" of Qt4 -# QT_QTMOTIF_INCLUDE_DIR Path to "include/QtMotif" of Qt4 -# QT_QTNETWORK_INCLUDE_DIR Path to "include/QtNetwork" of Qt4 -# QT_QTNSPLUGIN_INCLUDE_DIR Path to "include/QtNsPlugin" of Qt4 -# QT_QTOPENGL_INCLUDE_DIR Path to "include/QtOpenGL" of Qt4 -# QT_QTSQL_INCLUDE_DIR Path to "include/QtSql" of Qt4 -# QT_QTXML_INCLUDE_DIR Path to "include/QtXml" of Qt4 -# -# QT_LIBRARY_DIR Path to "lib" of Qt4 -# -# QT_QT3SUPPORT_LIBRARY Path+filename for Qt3Support library of Qt4 -# QT_QTASSISTANT_LIBRARY Path+filename for QtAssistant library of Qt4 -# QT_QTCORE_LIBRARY Path+filename for QtCore library of Qt4 -# QT_QTDESIGNER_LIBRARY Path+filename for QtDesigner library of Qt4 -# QT_QTGUI_LIBRARY Path+filename for QtGui library of Qt4 -# QT_QTMOTIF_LIBRARY Path+filename for QtMotif library of Qt4 -# QT_QTNETWORK_LIBRARY Path+filename for QtNetwork library of Qt4 -# QT_QTNSPLUGIN_LIBRARY Path+filename for QtNsPlugin library of Qt4 -# QT_QTOPENGL_LIBRARY Path+filename for QtOpenGL library of Qt4 -# QT_QTSQL_LIBRARY Path+filename for QtSql library of Qt4 -# QT_QTXML_LIBRARY Path+filename for QtXml library of Qt4 -# -# QT_QT3SUPPORT_LIBRARY_DEBUG Path+filename for Qt3Support_debug library of Qt -# QT_QTASSISTANT_LIBRARY_DEBUG Path+filename for QtAssistant_debug library -# of Qt4 -# QT_QTCORE_LIBRARY_DEBUG Path+filename for QtCore_debug library of Qt4 -# QT_QTDESIGNER_LIBRARY_DEBUG Path+filename for QtDesigner_debug library of Qt4 -# QT_QTGUI_LIBRARY_DEBUG Path+filename for QtGui_debug library of Qt4 -# QT_QTMOTIF_LIBRARY_DEBUG Path+filename for QtMotif_debug library of Qt4 -# QT_QTNETWORK_LIBRARY_DEBUG Path+filename for QtNetwork_debug library of Qt4 -# QT_QTNSPLUGIN_LIBRARY_DEBUG Path+filename for QtNsPlugin_debug library of Qt4 -# QT_QTOPENGL_LIBRARY_DEBUG Path+filename for QtOpenGL_debug library of Qt4 -# QT_QTSQL_LIBRARY_DEBUG Path+filename for QtSql_debug library of Qt4 -# QT_QTXML_LIBRARY_DEBUG Path+filename for QtXml_debug library of Qt4 -# +# - Find QT 4 +# This module can be used to find Qt4. +# This module defines a number of key variables and macros. First is +# QT_USE_FILE which is the path to a CMake file that can be included to compile +# Qt 4 applications and libraries. By default, the QtCore and QtGui +# libraries are loaded. This behavior can be changed by setting one or more +# of the following variables to true: +# QT_DONT_USE_QTCORE +# QT_DONT_USE_QTGUI +# QT_USE_QT3SUPPORT +# QT_USE_QTASSISTANT +# QT_USE_QTDESIGNER +# QT_USE_QTMOTIF +# QT_USE_QTNETWORK +# QT_USE_QTNSPLUGIN +# QT_USE_QTOPENGL +# QT_USE_QTSQL +# QT_USE_QTXML +# All the libraries required are stored in a variable called QT_LIBRARIES. +# Add this variable to your TARGET_LINK_LIBRARIES. +# +# macro QT4_WRAP_CPP(outfiles inputfile ... ) +# macro QT4_WRAP_UI(outfiles inputfile ... ) +# macro QT4_ADD_RESOURCE(outfiles inputfile ... ) +# +# QT_FOUND If false, don't try to use Qt. +# QT4_FOUND If false, don't try to use Qt 4. +# +# QT_QTCORE_FOUND True if QtCore was found. +# QT_QTGUI_FOUND True if QtGui was found. +# QT_QT3SUPPORT_FOUND True if Qt3Support was found. +# QT_QTASSISTANT_FOUND True if QtAssistant was found. +# QT_QTDESIGNER_FOUND True if QtDesigner was found. +# QT_QTMOTIF_FOUND True if QtMotif was found. +# QT_QTNETWORK_FOUND True if QtNetwork was found. +# QT_QTNSPLUGIN_FOUND True if QtNsPlugin was found. +# QT_QTOPENGL_FOUND True if QtOpenGL was found. +# QT_QTSQL_FOUND True if QtSql was found. +# QT_QTXML_FOUND True if QtXml was found. +# +# QT_DEFINITIONS Definitions to use when compiling code that +# uses Qt. +# +# QT_INCLUDES List of paths to all include directories of +# Qt4 QT_INCLUDE_DIR, QT_QT_INCLUDE_DIR, +# and QT_QTGUI_INCLUDE_DIR are +# always in this variable even if NOTFOUND, +# all other INCLUDE_DIRS are +# only added if they are found. +# +# QT_INCLUDE_DIR Path to "include" of Qt4 +# QT_QT_INCLUDE_DIR Path to "include/Qt" +# QT_QT3SUPPORT_INCLUDE_DIR Path to "include/Qt3Support" +# QT_QTASSISTANT_INCLUDE_DIR Path to "include/QtAssistant" +# QT_QTCORE_INCLUDE_DIR Path to "include/QtCore" +# QT_QTDESIGNER_INCLUDE_DIR Path to "include/QtDesigner" +# QT_QTGUI_INCLUDE_DIR Path to "include/QtGui" +# QT_QTMOTIF_INCLUDE_DIR Path to "include/QtMotif" +# QT_QTNETWORK_INCLUDE_DIR Path to "include/QtNetwork" +# QT_QTNSPLUGIN_INCLUDE_DIR Path to "include/QtNsPlugin" +# QT_QTOPENGL_INCLUDE_DIR Path to "include/QtOpenGL" +# QT_QTSQL_INCLUDE_DIR Path to "include/QtSql" +# QT_QTXML_INCLUDE_DIR Path to "include/QtXml" +# +# QT_LIBRARY_DIR Path to "lib" of Qt4 +# +# QT_QT3SUPPORT_LIBRARY Fullpath to Qt3Support library +# QT_QTASSISTANT_LIBRARY Fullpath to QtAssistant library +# QT_QTCORE_LIBRARY Fullpath to QtCore library +# QT_QTDESIGNER_LIBRARY Fullpath to QtDesigner library +# QT_QTGUI_LIBRARY Fullpath to QtGui library +# QT_QTMOTIF_LIBRARY Fullpath to QtMotif library +# QT_QTNETWORK_LIBRARY Fullpath to QtNetwork library +# QT_QTNSPLUGIN_LIBRARY Fullpath to QtNsPlugin library +# QT_QTOPENGL_LIBRARY Fullpath to QtOpenGL library +# QT_QTSQL_LIBRARY Fullpath to QtSql library +# QT_QTXML_LIBRARY Fullpath to QtXml library +# +# QT_QT3SUPPORT_LIBRARY_DEBUG Fullpath to Qt3Support_debug library +# QT_QTASSISTANT_LIBRARY_DEBUG Fullpath to QtAssistant_debug library +# +# QT_QTCORE_LIBRARY_DEBUG Fullpath to QtCore_debug +# QT_QTDESIGNER_LIBRARY_DEBUG Fullpath to QtDesigner_debug +# QT_QTGUI_LIBRARY_DEBUG Fullpath to QtGui_debug +# QT_QTMOTIF_LIBRARY_DEBUG Fullpath to QtMotif_debug +# QT_QTNETWORK_LIBRARY_DEBUG Fullpath to QtNetwork_debug +# QT_QTNSPLUGIN_LIBRARY_DEBUG Fullpath to QtNsPlugin_debug +# QT_QTOPENGL_LIBRARY_DEBUG Fullpath to QtOpenGL_debug +# QT_QTSQL_LIBRARY_DEBUG Fullpath to QtSql_debug +# QT_QTXML_LIBRARY_DEBUG Fullpath to QtXml_debug +# # also defined, but not for general use are -# QT_MOC_EXECUTABLE Where to find the moc tool. -# QT_UIC_EXECUTABLE Where to find the uic tool. -# QT_RCC_EXECUTABLE Where to find the rcc tool -# +# QT_MOC_EXECUTABLE Where to find the moc tool. +# QT_UIC_EXECUTABLE Where to find the uic tool. +# QT_RCC_EXECUTABLE Where to find the rcc tool +# # These are around for backwards compatibility # they will be set -# QT_WRAP_CPP Set true if QT_MOC_EXECUTABLE is found -# QT_WRAP_UI Set true if QT_UIC_EXECUTABLE is found -# -# +# QT_WRAP_CPP Set true if QT_MOC_EXECUTABLE is found +# QT_WRAP_UI Set true if QT_UIC_EXECUTABLE is found +# # These variables do _NOT_ have any effect anymore (compared to FindQt.cmake) -# QT_MT_REQUIRED Qt4 is now always multithreaded -# -# These variables are set to "" Because Qt structure changed (They make no sence in Qt4) -# QT_QT_LIBRARY Qt-Library is now splitt into different parts -# QT_QTMAIN_LIBRARY Qt-Library is now splitt into different parts +# QT_MT_REQUIRED Qt4 is now always multithreaded +# +# These variables are set to "" Because Qt structure changed +# (They make no sense in Qt4) +# QT_QT_LIBRARY Qt-Library is now splitt +# QT_QTMAIN_LIBRARY Qt-Library is now splitt SET(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake) @@ -130,12 +126,13 @@ SET(QT4_PATHS ${QT4_PATHS} ${GLOB_TEMP_VAR}) ENDIF(GLOB_TEMP_VAR) # check for qmake -FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake PATHS +FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake-qt4 qmake PATHS "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin" "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin" $ENV{QTDIR}/bin ${QT4_PATHS} ) + IF(QT_QMAKE_EXECUTABLE) EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION) @@ -143,45 +140,46 @@ SET(QT4_QMAKE_FOUND TRUE) ENDIF(QTVERSION MATCHES "4.*") ENDIF(QT_QMAKE_EXECUTABLE) + IF(QT4_QMAKE_FOUND) # Set QT_LIBRARY_DIR IF(NOT QT_LIBRARY_DIR) - EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE} - ARGS "-query QT_INSTALL_LIBS" - OUTPUT_VARIABLE QT_LIBRARY_DIR_TMP ) + EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE} + ARGS "-query QT_INSTALL_LIBS" + OUTPUT_VARIABLE QT_LIBRARY_DIR_TMP ) IF(EXISTS "${QT_LIBRARY_DIR_TMP}") - SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE PATH "Qt library dir") + SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE PATH "Qt library dir") ELSE(EXISTS "${QT_LIBRARY_DIR_TMP}") MESSAGE("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_LIBS as ${QT_LIBRARY_DIR_TMP}") MESSAGE("Warning: ${QT_LIBRARY_DIR_TMP} does not exist, Qt must not be installed correctly.") ENDIF(EXISTS "${QT_LIBRARY_DIR_TMP}") ENDIF(NOT QT_LIBRARY_DIR) - + IF (APPLE) - IF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) - SET(QT_USE_FRAMEWORKS ON - CACHE BOOL "Set to ON if Qt build uses frameworks.") - ELSE (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) - SET(QT_USE_FRAMEWORKS OFF - CACHE BOOL "Set to ON if Qt build uses frameworks.") - ENDIF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) - - MARK_AS_ADVANCED(QT_USE_FRAMEWORKS) + IF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) + SET(QT_USE_FRAMEWORKS ON + CACHE BOOL "Set to ON if Qt build uses frameworks.") + ELSE (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) + SET(QT_USE_FRAMEWORKS OFF + CACHE BOOL "Set to ON if Qt build uses frameworks.") + ENDIF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) + + MARK_AS_ADVANCED(QT_USE_FRAMEWORKS) ENDIF (APPLE) - + ######################################## # # Setting the INCLUDE-Variables # ######################################## IF (NOT QT_HEADERS_DIR) - # Set QT_QT_INCLUDE_DIR by searching for qglobal.h - IF(QT_QMAKE_EXECUTABLE) - EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE} - ARGS "-query QT_INSTALL_HEADERS" - OUTPUT_VARIABLE qt_headers ) - SET(QT_HEADERS_DIR ${qt_headers} CACHE INTERNAL "") - ENDIF(QT_QMAKE_EXECUTABLE) + # Set QT_QT_INCLUDE_DIR by searching for qglobal.h + IF(QT_QMAKE_EXECUTABLE) + EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE} + ARGS "-query QT_INSTALL_HEADERS" + OUTPUT_VARIABLE qt_headers ) + SET(QT_HEADERS_DIR ${qt_headers} CACHE INTERNAL "") + ENDIF(QT_QMAKE_EXECUTABLE) ENDIF (NOT QT_HEADERS_DIR) FILE(GLOB GLOB_TEMP_VAR /usr/local/qt-x11-commercial-3*/include/Qt/) SET(QT_PATH_INCLUDE ${GLOB_TEMP_VAR}) @@ -190,125 +188,126 @@ FIND_PATH( QT_QT_INCLUDE_DIR qglobal.h "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/include/Qt" ${QT_PATH_INCLUDE} - ${QT_HEADERS_DIR}/Qt - ${QT_LIBRARY_DIR}/QtCore.framework/Headers + ${QT_HEADERS_DIR}/Qt + ${QT_LIBRARY_DIR}/QtCore.framework/Headers $ENV{QTDIR}/include/Qt /usr/local/qt/include/Qt /usr/local/include/Qt /usr/lib/qt/include/Qt /usr/include/Qt /usr/share/qt4/include/Qt - "C:/Program Files/qt/include/Qt" + "$ENV{ProgramFiles}/qt/include/Qt" + "C:/Program Files/qt/include/Qt" /usr/include/qt4/Qt) # Set QT_INCLUDE_DIR by removine "/Qt" in the string ${QT_QT_INCLUDE_DIR} IF( QT_QT_INCLUDE_DIR AND NOT QT_INCLUDE_DIR) - IF (QT_USE_FRAMEWORKS) - SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR}) - ELSE (QT_USE_FRAMEWORKS) - STRING( REGEX REPLACE "/Qt$" "" qt4_include_dir ${QT_QT_INCLUDE_DIR}) - SET( QT_INCLUDE_DIR ${qt4_include_dir} CACHE PATH "") - ENDIF (QT_USE_FRAMEWORKS) + IF (QT_USE_FRAMEWORKS) + SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR}) + ELSE (QT_USE_FRAMEWORKS) + STRING( REGEX REPLACE "/Qt$" "" qt4_include_dir ${QT_QT_INCLUDE_DIR}) + SET( QT_INCLUDE_DIR ${qt4_include_dir} CACHE PATH "") + ENDIF (QT_USE_FRAMEWORKS) ENDIF( QT_QT_INCLUDE_DIR AND NOT QT_INCLUDE_DIR) IF( NOT QT_INCLUDE_DIR) - IF( NOT Qt_FIND_QUIETLY AND Qt_FIND_REQUIRED) - MESSAGE( SEND_ERROR "Could not find qglobal.h") - ENDIF( NOT Qt_FIND_QUIETLY AND Qt_FIND_REQUIRED) + IF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED) + MESSAGE( FATAL_ERROR "Could not find qglobal.h") + ENDIF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED) ENDIF( NOT QT_INCLUDE_DIR) IF (QT_USE_FRAMEWORKS) - SET(QT_DEFINITIONS ${QT_DEFINITIONS} - -F${QT_LIBRARY_DIR} - ) + SET(QT_DEFINITIONS ${QT_DEFINITIONS} + -F${QT_LIBRARY_DIR} + ) ENDIF (QT_USE_FRAMEWORKS) # Set QT_QT3SUPPORT_INCLUDE_DIR FIND_PATH( QT_QT3SUPPORT_INCLUDE_DIR Qt3Support - ${QT_INCLUDE_DIR}/Qt3Support - ${QT_LIBRARY_DIR}/Qt3Support.framework/Headers - ) + ${QT_INCLUDE_DIR}/Qt3Support + ${QT_LIBRARY_DIR}/Qt3Support.framework/Headers + ) # Set QT_QTCORE_INCLUDE_DIR FIND_PATH( QT_QTCORE_INCLUDE_DIR QtCore - ${QT_INCLUDE_DIR}/QtCore - ${QT_LIBRARY_DIR}/QtCore.framework/Headers - ) + ${QT_INCLUDE_DIR}/QtCore + ${QT_LIBRARY_DIR}/QtCore.framework/Headers + ) # Set QT_QTGUI_INCLUDE_DIR FIND_PATH( QT_QTGUI_INCLUDE_DIR QtGui - ${QT_INCLUDE_DIR}/QtGui - ${QT_LIBRARY_DIR}/QtGui.framework/Headers - ) + ${QT_INCLUDE_DIR}/QtGui + ${QT_LIBRARY_DIR}/QtGui.framework/Headers + ) # Set QT_QTMOTIF_INCLUDE_DIR FIND_PATH( QT_QTMOTIF_INCLUDE_DIR QtMotif ${QT_INCLUDE_DIR}/QtMotif) # Set QT_QTNETWORK_INCLUDE_DIR FIND_PATH( QT_QTNETWORK_INCLUDE_DIR QtNetwork - ${QT_INCLUDE_DIR}/QtNetwork - ${QT_LIBRARY_DIR}/QtNetwork.framework/Headers - ) + ${QT_INCLUDE_DIR}/QtNetwork + ${QT_LIBRARY_DIR}/QtNetwork.framework/Headers + ) # Set QT_QTNSPLUGIN_INCLUDE_DIR FIND_PATH( QT_QTNSPLUGIN_INCLUDE_DIR QtNsPlugin - ${QT_INCLUDE_DIR}/QtNsPlugin - ${QT_LIBRARY_DIR}/QtNsPlugin.framework/Headers - ) + ${QT_INCLUDE_DIR}/QtNsPlugin + ${QT_LIBRARY_DIR}/QtNsPlugin.framework/Headers + ) # Set QT_QTOPENGL_INCLUDE_DIR FIND_PATH( QT_QTOPENGL_INCLUDE_DIR QtOpenGL - ${QT_INCLUDE_DIR}/QtOpenGL - ${QT_LIBRARY_DIR}/QtOpenGL.framework/Headers - ) + ${QT_INCLUDE_DIR}/QtOpenGL + ${QT_LIBRARY_DIR}/QtOpenGL.framework/Headers + ) # Set QT_QTSQL_INCLUDE_DIR FIND_PATH( QT_QTSQL_INCLUDE_DIR QtSql - ${QT_INCLUDE_DIR}/QtSql - ${QT_LIBRARY_DIR}/QtSql.framework/Headers - ) + ${QT_INCLUDE_DIR}/QtSql + ${QT_LIBRARY_DIR}/QtSql.framework/Headers + ) # Set QT_QTXML_INCLUDE_DIR FIND_PATH( QT_QTXML_INCLUDE_DIR QtXml - ${QT_INCLUDE_DIR}/QtXml - ${QT_LIBRARY_DIR}/QtXml.framework/Headers - ) + ${QT_INCLUDE_DIR}/QtXml + ${QT_LIBRARY_DIR}/QtXml.framework/Headers + ) # Set QT_QTASSISTANT_INCLUDE_DIR FIND_PATH( QT_QTASSISTANT_INCLUDE_DIR QtAssistant - ${QT_INCLUDE_DIR}/QtAssistant - ${QT_HEADERS_DIR}/QtAssistant - ) + ${QT_INCLUDE_DIR}/QtAssistant + ${QT_HEADERS_DIR}/QtAssistant + ) # Set QT_QTDESIGNER_INCLUDE_DIR FIND_PATH( QT_QTDESIGNER_INCLUDE_DIR QDesignerComponents - ${QT_INCLUDE_DIR}/QtDesigner - ${QT_HEADERS_DIR}/QtDesigner - ) + ${QT_INCLUDE_DIR}/QtDesigner + ${QT_HEADERS_DIR}/QtDesigner + ) # Make variables changeble to the advanced user MARK_AS_ADVANCED( - QT_LIBRARY_DIR - QT_INCLUDE_DIR - QT_QT_INCLUDE_DIR - QT_QT3SUPPORT_INCLUDE_DIR - QT_QTASSISTANT_INCLUDE_DIR - QT_QTCORE_INCLUDE_DIR - QT_QTDESIGNER_INCLUDE_DIR - QT_QTGUI_INCLUDE_DIR - QT_QTMOTIF_INCLUDE_DIR - QT_QTNETWORK_INCLUDE_DIR - QT_QTNSPLUGIN_INCLUDE_DIR - QT_QTOPENGL_INCLUDE_DIR - QT_QTSQL_INCLUDE_DIR - QT_QTXML_INCLUDE_DIR - ) + QT_LIBRARY_DIR + QT_INCLUDE_DIR + QT_QT_INCLUDE_DIR + QT_QT3SUPPORT_INCLUDE_DIR + QT_QTASSISTANT_INCLUDE_DIR + QT_QTCORE_INCLUDE_DIR + QT_QTDESIGNER_INCLUDE_DIR + QT_QTGUI_INCLUDE_DIR + QT_QTMOTIF_INCLUDE_DIR + QT_QTNETWORK_INCLUDE_DIR + QT_QTNSPLUGIN_INCLUDE_DIR + QT_QTOPENGL_INCLUDE_DIR + QT_QTSQL_INCLUDE_DIR + QT_QTXML_INCLUDE_DIR + ) # Set QT_INCLUDES SET( QT_INCLUDES - ${QT_INCLUDE_DIR} - ${QT_QTCORE_INCLUDE_DIR} + ${QT_INCLUDE_DIR} + ${QT_QTCORE_INCLUDE_DIR} ${QT_QT_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} ) # append optional flags MACRO(QT4_APPEND_INCLUDES_FLAG FLAG) @@ -335,99 +334,99 @@ ######################################## IF (QT_USE_FRAMEWORKS) - # If FIND_LIBRARY found libraries in Apple frameworks, we would not have - # to jump through these hoops. - SET(QT_QTCORE_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtCore" - CACHE STRING "The QtCore library.") - SET(QT_QTCORE_LIBRARY_DEBUG "-F${QT_LIBRARY_DIR} -framework QtCore" - CACHE STRING "The QtCore library.") - SET(QT_QT3SUPPORT_LIBRARY "-framework Qt3Support" - CACHE STRING "The Qt3Support library.") - SET(QT_QT3SUPPORT_LIBRARY_DEBUG "-framework Qt3Support" - CACHE STRING "The Qt3Support library.") - SET(QT_QTGUI_LIBRARY "-framework QtGui" - CACHE STRING "The QtGui library.") - SET(QT_QTGUI_LIBRARY_DEBUG "-framework QtGui" - CACHE STRING "The QtGui library.") - SET(QT_QTNETWORK_LIBRARY "-framework QtNetwork" - CACHE STRING "The QtNetwork library.") - SET(QT_QTNETWORK_LIBRARY_DEBUG "-framework QtNetwork" - CACHE STRING "The QtNetwork library.") - SET(QT_QTOPENGL_LIBRARY "-framework QtOpenGL" - CACHE STRING "The QtOpenGL library.") + # If FIND_LIBRARY found libraries in Apple frameworks, we would not have + # to jump through these hoops. + SET(QT_QTCORE_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtCore" + CACHE STRING "The QtCore library.") + SET(QT_QTCORE_LIBRARY_DEBUG "-F${QT_LIBRARY_DIR} -framework QtCore" + CACHE STRING "The QtCore library.") + SET(QT_QT3SUPPORT_LIBRARY "-framework Qt3Support" + CACHE STRING "The Qt3Support library.") + SET(QT_QT3SUPPORT_LIBRARY_DEBUG "-framework Qt3Support" + CACHE STRING "The Qt3Support library.") + SET(QT_QTGUI_LIBRARY "-framework QtGui" + CACHE STRING "The QtGui library.") + SET(QT_QTGUI_LIBRARY_DEBUG "-framework QtGui" + CACHE STRING "The QtGui library.") + SET(QT_QTNETWORK_LIBRARY "-framework QtNetwork" + CACHE STRING "The QtNetwork library.") + SET(QT_QTNETWORK_LIBRARY_DEBUG "-framework QtNetwork" + CACHE STRING "The QtNetwork library.") + SET(QT_QTOPENGL_LIBRARY "-framework QtOpenGL" + CACHE STRING "The QtOpenGL library.") SET(QT_QTOPENGL_LIBRARY_DEBUG "-framework QtOpenGL" - CACHE STRING "The QtOpenGL library.") - SET(QT_QTSQL_LIBRARY "-framework QtSql" - CACHE STRING "The QtSql library.") - SET(QT_QTSQL_LIBRARY_DEBUG "-framework QtSql" - CACHE STRING "The QtSql library.") - SET(QT_QTXML_LIBRARY "-framework QtXml" - CACHE STRING "The QtXml library.") - SET(QT_QTXML_LIBRARY_DEBUG "-framework QtXml" - CACHE STRING "The QtXml library.") + CACHE STRING "The QtOpenGL library.") + SET(QT_QTSQL_LIBRARY "-framework QtSql" + CACHE STRING "The QtSql library.") + SET(QT_QTSQL_LIBRARY_DEBUG "-framework QtSql" + CACHE STRING "The QtSql library.") + SET(QT_QTXML_LIBRARY "-framework QtXml" + CACHE STRING "The QtXml library.") + SET(QT_QTXML_LIBRARY_DEBUG "-framework QtXml" + CACHE STRING "The QtXml library.") ELSE (QT_USE_FRAMEWORKS) - - # Set QT_QTCORE_LIBRARY by searching for a lib with "QtCore." as part of - # the filename - FIND_LIBRARY( QT_QTCORE_LIBRARY - NAMES QtCore QtCore4 - PATHS - ${QT_LIBRARY_DIR} - $ENV{QTDIR}/lib - /usr/local/qt/lib - /usr/local/lib - /usr/lib/qt/lib - /usr/lib - /usr/share/qt4/lib - C:/Progra~1/qt/lib - /usr/lib/qt4 ) - - # Set QT_QTCORE_LIBRARY_DEBUG by searching for a lib with "QtCore_debug" - # as part of the filename - FIND_LIBRARY( QT_QTCORE_LIBRARY_DEBUG - NAMES QtCore_debug QtCored4 - PATHS - ${QT_LIBRARY_DIR} - $ENV{QTDIR}/lib - /usr/local/qt/lib - /usr/local/lib - /usr/lib/qt/lib - /usr/lib - /usr/share/qt4/lib - C:/Progra~1/qt/lib - /usr/lib/qt4 ) - - # Set QT_QT3SUPPORT_LIBRARY - FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY NAMES Qt3Support Qt3Support4 PATHS ${QT_LIBRARY_DIR}) - FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_DEBUG NAMES Qt3Support_debug Qt3Supportd4 PATHS ${QT_LIBRARY_DIR}) - - # Set QT_QTGUI_LIBRARY - FIND_LIBRARY(QT_QTGUI_LIBRARY NAMES QtGui QtGui4 PATHS ${QT_LIBRARY_DIR}) - FIND_LIBRARY(QT_QTGUI_LIBRARY_DEBUG NAMES QtGui_debug QtGuid4 PATHS ${QT_LIBRARY_DIR}) - - # Set QT_QTMOTIF_LIBRARY - FIND_LIBRARY(QT_QTMOTIF_LIBRARY NAMES QtMotif PATHS ${QT_LIBRARY_DIR}) - FIND_LIBRARY(QT_QTMOTIF_LIBRARY_DEBUG NAMES QtMotif_debug PATHS ${QT_LIBRARY_DIR}) + + # Set QT_QTCORE_LIBRARY by searching for a lib with "QtCore." as part of + # the filename + FIND_LIBRARY( QT_QTCORE_LIBRARY + NAMES QtCore QtCore4 + PATHS + ${QT_LIBRARY_DIR} + $ENV{QTDIR}/lib + /usr/local/qt/lib + /usr/local/lib + /usr/lib/qt/lib + /usr/lib + /usr/share/qt4/lib + C:/Progra~1/qt/lib + /usr/lib/qt4 ) + + # Set QT_QTCORE_LIBRARY_DEBUG by searching for a lib with "QtCore_debug" + # as part of the filename + FIND_LIBRARY( QT_QTCORE_LIBRARY_DEBUG + NAMES QtCore_debug QtCored4 + PATHS + ${QT_LIBRARY_DIR} + $ENV{QTDIR}/lib + /usr/local/qt/lib + /usr/local/lib + /usr/lib/qt/lib + /usr/lib + /usr/share/qt4/lib + C:/Progra~1/qt/lib + /usr/lib/qt4 ) + + # Set QT_QT3SUPPORT_LIBRARY + FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY NAMES Qt3Support Qt3Support4 PATHS ${QT_LIBRARY_DIR}) + FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_DEBUG NAMES Qt3Support_debug Qt3Supportd4 PATHS ${QT_LIBRARY_DIR}) + + # Set QT_QTGUI_LIBRARY + FIND_LIBRARY(QT_QTGUI_LIBRARY NAMES QtGui QtGui4 PATHS ${QT_LIBRARY_DIR}) + FIND_LIBRARY(QT_QTGUI_LIBRARY_DEBUG NAMES QtGui_debug QtGuid4 PATHS ${QT_LIBRARY_DIR}) + + # Set QT_QTMOTIF_LIBRARY + FIND_LIBRARY(QT_QTMOTIF_LIBRARY NAMES QtMotif PATHS ${QT_LIBRARY_DIR}) + FIND_LIBRARY(QT_QTMOTIF_LIBRARY_DEBUG NAMES QtMotif_debug PATHS ${QT_LIBRARY_DIR}) # Set QT_QTNETWORK_LIBRARY - FIND_LIBRARY(QT_QTNETWORK_LIBRARY NAMES QtNetwork QtNetwork4 PATHS ${QT_LIBRARY_DIR}) - FIND_LIBRARY(QT_QTNETWORK_LIBRARY_DEBUG NAMES QtNetwork_debug QtNetworkd4 PATHS ${QT_LIBRARY_DIR}) + FIND_LIBRARY(QT_QTNETWORK_LIBRARY NAMES QtNetwork QtNetwork4 PATHS ${QT_LIBRARY_DIR}) + FIND_LIBRARY(QT_QTNETWORK_LIBRARY_DEBUG NAMES QtNetwork_debug QtNetworkd4 PATHS ${QT_LIBRARY_DIR}) # Set QT_QTNSPLUGIN_LIBRARY - FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY NAMES QtNsPlugin PATHS ${QT_LIBRARY_DIR}) - FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY_DEBUG NAMES QtNsPlugin_debug PATHS ${QT_LIBRARY_DIR}) + FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY NAMES QtNsPlugin PATHS ${QT_LIBRARY_DIR}) + FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY_DEBUG NAMES QtNsPlugin_debug PATHS ${QT_LIBRARY_DIR}) # Set QT_QTOPENGL_LIBRARY - FIND_LIBRARY(QT_QTOPENGL_LIBRARY NAMES QtOpenGL QtOpenGL4 PATHS ${QT_LIBRARY_DIR}) - FIND_LIBRARY(QT_QTOPENGL_LIBRARY_DEBUG NAMES QtOpenGL_debug QtOpenGLd4 PATHS ${QT_LIBRARY_DIR}) + FIND_LIBRARY(QT_QTOPENGL_LIBRARY NAMES QtOpenGL QtOpenGL4 PATHS ${QT_LIBRARY_DIR}) + FIND_LIBRARY(QT_QTOPENGL_LIBRARY_DEBUG NAMES QtOpenGL_debug QtOpenGLd4 PATHS ${QT_LIBRARY_DIR}) # Set QT_QTSQL_LIBRARY - FIND_LIBRARY(QT_QTSQL_LIBRARY NAMES QtSql QtSql4 PATHS ${QT_LIBRARY_DIR}) - FIND_LIBRARY(QT_QTSQL_LIBRARY_DEBUG NAMES QtSql_debug QtSqld4 PATHS ${QT_LIBRARY_DIR}) + FIND_LIBRARY(QT_QTSQL_LIBRARY NAMES QtSql QtSql4 PATHS ${QT_LIBRARY_DIR}) + FIND_LIBRARY(QT_QTSQL_LIBRARY_DEBUG NAMES QtSql_debug QtSqld4 PATHS ${QT_LIBRARY_DIR}) # Set QT_QTXML_LIBRARY - FIND_LIBRARY(QT_QTXML_LIBRARY NAMES QtXml QtXml4 PATHS ${QT_LIBRARY_DIR}) - FIND_LIBRARY(QT_QTXML_LIBRARY_DEBUG NAMES QtXml_debug QtXmld4 PATHS ${QT_LIBRARY_DIR}) + FIND_LIBRARY(QT_QTXML_LIBRARY NAMES QtXml QtXml4 PATHS ${QT_LIBRARY_DIR}) + FIND_LIBRARY(QT_QTXML_LIBRARY_DEBUG NAMES QtXml_debug QtXmld4 PATHS ${QT_LIBRARY_DIR}) ENDIF (QT_USE_FRAMEWORKS) @@ -441,31 +440,31 @@ # Make variables changeble to the advanced user MARK_AS_ADVANCED( - QT_QT3SUPPORT_LIBRARY - QT_QTASSISTANT_LIBRARY - QT_QTCORE_LIBRARY - QT_QTDESIGNER_LIBRARY - QT_QTGUI_LIBRARY - QT_QTMOTIF_LIBRARY - QT_QTNETWORK_LIBRARY - QT_QTNSPLUGIN_LIBRARY - QT_QTOPENGL_LIBRARY - QT_QTSQL_LIBRARY - QT_QTXML_LIBRARY ) + QT_QT3SUPPORT_LIBRARY + QT_QTASSISTANT_LIBRARY + QT_QTCORE_LIBRARY + QT_QTDESIGNER_LIBRARY + QT_QTGUI_LIBRARY + QT_QTMOTIF_LIBRARY + QT_QTNETWORK_LIBRARY + QT_QTNSPLUGIN_LIBRARY + QT_QTOPENGL_LIBRARY + QT_QTSQL_LIBRARY + QT_QTXML_LIBRARY ) # Make variables changeble to the advanced user MARK_AS_ADVANCED( - QT_QT3SUPPORT_LIBRARY_DEBUG - QT_QTASSISTANT_LIBRARY_DEBUG - QT_QTCORE_LIBRARY_DEBUG - QT_QTDESIGNER_LIBRARY_DEBUG - QT_QTGUI_LIBRARY_DEBUG - QT_QTMOTIF_LIBRARY_DEBUG - QT_QTNETWORK_LIBRARY_DEBUG - QT_QTNSPLUGIN_LIBRARY_DEBUG - QT_QTOPENGL_LIBRARY_DEBUG - QT_QTSQL_LIBRARY_DEBUG - QT_QTXML_LIBRARY_DEBUG ) + QT_QT3SUPPORT_LIBRARY_DEBUG + QT_QTASSISTANT_LIBRARY_DEBUG + QT_QTCORE_LIBRARY_DEBUG + QT_QTDESIGNER_LIBRARY_DEBUG + QT_QTGUI_LIBRARY_DEBUG + QT_QTMOTIF_LIBRARY_DEBUG + QT_QTNETWORK_LIBRARY_DEBUG + QT_QTNSPLUGIN_LIBRARY_DEBUG + QT_QTOPENGL_LIBRARY_DEBUG + QT_QTSQL_LIBRARY_DEBUG + QT_QTXML_LIBRARY_DEBUG ) ############################################ # @@ -577,7 +576,7 @@ ) IF(QT_MOC_EXECUTABLE) - SET ( QT_WRAP_CPP "YES") + SET ( QT_WRAP_CPP "YES") ENDIF(QT_MOC_EXECUTABLE) FIND_PROGRAM(QT_UIC_EXECUTABLE @@ -595,7 +594,7 @@ ) IF(QT_UIC_EXECUTABLE) - SET ( QT_WRAP_UI "YES") + SET ( QT_WRAP_UI "YES") ENDIF(QT_UIC_EXECUTABLE) FIND_PROGRAM(QT_RCC_EXECUTABLE @@ -613,9 +612,9 @@ ) MARK_AS_ADVANCED( - QT_UIC_EXECUTABLE - QT_MOC_EXECUTABLE - QT_RCC_EXECUTABLE ) + QT_UIC_EXECUTABLE + QT_MOC_EXECUTABLE + QT_RCC_EXECUTABLE ) ###################################### # @@ -629,24 +628,24 @@ MACRO(QT4_WRAP_CPP outfiles ) - # get include dirs - GET_DIRECTORY_PROPERTY(moc_includes_tmp INCLUDE_DIRECTORIES) - SET(moc_includes) - FOREACH(it ${moc_includes_tmp}) - SET(moc_includes ${moc_includes} "-I${it}") - ENDFOREACH(it) - - FOREACH(it ${ARGN}) - GET_FILENAME_COMPONENT(outfile ${it} NAME_WE) - - SET(infile ${CMAKE_CURRENT_SOURCE_DIR}/${it}) - SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/moc_${outfile}.cxx) - ADD_CUSTOM_COMMAND(OUTPUT ${outfile} - COMMAND ${QT_MOC_EXECUTABLE} - ARGS ${moc_includes} -o ${outfile} ${infile} - MAIN_DEPENDENCY ${infile}) - SET(${outfiles} ${${outfiles}} ${outfile}) - ENDFOREACH(it) + # get include dirs + GET_DIRECTORY_PROPERTY(moc_includes_tmp INCLUDE_DIRECTORIES) + SET(moc_includes) + FOREACH(it ${moc_includes_tmp}) + SET(moc_includes ${moc_includes} "-I${it}") + ENDFOREACH(it) + + FOREACH(it ${ARGN}) + GET_FILENAME_COMPONENT(outfile ${it} NAME_WE) + + SET(infile ${CMAKE_CURRENT_SOURCE_DIR}/${it}) + SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/moc_${outfile}.cxx) + ADD_CUSTOM_COMMAND(OUTPUT ${outfile} + COMMAND ${QT_MOC_EXECUTABLE} + ARGS ${moc_includes} -o ${outfile} ${infile} + MAIN_DEPENDENCY ${infile}) + SET(${outfiles} ${${outfiles}} ${outfile}) + ENDFOREACH(it) ENDMACRO(QT4_WRAP_CPP) @@ -655,16 +654,16 @@ MACRO(QT4_WRAP_UI outfiles ) - FOREACH(it ${ARGN}) - GET_FILENAME_COMPONENT(outfile ${it} NAME_WE) - SET(infile ${CMAKE_CURRENT_SOURCE_DIR}/${it}) - SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h) - ADD_CUSTOM_COMMAND(OUTPUT ${outfile} - COMMAND ${QT_UIC_EXECUTABLE} - ARGS -o ${outfile} ${infile} - MAIN_DEPENDENCY ${infile}) - SET(${outfiles} ${${outfiles}} ${outfile}) - ENDFOREACH(it) + FOREACH(it ${ARGN}) + GET_FILENAME_COMPONENT(outfile ${it} NAME_WE) + SET(infile ${CMAKE_CURRENT_SOURCE_DIR}/${it}) + SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h) + ADD_CUSTOM_COMMAND(OUTPUT ${outfile} + COMMAND ${QT_UIC_EXECUTABLE} + ARGS -o ${outfile} ${infile} + MAIN_DEPENDENCY ${infile}) + SET(${outfiles} ${${outfiles}} ${outfile}) + ENDFOREACH(it) ENDMACRO(QT4_WRAP_UI) @@ -673,16 +672,16 @@ MACRO(QT4_ADD_RESOURCES outfiles ) - FOREACH(it ${ARGN}) - GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE) - SET(infile ${CMAKE_CURRENT_SOURCE_DIR}/${it}) - SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx) - ADD_CUSTOM_COMMAND(OUTPUT ${outfile} - COMMAND ${QT_RCC_EXECUTABLE} - ARGS -name ${outfilename} -o ${outfile} ${infile} - MAIN_DEPENDENCY ${infile} ) - SET(${outfiles} ${${outfiles}} ${outfile}) - ENDFOREACH(it) + FOREACH(it ${ARGN}) + GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE) + SET(infile ${CMAKE_CURRENT_SOURCE_DIR}/${it}) + SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx) + ADD_CUSTOM_COMMAND(OUTPUT ${outfile} + COMMAND ${QT_RCC_EXECUTABLE} + ARGS -name ${outfilename} -o ${outfile} ${infile} + MAIN_DEPENDENCY ${infile} ) + SET(${outfiles} ${${outfiles}} ${outfile}) + ENDFOREACH(it) ENDMACRO(QT4_ADD_RESOURCES) @@ -690,20 +689,20 @@ ###################################### # - # deside if Qt got found + # decide if Qt got found # ###################################### # if the includes,libraries,moc,uic and rcc are found then we have it IF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE) SET( QT4_FOUND "YES" ) - IF( NOT Qt_FIND_QUIETLY) - MESSAGE(STATUS "Found Qt-Version ${QT_INST_MAJOR_VERSION}.${QT_INST_MINOR_VERSION}.${QT_INST_PATCH_VERSION}") - ENDIF( NOT Qt_FIND_QUIETLY) + IF( NOT Qt4_FIND_QUIETLY) + MESSAGE(STATUS "Found Qt-Version ${QTVERSION}") + ENDIF( NOT Qt4_FIND_QUIETLY) ELSE( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE) SET( QT4_FOUND "NO") - IF( Qt_FIND_REQUIRED) - MESSAGE( SEND_ERROR "Qt libraries, includes, moc, uic or/and rcc NOT found!") - ENDIF( Qt_FIND_REQUIRED) + IF( Qt4_FIND_REQUIRED) + MESSAGE( FATAL_ERROR "Qt libraries, includes, moc, uic or/and rcc NOT found!") + ENDIF( Qt4_FIND_REQUIRED) ENDIF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE) SET(QT_FOUND ${QT4_FOUND}) @@ -715,7 +714,7 @@ ####################################### # for unix add X11 stuff IF(UNIX) - FIND_PACKAGE(X11) + FIND_PACKAGE(X11) ENDIF(UNIX) @@ -732,7 +731,10 @@ SET( QT_QTMAIN_LIBRARY "") ELSE(QT4_QMAKE_FOUND) IF(QT_QMAKE_EXECUTABLE) - MESSAGE("QT_QMAKE_EXECUTABLE set to qmake version: QTVERSION = ${QTVERSION}\nQT_QMAKE_EXECUTABLE = ${QT_QMAKE_EXECUTABLE}, please set to path to qmake from qt4.") + MESSAGE("QT_QMAKE_EXECUTABLE set to qmake version: QTVERSION = ${QTVERSION}\nQT_QMAKE_EXECUTABLE = ${QT_QMAKE_EXECUTABLE}, please set to path to qmake from qt4.") ENDIF(QT_QMAKE_EXECUTABLE) + IF( Qt4_FIND_REQUIRED) + MESSAGE( FATAL_ERROR "Qt qmake not found!") + ENDIF( Qt4_FIND_REQUIRED) ENDIF(QT4_QMAKE_FOUND) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindQt.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindQt.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindQt.cmake 2005-09-16 04:38:36.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindQt.cmake 2006-01-26 01:16:49.000000000 +0800 @@ -1,21 +1,23 @@ -# searches for all installed versions of QT. +# - Searches for all installed versions of QT. # This should only be used if your project can work with multiple # versions of QT. If not, you should just directly use FindQt4 or FindQt3. -# -# If multiple versions of QT are found on the machine, then -# The user must set the option DESIRED_QT_VERSION to the version -# they want to use. If only one version of qt is found on the machine, -# then the DESIRED_QT_VERSION is set to that version and the -# matching FindQt3 or FindQt4 module is included. -# Once the user sets DESIRED_QT_VERSION, then the FindQt3 or FindQt4 module -# is included. +# If multiple versions of QT are found on the machine, then +# The user must set the option DESIRED_QT_VERSION to the version +# they want to use. If only one version of qt is found on the machine, +# then the DESIRED_QT_VERSION is set to that version and the +# matching FindQt3 or FindQt4 module is included. +# Once the user sets DESIRED_QT_VERSION, then the FindQt3 or FindQt4 module +# is included. +# +# QT_REQUIRED if this is set to TRUE then if CMake can +# not find QT4 or QT3 an error is raised +# and a message is sent to the user. # -# QT_REQUIRED if this is set to TRUE then if cmake can not find QT4 or QT3 -# an error is raised and a message is sent to the user. # DESIRED_QT_VERSION OPTION is created # QT4_INSTALLED is set to TRUE if qt4 is found. # QT3_INSTALLED is set to TRUE if qt3 is found. + # look for signs of qt3 installations FILE(GLOB GLOB_TEMP_VAR /usr/lib/qt-3*/bin/qmake) IF(GLOB_TEMP_VAR) @@ -58,23 +60,23 @@ IF(QT_QMAKE_EXECUTABLE_FINDQT) EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE_FINDQT} - ARGS "-query QT_INSTALL_HEADERS" - OUTPUT_VARIABLE qt_headers ) + ARGS "-query QT_INSTALL_HEADERS" + OUTPUT_VARIABLE qt_headers ) ENDIF(QT_QMAKE_EXECUTABLE_FINDQT) FIND_FILE( QT4_QGLOBAL_H_FILE qglobal.h "${QT_SEARCH_PATH}/Qt/include" "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/include/Qt" "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/include/Qt" - ${qt_headers}/Qt - $ENV{QTDIR}/include/Qt - /usr/local/qt/include/Qt - /usr/local/include/Qt - /usr/lib/qt/include/Qt - /usr/include/Qt - /usr/share/qt4/include/Qt - C:/Progra~1/qt/include/Qt ) - + ${qt_headers}/Qt + $ENV{QTDIR}/include/Qt + /usr/local/qt/include/Qt + /usr/local/include/Qt + /usr/lib/qt/include/Qt + /usr/include/Qt + /usr/share/qt4/include/Qt + C:/Progra~1/qt/include/Qt ) + IF(QT4_QGLOBAL_H_FILE) SET(QT4_INSTALLED TRUE) ENDIF(QT4_QGLOBAL_H_FILE) @@ -85,15 +87,15 @@ "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/include/Qt" "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/include/Qt" C:/Qt/3.3.3Educational/include - $ENV{QTDIR}/include - /usr/include/qt3/Qt - /usr/local/qt/include - /usr/local/include - /usr/lib/qt/include - /usr/include - /usr/share/qt3/include - C:/Progra~1/qt/include - /usr/include/qt3 ) + $ENV{QTDIR}/include + /usr/include/qt3/Qt + /usr/local/qt/include + /usr/local/include + /usr/lib/qt/include + /usr/include + /usr/share/qt3/include + C:/Progra~1/qt/include + /usr/include/qt3 ) IF(QT3_QGLOBAL_H_FILE) SET(QT3_INSTALLED TRUE) @@ -113,9 +115,13 @@ ENDIF(QT3_INSTALLED AND QT4_INSTALLED ) IF(DESIRED_QT_VERSION MATCHES 3) + SET(Qt3_FIND_REQUIRED ${Qt_FIND_REQUIRED}) + SET(Qt3_FIND_QUIETLY ${Qt_FIND_QUIETLY}) INCLUDE(FindQt3) ENDIF(DESIRED_QT_VERSION MATCHES 3) IF(DESIRED_QT_VERSION MATCHES 4) + SET(Qt4_FIND_REQUIRED ${Qt_FIND_REQUIRED}) + SET(Qt4_FIND_QUIETLY ${Qt_FIND_QUIETLY}) INCLUDE(FindQt4) ENDIF(DESIRED_QT_VERSION MATCHES 4) @@ -133,7 +139,7 @@ ENDIF(NOT QT_FOUND AND NOT DESIRED_QT_VERSION) IF(NOT QT_FOUND AND DESIRED_QT_VERSION) IF(QT_REQUIRED) - MESSAGE(SEND_ERROR "CMake was unable to find QT version: ${DESIRED_QT_VERSION}. Set advanced values QT_QMAKE_EXECUTABLE and QT${DESIRED_QT_VERSION}_QGLOBAL_FILE, if those are set then QT_QT_LIBRARY or QT_LIBRARY_DIR.") + MESSAGE(FATAL_ERROR "CMake was unable to find QT version: ${DESIRED_QT_VERSION}. Set advanced values QT_QMAKE_EXECUTABLE and QT${DESIRED_QT_VERSION}_QGLOBAL_FILE, if those are set then QT_QT_LIBRARY or QT_LIBRARY_DIR.") ELSE(QT_REQUIRED) MESSAGE( "CMake was unable to find desired QT version: ${DESIRED_QT_VERSION}. Set advanced values QT_QMAKE_EXECUTABLE and QT${DESIRED_QT_VERSION}_QGLOBAL_FILE.") ENDIF(QT_REQUIRED) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindQt.cmake.bak /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindQt.cmake.bak --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindQt.cmake.bak 2005-09-16 04:38:36.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindQt.cmake.bak 1970-01-01 08:00:00.000000000 +0800 @@ -1,141 +0,0 @@ -# searches for all installed versions of QT. -# This should only be used if your project can work with multiple -# versions of QT. If not, you should just directly use FindQt4 or FindQt3. -# -# If multiple versions of QT are found on the machine, then -# The user must set the option DESIRED_QT_VERSION to the version -# they want to use. If only one version of qt is found on the machine, -# then the DESIRED_QT_VERSION is set to that version and the -# matching FindQt3 or FindQt4 module is included. -# Once the user sets DESIRED_QT_VERSION, then the FindQt3 or FindQt4 module -# is included. -# -# QT_REQUIRED if this is set to TRUE then if cmake can not find QT4 or QT3 -# an error is raised and a message is sent to the user. -# DESIRED_QT_VERSION OPTION is created -# QT4_INSTALLED is set to TRUE if qt4 is found. -# QT3_INSTALLED is set to TRUE if qt3 is found. - -# look for signs of qt3 installations -FILE(GLOB GLOB_TEMP_VAR /usr/lib/qt-3*/bin/qmake) -IF(GLOB_TEMP_VAR) - SET(QT3_INSTALLED TRUE) -ENDIF(GLOB_TEMP_VAR) -SET(GLOB_TEMP_VAR) - -FILE(GLOB GLOB_TEMP_VAR /usr/local/qt-x11-commercial-3*/bin/qmake) -IF(GLOB_TEMP_VAR) - SET(QT3_INSTALLED TRUE) -ENDIF(GLOB_TEMP_VAR) -SET(GLOB_TEMP_VAR) - -# look for qt4 installations -FILE(GLOB GLOB_TEMP_VAR /usr/local/qt-x11-commercial-4*/bin/qmake) -IF(GLOB_TEMP_VAR) - SET(QT4_INSTALLED TRUE) -ENDIF(GLOB_TEMP_VAR) -SET(GLOB_TEMP_VAR) - -FILE(GLOB GLOB_TEMP_VAR /usr/local/Trolltech/Qt-4*/bin/qmake) -IF(GLOB_TEMP_VAR) - SET(QT4_INSTALLED TRUE) -ENDIF(GLOB_TEMP_VAR) -SET(GLOB_TEMP_VAR) - -# now find qmake -FIND_PROGRAM(QT_QMAKE_EXECUTABLE_FINDQT NAMES qmake PATHS "${QT_SEARCH_PATH}/bin" "$ENV{QTDIR}/bin") -IF(QT_QMAKE_EXECUTABLE_FINDQT) - EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE_FINDQT} ARGS "-query QT_VERSION" - OUTPUT_VARIABLE QTVERSION) - IF(QTVERSION MATCHES "4.*") - SET(QT4_INSTALLED TRUE) - ENDIF(QTVERSION MATCHES "4.*") - IF(QTVERSION MATCHES "Unknown") - SET(QT3_INSTALLED TRUE) - ENDIF(QTVERSION MATCHES "Unknown") -ENDIF(QT_QMAKE_EXECUTABLE_FINDQT) - -IF(QT_QMAKE_EXECUTABLE_FINDQT) - EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE_FINDQT} - ARGS "-query QT_INSTALL_HEADERS" - OUTPUT_VARIABLE qt_headers ) -ENDIF(QT_QMAKE_EXECUTABLE_FINDQT) - -FIND_FILE( QT4_QGLOBAL_H_FILE qglobal.h - "${QT_SEARCH_PATH}/Qt/include" - "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/include/Qt" - "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/include/Qt" - ${qt_headers}/Qt - $ENV{QTDIR}/include/Qt - /usr/local/qt/include/Qt - /usr/local/include/Qt - /usr/lib/qt/include/Qt - /usr/include/Qt - /usr/share/qt4/include/Qt - C:/Progra~1/qt/include/Qt ) - -IF(QT4_QGLOBAL_H_FILE) - SET(QT4_INSTALLED TRUE) -ENDIF(QT4_QGLOBAL_H_FILE) - -FIND_FILE( QT3_QGLOBAL_H_FILE qglobal.h - "${QT_SEARCH_PATH}/Qt/include" - "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.1;InstallDir]/include/Qt" - "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/include/Qt" - "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/include/Qt" - C:/Qt/3.3.3Educational/include - $ENV{QTDIR}/include - /usr/include/qt3/Qt - /usr/local/qt/include - /usr/local/include - /usr/lib/qt/include - /usr/include - /usr/share/qt3/include - C:/Progra~1/qt/include - /usr/include/qt3 ) - -IF(QT3_QGLOBAL_H_FILE) - SET(QT3_INSTALLED TRUE) -ENDIF(QT3_QGLOBAL_H_FILE) - -IF(QT3_INSTALLED AND QT4_INSTALLED ) - # force user to pick if we have both - SET(DESIRED_QT_VERSION 0 CACHE STRING "Pick a version of QT to use: 3 or 4") -ELSE(QT3_INSTALLED AND QT4_INSTALLED ) - # if only one found then pick that one - IF(QT3_INSTALLED) - SET(DESIRED_QT_VERSION 3 CACHE STRING "Pick a version of QT to use: 3 or 4") - ENDIF(QT3_INSTALLED) - IF(QT4_INSTALLED) - SET(DESIRED_QT_VERSION 4 CACHE STRING "Pick a version of QT to use: 3 or 4") - ENDIF(QT4_INSTALLED) -ENDIF(QT3_INSTALLED AND QT4_INSTALLED ) - -IF(DESIRED_QT_VERSION MATCHES 3) - INCLUDE(FindQt3) -ENDIF(DESIRED_QT_VERSION MATCHES 3) -IF(DESIRED_QT_VERSION MATCHES 4) - INCLUDE(FindQt4) -ENDIF(DESIRED_QT_VERSION MATCHES 4) - -IF(NOT QT3_INSTALLED AND NOT QT4_INSTALLED) - IF(QT_REQUIRED) - MESSAGE(SEND_ERROR "CMake was unable to find any QT versions, put qmake in your path, or set QT_QMAKE_EXECUTABLE.") - ENDIF(QT_REQUIRED) -ELSE(NOT QT3_INSTALLED AND NOT QT4_INSTALLED) - IF(NOT QT_FOUND AND NOT DESIRED_QT_VERSION) - IF(QT_REQUIRED) - MESSAGE(SEND_ERROR "Multiple versions of QT found please set DESIRED_QT_VERSION") - ELSE(QT_REQUIRED) - MESSAGE("Multiple versions of QT found please set DESIRED_QT_VERSION") - ENDIF(QT_REQUIRED) - ENDIF(NOT QT_FOUND AND NOT DESIRED_QT_VERSION) - IF(NOT QT_FOUND AND DESIRED_QT_VERSION) - IF(QT_REQUIRED) - MESSAGE(SEND_ERROR "CMake was unable to find QT version: ${DESIRED_QT_VERSION}. Set advanced values QT_QMAKE_EXECUTABLE and QT${DESIRED_QT_VERSION}_QGLOBAL_FILE, if those are set then QT_QT_LIBRARY or QT_LIBRARY_DIR.") - ELSE(QT_REQUIRED) - MESSAGE( "CMake was unable to find desired QT version: ${DESIRED_QT_VERSION}. Set advanced values QT_QMAKE_EXECUTABLE and QT${DESIRED_QT_VERSION}_QGLOBAL_FILE.") - ENDIF(QT_REQUIRED) - ENDIF(NOT QT_FOUND AND DESIRED_QT_VERSION) -ENDIF(NOT QT3_INSTALLED AND NOT QT4_INSTALLED) -MARK_AS_ADVANCED(QT3_QGLOBAL_H_FILE QT4_QGLOBAL_H_FILE QT_QMAKE_EXECUTABLE_FINDQT) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindRuby.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindRuby.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindRuby.cmake 2005-04-08 02:27:01.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindRuby.cmake 2005-12-16 03:17:42.000000000 +0800 @@ -1,10 +1,10 @@ -# +# - Find ruby # This module finds if RUBY is installed and determines where the include files # and libraries are. It also determines what the name of the library is. This # code sets the following variables: # -# RUBY_INCLUDE_PATH = path to where object.h can be found -# RUBY_EXECUTABLE = full path to the ruby binary +# RUBY_INCLUDE_PATH = path to where ruby.h can be found +# RUBY_EXECUTABLE = full path to the ruby binary # SET(RUBY_POSSIBLE_INCLUDE_PATHS diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSDL.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSDL.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSDL.cmake 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSDL.cmake 2005-12-16 03:17:42.000000000 +0800 @@ -1,14 +1,13 @@ -# Locate SDL library +# - Locate the SDL library # This module defines -# SDL_LIBRARY, the name of the library to link against -# SDL_FOUND, if false, do not try to link to SDL -# SDL_INCLUDE_DIR, where to find SDL.h +# SDL_LIBRARY, the library to link against +# SDL_FOUND, if false, do not try to link to SDL +# SDL_INCLUDE_DIR, where to find SDL.h # # Don't forget to include SDLmain.h and SDLmain.m your project for the # OS X framework based version. (Other versions link to -lSDLmain which # this module will try to find on your behalf.) Also for OS X, this # module will automatically add the -framework Cocoa on your behalf. -# # $SDLDIR is an environment variable that would # correspond to the ./configure --prefix=$SDLDIR # used in building SDL. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSDL.cmake.bak /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSDL.cmake.bak --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSDL.cmake.bak 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSDL.cmake.bak 1970-01-01 08:00:00.000000000 +0800 @@ -1,162 +0,0 @@ -# Locate SDL library -# This module defines -# SDL_LIBRARY, the name of the library to link against -# SDL_FOUND, if false, do not try to link to SDL -# SDL_INCLUDE_DIR, where to find SDL.h -# -# Don't forget to include SDLmain.h and SDLmain.m your project for the -# OS X framework based version. (Other versions link to -lSDLmain which -# this module will try to find on your behalf.) Also for OS X, this -# module will automatically add the -framework Cocoa on your behalf. -# -# $SDLDIR is an environment variable that would -# correspond to the ./configure --prefix=$SDLDIR -# used in building SDL. -# l.e.galup 9-20-02 -# -# Modified by Eric Wing. -# Added new modifications to recognize OS X frameworks and -# additional Unix paths (FreeBSD, etc). -# Also corrected the header search path to follow "proper" SDL guidelines. -# Added a search for SDLmain which is needed by some platforms. -# Added a search for threads which is needed by some platforms. -# Added needed compile switches for MinGW. -# -# On OSX, this will prefer the Framework version (if found) over others. -# People will have to manually change the cache values of -# SDL_LIBRARY to override this selection. -# -# Note that the header path has changed from SDL/SDL.h to just SDL.h -# This needed to change because "proper" SDL convention -# is #include "SDL.h", not . This is done for portability -# reasons because not all systems place things in SDL/ (see FreeBSD). -FIND_PATH(SDL_INCLUDE_DIR SDL.h - $ENV{SDLDIR}/include - ~/Library/Frameworks/SDL.framework/Headers - /Library/Frameworks/SDL.framework/Headers - /usr/local/include/SDL - /usr/include/SDL - /usr/local/include/SDL12 - /usr/local/include/SDL11 # FreeBSD ports - /usr/include/SDL12 - /usr/include/SDL11 - /usr/local/include - /usr/include - /sw/include/SDL # Fink - /sw/include - /opt/local/include/SDL # DarwinPorts - /opt/local/include - /opt/csw/include/SDL # Blastwave - /opt/csw/include - /opt/include/SDL - /opt/include - ) -# I'm not sure if I should do a special casing for Apple. It is -# unlikely that other Unix systems will find the framework path. -# But if they do ([Next|Open|GNU]Step?), -# do they want the -framework option also? -IF(${SDL_INCLUDE_DIR} MATCHES ".framework") - # The Cocoa framework must be linked into SDL because SDL is Cocoa based. - # Remember that the OS X framework version expects you to drop in - # SDLmain.h and SDLmain.m directly into your project. - # (Cocoa link moved to bottom of this script.) - # SET (SDL_LIBRARY "-framework SDL -framework Cocoa" CACHE STRING "SDL framework for OSX") - # SET(SDL_LIBRARY "-framework SDL" CACHE STRING "SDL framework for OSX") - # Extract the path the framework resides in so we can use it for the -F flag - STRING(REGEX REPLACE "(.*)/.*\\.framework/.*" "\\1" SDL_FRAMEWORK_PATH_TEMP ${SDL_INCLUDE_DIR}) - IF("${SDL_FRAMEWORK_PATH_TEMP}" STREQUAL "/Library/Frameworks" - OR "${SDL_FRAMEWORK_PATH_TEMP}" STREQUAL "/System/Library/Frameworks" - ) - # String is in default search path, don't need to use -F - SET(SDL_LIBRARY_TEMP "-framework SDL") - ELSE("${SDL_FRAMEWORK_PATH_TEMP}" STREQUAL "/Library/Frameworks" - OR "${SDL_FRAMEWORK_PATH_TEMP}" STREQUAL "/System/Library/Frameworks" - ) - # String is not /Library/Frameworks, need to use -F - SET(SDL_LIBRARY_TEMP "-F${SDL_FRAMEWORK_PATH_TEMP} -framework SDL") - ENDIF("${SDL_FRAMEWORK_PATH_TEMP}" STREQUAL "/Library/Frameworks" - OR "${SDL_FRAMEWORK_PATH_TEMP}" STREQUAL "/System/Library/Frameworks" - ) - # Clear the temp variable so nobody can see it - SET(SDL_FRAMEWORK_PATH_TEMP "" CACHE INTERNAL "") - -ELSE(${SDL_INCLUDE_DIR} MATCHES ".framework") - # SDL-1.1 is the name used by FreeBSD ports... - # don't confuse it for the version number. - FIND_LIBRARY(SDL_LIBRARY_TEMP - NAMES SDL SDL-1.1 - PATHS - $ENV{SDLDIR}/lib - /usr/local/lib - /usr/lib - /sw/lib - /opt/local/lib - /opt/csw/lib - /opt/lib - ) - # Non-OS X framework versions expect you to also dynamically link to - # SDLmain. This is mainly for Windows and OS X. Other platforms - # seem to provide SDLmain for compatibility even though they don't - # necessarily need it. - FIND_LIBRARY(SDLMAIN_LIBRARY - NAMES SDLmain SDLmain-1.1 - PATHS - $ENV{SDLDIR}/lib - /usr/local/lib - /usr/lib - /sw/lib - /opt/local/lib - /opt/csw/lib - /opt/lib - ) -ENDIF(${SDL_INCLUDE_DIR} MATCHES ".framework") - -# SDL may require threads on your system. -# The Apple build may not need an explicit flag because one of the -# frameworks may already provide it. -# But for non-OSX systems, I will use the CMake Threads package. -IF(NOT APPLE) - FIND_PACKAGE(Threads) -ENDIF(NOT APPLE) - -# MinGW needs an additional library, mwindows -# It's total link flags should look like -lmingw32 -lSDLmain -lSDL -lmwindows -# (Actually on second look, I think it only needs one of the m* libraries.) -IF(MINGW) - SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW") -ENDIF(MINGW) - -SET(SDL_FOUND "NO") -IF(SDL_LIBRARY) - # For SDLmain - IF(SDLMAIN_LIBRARY) - SET(SDL_LIBRARY_TEMP ${SDLMAIN_LIBRARY} ${SDL_LIBRARY_TEMP}) - ENDIF(SDLMAIN_LIBRARY) - - # For OS X, SDL uses Cocoa as a backend so it must link to Cocoa. - # CMake doesn't display the -framework Cocoa string in the UI even - # though it actually is there. I think it has something to do - # with the CACHE STRING. Maybe somebody else knows how to fix this. - # The problem is mainly cosmetic, and not a functional issue. - IF(APPLE) - SET(SDL_LIBRARY_TEMP ${SDL_LIBRARY_TEMP} "-framework Cocoa") - ENDIF(APPLE) - - # For threads, as mentioned Apple doesn't need this. - # In fact, there seems to be a problem if Find the threads package - # and try using this line, so I'm just skipping it entirely for OS X. - IF(NOT APPLE) - SET(SDL_LIBRARY_TEMP ${SDL_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT}) - ENDIF(NOT APPLE) - - # For MinGW library - IF(MINGW) - SET(SDL_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL_LIBRARY_TEMP}) - ENDIF(MINGW) - - # Set the final string here so the GUI reflects the final state. - SET(SDL_LIBRARY ${SDL_LIBRARY_TEMP} CACHE STRING "Where the SDL Library can be found") - - SET(SDL_FOUND "YES") -ENDIF(SDL_LIBRARY_TEMP) - diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSDL_image.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSDL_image.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSDL_image.cmake 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSDL_image.cmake 2005-12-16 03:17:42.000000000 +0800 @@ -1,8 +1,8 @@ -# Locate SDL_image library +# - Locate SDL_image library # This module defines -# SDLIMAGE_LIBRARY, the name of the library to link against -# SDLIMAGE_FOUND, if false, do not try to link to SDL -# SDLIMAGE_INCLUDE_DIR, where to find SDL/SDL.h +# SDLIMAGE_LIBRARY, the library to link against +# SDLIMAGE_FOUND, if false, do not try to link to SDL +# SDLIMAGE_INCLUDE_DIR, where to find SDL/SDL.h # # $SDLDIR is an environment variable that would # correspond to the ./configure --prefix=$SDLDIR diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSDL_image.cmake.bak /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSDL_image.cmake.bak --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSDL_image.cmake.bak 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSDL_image.cmake.bak 1970-01-01 08:00:00.000000000 +0800 @@ -1,55 +0,0 @@ -# Locate SDL_image library -# This module defines -# SDLIMAGE_LIBRARY, the name of the library to link against -# SDLIMAGE_FOUND, if false, do not try to link to SDL -# SDLIMAGE_INCLUDE_DIR, where to find SDL/SDL.h -# -# $SDLDIR is an environment variable that would -# correspond to the ./configure --prefix=$SDLDIR -# used in building SDL. -# -# Created by Eric Wing. This was influenced by the FindSDL.cmake -# module, but with modifications to recognize OS X frameworks and -# additional Unix paths (FreeBSD, etc). - -# On OSX, this will prefer the Framework version (if found) over others. -# People will have to manually change the cache values of -# SDLIMAGE_LIBRARY to override this selection. -FIND_PATH(SDLIMAGE_INCLUDE_DIR SDL_image.h - ~/Library/Frameworks/SDL_image.framework/Headers - /Library/Frameworks/SDL_image.framework/Headers - $ENV{SDLDIR}/include - $ENV{SDLIMAGEDIR}/include - /usr/include/SDL - /usr/include/SDL12 - /usr/include/SDL11 - /usr/include - /usr/local/include/SDL - /usr/local/include/SDL12 - /usr/local/include/SDL11 - /usr/local/include - /sw/include - ) -# I'm not sure if I should do a special casing for Apple. It is -# unlikely that other Unix systems will find the framework path. -# But if they do ([Next|Open|GNU]Step?), -# do they want the -framework option also? -IF(${SDLIMAGE_INCLUDE_DIR} MATCHES ".framework") - SET (SDLIMAGE_LIBRARY "-framework SDL_image" CACHE STRING "SDL_image framework for OSX") -ELSE(${SDLIMAGE_INCLUDE_DIR} MATCHES ".framework") - FIND_LIBRARY(SDLIMAGE_LIBRARY - NAMES SDL_image - PATHS - $ENV{SDLDIR}/lib - $ENV{SDLIMAGEDIR}/lib - /usr/lib - /usr/local/lib - /sw/lib - ) -ENDIF(${SDLIMAGE_INCLUDE_DIR} MATCHES ".framework") - -SET(SDLIMAGE_FOUND "NO") -IF(SDLIMAGE_LIBRARY) - SET(SDLIMAGE_FOUND "YES") -ENDIF(SDLIMAGE_LIBRARY) - diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSDL_mixer.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSDL_mixer.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSDL_mixer.cmake 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSDL_mixer.cmake 2005-12-16 03:17:42.000000000 +0800 @@ -1,8 +1,8 @@ -# Locate SDL_mixer library +# - Locate the SDL_mixer library # This module defines -# SDLMIXER_LIBRARY, the name of the library to link against -# SDLMIXER_FOUND, if false, do not try to link to SDL -# SDLMIXER_INCLUDE_DIR, where to find SDL/SDL.h +# SDLMIXER_LIBRARY, library to link against +# SDLMIXER_FOUND, if false, do not try to link to SDL +# SDLMIXER_INCLUDE_DIR, where to find SDL/SDL.h # # $SDLDIR is an environment variable that would # correspond to the ./configure --prefix=$SDLDIR diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSDL_mixer.cmake.bak /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSDL_mixer.cmake.bak --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSDL_mixer.cmake.bak 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSDL_mixer.cmake.bak 1970-01-01 08:00:00.000000000 +0800 @@ -1,55 +0,0 @@ -# Locate SDL_mixer library -# This module defines -# SDLMIXER_LIBRARY, the name of the library to link against -# SDLMIXER_FOUND, if false, do not try to link to SDL -# SDLMIXER_INCLUDE_DIR, where to find SDL/SDL.h -# -# $SDLDIR is an environment variable that would -# correspond to the ./configure --prefix=$SDLDIR -# used in building SDL. -# -# Created by Eric Wing. This was influenced by the FindSDL.cmake -# module, but with modifications to recognize OS X frameworks and -# additional Unix paths (FreeBSD, etc). - -# On OSX, this will prefer the Framework version (if found) over others. -# People will have to manually change the cache values of -# SDLMIXER_LIBRARY to override this selection. -FIND_PATH(SDLMIXER_INCLUDE_DIR SDL_mixer.h - ~/Library/Frameworks/SDL_mixer.framework/Headers - /Library/Frameworks/SDL_mixer.framework/Headers - $ENV{SDLDIR}/include - $ENV{SDLMIXERDIR}/include - /usr/include/SDL - /usr/include/SDL12 - /usr/include/SDL11 - /usr/include - /usr/local/include/SDL - /usr/local/include/SDL12 - /usr/local/include/SDL11 - /usr/local/include - /sw/include - ) -# I'm not sure if I should do a special casing for Apple. It is -# unlikely that other Unix systems will find the framework path. -# But if they do ([Next|Open|GNU]Step?), -# do they want the -framework option also? -IF(${SDLMIXER_INCLUDE_DIR} MATCHES ".framework") - SET (SDLMIXER_LIBRARY "-framework SDL_mixer" CACHE STRING "SDL_mixer framework for OSX") -ELSE(${SDLMIXER_INCLUDE_DIR} MATCHES ".framework") - FIND_LIBRARY(SDLMIXER_LIBRARY - NAMES SDL_mixer - PATHS - $ENV{SDLDIR}/lib - $ENV{SDLMIXERDIR}/lib - /usr/lib - /usr/local/lib - /sw/lib - ) -ENDIF(${SDLMIXER_INCLUDE_DIR} MATCHES ".framework") - -SET(SDLMIXER_FOUND "NO") -IF(SDLMIXER_LIBRARY) - SET(SDLMIXER_FOUND "YES") -ENDIF(SDLMIXER_LIBRARY) - diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSDL_net.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSDL_net.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSDL_net.cmake 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSDL_net.cmake 2005-12-16 03:17:43.000000000 +0800 @@ -1,17 +1,16 @@ -# Locate SDL_net library +# - Locate the SDL_net library # This module defines -# SDLNET_LIBRARY, the name of the library to link against -# SDLNET_FOUND, if false, do not try to link against -# SDLNET_INCLUDE_DIR, where to find the headers -# +# SDLNET_LIBRARY, the library to link against +# SDLNET_FOUND, if false, do not try to link against +# SDLNET_INCLUDE_DIR, where to find the headers +# # $SDLDIR is an environment variable that would # correspond to the ./configure --prefix=$SDLDIR # used in building SDL. -# +# # Created by Eric Wing. This was influenced by the FindSDL.cmake # module, but with modifications to recognize OS X frameworks and # additional Unix paths (FreeBSD, etc). - # On OSX, this will prefer the Framework version (if found) over others. # People will have to manually change the cache values of # SDLNET_LIBRARY to override this selection. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSDL_net.cmake.bak /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSDL_net.cmake.bak --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSDL_net.cmake.bak 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSDL_net.cmake.bak 1970-01-01 08:00:00.000000000 +0800 @@ -1,55 +0,0 @@ -# Locate SDL_net library -# This module defines -# SDLNET_LIBRARY, the name of the library to link against -# SDLNET_FOUND, if false, do not try to link against -# SDLNET_INCLUDE_DIR, where to find the headers -# -# $SDLDIR is an environment variable that would -# correspond to the ./configure --prefix=$SDLDIR -# used in building SDL. -# -# Created by Eric Wing. This was influenced by the FindSDL.cmake -# module, but with modifications to recognize OS X frameworks and -# additional Unix paths (FreeBSD, etc). - -# On OSX, this will prefer the Framework version (if found) over others. -# People will have to manually change the cache values of -# SDLNET_LIBRARY to override this selection. -FIND_PATH(SDLNET_INCLUDE_DIR SDL_net.h - ~/Library/Frameworks/SDL_net.framework/Headers - /Library/Frameworks/SDL_net.framework/Headers - $ENV{SDLDIR}/include - $ENV{SDLNETDIR}/include - /usr/include/SDL - /usr/include/SDL12 - /usr/include/SDL11 - /usr/include - /usr/local/include/SDL - /usr/local/include/SDL12 - /usr/local/include/SDL11 - /usr/local/include - /sw/include - ) -# I'm not sure if I should do a special casing for Apple. It is -# unlikely that other Unix systems will find the framework path. -# But if they do ([Next|Open|GNU]Step?), -# do they want the -framework option also? -IF(${SDLNET_INCLUDE_DIR} MATCHES ".framework") - SET (SDLNET_LIBRARY "-framework SDL_net" CACHE STRING "SDL_net framework for OSX") -ELSE(${SDLNET_INCLUDE_DIR} MATCHES ".framework") - FIND_LIBRARY(SDLNET_LIBRARY - NAMES SDL_net - PATHS - $ENV{SDLDIR}/lib - $ENV{SDLNET}/lib - /usr/lib - /usr/local/lib - /sw/lib - ) -ENDIF(${SDLNET_INCLUDE_DIR} MATCHES ".framework") - -SET(SDLNET_FOUND "NO") -IF(SDLNET_LIBRARY) - SET(SDLNET_FOUND "YES") -ENDIF(SDLNET_LIBRARY) - diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSDL_sound.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSDL_sound.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSDL_sound.cmake 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSDL_sound.cmake 2006-01-13 02:48:36.000000000 +0800 @@ -1,8 +1,7 @@ -# Locates the SDL_sound library - +# - Locates the SDL_sound library # This module depends on SDL being found and # must be called AFTER FindSDL.cmake is called. - +# # This module defines # SDL_SOUND_INCLUDE_DIR, where to find SDL_sound.h # SDL_SOUND_FOUND, if false, do not try to link to SDL @@ -12,43 +11,44 @@ # flags to SDL_SOUND_LIBRARIES. This is prepended to SDL_SOUND_LIBRARIES. # This is available mostly for cases this module failed to anticipate for # and you must add additional flags. This is marked as ADVANCED. - # # This module also defines (but you shouldn't need to use directly) # SDL_SOUND_LIBRARY, the name of just the SDL_sound library you would link # against. Use SDL_SOUND_LIBRARIES for you link instructions and not this one. # And might define the following as needed -# MIKMOD_LIBRARY -# MODPLUG_LIBRARY -# OGG_LIBRARY -# VORBIS_LIBRARY -# SMPEG_LIBRARY -# FLAC_LIBRARY -# SPEEX_LIBRARY +# MIKMOD_LIBRARY +# MODPLUG_LIBRARY +# OGG_LIBRARY +# VORBIS_LIBRARY +# SMPEG_LIBRARY +# FLAC_LIBRARY +# SPEEX_LIBRARY # -# Typically, you should not use these variables directly, and you should use -# SDL_SOUND_LIBRARIES which contains SDL_SOUND_LIBRARY and the other audio libraries -# (if needed) to successfully compile on your system . +# Typically, you should not use these variables directly, and you should use +# SDL_SOUND_LIBRARIES which contains SDL_SOUND_LIBRARY and the other audio +# libraries (if needed) to successfully compile on your system . # # Created by Eric Wing. -# This module is a bit more complicated than the other FindSDL* family modules. -# The reason is that SDL_sound can be compiled in a large variety of different ways -# which are independent of platform. SDL_sound may dynamically link against other 3rd -# party libraries to get additional codec support, such as Ogg Vorbis, SMPEG, ModPlug, -# MikMod, FLAC, Speex, and potentially others. -# Under some circumstances which I don't fully understand, -# there seems to be a requirement -# that dependent libraries of libraries you use must also be explicitly -# linked against in order to successfully compile. SDL_sound does not currently -# have any system in place to know how it was compiled. -# So this CMake module does the hard work in trying to discover which 3rd party -# libraries are required for building (if any). -# This module uses a brute force approach to create a test program that uses SDL_sound, -# and then tries to build it. If the build fails, it parses the error output for -# known symbol names to figure out which libraries are needed. # -# Responds to the $SDLDIR and $SDLSOUNDDIR environmental variable that would -# correspond to the ./configure --prefix=$SDLDIR used in building SDL. +# This module is a bit more complicated than the other FindSDL* family +# modules. The reason is that SDL_sound can be compiled in a large variety +# of different ways which are independent of platform. SDL_sound may +# dynamically link against other 3rd party libraries to get additional codec +# support, such as Ogg Vorbis, SMPEG, ModPlug, MikMod, FLAC, Speex, and +# potentially others. Under some circumstances which I don't fully +# understand, there seems to be a requirement that dependent libraries of +# libraries you use must also be explicitly linked against in order to +# successfully compile. SDL_sound does not currently have any system in place +# to know how it was compiled. So this CMake module does the hard work in +# trying to discover which 3rd party libraries are required for building (if +# any). +# +# This module uses a brute force approach to create a test program that uses +# SDL_sound, and then tries to build it. If the build fails, it parses the +# error output for known symbol names to figure out which libraries are +# needed. Responds to the $SDLDIR and $SDLSOUNDDIR environmental variable +# that would correspond to the ./configure --prefix=$SDLDIR used in building +# SDL. # # On OSX, this will prefer the Framework version (if found) over others. # People will have to manually change the cache values of @@ -90,7 +90,7 @@ OR "${SDL_SOUND_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks" ) # String is in default search path, don't need to use -F - SET (SDL_SOUND_LIBRARY "-framework SDL_sound" CACHE STRING "SDL_sound framework for OSX") + SET (SDL_SOUND_LIBRARY "-framework SDL_sound" CACHE STRING "SDL_sound framework for OSX") ELSE("${SDL_SOUND_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks" OR "${SDL_SOUND_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks" ) @@ -147,7 +147,7 @@ # To minimize external dependencies, create a sdlsound test program # which will be used to figure out if additional link dependencies are # required for the link phase. - FILE(WRITE ${PROJECT_BINARY_DIR}/CMakeTmp/DetermineSoundLibs.c + FILE(WRITE ${PROJECT_BINARY_DIR}/CMakeFiles/CMakeTmp/DetermineSoundLibs.c "#include \"SDL_sound.h\" #include \"SDL.h\" int main(int argc, char* argv[]) @@ -176,7 +176,7 @@ # in the TARGET_LINK_LIBRARIES, I seem to loose everything # in the SDL_LIBRARY string after the "-framework". # But if I quote the stuff in INCLUDE_DIRECTORIES, it doesn't work. - FILE(WRITE ${PROJECT_BINARY_DIR}/CMakeTmp/CMakeLists.txt + FILE(WRITE ${PROJECT_BINARY_DIR}/CMakeFiles/CMakeTmp/CMakeLists.txt "PROJECT(DetermineSoundLibs) INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}) ADD_EXECUTABLE(DetermineSoundLibs DetermineSoundLibs.c) @@ -185,8 +185,8 @@ TRY_COMPILE( MY_RESULT - ${PROJECT_BINARY_DIR}/CMakeTmp - ${PROJECT_BINARY_DIR}/CMakeTmp + ${PROJECT_BINARY_DIR}/CMakeFiles/CMakeTmp + ${PROJECT_BINARY_DIR}/CMakeFiles/CMakeTmp DetermineSoundLibs OUTPUT_VARIABLE MY_OUTPUT ) @@ -216,7 +216,7 @@ OR "${TEMP_SDLSOUND_MIKMOD_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks" ) # It's in the default search path so I don't need to use -F - SET(MIKMOD_LIBRARY "-framework libmikmod-coreaudio" CACHE STRING "MikMod framework for OSX") + SET(MIKMOD_LIBRARY "-framework libmikmod-coreaudio" CACHE STRING "MikMod framework for OSX") ELSE("${TEMP_SDLSOUND_MIKMOD_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks" OR "${TEMP_SDLSOUND_MIKMOD_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks" ) @@ -314,7 +314,7 @@ OR "${TEMP_SDLSOUND_VORBIS_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks" ) # It's in the default search path so I don't need to use -F - SET(VORBIS_LIBRARY "-framework Vorbis" CACHE STRING "Vorbis framework for OSX") + SET(VORBIS_LIBRARY "-framework Vorbis" CACHE STRING "Vorbis framework for OSX") ELSE("${TEMP_SDLSOUND_VORBIS_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks" OR "${TEMP_SDLSOUND_VORBIS_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks" ) @@ -360,7 +360,7 @@ OR "${TEMP_SDLSOUND_OGG_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks" ) # It's in the default search path so I don't need to use -F - SET(OGG_LIBRARY "-framework Ogg" CACHE STRING "Ogg framework for OSX") + SET(OGG_LIBRARY "-framework Ogg" CACHE STRING "Ogg framework for OSX") ELSE("${TEMP_SDLSOUND_OGG_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks" OR "${TEMP_SDLSOUND_OGG_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks" ) @@ -410,7 +410,7 @@ OR "${TEMP_SDLSOUND_SMPEG_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks" ) # It's in the default search path so I don't need to use -F - SET(SMPEG_LIBRARY "-framework smpeg" CACHE STRING "SMPEG framework for OSX") + SET(SMPEG_LIBRARY "-framework smpeg" CACHE STRING "SMPEG framework for OSX") ELSE("${TEMP_SDLSOUND_SMPEG_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks" OR "${TEMP_SDLSOUND_SMPEG_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks" ) @@ -459,7 +459,7 @@ OR "${TEMP_SDLSOUND_FLAC_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks" ) # It's in the default search path so I don't need to use -F - SET(FLAC_LIBRARY "-framework FLAC" CACHE STRING "FLAC framework for OSX") + SET(FLAC_LIBRARY "-framework FLAC" CACHE STRING "FLAC framework for OSX") ELSE("${TEMP_SDLSOUND_FLAC_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks" OR "${TEMP_SDLSOUND_FLAC_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks" ) @@ -555,7 +555,7 @@ OR "${TEMP_SDLSOUND_OGG_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks" ) # It's in the default search path so I don't need to use -F - SET(OGG_LIBRARY "-framework Ogg" CACHE STRING "Ogg framework for OSX") + SET(OGG_LIBRARY "-framework Ogg" CACHE STRING "Ogg framework for OSX") ELSE("${TEMP_SDLSOUND_OGG_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks" OR "${TEMP_SDLSOUND_OGG_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks" ) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSDL_ttf.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSDL_ttf.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSDL_ttf.cmake 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSDL_ttf.cmake 2005-12-16 03:17:43.000000000 +0800 @@ -1,17 +1,15 @@ -# Locate SDL_ttf library +# - Locate SDL_ttf library # This module defines -# SDLTTF_LIBRARY, the name of the library to link against -# SDLTTF_FOUND, if false, do not try to link to SDL -# SDLTTF_INCLUDE_DIR, where to find SDL/SDL.h -# +# SDLTTF_LIBRARY, the library to link against +# SDLTTF_FOUND, if false, do not try to link to SDL +# SDLTTF_INCLUDE_DIR, where to find SDL/SDL.h +# # $SDLDIR is an environment variable that would # correspond to the ./configure --prefix=$SDLDIR # used in building SDL. -# # Created by Eric Wing. This was influenced by the FindSDL.cmake # module, but with modifications to recognize OS X frameworks and # additional Unix paths (FreeBSD, etc). - # On OSX, this will prefer the Framework version (if found) over others. # People will have to manually change the cache values of # SDLTTF_LIBRARY to override this selection. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSDL_ttf.cmake.bak /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSDL_ttf.cmake.bak --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSDL_ttf.cmake.bak 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSDL_ttf.cmake.bak 1970-01-01 08:00:00.000000000 +0800 @@ -1,55 +0,0 @@ -# Locate SDL_ttf library -# This module defines -# SDLTTF_LIBRARY, the name of the library to link against -# SDLTTF_FOUND, if false, do not try to link to SDL -# SDLTTF_INCLUDE_DIR, where to find SDL/SDL.h -# -# $SDLDIR is an environment variable that would -# correspond to the ./configure --prefix=$SDLDIR -# used in building SDL. -# -# Created by Eric Wing. This was influenced by the FindSDL.cmake -# module, but with modifications to recognize OS X frameworks and -# additional Unix paths (FreeBSD, etc). - -# On OSX, this will prefer the Framework version (if found) over others. -# People will have to manually change the cache values of -# SDLTTF_LIBRARY to override this selection. -FIND_PATH(SDLTTF_INCLUDE_DIR SDL_ttf.h - ~/Library/Frameworks/SDL_ttf.framework/Headers - /Library/Frameworks/SDL_ttf.framework/Headers - $ENV{SDLDIR}/include - $ENV{SDLTTFDIR}/include - /usr/include/SDL - /usr/include/SDL12 - /usr/include/SDL11 - /usr/include - /usr/local/include/SDL - /usr/local/include/SDL12 - /usr/local/include/SDL11 - /usr/local/include - /sw/include - ) -# I'm not sure if I should do a special casing for Apple. It is -# unlikely that other Unix systems will find the framework path. -# But if they do ([Next|Open|GNU]Step?), -# do they want the -framework option also? -IF(${SDLTTF_INCLUDE_DIR} MATCHES ".framework") - SET (SDLTTF_LIBRARY "-framework SDL_ttf" CACHE STRING "SDL_ttf framework for OSX") -ELSE(${SDLTTF_INCLUDE_DIR} MATCHES ".framework") - FIND_LIBRARY(SDLTTF_LIBRARY - NAMES SDL_ttf - PATHS - $ENV{SDLDIR}/lib - $ENV{SDLTTFDIR}/lib - /usr/lib - /usr/local/lib - /sw/lib - ) -ENDIF(${SDLTTF_INCLUDE_DIR} MATCHES ".framework") - -SET(SDLTTF_FOUND "NO") -IF(SDLTTF_LIBRARY) - SET(SDLTTF_FOUND "YES") -ENDIF(SDLTTF_LIBRARY) - diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSelfPackers.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSelfPackers.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSelfPackers.cmake 2004-08-27 10:52:53.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSelfPackers.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,10 +1,9 @@ -# -# this module looks for some executable packers (i.e. softwares that +# - Find upx +# This module looks for some executable packers (i.e. softwares that # compress executables or shared libs into on-the-fly self-extracting # executables or shared libs. -# # Examples: -# UPX: http://wildsau.idv.uni-linz.ac.at/mfx/upx.html +# UPX: http://wildsau.idv.uni-linz.ac.at/mfx/upx.html INCLUDE(FindCygwin) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSWIG.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSWIG.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindSWIG.cmake 2005-04-08 02:27:01.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindSWIG.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,3 +1,9 @@ +# - Find SWIG +# This module finds an installed SWIG. It sets the following variables: +# SWIG_FOUND - set to true if SWIG is found +# SWIG_DIR - the directory where swig is installed +# SWIG_EXECUTABLE - the path to the swig executable + SET(SWIG_FOUND FOOBAR) FIND_PATH(SWIG_DIR SWIGConfig.cmake diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindTCL.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindTCL.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindTCL.cmake 2005-04-08 02:27:01.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindTCL.cmake 2006-03-10 00:35:38.000000000 +0800 @@ -1,22 +1,20 @@ -# +# - Find Tcl includes and libraries. # This module finds if TCL is installed and determines where the # include files and libraries are. It also determines what the name of # the library is. This code sets the following variables: -# -# TCL_LIBRARY = full path to the Tcl library (tcl tcl80 etc) -# TCL_LIBRARY_DEBUG = full path to the Tcl library (debug) -# TCL_STUB_LIBRARY = full path to the Tcl stub library -# TCL_STUB_LIBRARY_DEBUG = full path to the Tcl stub library (debug) -# TCL_INCLUDE_PATH = path to where tcl.h can be found -# TCL_TCLSH = full path to the tclsh binary (tcl tcl80 etc) -# TK_LIBRARY = full path to the Tk library (tk tk80 etc) -# TK_LIBRARY_DEBUG = full path to the Tk library (debug) -# TK_STUB_LIBRARY = full path to the Tk stub library -# TK_STUB_LIBRARY_DEBUG = full path to the Tk stub library (debug) -# TK_INCLUDE_PATH = path to where tk.h can be found -# TK_INTERNAL_PATH = path to where tkWinInt.h can be found -# TK_WISH = full path to the wish binary (wish wish80 etc) -# +# TCL_LIBRARY = path to Tcl library (tcl tcl80) +# TCL_LIBRARY_DEBUG = path to Tcl library (debug) +# TCL_STUB_LIBRARY = path to Tcl stub library +# TCL_STUB_LIBRARY_DEBUG = path to debug stub library +# TCL_INCLUDE_PATH = path to where tcl.h can be found +# TCL_TCLSH = path to tclsh binary (tcl tcl80) +# TK_LIBRARY = path to Tk library (tk tk80 etc) +# TK_LIBRARY_DEBUG = path to Tk library (debug) +# TK_STUB_LIBRARY = path to Tk stub library +# TK_STUB_LIBRARY_DEBUG = path to debug Tk stub library +# TK_INCLUDE_PATH = path to where tk.h can be found +# TK_INTERNAL_PATH = path to where tkWinInt.h is found +# TK_WISH = full path to the wish executable INCLUDE(CMakeFindFrameworks) INCLUDE(FindTclsh) @@ -30,6 +28,7 @@ "${TK_WISH_PATH}/../lib" "${TCL_INCLUDE_PATH}/../lib" "${TK_INCLUDE_PATH}/../lib" + "$ENV{ProgramFiles}/Tcl/Lib" "C:/Program Files/Tcl/lib" "C:/Tcl/lib" [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/lib @@ -114,6 +113,7 @@ [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.3;Root]/include [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.2;Root]/include [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.0;Root]/include + "$ENV{ProgramFiles}/Tcl/include" "C:/Program Files/Tcl/include" C:/Tcl/include /usr/include @@ -150,26 +150,6 @@ ) ENDIF(WIN32) -IF(Tcl_FRAMEWORKS) - # If we are using the Tcl framework, link to it. - IF("${TCL_INCLUDE_PATH}" MATCHES "Tcl\\.framework") - SET(TCL_LIBRARY "") - ENDIF("${TCL_INCLUDE_PATH}" MATCHES "Tcl\\.framework") - IF(NOT TCL_LIBRARY) - SET (TCL_LIBRARY "-framework Tcl" CACHE FILEPATH "Tcl Framework" FORCE) - ENDIF(NOT TCL_LIBRARY) -ENDIF(Tcl_FRAMEWORKS) - -IF(Tk_FRAMEWORKS) - # If we are using the Tk framework, link to it. - IF("${TK_INCLUDE_PATH}" MATCHES "Tk\\.framework") - SET(TK_LIBRARY "") - ENDIF("${TK_INCLUDE_PATH}" MATCHES "Tk\\.framework") - IF(NOT TK_LIBRARY) - SET (TK_LIBRARY "-framework Tk" CACHE FILEPATH "Tk Framework" FORCE) - ENDIF(NOT TK_LIBRARY) -ENDIF(Tk_FRAMEWORKS) - MARK_AS_ADVANCED( TCL_STUB_LIBRARY TCL_STUB_LIBRARY_DEBUG diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindTclsh.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindTclsh.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindTclsh.cmake 2004-04-01 05:44:43.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindTclsh.cmake 2005-12-16 03:17:43.000000000 +0800 @@ -1,11 +1,8 @@ -# +# - Find tclsh # This module finds if TCL is installed and determines where the # include files and libraries are. It also determines what the name of # the library is. This code sets the following variables: -# -# TCL_TCLSH = the full path to the tclsh binary (tcl tcl80 etc) -# - +# TCL_TCLSH = the path to the tclsh executable # In cygwin, look for the cygwin version first. Don't look for it later to # avoid finding the cygwin version on a Win32 build. IF(WIN32) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindThreads.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindThreads.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindThreads.cmake 2005-08-12 02:02:18.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindThreads.cmake 2005-12-16 03:17:43.000000000 +0800 @@ -1,10 +1,10 @@ -# This module determines the thread library of the system. +# - This module determines the thread library of the system. # The following variables are set -# CMAKE_THREAD_LIBS_INIT - the thread library to link into an application (-lpthread ) -# CMAKE_USE_SPROC_INIT - are we using sproc? -# CMAKE_USE_WIN32_THREADS_INIT - are we using WIN32 threads -# CMAKE_USE_PTHREADS_INIT - are we using pthreads -# CMAKE_HP_PTHREADS_INIT - are we using hp pthreads +# CMAKE_THREAD_LIBS_INIT - the thread library +# CMAKE_USE_SPROC_INIT - are we using sproc? +# CMAKE_USE_WIN32_THREADS_INIT - using WIN32 threads? +# CMAKE_USE_PTHREADS_INIT - are we using pthreads +# CMAKE_HP_PTHREADS_INIT - are we using hp pthreads INCLUDE (CheckIncludeFile) INCLUDE (CheckIncludeFiles) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindTIFF.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindTIFF.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindTIFF.cmake 2005-04-08 02:27:01.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindTIFF.cmake 2006-02-10 04:08:16.000000000 +0800 @@ -1,23 +1,22 @@ -# +# - Find TIFF library # Find the native TIFF includes and library -# # This module defines -# TIFF_INCLUDE_DIR, where to find tiff.h, etc. -# TIFF_LIBRARIES, the libraries to link against to use TIFF. -# TIFF_FOUND, If false, do not try to use TIFF. - +# TIFF_INCLUDE_DIR, where to find tiff.h, etc. +# TIFF_LIBRARIES, libraries to link against to use TIFF. +# TIFF_FOUND, If false, do not try to use TIFF. # also defined, but not for general use are -# TIFF_LIBRARY, where to find the TIFF library. +# TIFF_LIBRARY, where to find the TIFF library. FIND_PATH(TIFF_INCLUDE_DIR tiff.h /usr/local/include /usr/include ) -FIND_LIBRARY(TIFF_LIBRARY tiff - /usr/lib - /usr/local/lib -) +SET(TIFF_NAMES ${TIFF_NAMES} tiff) +FIND_LIBRARY(TIFF_LIBRARY + NAMES ${TIFF_NAMES} + PATHS /usr/lib /usr/local/lib + ) IF(TIFF_INCLUDE_DIR) IF(TIFF_LIBRARY) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindUnixCommands.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindUnixCommands.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindUnixCommands.cmake 2004-08-27 10:52:53.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindUnixCommands.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,5 +1,5 @@ -# -# this module looks for some usual Unix commands +# - Find unix commands from cygwin +# This module looks for some usual Unix commands. # INCLUDE(FindCygwin) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindVTK.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindVTK.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindVTK.cmake 2004-08-27 10:52:53.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindVTK.cmake 2005-12-16 03:17:43.000000000 +0800 @@ -1,30 +1,30 @@ -# -# Find a VTK installation or build tree. -# +# - Find a VTK installation or build tree. # The following variables are set if VTK is found. If VTK is not # found, VTK_FOUND is set to false. -# -# VTK_FOUND - Set to true when VTK is found. -# VTK_USE_FILE - CMake source file to setup a project to use VTK. -# VTK_MAJOR_VERSION - The VTK major version number. -# VTK_MINOR_VERSION - The VTK minor version number (odd for non-release). -# VTK_BUILD_VERSION - The VTK patch level (meaningless for odd minor). -# VTK_INCLUDE_DIRS - Include directories for VTK headers. -# VTK_LIBRARY_DIRS - Link directories for VTK libraries. -# VTK_KITS - List of VTK kits, in all CAPS (COMMON, IO, ...). -# VTK_LANGUAGES - List of wrapped languages, in all CAPS (TCL, ...). -# +# VTK_FOUND - Set to true when VTK is found. +# VTK_USE_FILE - CMake file to use VTK. +# VTK_MAJOR_VERSION - The VTK major version number. +# VTK_MINOR_VERSION - The VTK minor version number +# (odd non-release). +# VTK_BUILD_VERSION - The VTK patch level +# (meaningless for odd minor). +# VTK_INCLUDE_DIRS - Include directories for VTK +# VTK_LIBRARY_DIRS - Link directories for VTK libraries +# VTK_KITS - List of VTK kits, in CAPS +# (COMMON,IO,) etc. +# VTK_LANGUAGES - List of wrapped languages, in CAPS +# (TCL, PYHTON,) etc. # The following cache entries must be set by the user to locate VTK: -# -# VTK_DIR - The directory containing VTKConfig.cmake. This is either -# the root of the build tree, or the lib/vtk -# directory. This is the only cache entry. -# -# The following variables are set for backward compatability and +# VTK_DIR - The directory containing VTKConfig.cmake. +# This is either the root of the build tree, +# or the lib/vtk directory. This is the +# only cache entry. +# The following variables are set for backward compatibility and # should not be used in new code: -# -# USE_VTK_FILE - The full path to the UseVTK.cmake file. This is provided -# for backward compatability. Use VTK_USE_FILE instead. +# USE_VTK_FILE - The full path to the UseVTK.cmake file. +# This is provided for backward +# compatibility. Use VTK_USE_FILE +# instead. # # Construct consitent error messages for use below. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindWget.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindWget.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindWget.cmake 2004-08-27 10:52:53.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindWget.cmake 2005-12-16 03:17:43.000000000 +0800 @@ -1,9 +1,8 @@ -# -# this module looks for wget -# -# This module defines the following values -# WGET_EXECUTABLE: This variable defines the full path to the wget tool. -# WGET_FOUND: True if wget has been found. +# - Find wget +# This module looks for wget. This module defines the +# following values: +# WGET_EXECUTABLE: the full path to the wget tool. +# WGET_FOUND: True if wget has been found. INCLUDE(FindCygwin) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindWish.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindWish.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindWish.cmake 2003-11-04 22:36:33.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindWish.cmake 2005-12-16 03:17:43.000000000 +0800 @@ -1,12 +1,11 @@ -# +# - Find wish installation # This module finds if TCL is installed and determines where the # include files and libraries are. It also determines what the name of # the library is. This code sets the following variables: # -# TK_WISH = the full path to the wish binary (wish wish80 etc) +# TK_WISH = the path to the wish executable # - -# if UNIX is defined, then look for the cygwin version first +# if UNIX is defined, then it will look for the cygwin version first IF(UNIX) FIND_PROGRAM(TK_WISH cygwish80 ) ENDIF(UNIX) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindwxWindows.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindwxWindows.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindwxWindows.cmake 2004-08-27 10:52:53.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindwxWindows.cmake 2006-01-13 00:10:22.000000000 +0800 @@ -1,70 +1,69 @@ -## -## This module finds if wxWindows is installed and determines where the -## include files and libraries are. It also determines what the name of -## the library is. This code sets the following variables: -## -## ------------------------------------------------------------------ -## -## WXWINDOWS_FOUND = system has WxWindows (in desired config. build) -## -## WXWINDOWS_LIBRARIES = full path to the wxWindows libraries -## on Unix/Linux with additional linker flags from -## "wx-config --libs" -## -## CMAKE_WXWINDOWS_CXX_FLAGS = Unix compiler flags for wxWindows, essentially -## "`wx-config --cxxflags`" -## -## WXWINDOWS_INCLUDE_DIR = where to find headers "wx/wx.h" "wx/setup.h" -## -## WXWINDOWS_LINK_DIRECTORIES = link directories, useful for rpath on Unix -## -## WXWINDOWS_DEFINITIONS = extra defines -## -## deprecated: -## * CMAKE_WX_CAN_COMPILE -## * WXWINDOWS_LIBRARY -## * CMAKE_WX_CXX_FLAGS -## * WXWINDOWS_INCLUDE_PATH -## -## ------------------------------------------------------------------ -## -## USAGE: -## # for convenience include Use_wxWindows.cmake in your projects -## CMakeLists.txt: -## -## # if you need OpenGL support please -## SET(WXWINDOWS_USE_GL 1) -## # in your CMakeLists.txt *before* you include this file. -## -## # just include Use_wxWindows.cmake -## # in your projects CMakeLists.txt -## INCLUDE(Use_wxWindows) -## -## ------------------------------------------------------------------ -## Author Jan Woetzel (07/2003) -## ------------------------------------------------------------------ -## -## -changed variable names to conventions from cmakes readme.txt (Jan Woetzel -## 07/07/2003) -## -added definition WINVER for WIN32 (Jan Woetzel 07/07//2003) -## -added IF(CMAKE_WXWINDOWS_CONFIG_EXECUTABLE) found and changed -## CMAKE_WX_CONFIG to CMAKE_WXWINDOWS_CONFIG_EXECUTABLE (Jan Woetzel -## 07/22/2003) -## -removed OPTION for CMAKE_WXWINDOWS_USE_GL. Force the developer to SET it. -## -## status: -## tested with: -## -cmake 1.6.7, Linux (Suse 7.3), wxWindows 2.4.0, gcc 2.95 -## -cmake 1.6.7, Linux (Suse 8.2), wxWindows 2.4.0, gcc 3.3 -## -cmake 1.6.7, Linux (Suse 8.2), wxWindows 2.4.1-patch1, gcc 3.3 -## -cmake 1.6.7, MS Windows XP home, wxWindows 2.4.1, MS Visual Studio .net 7 -## 2002 (static build) -## -## TODO: -## -OPTION for unicode builds -## -change WXWINDOWS_USE_GL to use FindOpenGL.cmake or let the user do it -## -testing of DLL linking under MS WIN32 -## +# - Find wxWindows (wxWidgets) installation +# This module finds if wxWindows/wxWidgets is installed and determines where +# the include files and libraries are. It also determines what the name of +# the library is. This code sets the following variables: +# +# WXWINDOWS_FOUND = system has WxWindows +# WXWINDOWS_LIBRARIES = path to the wxWindows libraries +# on Unix/Linux with additional +# linker flags from +# "wx-config --libs" +# CMAKE_WXWINDOWS_CXX_FLAGS = Compiler flags for wxWindows, +# essentially "`wx-config --cxxflags`" +# on Linux +# WXWINDOWS_INCLUDE_DIR = where to find "wx/wx.h" and "wx/setup.h" +# WXWINDOWS_LINK_DIRECTORIES = link directories, useful for rpath on +# Unix +# WXWINDOWS_DEFINITIONS = extra defines +# +# DEPRECATED +# CMAKE_WX_CAN_COMPILE +# WXWINDOWS_LIBRARY +# CMAKE_WX_CXX_FLAGS +# WXWINDOWS_INCLUDE_PATH +# +# OPTIONS +# If you need OpenGL support please +# SET(WXWINDOWS_USE_GL 1) +# in your CMakeLists.txt *before* you include this file. +# +# For convenience include Use_wxWindows.cmake in your project's +# CMakeLists.txt using INCLUDE(Use_wxWindows). +# +# USAGE +# SET(WXWINDOWS_USE_GL 1) +# FIND_PACKAGE(wxWindows) +# +# NOTES +# wxWidgets 2.6.x is supported for monolithic builds +# e.g. compiled in wx/build/msw dir as: +# nmake -f makefile.vc BUILD=debug SHARED=0 USE_OPENGL=1 MONOLITHIC=1 +# +# AUTHOR +# Jan Woetzel (07/2003-01/2006) + + +# ------------------------------------------------------------------ +# +# -removed OPTION for CMAKE_WXWINDOWS_USE_GL. Force the developer to SET it before calling this. +# -major update for wx 2.6.2 and monolithic build option. (10/2005) +# +# STATUS +# tested with: +# cmake 1.6.7, Linux (Suse 7.3), wxWindows 2.4.0, gcc 2.95 +# cmake 1.6.7, Linux (Suse 8.2), wxWindows 2.4.0, gcc 3.3 +# cmake 1.6.7, Linux (Suse 8.2), wxWindows 2.4.1-patch1, gcc 3.3 +# cmake 1.6.7, MS Windows XP home, wxWindows 2.4.1, MS Visual Studio .net 7 2002 (static build) +# cmake 2.0.5 on Windows XP and Suse Linux 9.2 +# cmake 2.0.6 on Windows XP and Suse Linux 9.2, wxWidgets 2.6.2 MONOLITHIC build +# cmake 2.2.2 on Windows XP, MS Visual Studio .net 2003 7.1 wxWidgets 2.6.2 MONOLITHIC build +# +# TODO +# -OPTION for unicode builds +# -further testing of DLL linking under MS WIN32 +# -better support for non-monolithic builds +# + IF(WIN32) SET(WIN32_STYLE_FIND 1) @@ -79,7 +78,7 @@ IF(WIN32_STYLE_FIND) - + ## ###################################################################### ## ## Windows specific: @@ -91,37 +90,251 @@ SET (WXWINDOWS_POSSIBLE_ROOT_PATHS $ENV{WXWIN} - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\wxWindows_is1;Inno Setup: App Path]" ) + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\wxWidgets_is1;Inno Setup: App Path]" ## WX 2.6.x + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\wxWindows_is1;Inno Setup: App Path]" ## WX 2.4.x + C:\\wxWidgets-2.6.2 + D:\\wxWidgets-2.6.2 + C:\\wxWidgets-2.6.1 + D:\\wxWidgets-2.6.1 + C:\\wxWindows-2.4.2 + D:\\wxWindows-2.4.2 + ) + ## WX supports monolithic and multiple smaller libs (since 2.5.x), we prefer monolithic for now. + ## monolithic = WX is built as a single big library + ## e.g. compile on WIN32 as "nmake -f makefile.vc MONOLITHIC=1 BUILD=debug SHARED=0 USE_OPENGL=1" (JW) + OPTION(WXWINDOWS_USE_MONOLITHIC "Use monolithic build of WX??" ON) + MARK_AS_ADVANCED(WXWINDOWS_USE_MONOLITHIC) + + ## GL libs used? + OPTION(WXWINDOWS_USE_GL "Use Wx with GL support(glcanvas)?" ON) + MARK_AS_ADVANCED(WXWINDOWS_USE_GL) + + + ## avoid mixing of headers and libs between multiple installed WX versions, + ## select just one tree here: FIND_PATH(WXWINDOWS_ROOT_DIR include/wx/wx.h - ${WXWINDOWS_POSSIBLE_ROOT_PATHS} ) + ${WXWINDOWS_POSSIBLE_ROOT_PATHS} ) + # MESSAGE("DBG found WXWINDOWS_ROOT_DIR: ${WXWINDOWS_ROOT_DIR}") - ## MESSAGE("DBG found WXWINDOWS_ROOT_DIR: ${WXWINDOWS_ROOT_DIR}") ## find libs for combination of static/shared with release/debug + ## be careful if you add something here, + ## avoid mixing of headers and libs of different wx versions, + ## there may be multiple WX version s installed. SET (WXWINDOWS_POSSIBLE_LIB_PATHS - "${WXWINDOWS_ROOT_DIR}/lib" ) + "${WXWINDOWS_ROOT_DIR}/lib" + ) + + ## monolithic? + IF (WXWINDOWS_USE_MONOLITHIC) + + FIND_LIBRARY(WXWINDOWS_STATIC_LIBRARY + NAMES wx wxmsw wxmsw26 + PATHS + "${WXWINDOWS_ROOT_DIR}/lib/vc_lib" + ${WXWINDOWS_POSSIBLE_LIB_PATHS} + DOC "wxWindows static release build library" ) + + FIND_LIBRARY(WXWINDOWS_STATIC_DEBUG_LIBRARY + NAMES wxd wxmswd wxmsw26d + PATHS + "${WXWINDOWS_ROOT_DIR}/lib/vc_lib" + ${WXWINDOWS_POSSIBLE_LIB_PATHS} + DOC "wxWindows static debug build library" ) + + FIND_LIBRARY(WXWINDOWS_SHARED_LIBRARY + NAMES wxmsw26 wxmsw262 wxmsw24 wxmsw242 wxmsw241 wxmsw240 wx23_2 wx22_9 + PATHS + "${WXWINDOWS_ROOT_DIR}/lib/vc_dll" + ${WXWINDOWS_POSSIBLE_LIB_PATHS} + DOC "wxWindows shared release build library" ) + + FIND_LIBRARY(WXWINDOWS_SHARED_DEBUG_LIBRARY + NAMES wxmsw26d wxmsw262d wxmsw24d wxmsw241d wxmsw240d wx23_2d wx22_9d + PATHS + "${WXWINDOWS_ROOT_DIR}/lib/vc_dll" + ${WXWINDOWS_POSSIBLE_LIB_PATHS} + DOC "wxWindows shared debug build library " ) + + + ## + ## required for WXWINDOWS_USE_GL + ## gl lib is always build separate: + ## + FIND_LIBRARY(WXWINDOWS_STATIC_LIBRARY_GL + NAMES wx_gl wxmsw_gl wxmsw26_gl + PATHS + "${WXWINDOWS_ROOT_DIR}/lib/vc_lib" + ${WXWINDOWS_POSSIBLE_LIB_PATHS} + DOC "wxWindows static release build GL library" ) + + FIND_LIBRARY(WXWINDOWS_STATIC_DEBUG_LIBRARY_GL + NAMES wxd_gl wxmswd_gl wxmsw26d_gl + PATHS + "${WXWINDOWS_ROOT_DIR}/lib/vc_lib" + ${WXWINDOWS_POSSIBLE_LIB_PATHS} + DOC "wxWindows static debug build GL library" ) + + + FIND_LIBRARY(WXWINDOWS_STATIC_DEBUG_LIBRARY_PNG + NAMES wxpngd + PATHS + "${WXWINDOWS_ROOT_DIR}/lib/vc_lib" + ${WXWINDOWS_POSSIBLE_LIB_PATHS} + DOC "wxWindows static debug png library" ) + + FIND_LIBRARY(WXWINDOWS_STATIC_LIBRARY_PNG + NAMES wxpng + PATHS + "${WXWINDOWS_ROOT_DIR}/lib/vc_lib" + ${WXWINDOWS_POSSIBLE_LIB_PATHS} + DOC "wxWindows static png library" ) + + FIND_LIBRARY(WXWINDOWS_STATIC_DEBUG_LIBRARY_TIFF + NAMES wxtiffd + PATHS + "${WXWINDOWS_ROOT_DIR}/lib/vc_lib" + ${WXWINDOWS_POSSIBLE_LIB_PATHS} + DOC "wxWindows static debug tiff library" ) + + FIND_LIBRARY(WXWINDOWS_STATIC_LIBRARY_TIFF + NAMES wxtiff + PATHS + "${WXWINDOWS_ROOT_DIR}/lib/vc_lib" + ${WXWINDOWS_POSSIBLE_LIB_PATHS} + DOC "wxWindows static tiff library" ) + + FIND_LIBRARY(WXWINDOWS_STATIC_DEBUG_LIBRARY_JPEG + NAMES wxjpegd wxjpgd + PATHS + "${WXWINDOWS_ROOT_DIR}/lib/vc_lib" + ${WXWINDOWS_POSSIBLE_LIB_PATHS} + DOC "wxWindows static debug jpeg library" ) + + FIND_LIBRARY(WXWINDOWS_STATIC_LIBRARY_JPEG + NAMES wxjpeg wxjpg + PATHS + "${WXWINDOWS_ROOT_DIR}/lib/vc_lib" + ${WXWINDOWS_POSSIBLE_LIB_PATHS} + DOC "wxWindows static jpeg library" ) + + FIND_LIBRARY(WXWINDOWS_STATIC_DEBUG_LIBRARY_ZLIB + NAMES wxzlibd + PATHS + "${WXWINDOWS_ROOT_DIR}/lib/vc_lib" + ${WXWINDOWS_POSSIBLE_LIB_PATHS} + DOC "wxWindows static debug zlib library" ) + + FIND_LIBRARY(WXWINDOWS_STATIC_LIBRARY_ZLIB + NAMES wxzlib + PATHS + "${WXWINDOWS_ROOT_DIR}/lib/vc_lib" + ${WXWINDOWS_POSSIBLE_LIB_PATHS} + DOC "wxWindows static zib library" ) + + FIND_LIBRARY(WXWINDOWS_STATIC_DEBUG_LIBRARY_REGEX + NAMES wxregexd + PATHS + "${WXWINDOWS_ROOT_DIR}/lib/vc_lib" + ${WXWINDOWS_POSSIBLE_LIB_PATHS} + DOC "wxWindows static debug regex library" ) + + FIND_LIBRARY(WXWINDOWS_STATIC_LIBRARY_REGEX + NAMES wxregex + PATHS + "${WXWINDOWS_ROOT_DIR}/lib/vc_lib" + ${WXWINDOWS_POSSIBLE_LIB_PATHS} + DOC "wxWindows static regex library" ) + + + + ## untested: + FIND_LIBRARY(WXWINDOWS_SHARED_LIBRARY_GL + NAMES wx_gl wxmsw_gl wxmsw26_gl + PATHS + "${WXWINDOWS_ROOT_DIR}/lib/vc_dll" + ${WXWINDOWS_POSSIBLE_LIB_PATHS} + DOC "wxWindows shared release build GL library" ) + + FIND_LIBRARY(WXWINDOWS_SHARED_DEBUG_LIBRARY_GL + NAMES wxd_gl wxmswd_gl wxmsw26d_gl + PATHS + "${WXWINDOWS_ROOT_DIR}/lib/vc_dll" + ${WXWINDOWS_POSSIBLE_LIB_PATHS} + DOC "wxWindows shared debug build GL library" ) + + + ELSE (WXWINDOWS_USE_MONOLITHIC) + ## WX is built as multiple small pieces libraries instead of monolithic + + ## DEPECATED (jw) replaced by more general WXWINDOWS_USE_MONOLITHIC ON/OFF + # OPTION(WXWINDOWS_SEPARATE_LIBS_BUILD "Is wxWindows build with separate libs?" OFF) + + ## HACK: This is very dirty. + ## because the libs of a particular version are explicitly listed + ## and NOT searched/verified. + ## TODO: Really search for each lib, then decide for + ## monolithic x debug x shared x GL (=16 combinations) for at least 18 libs + ## --> about 288 combinations + ## thus we need a different approach so solve this correctly ... + + MESSAGE(STATUS "Warning: You are trying to use wxWidgets without monolithic build (WXWINDOWS_SEPARATE_LIBS_BUILD). This is a HACK, libraries are not verified! (JW).") + + SET(WXWINDOWS_STATIC_LIBS ${WXWINDOWS_STATIC_LIBS} + wxbase26 + wxbase26_net + wxbase26_odbc + wxbase26_xml + wxmsw26_adv + wxmsw26_core + wxmsw26_dbgrid + wxmsw26_gl + wxmsw26_html + wxmsw26_media + wxmsw26_qa + wxmsw26_xrc + wxexpat + wxjpeg + wxpng + wxregex + wxtiff + wxzlib + comctl32 + rpcrt4 + wsock32 + ) + ## HACK: feed in to optimized / debug libaries if both were FOUND. + SET(WXWINDOWS_STATIC_DEBUG_LIBS ${WXWINDOWS_STATIC_DEBUG_LIBS} + wxbase26d + wxbase26d_net + wxbase26d_odbc + wxbase26d_xml + wxmsw26d_adv + wxmsw26d_core + wxmsw26d_dbgrid + wxmsw26d_gl + wxmsw26d_html + wxmsw26d_media + wxmsw26d_qa + wxmsw26d_xrc + wxexpatd + wxjpegd + wxpngd + wxregexd + wxtiffd + wxzlibd + comctl32 + rpcrt4 + wsock32 + ) + ENDIF (WXWINDOWS_USE_MONOLITHIC) - FIND_LIBRARY(WXWINDOWS_STATIC_LIBRARY - NAMES wx wxmsw - PATHS ${WXWINDOWS_POSSIBLE_LIB_PATHS} - DOC "wxWindows static release build library" ) - - FIND_LIBRARY(WXWINDOWS_STATIC_DEBUG_LIBRARY - NAMES wxd wxmswd - PATHS ${WXWINDOWS_POSSIBLE_LIB_PATHS} - DOC "wxWindows static debug build library" ) - - FIND_LIBRARY(WXWINDOWS_SHARED_LIBRARY - NAMES wxmsw24 wxmsw241 wxmsw240 wx23_2 wx22_9 - PATHS ${WXWINDOWS_POSSIBLE_LIB_PATHS} - DOC "wxWindows shared release build library" ) - - FIND_LIBRARY(WXWINDOWS_SHARED_DEBUG_LIBRARY - NAMES wxmsw24d wxmsw241d wxmsw240d wx23_2d wx22_9d - PATHS ${WXWINDOWS_POSSIBLE_LIB_PATHS} - DOC "wxWindows shared debug build library " ) + ## + ## now we should have found all WX libs available on the system. + ## let the user decide which of the available onse to use. + ## ## if there is at least one shared lib available ## let user choose wether to use shared or static wxwindows libs @@ -130,36 +343,35 @@ OPTION(WXWINDOWS_USE_SHARED_LIBS "Use shared versions (dll) of wxWindows libraries?" OFF) MARK_AS_ADVANCED(WXWINDOWS_USE_SHARED_LIBS) - ENDIF(WXWINDOWS_SHARED_LIBRARY OR WXWINDOWS_SHARED_DEBUG_LIBRARY) - + ENDIF(WXWINDOWS_SHARED_LIBRARY OR WXWINDOWS_SHARED_DEBUG_LIBRARY) - ## add system libraries wxwindows depends on - SET(CMAKE_WXWINDOWS_LIBRARIES ${CMAKE_WXWINDOWS_LIBRARIES} + ## add system libraries wxwindows always seems to depend on + SET(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES} comctl32 rpcrt4 wsock32 - ## presumably ctl3d32 is not neccesary (Jan Woetzel 07/2003) - # ctl3d32 - # debug ${WXWINDOWS_ROOT_DIR}/lib/zlibd.lib optimized ${WXWINDOWS_ROOT_DIR}/lib/zlibd.lib - # debug ${WXWINDOWS_ROOT_DIR}/lib/regexd.lib optimized ${WXWINDOWS_ROOT_DIR}/lib/regexd.lib - # debug ${WXWINDOWS_ROOT_DIR}/lib/pngd.lib optimized ${WXWINDOWS_ROOT_DIR}/lib/pngd.lib - # debug ${WXWINDOWS_ROOT_DIR}/lib/jpegd.lib optimized ${WXWINDOWS_ROOT_DIR}/lib/jpegd.lib - # debug ${WXWINDOWS_ROOT_DIR}/lib/tiffd.lib optimized ${WXWINDOWS_ROOT_DIR}/lib/tiff.lib - ) - - # JW removed option and force the develper th SET it. - # OPTION(WXWINDOWS_USE_GL "use wxWindows with GL support (use additional - # opengl, glu libs)?" OFF) + ) - ## opengl/glu: (TODO/FIXME: better use FindOpenGL.cmake here + IF (NOT WXWINDOWS_USE_SHARED_LIBS) + SET(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES} + ## these ones dont seem required, in particular ctl3d32 is not neccesary (Jan Woetzel 07/2003) + # ctl3d32 + debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_ZLIB} optimized ${WXWINDOWS_STATIC_LIBRARY_ZLIB} + debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_REGEX} optimized ${WXWINDOWS_STATIC_LIBRARY_REGEX} + debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_PNG} optimized ${WXWINDOWS_STATIC_LIBRARY_PNG} + debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_JPEG} optimized ${WXWINDOWS_STATIC_LIBRARY_JPEG} + debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_TIFF} optimized ${WXWINDOWS_STATIC_LIBRARY_TIFF} + ) + ENDIF (NOT WXWINDOWS_USE_SHARED_LIBS) + + ## opengl/glu: TODO/FIXME: better use FindOpenGL.cmake here + ## assume release versions of glu an dopengl, here. IF (WXWINDOWS_USE_GL) - SET(CMAKE_WXWINDOWS_LIBRARIES ${CMAKE_WXWINDOWS_LIBRARIES} + SET(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES} opengl32 - glu32 - ) + glu32 ) ENDIF (WXWINDOWS_USE_GL) - ## ## select between use of shared or static wxWindows lib then set libs to use ## for debug and optimized build. so the user can switch between debug and @@ -171,26 +383,40 @@ IF(WXWINDOWS_USE_SHARED_LIBS) ##MESSAGE("DBG wxWindows use shared lib selected.") + ## assume that both builds use the same setup(.h) for simplicity ## shared: both wx (debug and release) found? + ## assume that both builds use the same setup(.h) for simplicity IF(WXWINDOWS_SHARED_DEBUG_LIBRARY AND WXWINDOWS_SHARED_LIBRARY) ##MESSAGE("DBG wx shared: debug and optimized found.") - SET(WXWINDOWS_LIBRARIES ${CMAKE_WXWINDOWS_LIBRARIES} - debug ${WXWINDOWS_SHARED_DEBUG_LIBRARY} - optimized ${WXWINDOWS_SHARED_LIBRARY} ) FIND_PATH(WXWINDOWS_INCLUDE_DIR_SETUPH wx/setup.h ${WXWINDOWS_ROOT_DIR}/lib/mswdlld - ${WXWINDOWS_ROOT_DIR}/lib/mswdll ) + ${WXWINDOWS_ROOT_DIR}/lib/mswdll + ${WXWINDOWS_ROOT_DIR}/lib/vc_dll/mswd + ${WXWINDOWS_ROOT_DIR}/lib/vc_dll/msw ) + SET(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES} + debug ${WXWINDOWS_SHARED_DEBUG_LIBRARY} + optimized ${WXWINDOWS_SHARED_LIBRARY} ) + IF (WXWINDOWS_USE_GL) + SET(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES} + debug ${WXWINDOWS_SHARED_DEBUG_LIBRARY_GL} + optimized ${WXWINDOWS_SHARED_LIBRARY_GL} ) + ENDIF (WXWINDOWS_USE_GL) ENDIF(WXWINDOWS_SHARED_DEBUG_LIBRARY AND WXWINDOWS_SHARED_LIBRARY) ## shared: only debug wx lib found? IF(WXWINDOWS_SHARED_DEBUG_LIBRARY) IF(NOT WXWINDOWS_SHARED_LIBRARY) ##MESSAGE("DBG wx shared: debug (but no optimized) found.") - SET(WXWINDOWS_LIBRARIES ${CMAKE_WXWINDOWS_LIBRARIES} - ${WXWINDOWS_SHARED_DEBUG_LIBRARY} ) FIND_PATH(WXWINDOWS_INCLUDE_DIR_SETUPH wx/setup.h - ${WXWINDOWS_ROOT_DIR}/lib/mswdlld ) + ${WXWINDOWS_ROOT_DIR}/lib/mswdlld + ${WXWINDOWS_ROOT_DIR}/lib/vc_dll/mswd ) + SET(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES} + ${WXWINDOWS_SHARED_DEBUG_LIBRARY} ) + IF (WXWINDOWS_USE_GL) + SET(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES} + ${WXWINDOWS_SHARED_DEBUG_LIBRARY_GL} ) + ENDIF (WXWINDOWS_USE_GL) ENDIF(NOT WXWINDOWS_SHARED_LIBRARY) ENDIF(WXWINDOWS_SHARED_DEBUG_LIBRARY) @@ -198,44 +424,63 @@ IF(NOT WXWINDOWS_SHARED_DEBUG_LIBRARY) IF(WXWINDOWS_SHARED_LIBRARY) ##MESSAGE("DBG wx shared: optimized (but no debug) found.") - SET(WXWINDOWS_LIBRARIES ${CMAKE_WXWINDOWS_LIBRARIES} - ${WXWINDOWS_SHARED_DEBUG_LIBRARY} ) FIND_PATH(WXWINDOWS_INCLUDE_DIR_SETUPH wx/setup.h - ${WXWINDOWS_ROOT_DIR}/lib/mswdll ) + ${WXWINDOWS_ROOT_DIR}/lib/mswdll + ${WXWINDOWS_ROOT_DIR}/lib/vc_dll/msw ) + SET(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES} + ${WXWINDOWS_SHARED_DEBUG_LIBRARY} ) + IF (WXWINDOWS_USE_GL) + SET(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES} + ${WXWINDOWS_SHARED_DEBUG_LIBRARY_GL} ) + ENDIF (WXWINDOWS_USE_GL) ENDIF(WXWINDOWS_SHARED_LIBRARY) ENDIF(NOT WXWINDOWS_SHARED_DEBUG_LIBRARY) ## shared: none found? IF(NOT WXWINDOWS_SHARED_DEBUG_LIBRARY) IF(NOT WXWINDOWS_SHARED_LIBRARY) - MESSAGE(SEND_ERROR + MESSAGE(STATUS "No shared wxWindows lib found, but WXWINDOWS_USE_SHARED_LIBS=${WXWINDOWS_USE_SHARED_LIBS}.") ENDIF(NOT WXWINDOWS_SHARED_LIBRARY) ENDIF(NOT WXWINDOWS_SHARED_DEBUG_LIBRARY) - + ######################################################################################### ELSE(WXWINDOWS_USE_SHARED_LIBS) - ##MESSAGE("DBG wxWindows static lib selected.") + ##jw: DEPRECATED IF(NOT WXWINDOWS_SEPARATE_LIBS_BUILD) + ## static: both wx (debug and release) found? + ## assume that both builds use the same setup(.h) for simplicity IF(WXWINDOWS_STATIC_DEBUG_LIBRARY AND WXWINDOWS_STATIC_LIBRARY) ##MESSAGE("DBG wx static: debug and optimized found.") - SET(WXWINDOWS_LIBRARIES ${CMAKE_WXWINDOWS_LIBRARIES} - debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY} - optimized ${WXWINDOWS_STATIC_LIBRARY} ) FIND_PATH(WXWINDOWS_INCLUDE_DIR_SETUPH wx/setup.h ${WXWINDOWS_ROOT_DIR}/lib/mswd - ${WXWINDOWS_ROOT_DIR}/lib/msw ) + ${WXWINDOWS_ROOT_DIR}/lib/msw + ${WXWINDOWS_ROOT_DIR}/lib/vc_lib/mswd + ${WXWINDOWS_ROOT_DIR}/lib/vc_lib/msw ) + SET(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES} + debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY} + optimized ${WXWINDOWS_STATIC_LIBRARY} ) + IF (WXWINDOWS_USE_GL) + SET(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES} + debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_GL} + optimized ${WXWINDOWS_STATIC_LIBRARY_GL} ) + ENDIF (WXWINDOWS_USE_GL) ENDIF(WXWINDOWS_STATIC_DEBUG_LIBRARY AND WXWINDOWS_STATIC_LIBRARY) ## static: only debug wx lib found? IF(WXWINDOWS_STATIC_DEBUG_LIBRARY) IF(NOT WXWINDOWS_STATIC_LIBRARY) ##MESSAGE("DBG wx static: debug (but no optimized) found.") - SET(WXWINDOWS_LIBRARIES ${CMAKE_WXWINDOWS_LIBRARIES} - ${WXWINDOWS_STATIC_DEBUG_LIBRARY} ) FIND_PATH(WXWINDOWS_INCLUDE_DIR_SETUPH wx/setup.h - ${WXWINDOWS_ROOT_DIR}/lib/mswd ) + ${WXWINDOWS_ROOT_DIR}/lib/mswd + ${WXWINDOWS_ROOT_DIR}/lib/vc_lib/mswd ) + SET(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES} + ${WXWINDOWS_STATIC_DEBUG_LIBRARY} ) + IF (WXWINDOWS_USE_GL) + SET(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES} + ${WXWINDOWS_STATIC_DEBUG_LIBRARY_GL} ) + ENDIF (WXWINDOWS_USE_GL) ENDIF(NOT WXWINDOWS_STATIC_LIBRARY) ENDIF(WXWINDOWS_STATIC_DEBUG_LIBRARY) @@ -243,25 +488,29 @@ IF(NOT WXWINDOWS_STATIC_DEBUG_LIBRARY) IF(WXWINDOWS_STATIC_LIBRARY) ##MESSAGE("DBG wx static: optimized (but no debug) found.") - SET(WXWINDOWS_LIBRARIES ${CMAKE_WXWINDOWS_LIBRARIES} - ${WXWINDOWS_STATIC_DEBUG_LIBRARY} ) FIND_PATH(WXWINDOWS_INCLUDE_DIR_SETUPH wx/setup.h - ${WXWINDOWS_ROOT_DIR}/lib/msw ) + ${WXWINDOWS_ROOT_DIR}/lib/msw + ${WXWINDOWS_ROOT_DIR}/lib/vc_lib/msw ) + SET(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES} + ${WXWINDOWS_STATIC_LIBRARY} ) + IF (WXWINDOWS_USE_GL) + SET(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES} + ${WXWINDOWS_STATIC_LIBRARY_GL} ) + ENDIF (WXWINDOWS_USE_GL) ENDIF(WXWINDOWS_STATIC_LIBRARY) ENDIF(NOT WXWINDOWS_STATIC_DEBUG_LIBRARY) ## static: none found? - IF(NOT WXWINDOWS_STATIC_DEBUG_LIBRARY) + IF(NOT WXWINDOWS_STATIC_DEBUG_LIBRARY AND NOT WXWINDOWS_SEPARATE_LIBS_BUILD) IF(NOT WXWINDOWS_STATIC_LIBRARY) - MESSAGE(SEND_ERROR + MESSAGE(STATUS "No static wxWindows lib found, but WXWINDOWS_USE_SHARED_LIBS=${WXWINDOWS_USE_SHARED_LIBS}.") ENDIF(NOT WXWINDOWS_STATIC_LIBRARY) - ENDIF(NOT WXWINDOWS_STATIC_DEBUG_LIBRARY) - + ENDIF(NOT WXWINDOWS_STATIC_DEBUG_LIBRARY AND NOT WXWINDOWS_SEPARATE_LIBS_BUILD) ENDIF(WXWINDOWS_USE_SHARED_LIBS) - ## not neccessary in wxWindows 2.4.1 + ## not neccessary in wxWindows 2.4.1 and 2.6.2 ## but it may fix a previous bug, see ## http://lists.wxwindows.org/cgi-bin/ezmlm-cgi?8:mss:37574:200305:mpdioeneabobmgjenoap OPTION(WXWINDOWS_SET_DEFINITIONS "Set additional defines for wxWindows" OFF) @@ -274,32 +523,46 @@ ENDIF (WXWINDOWS_SET_DEFINITIONS) + ## Find the include directories for wxwindows ## the first, build specific for wx/setup.h was determined before. - ## add inc dir for general for "wx/wx.h" - SET (WXWINDOWS_POSSIBLE_INCLUDE_PATHS - "${WXWINDOWS_ROOT_DIR}/include" - ) + ## add inc dir for general for "wx/wx.h" FIND_PATH(WXWINDOWS_INCLUDE_DIR wx/wx.h - ${WXWINDOWS_POSSIBLE_INCLUDE_PATHS} - ) - # append the build specific include dir for wx/setup.h: + "${WXWINDOWS_ROOT_DIR}/include" ) + ## append the build specific include dir for wx/setup.h: IF (WXWINDOWS_INCLUDE_DIR_SETUPH) SET(WXWINDOWS_INCLUDE_DIR ${WXWINDOWS_INCLUDE_DIR} ${WXWINDOWS_INCLUDE_DIR_SETUPH} ) ENDIF (WXWINDOWS_INCLUDE_DIR_SETUPH) + + MARK_AS_ADVANCED( WXWINDOWS_ROOT_DIR WXWINDOWS_INCLUDE_DIR WXWINDOWS_INCLUDE_DIR_SETUPH WXWINDOWS_STATIC_LIBRARY + WXWINDOWS_STATIC_LIBRARY_GL WXWINDOWS_STATIC_DEBUG_LIBRARY + WXWINDOWS_STATIC_DEBUG_LIBRARY_GL + WXWINDOWS_STATIC_LIBRARY_ZLIB + WXWINDOWS_STATIC_DEBUG_LIBRARY_ZLIB + WXWINDOWS_STATIC_LIBRARY_REGEX + WXWINDOWS_STATIC_DEBUG_LIBRARY_REGEX + WXWINDOWS_STATIC_LIBRARY_PNG + WXWINDOWS_STATIC_DEBUG_LIBRARY_PNG + WXWINDOWS_STATIC_LIBRARY_JPEG + WXWINDOWS_STATIC_DEBUG_LIBRARY_JPEG + WXWINDOWS_STATIC_DEBUG_LIBRARY_TIFF + WXWINDOWS_STATIC_LIBRARY_TIFF WXWINDOWS_SHARED_LIBRARY WXWINDOWS_SHARED_DEBUG_LIBRARY + WXWINDOWS_SHARED_LIBRARY_GL + WXWINDOWS_SHARED_DEBUG_LIBRARY_GL ) ELSE(WIN32_STYLE_FIND) + IF (UNIX_STYLE_FIND) ## ###################################################################### ## @@ -314,12 +577,13 @@ # JW removed option and force the develper th SET it. # OPTION(WXWINDOWS_USE_GL "use wxWindows with GL support (use additional - # --gl-libs for wx-config)?" OFF) + # --gl-libs for wx-config)?" OFF) # wx-config should be in your path anyhow, usually no need to set WXWIN or # search in ../wx or ../../wx FIND_PROGRAM(CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE wx-config $ENV{WXWIN} + $ENV{WXWIN}/bin ../wx/bin ../../wx/bin ) @@ -328,7 +592,7 @@ # use shared/static wx lib? # remember: always link shared to use systems GL etc. libs (no static - # linking, just link *against* static .a libs) + # linking, just link *against* static .a libs) IF(WXWINDOWS_USE_SHARED_LIBS) SET(WX_CONFIG_ARGS_LIBS "--libs") ELSE(WXWINDOWS_USE_SHARED_LIBS) @@ -342,14 +606,14 @@ ##MESSAGE("DBG: WX_CONFIG_ARGS_LIBS=${WX_CONFIG_ARGS_LIBS}===") # set CXXFLAGS to be fed into CMAKE_CXX_FLAGS by the user: - SET(CMAKE_WXWINDOWS_CXX_FLAGS "`${CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE} --cxxflags`") + SET(CMAKE_WXWINDOWS_CXX_FLAGS "`${CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE} --cxxflags|sed -e s/-I/-isystem/g`") ##MESSAGE("DBG: for compilation: - ##CMAKE_WXWINDOWS_CXX_FLAGS=${CMAKE_WXWINDOWS_CXX_FLAGS}===") + ##CMAKE_WXWINDOWS_CXX_FLAGS=${CMAKE_WXWINDOWS_CXX_FLAGS}===") # keep the back-quoted string for clarity SET(WXWINDOWS_LIBRARIES "`${CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE} ${WX_CONFIG_ARGS_LIBS}`") ##MESSAGE("DBG2: for linking: - ##WXWINDOWS_LIBRARIES=${WXWINDOWS_LIBRARIES}===") + ##WXWINDOWS_LIBRARIES=${WXWINDOWS_LIBRARIES}===") # evaluate wx-config output to separate linker flags and linkdirs for # rpath: @@ -361,16 +625,16 @@ ## use regular expression to match wildcard equivalent "-L*" ## with is a space or a semicolon STRING(REGEX MATCHALL "[-][L]([^ ;])+" WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX "${WX_CONFIG_LIBS}" ) - #MESSAGE("DBG WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX=${WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX}") + # MESSAGE("DBG WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX=${WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX}") ## remove prefix -L because we need the pure directory for LINK_DIRECTORIES ## replace -L by ; because the separator seems to be lost otherwise (bug or - ## feature?) + ## feature?) IF(WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX) STRING(REGEX REPLACE "[-][L]" ";" WXWINDOWS_LINK_DIRECTORIES ${WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX} ) - #MESSAGE("DBG WXWINDOWS_LINK_DIRECTORIES=${WXWINDOWS_LINK_DIRECTORIES}") + # MESSAGE("DBG WXWINDOWS_LINK_DIRECTORIES=${WXWINDOWS_LINK_DIRECTORIES}") ENDIF(WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX) - + ## replace space separated string by semicolon separated vector to make it ## work with LINK_DIRECTORIES @@ -384,30 +648,30 @@ ) - # we really need wx-config... + ## we really need wx-config... ELSE(CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE) - MESSAGE(SEND_ERROR "Cannot find wx-config anywhere on the system. Please put the file into your path or specify it in CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE.") + MESSAGE(STATUS "Cannot find wx-config anywhere on the system. Please put the file into your path or specify it in CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE.") MARK_AS_ADVANCED(CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE) ENDIF(CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE) ELSE(UNIX_STYLE_FIND) - MESSAGE(SEND_ERROR "FindwxWindows.cmake: Platform unknown/unsupported by FindwxWindows.cmake. It's neither WIN32 nor UNIX") + MESSAGE(STATUS "FindwxWindows.cmake: Platform unknown/unsupported by FindwxWindows.cmake. It's neither WIN32 nor UNIX") ENDIF(UNIX_STYLE_FIND) ENDIF(WIN32_STYLE_FIND) IF(WXWINDOWS_LIBRARIES) IF(WXWINDOWS_INCLUDE_DIR OR CMAKE_WXWINDOWS_CXX_FLAGS) - ## found all we need. SET(WXWINDOWS_FOUND 1) ## set deprecated variables for backward compatibility: SET(CMAKE_WX_CAN_COMPILE ${WXWINDOWS_FOUND}) - SET(WXWINDOWS_LIBRARY ${WXWINDOWS_LIBRARIES}) + SET(WXWINDOWS_LIBRARY ${WXWINDOWS_LIBRARIES}) SET(WXWINDOWS_INCLUDE_PATH ${WXWINDOWS_INCLUDE_DIR}) + SET(WXWINDOWS_LINK_DIRECTORIES ${WXWINDOWS_LINK_DIRECTORIES}) SET(CMAKE_WX_CXX_FLAGS ${CMAKE_WXWINDOWS_CXX_FLAGS}) ENDIF(WXWINDOWS_INCLUDE_DIR OR CMAKE_WXWINDOWS_CXX_FLAGS) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindX11.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindX11.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindX11.cmake 2005-04-08 02:27:01.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindX11.cmake 2005-12-16 03:17:43.000000000 +0800 @@ -1,10 +1,8 @@ -# -# try to find X11 on UNIX systems. -# -# The following values are defined -# X11_FOUND - True if X11 is available -# X11_INCLUDE_DIR - include directories to use X11 -# X11_LIBRARIES - link against these to use X11 +# - Find X11 installation +# Try to find X11 on UNIX systems. The following values are defined +# X11_FOUND - True if X11 is available +# X11_INCLUDE_DIR - include directories to use X11 +# X11_LIBRARIES - link against these to use X11 IF (UNIX) SET(X11_FOUND 0) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindZLIB.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindZLIB.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/FindZLIB.cmake 2005-09-09 02:59:57.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/FindZLIB.cmake 2006-02-10 04:08:16.000000000 +0800 @@ -1,18 +1,19 @@ -# +# - Find zlib # Find the native ZLIB includes and library # -# ZLIB_INCLUDE_DIR - where to find zlib.h, etc. -# ZLIB_LIBRARIES - List of fully qualified libraries to link against when using zlib. -# ZLIB_FOUND - Do not attempt to use zlib if "no" or undefined. +# ZLIB_INCLUDE_DIR - where to find zlib.h, etc. +# ZLIB_LIBRARIES - List of libraries when using zlib. +# ZLIB_FOUND - True if zlib found. FIND_PATH(ZLIB_INCLUDE_DIR zlib.h /usr/local/include /usr/include ) -FIND_LIBRARY(ZLIB_LIBRARY z - /usr/lib - /usr/local/lib +SET(ZLIB_NAMES ${ZLIB_NAMES} z zlib) +FIND_LIBRARY(ZLIB_LIBRARY + NAMES ${ZLIB_NAMES} + PATHS /usr/lib /usr/local/lib ) IF(ZLIB_INCLUDE_DIR) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/InstallRequiredSystemLibraries.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/InstallRequiredSystemLibraries.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/InstallRequiredSystemLibraries.cmake 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/InstallRequiredSystemLibraries.cmake 2006-03-02 02:15:44.000000000 +0800 @@ -0,0 +1,29 @@ +# Hack for Visual Studio support +# Search for system runtime libraries based on the platform. This is +# not complete because it is used only for the release process by the +# developers. +IF(MSVC) + STRING(REGEX REPLACE "\\\\" "/" SYSTEMROOT "$ENV{SYSTEMROOT}") + FOREACH(lib + "${SYSTEMROOT}/system32/mfc71.dll" + "${SYSTEMROOT}/system32/msvcp71.dll" + "${SYSTEMROOT}/system32/msvcr71.dll" + ) + IF(EXISTS ${lib}) + SET(CMake_INSTALL_SYSTEM_RUNTIME_LIBS + ${CMake_INSTALL_SYSTEM_RUNTIME_LIBS} ${lib}) + ENDIF(EXISTS ${lib}) + ENDFOREACH(lib) +ENDIF(MSVC) + +# Include system runtime libraries in the installation if any are +# specified by CMake_INSTALL_SYSTEM_RUNTIME_LIBS. +IF(CMake_INSTALL_SYSTEM_RUNTIME_LIBS) + IF(WIN32) + INSTALL_PROGRAMS(/bin ${CMake_INSTALL_SYSTEM_RUNTIME_LIBS}) + ELSE(WIN32) + INSTALL_PROGRAMS(/lib ${CMake_INSTALL_SYSTEM_RUNTIME_LIBS}) + ENDIF(WIN32) +ENDIF(CMake_INSTALL_SYSTEM_RUNTIME_LIBS) + + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/kde3init_dummy.cpp.in /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/kde3init_dummy.cpp.in --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/kde3init_dummy.cpp.in 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/kde3init_dummy.cpp.in 2006-03-10 03:10:59.000000000 +0800 @@ -0,0 +1,6 @@ + +/* used by KDE3Macros.cmake */ + +extern "C" int kdemain(int argc, char* argv[]); +extern "C" int kdeinitmain(int argc, char* argv[]) { return kdemain(argc,argv); } +int main(int argc, char* argv[]) { return kdemain(argc,argv); } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/KDE3Macros.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/KDE3Macros.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/KDE3Macros.cmake 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/KDE3Macros.cmake 2006-03-10 03:10:59.000000000 +0800 @@ -0,0 +1,375 @@ + + +# See FindKDE3.cmake for documentation. +# +# this file contains the following macros: +# KDE3_ADD_DCOP_SKELS +# KDE3_ADD_DCOP_STUBS +# KDE3_ADD_MOC_FILES +# KDE3_ADD_UI_FILES +# KDE3_ADD_KCFG_FILES +# KDE3_AUTOMOC +# KDE3_INSTALL_LIBTOOL_FILE +# KDE3_CREATE_FINAL_FILE +# KDE3_ADD_KPART +# KDE3_ADD_KDEINIT_EXECUTABLE +# KDE3_ADD_EXECUTABLE + + +#neundorf@kde.org + +INCLUDE(MacroLibrary) + +#create the kidl and skeletion file for dcop stuff +#usage: KDE_ADD_COP_SKELS(foo_SRCS ${dcop_headers}) +MACRO(KDE3_ADD_DCOP_SKELS _sources) + FOREACH (_current_FILE ${ARGN}) + + GET_FILENAME_COMPONENT(_tmp_FILE ${_current_FILE} ABSOLUTE) + GET_FILENAME_COMPONENT(_basename ${_tmp_FILE} NAME_WE) + + SET(_skel ${CMAKE_CURRENT_BINARY_DIR}/${_basename}_skel.cpp) + SET(_kidl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.kidl) + + IF (NOT HAVE_${_basename}_KIDL_RULE) + SET(HAVE_${_basename}_KIDL_RULE ON) + + ADD_CUSTOM_COMMAND(OUTPUT ${_kidl} + COMMAND ${KDE3_DCOPIDL_EXECUTABLE} + ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${_current_FILE} > ${_kidl} + DEPENDS ${_tmp_FILE} + ) + ENDIF (NOT HAVE_${_basename}_KIDL_RULE) + + IF (NOT HAVE_${_basename}_SKEL_RULE) + SET(HAVE_${_basename}_SKEL_RULE ON) + + ADD_CUSTOM_COMMAND(OUTPUT ${_skel} + COMMAND ${KDE3_DCOPIDL2CPP_EXECUTABLE} + ARGS --c++-suffix cpp --no-signals --no-stub ${_kidl} + DEPENDS ${_kidl} + ) + + ENDIF (NOT HAVE_${_basename}_SKEL_RULE) + + SET(${_sources} ${${_sources}} ${_skel}) + + ENDFOREACH (_current_FILE) + +ENDMACRO(KDE3_ADD_DCOP_SKELS) + + +MACRO(KDE3_ADD_DCOP_STUBS _sources) + FOREACH (_current_FILE ${ARGN}) + + GET_FILENAME_COMPONENT(_tmp_FILE ${_current_FILE} ABSOLUTE) + + GET_FILENAME_COMPONENT(_basename ${_tmp_FILE} NAME_WE) + + SET(_stub_CPP ${CMAKE_CURRENT_BINARY_DIR}/${_basename}_stub.cpp) + SET(_kidl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.kidl) + + IF (NOT HAVE_${_basename}_KIDL_RULE) + SET(HAVE_${_basename}_KIDL_RULE ON) + + + ADD_CUSTOM_COMMAND(OUTPUT ${_kidl} + COMMAND ${KDE3_DCOPIDL_EXECUTABLE} + ARGS ${tmp_FILE} > ${_kidl} + DEPENDS ${tmp_FILE} + ) + + ENDIF (NOT HAVE_${_basename}_KIDL_RULE) + + + IF (NOT HAVE_${_basename}_STUB_RULE) + SET(HAVE_${_basename}_STUB_RULE ON) + + ADD_CUSTOM_COMMAND(OUTPUT ${_stub_CPP} + COMMAND ${KDE3_DCOPIDL2CPP_EXECUTABLE} + ARGS --c++-suffix cpp --no-signals --no-skel ${_kidl} + DEPENDS ${_kidl} + ) + + ENDIF (NOT HAVE_${_basename}_STUB_RULE) + + SET(${_sources} ${${_sources}} ${_stub_CPP}) + + ENDFOREACH (_current_FILE) + +ENDMACRO(KDE3_ADD_DCOP_STUBS) + + +MACRO(KDE3_ADD_KCFG_FILES _sources) + FOREACH (_current_FILE ${ARGN}) + + GET_FILENAME_COMPONENT(_tmp_FILE ${_current_FILE} ABSOLUTE) + + GET_FILENAME_COMPONENT(_basename ${_tmp_FILE} NAME_WE) + + FILE(READ ${_tmp_FILE} _contents) + STRING(REGEX REPLACE "^(.*\n)?File=([^\n]+)\n.*$" "\\2" _kcfg_FILE "${_contents}") + + SET(_src_FILE ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp) + SET(_header_FILE ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h) + + ADD_CUSTOM_COMMAND(OUTPUT ${_src_FILE} + COMMAND ${KDE3_KCFGC_EXECUTABLE} + ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${_kcfg_FILE} ${_tmp_FILE} + DEPENDS ${_tmp_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/${_kcfg_FILE} ) + + SET(${_sources} ${${_sources}} ${_src_FILE}) + + ENDFOREACH (_current_FILE) + +ENDMACRO(KDE3_ADD_KCFG_FILES) + + +#create the moc files and add them to the list of sources +#usage: KDE_ADD_MOC_FILES(foo_SRCS ${moc_headers}) +MACRO(KDE3_ADD_MOC_FILES _sources) + FOREACH (_current_FILE ${ARGN}) + + GET_FILENAME_COMPONENT(_tmp_FILE ${_current_FILE} ABSOLUTE) + + GET_FILENAME_COMPONENT(_basename ${_tmp_FILE} NAME_WE) + SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc.cpp) + + ADD_CUSTOM_COMMAND(OUTPUT ${_moc} + COMMAND ${QT_MOC_EXECUTABLE} + ARGS ${_tmp_FILE} -o ${_moc} + DEPENDS ${_tmp_FILE} + ) + + SET(${_sources} ${${_sources}} ${_moc}) + + ENDFOREACH (_current_FILE) +ENDMACRO(KDE3_ADD_MOC_FILES) + + +GET_FILENAME_COMPONENT( KDE3_MODULE_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) + +#create the implementation files from the ui files and add them to the list of sources +#usage: KDE_ADD_UI_FILES(foo_SRCS ${ui_files}) +MACRO(KDE3_ADD_UI_FILES _sources ) + FOREACH (_current_FILE ${ARGN}) + + GET_FILENAME_COMPONENT(_tmp_FILE ${_current_FILE} ABSOLUTE) + + GET_FILENAME_COMPONENT(_basename ${_tmp_FILE} NAME_WE) + SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h) + SET(_src ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp) + SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc.cpp) + + ADD_CUSTOM_COMMAND(OUTPUT ${_header} + COMMAND ${QT_UIC_EXECUTABLE} + ARGS -nounload -o ${_header} ${CMAKE_CURRENT_SOURCE_DIR}/${_current_FILE} + DEPENDS ${_tmp_FILE} + ) + + ADD_CUSTOM_COMMAND(OUTPUT ${_src} + COMMAND ${CMAKE_COMMAND} + ARGS + -DKDE_UIC_FILE:STRING=${_tmp_FILE} + -DKDE_UIC_CPP_FILE:STRING=${_src} + -DKDE_UIC_H_FILE:STRING=${_header} + -P ${KDE3_MODULE_DIR}/kde3uic.cmake + DEPENDS ${_header} + ) + + ADD_CUSTOM_COMMAND(OUTPUT ${_moc} + COMMAND ${QT_MOC_EXECUTABLE} + ARGS ${_header} -o ${_moc} + DEPENDS ${_header} + ) + + SET(${_sources} ${${_sources}} ${_src} ${_moc} ) + + ENDFOREACH (_current_FILE) +ENDMACRO(KDE3_ADD_UI_FILES) + + +MACRO(KDE3_AUTOMOC) + SET(_matching_FILES ) + FOREACH (_current_FILE ${ARGN}) + + GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE) + + # if "SKIP_AUTOMOC" is set to true, we will not handle this file here. + # here. this is required to make bouic work correctly: + # we need to add generated .cpp files to the sources (to compile them), + # but we cannot let automoc handle them, as the .cpp files don't exist yet when + # cmake is run for the very first time on them -> however the .cpp files might + # exist at a later run. at that time we need to skip them, so that we don't add two + # different rules for the same moc file + GET_SOURCE_FILE_PROPERTY(_skip ${_abs_FILE} SKIP_AUTOMOC) + + IF (EXISTS ${_abs_FILE} AND NOT _skip) + + FILE(READ ${_abs_FILE} _contents) + + GET_FILENAME_COMPONENT(_abs_PATH ${_abs_FILE} PATH) + + STRING(REGEX MATCHALL "#include +[^ ]+\\.moc[\">]" _match "${_contents}") + IF(_match) + FOREACH (_current_MOC_INC ${_match}) + STRING(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}") + + GET_FILENAME_COMPONENT(_basename ${_current_MOC} NAME_WE) +# SET(_header ${CMAKE_CURRENT_SOURCE_DIR}/${_basename}.h) + SET(_header ${_abs_PATH}/${_basename}.h) + SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC}) + + ADD_CUSTOM_COMMAND(OUTPUT ${_moc} + COMMAND ${QT_MOC_EXECUTABLE} + ARGS ${_header} -o ${_moc} + DEPENDS ${_header} + ) + + MACRO_ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc}) + + ENDFOREACH (_current_MOC_INC) + ENDIF(_match) + + ENDIF (EXISTS ${_abs_FILE} AND NOT _skip) + ENDFOREACH (_current_FILE) +ENDMACRO(KDE3_AUTOMOC) + + +MACRO(KDE3_INSTALL_ICONS _theme) + ADD_CUSTOM_TARGET(install_icons ) + SET_TARGET_PROPERTIES(install_icons PROPERTIES POST_INSTALL_SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake ) + FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake "# icon installations rules\n") + FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake "SET(CMAKE_BACKWARDS_COMPATIBILITY \"2.2\") \n") + + FILE(GLOB _icons *.png) + FOREACH(_current_ICON ${_icons} ) + STRING(REGEX REPLACE "^.*/[a-zA-Z]+([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" "\\1" _size "${_current_ICON}") + STRING(REGEX REPLACE "^.*/[a-zA-Z]+([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" "\\2" _group "${_current_ICON}") + STRING(REGEX REPLACE "^.*/[a-zA-Z]+([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" "\\3" _name "${_current_ICON}") + + SET(_icon_GROUP "actions") + + IF(${_group} STREQUAL "mime") + SET(_icon_GROUP "mimetypes") + ENDIF(${_group} STREQUAL "mime") + + IF(${_group} STREQUAL "filesys") + SET(_icon_GROUP "filesystems") + ENDIF(${_group} STREQUAL "filesys") + + IF(${_group} STREQUAL "device") + SET(_icon_GROUP "devices") + ENDIF(${_group} STREQUAL "device") + + IF(${_group} STREQUAL "app") + SET(_icon_GROUP "apps") + ENDIF(${_group} STREQUAL "app") + + IF(${_group} STREQUAL "action") + SET(_icon_GROUP "actions") + ENDIF(${_group} STREQUAL "action") + +# message(STATUS "icon: ${_current_ICON} size: ${_size} group: ${_group} name: ${_name}" ) + SET(_ICON_INSTALL_NAME ${CMAKE_INSTALL_PREFIX}/share/icons/${_theme}/${_size}x${_size}/${_icon_GROUP}/${_name}) + FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake "message(STATUS \"Installing ${_ICON_INSTALL_NAME}\") \n") + FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake "CONFIGURE_FILE( ${_current_ICON} ${_ICON_INSTALL_NAME} COPYONLY) \n") + + ENDFOREACH (_current_ICON) +ENDMACRO(KDE3_INSTALL_ICONS) + + +MACRO(KDE3_INSTALL_LIBTOOL_FILE _target) + GET_TARGET_PROPERTY(_target_location ${_target} LOCATION) + + GET_FILENAME_COMPONENT(_laname ${_target_location} NAME_WE) + GET_FILENAME_COMPONENT(_soname ${_target_location} NAME) + SET(_laname ${CMAKE_CURRENT_BINARY_DIR}/${_laname}.la) + + FILE(WRITE ${_laname} "# ${_laname} - a libtool library file, generated by cmake \n") + FILE(APPEND ${_laname} "# The name that we can dlopen(3).\n") + FILE(APPEND ${_laname} "dlname='${_soname}'\n") + FILE(APPEND ${_laname} "# Names of this library\n") + FILE(APPEND ${_laname} "library_names='${_soname} ${_soname} ${_soname}'\n") + FILE(APPEND ${_laname} "# The name of the static archive\n") + FILE(APPEND ${_laname} "old_library=''\n") + FILE(APPEND ${_laname} "# Libraries that this one depends upon.\n") + FILE(APPEND ${_laname} "dependency_libs=''\n") +# FILE(APPEND ${_laname} "dependency_libs='${${_target}_LIB_DEPENDS}'\n") + FILE(APPEND ${_laname} "# Version information.\ncurrent=0\nage=0\nrevision=0\n") + FILE(APPEND ${_laname} "# Is this an already installed library?\ninstalled=yes\n") + FILE(APPEND ${_laname} "# Should we warn about portability when linking against -modules?\nshouldnotlink=yes\n") + FILE(APPEND ${_laname} "# Files to dlopen/dlpreopen\ndlopen=''\ndlpreopen=''\n") + FILE(APPEND ${_laname} "# Directory that this library needs to be installed in:\n") + FILE(APPEND ${_laname} "libdir='${CMAKE_INSTALL_PREFIX}/lib/kde3'\n") + + INSTALL_FILES(/lib/kde3 FILES ${_laname}) +ENDMACRO(KDE3_INSTALL_LIBTOOL_FILE) + + +MACRO(KDE3_CREATE_FINAL_FILE _filename) + FILE(WRITE ${_filename} "//autogenerated file\n") + FOREACH (_current_FILE ${ARGN}) + FILE(APPEND ${_filename} "#include \"${_current_FILE}\"\n") + ENDFOREACH (_current_FILE) + +ENDMACRO(KDE3_CREATE_FINAL_FILE) + + +OPTION(KDE3_ENABLE_FINAL "Enable final all-in-one compilation") +OPTION(KDE3_BUILD_TESTS "Build the tests") + + +MACRO(KDE3_ADD_KPART _target_NAME _with_PREFIX) +#is the first argument is "WITH_PREFIX" then keep the standard "lib" prefix, otherwise SET the prefix empty + IF (${_with_PREFIX} STREQUAL "WITH_PREFIX") + SET(_first_SRC) + ELSE (${_with_PREFIX} STREQUAL "WITH_PREFIX") + SET(_first_SRC ${_with_PREFIX}) + ENDIF (${_with_PREFIX} STREQUAL "WITH_PREFIX") + + IF (KDE3_ENABLE_FINAL) + KDE3_CREATE_FINAL_FILE(${_target_NAME}_final.cpp ${_first_SRC} ${ARGN}) + ADD_LIBRARY(${_target_NAME} MODULE ${_target_NAME}_final.cpp) + ELSE (KDE3_ENABLE_FINAL) + ADD_LIBRARY(${_target_NAME} MODULE ${_first_SRC} ${ARGN}) + ENDIF (KDE3_ENABLE_FINAL) + + IF(_first_SRC) + SET_TARGET_PROPERTIES(${_target_NAME} PROPERTIES PREFIX "") + ENDIF(_first_SRC) + + KDE3_INSTALL_LIBTOOL_FILE(${_target_NAME}) + +ENDMACRO(KDE3_ADD_KPART) + + +MACRO(KDE3_ADD_KDEINIT_EXECUTABLE _target_NAME ) + + IF (KDE3_ENABLE_FINAL) + KDE3_CREATE_FINAL_FILE(${_target_NAME}_final.cpp ${ARGN}) + ADD_LIBRARY(kdeinit_${_target_NAME} SHARED ${_target_NAME}_final.cpp) + ELSE (KDE3_ENABLE_FINAL) + ADD_LIBRARY(kdeinit_${_target_NAME} SHARED ${ARGN} ) + ENDIF (KDE3_ENABLE_FINAL) + + CONFIGURE_FILE(${KDE3_MODULE_DIR}/kde3init_dummy.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_dummy.cpp) + + ADD_EXECUTABLE( ${_target_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_dummy.cpp ) + TARGET_LINK_LIBRARIES( ${_target_NAME} kdeinit_${_target_NAME} ) + +ENDMACRO(KDE3_ADD_KDEINIT_EXECUTABLE) + + +MACRO(KDE3_ADD_EXECUTABLE _target_NAME ) + + IF (KDE3_ENABLE_FINAL) + KDE3_CREATE_FINAL_FILE(${_target_NAME}_final.cpp ${ARGN}) + ADD_EXECUTABLE(${_target_NAME} ${_target_NAME}_final.cpp) + ELSE (KDE3_ENABLE_FINAL) + ADD_EXECUTABLE(${_target_NAME} ${ARGN} ) + ENDIF (KDE3_ENABLE_FINAL) + +ENDMACRO(KDE3_ADD_EXECUTABLE) + + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/kde3uic.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/kde3uic.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/kde3uic.cmake 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/kde3uic.cmake 2006-03-10 03:10:59.000000000 +0800 @@ -0,0 +1,20 @@ + + +# used internally by KDE3Macros.cmake +# neundorf@kde.org + + +EXECUTE_PROCESS(COMMAND uic + -nounload -tr tr2i18n + -impl ${KDE_UIC_H_FILE} + ${KDE_UIC_FILE} + OUTPUT_VARIABLE _uic_CONTENTS + ERROR_QUIET + ) + +STRING(REGEX REPLACE "tr2i18n\\(\"\"\\)" "QString::null" _uic_CONTENTS "${_uic_CONTENTS}" ) +STRING(REGEX REPLACE "tr2i18n\\(\"\", \"\"\\)" "QString::null" _uic_CONTENTS "${_uic_CONTENTS}" ) + +FILE(WRITE ${KDE_UIC_CPP_FILE} "#include \n#include \n\n") +FILE(APPEND ${KDE_UIC_CPP_FILE} "${_uic_CONTENTS}") + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/NSIS.template.in /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/NSIS.template.in --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/NSIS.template.in 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/NSIS.template.in 2006-03-02 04:00:07.000000000 +0800 @@ -0,0 +1,451 @@ +; CPack install script designed for a nmake build + +;-------------------------------- +; You must define these values + + !define VERSION "@CPACK_PACKAGE_VERSION@" + !define PATCH "@CPACK_PACKAGE_VERSION_PATCH@" + !define INST_DIR "@CPACK_TEMPORARY_DIRECTORY@" + +;-------------------------------- +;Variables + + Var MUI_TEMP + Var STARTMENU_FOLDER + Var SV_ALLUSERS + +;-------------------------------- +;Include Modern UI + + !include "MUI.nsh" + + ;Default installation folder + InstallDir "$PROGRAMFILES\@CPACK_PACKAGE_INSTALL_DIRECTORY@" + +;-------------------------------- +; determine admin versus local install +; Is install for "AllUsers" or "JustMe"? +; Default to "JustMe" - set to "AllUsers" if admin or on Win9x +; This function is used for the very first "custom page" of the installer. +; This custom page does not show up visibly, but it executes prior to the +; first visible page and sets up $INSTDIR properly... +; Choose different default installation folder based on SV_ALLUSERS... +; "Program Files" for AllUsers, "My Documents" for JustMe... + +Function .onInit + StrCpy $SV_ALLUSERS "JustMe" + StrCpy $INSTDIR "$DOCUMENTS\@CPACK_PACKAGE_INSTALL_DIRECTORY@" + + ClearErrors + UserInfo::GetName + IfErrors noLM + Pop $0 + UserInfo::GetAccountType + Pop $1 + StrCmp $1 "Admin" 0 +3 + SetShellVarContext all + ;MessageBox MB_OK 'User "$0" is in the Admin group' + StrCpy $SV_ALLUSERS "AllUsers" + Goto done + StrCmp $1 "Power" 0 +3 + SetShellVarContext all + ;MessageBox MB_OK 'User "$0" is in the Power Users group' + StrCpy $SV_ALLUSERS "AllUsers" + Goto done + + noLM: + StrCpy $SV_ALLUSERS "AllUsers" + ;Get installation folder from registry if available + + done: + StrCmp $SV_ALLUSERS "AllUsers" 0 +2 + StrCpy $INSTDIR "$PROGRAMFILES\@CPACK_PACKAGE_INSTALL_DIRECTORY@" +FunctionEnd + +;-------------------------------- +;General + + ;Name and file + Name "@CPACK_PACKAGE_INSTALL_DIRECTORY@" + OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@" + +;-------------------------------- +;Interface Settings + + !define MUI_HEADERIMAGE + !define MUI_ABORTWARNING + +;-------------------------------- +; path functions + +!verbose 3 +!include "WinMessages.NSH" +!verbose 4 + +; AddToPath - Adds the given dir to the search path. +; Input - head of the stack +; Note - Win9x systems requires reboot + +Function AddToPath + Exch $0 + Push $1 + Push $2 + Push $3 + + # don't add if the path doesn't exist + IfFileExists "$0\*.*" "" AddToPath_done + + ReadEnvStr $1 PATH + Push "$1;" + Push "$0;" + Call StrStr + Pop $2 + StrCmp $2 "" "" AddToPath_done + Push "$1;" + Push "$0\;" + Call StrStr + Pop $2 + StrCmp $2 "" "" AddToPath_done + GetFullPathName /SHORT $3 $0 + Push "$1;" + Push "$3;" + Call StrStr + Pop $2 + StrCmp $2 "" "" AddToPath_done + Push "$1;" + Push "$3\;" + Call StrStr + Pop $2 + StrCmp $2 "" "" AddToPath_done + + Call IsNT + Pop $1 + StrCmp $1 1 AddToPath_NT + ; Not on NT + StrCpy $1 $WINDIR 2 + FileOpen $1 "$1\autoexec.bat" a + FileSeek $1 -1 END + FileReadByte $1 $2 + IntCmp $2 26 0 +2 +2 # DOS EOF + FileSeek $1 -1 END # write over EOF + FileWrite $1 "$\r$\nSET PATH=%PATH%;$3$\r$\n" + FileClose $1 + SetRebootFlag true + Goto AddToPath_done + + AddToPath_NT: + ReadRegStr $1 SHCTX "Environment" "PATH" + StrCpy $2 $1 1 -1 # copy last char + StrCmp $2 ";" 0 +2 # if last char == ; + StrCpy $1 $1 -1 # remove last char + StrCmp $1 "" AddToPath_NTdoIt + StrCpy $0 "$1;$0" + AddToPath_NTdoIt: + WriteRegExpandStr SHCTX "Environment" "PATH" $0 + SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 + + AddToPath_done: + Pop $3 + Pop $2 + Pop $1 + Pop $0 +FunctionEnd + +; RemoveFromPath - Remove a given dir from the path +; Input: head of the stack + +Function un.RemoveFromPath + Exch $0 + Push $1 + Push $2 + Push $3 + Push $4 + Push $5 + Push $6 + + IntFmt $6 "%c" 26 # DOS EOF + + Call un.IsNT + Pop $1 + StrCmp $1 1 unRemoveFromPath_NT + ; Not on NT + StrCpy $1 $WINDIR 2 + FileOpen $1 "$1\autoexec.bat" r + GetTempFileName $4 + FileOpen $2 $4 w + GetFullPathName /SHORT $0 $0 + StrCpy $0 "SET PATH=%PATH%;$0" + Goto unRemoveFromPath_dosLoop + + unRemoveFromPath_dosLoop: + FileRead $1 $3 + StrCpy $5 $3 1 -1 # read last char + StrCmp $5 $6 0 +2 # if DOS EOF + StrCpy $3 $3 -1 # remove DOS EOF so we can compare + StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoopRemoveLine + StrCmp $3 "$0$\n" unRemoveFromPath_dosLoopRemoveLine + StrCmp $3 "$0" unRemoveFromPath_dosLoopRemoveLine + StrCmp $3 "" unRemoveFromPath_dosLoopEnd + FileWrite $2 $3 + Goto unRemoveFromPath_dosLoop + unRemoveFromPath_dosLoopRemoveLine: + SetRebootFlag true + Goto unRemoveFromPath_dosLoop + + unRemoveFromPath_dosLoopEnd: + FileClose $2 + FileClose $1 + StrCpy $1 $WINDIR 2 + Delete "$1\autoexec.bat" + CopyFiles /SILENT $4 "$1\autoexec.bat" + Delete $4 + Goto unRemoveFromPath_done + + unRemoveFromPath_NT: + ReadRegStr $1 SHCTX "Environment" "PATH" + StrCpy $5 $1 1 -1 # copy last char + StrCmp $5 ";" +2 # if last char != ; + StrCpy $1 "$1;" # append ; + Push $1 + Push "$0;" + Call un.StrStr ; Find `$0;` in $1 + Pop $2 ; pos of our dir + StrCmp $2 "" unRemoveFromPath_done + ; else, it is in path + # $0 - path to add + # $1 - path var + StrLen $3 "$0;" + StrLen $4 $2 + StrCpy $5 $1 -$4 # $5 is now the part before the path to remove + StrCpy $6 $2 "" $3 # $6 is now the part after the path to remove + StrCpy $3 $5$6 + + StrCpy $5 $3 1 -1 # copy last char + StrCmp $5 ";" 0 +2 # if last char == ; + StrCpy $3 $3 -1 # remove last char + + WriteRegExpandStr SHCTX "Environment" "PATH" $3 + SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 + + unRemoveFromPath_done: + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Pop $0 +FunctionEnd + +########################################### +# Utility Functions # +########################################### + +; IsNT +; no input +; output, top of the stack = 1 if NT or 0 if not +; +; Usage: +; Call IsNT +; Pop $R0 +; ($R0 at this point is 1 or 0) + +!macro IsNT un +Function ${un}IsNT + Push $0 + ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion + StrCmp $0 "" 0 IsNT_yes + ; we are not NT. + Pop $0 + Push 0 + Return + + IsNT_yes: + ; NT!!! + Pop $0 + Push 1 +FunctionEnd +!macroend +!insertmacro IsNT "" +!insertmacro IsNT "un." + +; StrStr +; input, top of stack = string to search for +; top of stack-1 = string to search in +; output, top of stack (replaces with the portion of the string remaining) +; modifies no other variables. +; +; Usage: +; Push "this is a long ass string" +; Push "ass" +; Call StrStr +; Pop $R0 +; ($R0 at this point is "ass string") + +!macro StrStr un +Function ${un}StrStr +Exch $R1 ; st=haystack,old$R1, $R1=needle + Exch ; st=old$R1,haystack + Exch $R2 ; st=old$R1,old$R2, $R2=haystack + Push $R3 + Push $R4 + Push $R5 + StrLen $R3 $R1 + StrCpy $R4 0 + ; $R1=needle + ; $R2=haystack + ; $R3=len(needle) + ; $R4=cnt + ; $R5=tmp + loop: + StrCpy $R5 $R2 $R3 $R4 + StrCmp $R5 $R1 done + StrCmp $R5 "" done + IntOp $R4 $R4 + 1 + Goto loop +done: + StrCpy $R1 $R2 "" $R4 + Pop $R5 + Pop $R4 + Pop $R3 + Pop $R2 + Exch $R1 +FunctionEnd +!macroend +!insertmacro StrStr "" +!insertmacro StrStr "un." + +;-------------------------------- +; Define some macro setting for the gui + + !define MUI_HEADERIMAGE_BITMAP "@CPACK_PACKAGE_ICON@" + +;-------------------------------- +;Pages + + !insertmacro MUI_PAGE_DIRECTORY + + ;Start Menu Folder Page Configuration + !define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX" + !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" + !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" + !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER + + !insertmacro MUI_PAGE_INSTFILES + + !insertmacro MUI_UNPAGE_CONFIRM + !insertmacro MUI_UNPAGE_INSTFILES + +;-------------------------------- +;Languages + + !insertmacro MUI_LANGUAGE "English" + +;-------------------------------- +;Installer Sections + +Section "Add to path" + Push $INSTDIR\bin + StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 +2 + Call AddToPath +SectionEnd + +Section "Installer Section" InstSection + + ;Use the entire tree produced by the INSTALL target. Keep the + ;list of directories here in sync with the RMDir commands below. + SetOutPath "$INSTDIR" + File /r "${INST_DIR}\*.*" + + ;Store installation folder + WriteRegStr SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "" $INSTDIR + + ;Create uninstaller + WriteUninstaller "$INSTDIR\Uninstall.exe" + + !insertmacro MUI_STARTMENU_WRITE_BEGIN Application + + ;Create shortcuts + CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER" +@CPACK_NSIS_CREATE_ICONS@ + CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe" + +@CPACK_NSIS_EXTRA_INSTALL_COMMANDS@ + + !insertmacro MUI_STARTMENU_WRITE_END + +SectionEnd + + +;-------------------------------- +; determine admin versus local install +Function un.onInit + + ClearErrors + UserInfo::GetName + IfErrors noLM + Pop $0 + UserInfo::GetAccountType + Pop $1 + StrCmp $1 "Admin" 0 +3 + SetShellVarContext all + ;MessageBox MB_OK 'User "$0" is in the Admin group' + Goto done + StrCmp $1 "Power" 0 +3 + SetShellVarContext all + ;MessageBox MB_OK 'User "$0" is in the Power Users group' + Goto done + + noLM: + ;Get installation folder from registry if available + + done: +FunctionEnd + +;-------------------------------- +;Uninstaller Section + +Section "Uninstall" + +@CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS@ + + ;Remove files we installed. + ;Keep the list of directories here in sync with the File commands above. +@CPACK_NSIS_DELETE_FILES@ +@CPACK_NSIS_DELETE_DIRECTORIES@ + + ;Remove the uninstaller itself. + Delete "$INSTDIR\Uninstall.exe" + + ;Remove the installation directory if it is empty. + RMDir "$INSTDIR" + + ; Remove the registry entries. + DeleteRegKey SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" + + !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP + + Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk" +@CPACK_NSIS_DELETE_ICONS@ + + ;Delete empty start menu parent diretories + StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP" + + startMenuDeleteLoop: + ClearErrors + RMDir $MUI_TEMP + GetFullPathName $MUI_TEMP "$MUI_TEMP\.." + + IfErrors startMenuDeleteLoopDone + + StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop + startMenuDeleteLoopDone: + + DeleteRegKey /ifempty SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" + + Push $INSTDIR\bin + StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 +2 + Call un.RemoveFromPath +SectionEnd + + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/AIX.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/AIX.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/AIX.cmake 2005-09-07 00:55:12.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/AIX.cmake 2006-03-10 04:00:37.000000000 +0800 @@ -26,4 +26,8 @@ SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,-brtl,-bexpall") # +s, flag for exe link to use shared lib SET(CMAKE_SHARED_LIBRARY_C_FLAGS " ") SET(CMAKE_SHARED_MODULE_C_FLAGS " ") + SET (CMAKE_C_FLAGS_DEBUG_INIT "-g") + SET (CMAKE_C_FLAGS_RELEASE_INIT "-O -DNDEBUG") + SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "-O -DNDEBUG") + SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-g") ENDIF(CMAKE_COMPILER_IS_GNUCC) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/CYGWIN.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/CYGWIN.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/CYGWIN.cmake 2004-08-27 02:55:54.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/CYGWIN.cmake 2006-03-07 04:14:23.000000000 +0800 @@ -1,7 +1,30 @@ SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -Wl,--export-all-symbols -Wl,--enable-auto-import") +SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}) SET(CMAKE_DL_LIBS "-lgdi32" ) -SET(CMAKE_SHARED_LIBRARY_PREFIX "lib") +SET(CMAKE_SHARED_LIBRARY_PREFIX "cyg") SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") +SET(CMAKE_SHARED_MODULE_PREFIX "lib") +SET(CMAKE_SHARED_MODULE_SUFFIX ".dll") +SET(CMAKE_IMPORT_LIBRARY_PREFIX "lib") +SET(CMAKE_IMPORT_LIBRARY_SUFFIX ".dll.a") # no pic for gcc on cygwin SET(CMAKE_SHARED_LIBRARY_C_FLAGS "") SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "") +SET(CMAKE_EXECUTABLE_SUFFIX ".exe") # .exe + +# Modules have a different default prefix that shared libs. +SET(CMAKE_MODULE_EXISTS 1) + +SET(CMAKE_FIND_LIBRARY_PREFIXES "cyg" "lib") +SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ".dll.a" ".a") + +SET(CMAKE_C_CREATE_SHARED_MODULE + " -o ") +SET(CMAKE_CXX_CREATE_SHARED_MODULE + " -o ") + +SET(CMAKE_C_CREATE_SHARED_LIBRARY + " -o -Wl,--out-implib, ") +SET(CMAKE_CXX_CREATE_SHARED_LIBRARY + " -o -Wl,--out-implib, ") +INCLUDE(Platform/UnixPaths) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/CYGWIN-g77.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/CYGWIN-g77.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/CYGWIN-g77.cmake 2005-08-12 02:02:19.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/CYGWIN-g77.cmake 2006-01-04 03:00:48.000000000 +0800 @@ -2,4 +2,5 @@ SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") SET(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "") SET(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "") +SET(CMAKE_EXECUTABLE_SUFFIX ".exe") # .exe INCLUDE(Platform/g77) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/Darwin.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/Darwin.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/Darwin.cmake 2005-06-21 04:31:34.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/Darwin.cmake 2006-03-15 03:03:16.000000000 +0800 @@ -4,8 +4,12 @@ SET(CMAKE_SHARED_MODULE_SUFFIX ".so") SET(CMAKE_MODULE_EXISTS 1) SET(CMAKE_DL_LIBS "") -SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib") -SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle") +SET(CMAKE_C_LINK_FLAGS "-headerpad_max_install_names") +SET(CMAKE_CXX_LINK_FLAGS "-headerpad_max_install_names") +SET(CMAKE_PLATFORM_HAS_INSTALLNAME 1) +SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -headerpad_max_install_names") +SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -headerpad_max_install_names") +SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a") IF("${CMAKE_BACKWARDS_COMPATIBILITY}" MATCHES "^1\\.[0-6]$") SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS @@ -13,38 +17,37 @@ ENDIF("${CMAKE_BACKWARDS_COMPATIBILITY}" MATCHES "^1\\.[0-6]$") IF(NOT XCODE) -# Enable shared library versioning. + # Enable shared library versioning. This flag is not actually referenced + # but the fact that the setting exists will cause the generators to support + # soname computation. SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name") SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-install_name") ENDIF(NOT XCODE) -# OSX does not really implement an rpath, but it does allow a path to -# be specified in the soname field of a dylib. -IF(CMAKE_SKIP_RPATH) - # No rpath requested. Just use the soname directly. - SET(CMAKE_C_CREATE_SHARED_LIBRARY - " -o ") - SET(CMAKE_CXX_CREATE_SHARED_LIBRARY - " -o ") -ELSE(CMAKE_SKIP_RPATH) - # Support for rpath is requested. Approximate it by putting the - # full path to the library in the soname field. Then when executables - # link the library they will copy this full path as the name to use - # to find the library. We can get the directory containing the library - # by using the dirname of the . It may be a relative path - # so we use a "cd ...;pwd" trick to convert it to a full path at - # build time. - SET(CMAKE_C_CREATE_SHARED_LIBRARY - " -o \"`cd \\`dirname \\`\;pwd`/\" ") - SET(CMAKE_CXX_CREATE_SHARED_LIBRARY - " -o \"`cd \\`dirname \\`\;pwd`/\" ") -ENDIF(CMAKE_SKIP_RPATH) +SET(CMAKE_C_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS -w) +SET(CMAKE_CXX_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS -w) +SET(CMAKE_C_CREATE_SHARED_LIBRARY + " -o -install_name ") +SET(CMAKE_CXX_CREATE_SHARED_LIBRARY + " -o -install_name ") SET(CMAKE_CXX_CREATE_SHARED_MODULE - " -o ") + " -o ") SET(CMAKE_C_CREATE_SHARED_MODULE - " -o ") + " -o ") SET(CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES /usr/local/include) +# default to searching for frameworks first +SET(CMAKE_FIND_FRAMEWORK FIRST) +# set up the default search directories for frameworks +SET(CMAKE_SYSTEM_FRAMEWORK_PATH + ~/Library/Frameworks + /Library/Frameworks/Network + /Network/Library/Frameworks + /System/Library/Frameworks) + +INCLUDE(Platform/UnixPaths) +SET(CMAKE_SYSTEM_INCLUDE_PATH ${CMAKE_SYSTEM_INCLUDE_PATH} /sw/include) +SET(CMAKE_SYSTEM_LIBRARY_PATH ${CMAKE_SYSTEM_LIBRARY_PATH} /sw/lib) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/FreeBSD.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/FreeBSD.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/FreeBSD.cmake 2004-09-23 02:42:05.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/FreeBSD.cmake 2006-03-17 00:15:24.000000000 +0800 @@ -5,5 +5,7 @@ SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty + SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") + SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-Wl,-soname,") ENDIF(EXISTS /usr/include/dlfcn.h) # include the gcc flags diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/HP-UX.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/HP-UX.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/HP-UX.cmake 2004-09-23 02:42:05.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/HP-UX.cmake 2006-02-10 04:05:13.000000000 +0800 @@ -1,5 +1,6 @@ SET(CMAKE_SHARED_LIBRARY_SUFFIX ".sl") # .so SET(CMAKE_DL_LIBS "-ldld") +SET(CMAKE_FIND_LIBRARY_SUFFIXES ".sl" ".so" ".a") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/IRIX64.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/IRIX64.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/IRIX64.cmake 2005-08-12 02:02:19.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/IRIX64.cmake 2006-03-16 03:14:03.000000000 +0800 @@ -5,7 +5,7 @@ SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "") # : or empty SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-Wl,-soname,") -IF(NOT CMAKE_COMPILER_IS_GNUCXX) +IF(NOT CMAKE_COMPILER_IS_GNUCC) # Set default flags init. SET(CMAKE_C_FLAGS_INIT "") SET(CMAKE_CXX_FLAGS_INIT "") @@ -42,4 +42,4 @@ SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-O3 -DNDEBUG") SET (CMAKE_CXX_FLAGS_RELEASE_INIT "-O2 -DNDEBUG") SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O2") -ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX) +ENDIF(NOT CMAKE_COMPILER_IS_GNUCC) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/Linux.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/Linux.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/Linux.cmake 2004-09-23 02:42:05.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/Linux.cmake 2006-03-03 02:30:22.000000000 +0800 @@ -7,3 +7,4 @@ SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-Wl,-soname,") +INCLUDE(Platform/UnixPaths) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/Linux-icpc.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/Linux-icpc.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/Linux-icpc.cmake 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/Linux-icpc.cmake 2005-11-23 00:44:07.000000000 +0800 @@ -0,0 +1,12 @@ +SET (CMAKE_C_FLAGS_INIT "") +SET (CMAKE_C_FLAGS_DEBUG_INIT "-g") +SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") +SET (CMAKE_C_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") +SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") + +SET (CMAKE_CXX_FLAGS_INIT "") +SET (CMAKE_CXX_FLAGS_DEBUG_INIT "-g") +SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") +SET (CMAKE_CXX_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") +SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/SunOS.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/SunOS.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/SunOS.cmake 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/SunOS.cmake 2006-03-03 02:30:22.000000000 +0800 @@ -60,3 +60,4 @@ " ") ENDIF(CMAKE_CXX_COMPILER) ENDIF(CMAKE_COMPILER_IS_GNUCXX) +INCLUDE(Platform/UnixPaths) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/UnixPaths.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/UnixPaths.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/UnixPaths.cmake 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/UnixPaths.cmake 2006-03-03 02:30:22.000000000 +0800 @@ -0,0 +1,5 @@ +SET(CMAKE_SYSTEM_INCLUDE_PATH ${CMAKE_SYSTEM_INCLUDE_PATH} /usr/include + /usr/local/include /usr/local /usr/X11R6/include /usr/include/X11) +SET(CMAKE_SYSTEM_LIBRARY_PATH ${CMAKE_SYSTEM_LIBRARY_PATH} /lib /use/lib /usr/local/lib + /usr/lib/w32api /usr/X11R6/lib /opt/local/lib /opt/csw/lib /opt/lib ) +SET(CMAKE_SYSTEM_PROGRAM_PATH ${CMAKE_SYSTEM_PROGRAM_PATH} /bin /usr/bin /usr/local/bin /sbin) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/Windows-bcc32.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/Windows-bcc32.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/Windows-bcc32.cmake 2005-06-30 00:07:09.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/Windows-bcc32.cmake 2006-02-19 04:37:22.000000000 +0800 @@ -16,6 +16,8 @@ SET(CMAKE_SHARED_BUILD_C_FLAGS "-tWR") SET(BORLAND 1) +SET(CMAKE_FIND_LIBRARY_SUFFIXES "-bcc.lib" ".lib") + # uncomment these out to debug makefiles #SET(CMAKE_START_TEMP_FILE "") #SET(CMAKE_END_TEMP_FILE "") @@ -27,7 +29,7 @@ # create a shared C++ library SET(CMAKE_CXX_CREATE_SHARED_LIBRARY " ${CMAKE_START_TEMP_FILE}-e -tWD -tWR ${CMAKE_END_TEMP_FILE}" - "implib -c -w .lib .dll" + "implib -c -w " ) SET(CMAKE_CXX_CREATE_SHARED_MODULE ${CMAKE_CXX_CREATE_SHARED_LIBRARY}) @@ -35,7 +37,7 @@ # create a C shared library SET(CMAKE_C_CREATE_SHARED_LIBRARY " ${CMAKE_START_TEMP_FILE}-e -tWD -tWR ${CMAKE_END_TEMP_FILE}" - "implib -c -w .lib .dll" + "implib -c -w " ) # create a C shared module just copy the shared library rule @@ -72,12 +74,12 @@ # extra flags for a console app SET(CMAKE_CREATE_CONSOLE_EXE "-tWC" ) -SET (CMAKE_CXX_FLAGS_INIT "-w- -whid -waus -wpar -tWM") +SET (CMAKE_CXX_FLAGS_INIT "-tWM") SET (CMAKE_CXX_FLAGS_DEBUG_INIT "-Od -v") SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-O1 -DNDEBUG") SET (CMAKE_CXX_FLAGS_RELEASE_INIT "-O2 -DNDEBUG") SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-Od") -SET (CMAKE_C_FLAGS_INIT "-w- -whid -waus -tWM") +SET (CMAKE_C_FLAGS_INIT "-tWM") SET (CMAKE_C_FLAGS_DEBUG_INIT "-Od -v") SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "-O1 -DNDEBUG") SET (CMAKE_C_FLAGS_RELEASE_INIT "-O2 -DNDEBUG") diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/Windows-cl.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/Windows-cl.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/Windows-cl.cmake 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/Windows-cl.cmake 2006-03-17 06:40:48.000000000 +0800 @@ -1,40 +1,41 @@ # try to load any previously computed information for C on this platform INCLUDE( ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeCPlatform.cmake OPTIONAL) +# try to load any previously computed information for CXX on this platform +INCLUDE( ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeCXXPlatform.cmake OPTIONAL) SET(CMAKE_LIBRARY_PATH_FLAG "-LIBPATH:") SET(CMAKE_LINK_LIBRARY_FLAG "") SET(WIN32 1) +SET(MSVC 1) IF(CMAKE_VERBOSE_MAKEFILE) SET(CMAKE_CL_NOLOGO) ELSE(CMAKE_VERBOSE_MAKEFILE) SET(CMAKE_CL_NOLOGO "/nologo") ENDIF(CMAKE_VERBOSE_MAKEFILE) -# create a shared C++ library +# create a shared C++ library SET(CMAKE_CXX_CREATE_SHARED_LIBRARY - "link ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} /out: /dll ${CMAKE_END_TEMP_FILE}") - -SET(CMAKE_CXX_CREATE_SHARED_MODULE ${CMAKE_CXX_CREATE_SHARED_LIBRARY}) + "link ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} /out: /dll ${CMAKE_END_TEMP_FILE}") +SET(CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_LIBRARY}") # create a C shared library -SET(CMAKE_C_CREATE_SHARED_LIBRARY ${CMAKE_CXX_CREATE_SHARED_LIBRARY}) +SET(CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY}") # create a C shared module just copy the shared library rule -SET(CMAKE_C_CREATE_SHARED_MODULE ${CMAKE_C_CREATE_SHARED_LIBRARY}) - +SET(CMAKE_C_CREATE_SHARED_MODULE "${CMAKE_C_CREATE_SHARED_LIBRARY}") # create a C++ static library SET(CMAKE_CXX_CREATE_STATIC_LIBRARY "lib ${CMAKE_CL_NOLOGO} /out: ") # create a C static library -SET(CMAKE_C_CREATE_STATIC_LIBRARY ${CMAKE_CXX_CREATE_STATIC_LIBRARY}) +SET(CMAKE_C_CREATE_STATIC_LIBRARY "${CMAKE_CXX_CREATE_STATIC_LIBRARY}") # compile a C++ file into an object file SET(CMAKE_CXX_COMPILE_OBJECT - " ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} /TP -DWIN32 /Fo -c ${CMAKE_END_TEMP_FILE}") + " ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} /TP /Fo -c ${CMAKE_END_TEMP_FILE}") # compile a C file into an object file SET(CMAKE_C_COMPILE_OBJECT - " ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} -DWIN32 /Fo -c ${CMAKE_END_TEMP_FILE}") + " ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} /Fo -c ${CMAKE_END_TEMP_FILE}") SET(CMAKE_C_LINK_EXECUTABLE @@ -115,12 +116,12 @@ # try to figure out if we are running the free command line # tools from Microsoft. These tools do not provide debug libraries, # so the link flags used have to be different. - MAKE_DIRECTORY("${CMAKE_BINARY_DIR}/CMakeTmp2") + MAKE_DIRECTORY("${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp2") SET(testForFreeVCFile "${CMAKE_ROOT}/Modules/CMakeTestForFreeVC.cxx") STRING(REGEX REPLACE "/" "\\\\" testForFreeVCFile "${testForFreeVCFile}") MESSAGE(STATUS "Check if this is a free VC compiler") - EXEC_PROGRAM(${CMAKE_C_COMPILER} ${CMAKE_BINARY_DIR}/CMakeTmp2 + EXEC_PROGRAM(${CMAKE_C_COMPILER} ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp2 ARGS /nologo /MD /EHsc \"${testForFreeVCFile}\" OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT @@ -145,48 +146,62 @@ # default to Debug builds IF(CMAKE_COMPILER_2005) + # for 2005 make sure the manifest is put in the dll with mt + SET(CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY}" + "mt /manifest .manifest /outputresource:\;#2") + SET(CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_LIBRARY}") + # create a C shared library + SET(CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY}") + # create a C shared module just copy the shared library rule + SET(CMAKE_C_CREATE_SHARED_MODULE "${CMAKE_C_CREATE_SHARED_LIBRARY}") + SET(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE}" + "mt /manifest .manifest /outputresource:\;#2") + SET(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE}" + "mt /manifest .manifest /outputresource:\;#2") SET(CMAKE_BUILD_TYPE_INIT Debug) - SET (CMAKE_CXX_FLAGS_INIT "/W3 /Zm1000 /EHsc /GR") - SET (CMAKE_CXX_FLAGS_DEBUG_INIT "/MDd /Zi /Od /RTC1") - SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/MD /O1 /D NDEBUG") - SET (CMAKE_CXX_FLAGS_RELEASE_INIT "/MD /O2 /D NDEBUG") - SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /D NDEBUG") - SET (CMAKE_C_FLAGS_INIT "/W3 /Zm1000") - SET (CMAKE_C_FLAGS_DEBUG_INIT "/MDd /Zi /Od /GZ") - SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "/MD /O1 /D NDEBUG") - SET (CMAKE_C_FLAGS_RELEASE_INIT "/MD /O2 /D NDEBUG") - SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /D NDEBUG") - SET (CMAKE_STANDARD_LIBRARIES "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib" CACHE STRING - "Libraries linked by defalut with all applications.") + SET (CMAKE_CXX_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /Zm1000 /EHsc /GR") + SET (CMAKE_CXX_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1") + SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/MD /O1 /Ob1 /D NDEBUG") + SET (CMAKE_CXX_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /D NDEBUG") + SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /D NDEBUG") + SET (CMAKE_C_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /Zm1000") + SET (CMAKE_C_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1") + SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "/MD /O1 /Ob1 /D NDEBUG") + SET (CMAKE_C_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /D NDEBUG") + SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /D NDEBUG") + SET (CMAKE_STANDARD_LIBRARIES "kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib " CACHE STRING + "Libraries linked by defalut with all applications.") ELSE(CMAKE_COMPILER_2005) IF(CMAKE_USING_VC_FREE_TOOLS) MESSAGE(STATUS "Using FREE VC TOOLS, NO DEBUG available") SET(CMAKE_BUILD_TYPE_INIT Release) - SET (CMAKE_CXX_FLAGS_INIT "/W3 /Zm1000 /GX /GR") - SET (CMAKE_CXX_FLAGS_DEBUG_INIT "/MTd /Zi /Od /GZ") - SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/MT /O1") - SET (CMAKE_CXX_FLAGS_RELEASE_INIT "/MT /O2") - SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2") - SET (CMAKE_C_FLAGS_INIT "/W3 /Zm1000 /GX /GR") - SET (CMAKE_C_FLAGS_DEBUG_INIT "/MTd /Zi /Od /GZ") - SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "/MT /O1") - SET (CMAKE_C_FLAGS_RELEASE_INIT "/MT /O2") - SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2") + SET (CMAKE_CXX_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /Zm1000 /GX /GR") + SET (CMAKE_CXX_FLAGS_DEBUG_INIT "/D_DEBUG /MTd /Zi /Ob0 /Od /GZ") + SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/MT /O1 /Ob1") + SET (CMAKE_CXX_FLAGS_RELEASE_INIT "/MT /O2 /Ob2") + SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1") + SET (CMAKE_C_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /Zm1000 /GX /GR") + SET (CMAKE_C_FLAGS_DEBUG_INIT "/D_DEBUG /MTd /Zi /Ob0 /Od /GZ") + SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "/MT /O1 /Ob1") + SET (CMAKE_C_FLAGS_RELEASE_INIT "/MT /O2 /Ob2") + SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1") SET (CMAKE_STANDARD_LIBRARIES "kernel32.lib user32.lib gdi32.lib advapi32.lib rpcrt4.lib" CACHE STRING "Libraries linked by defalut with all applications.") + SET (CMAKE_STANDARD_LIBRARIES "kernel32.lib user32.lib gdi32.lib advapi32.lib rpcrt4.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib" CACHE STRING + "Libraries linked by defalut with all applications.") ELSE(CMAKE_USING_VC_FREE_TOOLS) SET(CMAKE_BUILD_TYPE_INIT Debug) - SET (CMAKE_CXX_FLAGS_INIT "/W3 /Zm1000 /GX /GR") - SET (CMAKE_CXX_FLAGS_DEBUG_INIT "/MDd /Zi /Od /GZ") - SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/MD /O1 /D NDEBUG") - SET (CMAKE_CXX_FLAGS_RELEASE_INIT "/MD /O2 /D NDEBUG") - SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /D NDEBUG") - SET (CMAKE_C_FLAGS_INIT "/W3 /Zm1000") - SET (CMAKE_C_FLAGS_DEBUG_INIT "/MDd /Zi /Od /GZ") - SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "/MD /O1 /D NDEBUG") - SET (CMAKE_C_FLAGS_RELEASE_INIT "/MD /O2 /D NDEBUG") - SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /D NDEBUG") - SET (CMAKE_STANDARD_LIBRARIES "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib" CACHE STRING + SET (CMAKE_CXX_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /Zm1000 /GX /GR") + SET (CMAKE_CXX_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od /GZ") + SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/MD /O1 /Ob1 /D NDEBUG") + SET (CMAKE_CXX_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /D NDEBUG") + SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /D NDEBUG") + SET (CMAKE_C_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /Zm1000") + SET (CMAKE_C_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od /GZ") + SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "/MD /O1 /Ob1 /D NDEBUG") + SET (CMAKE_C_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /D NDEBUG") + SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /D NDEBUG") + SET (CMAKE_STANDARD_LIBRARIES "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib" CACHE STRING "Libraries linked by defalut with all applications.") ENDIF(CMAKE_USING_VC_FREE_TOOLS) ENDIF(CMAKE_COMPILER_2005) @@ -216,5 +231,14 @@ # save computed information for this platform -CONFIGURE_FILE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake.in - ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeCPlatform.cmake IMMEDIATE) +IF(NOT EXISTS "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeCPlatform.cmake") + CONFIGURE_FILE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake.in + ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeCPlatform.cmake IMMEDIATE) +ENDIF(NOT EXISTS "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeCPlatform.cmake") + +IF(NOT EXISTS "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeCXXPlatform.cmake") + CONFIGURE_FILE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake.in + ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeCXXPlatform.cmake IMMEDIATE) +ENDIF(NOT EXISTS "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeCXXPlatform.cmake") + +INCLUDE(Platform/WindowsPaths) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/Windows.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/Windows.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/Windows.cmake 2003-08-22 04:22:22.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/Windows.cmake 2006-02-19 04:37:22.000000000 +0800 @@ -2,9 +2,15 @@ SET(CMAKE_STATIC_LIBRARY_SUFFIX ".lib") SET(CMAKE_SHARED_LIBRARY_PREFIX "") # lib SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") # .so +SET(CMAKE_IMPORT_LIBRARY_PREFIX "") +SET(CMAKE_IMPORT_LIBRARY_SUFFIX ".lib") +SET(CMAKE_EXECUTABLE_SUFFIX ".exe") # .exe SET(CMAKE_LINK_LIBRARY_SUFFIX ".lib") SET(CMAKE_DL_LIBS "") +SET(CMAKE_FIND_LIBRARY_PREFIXES "") +SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib") + # for borland make long command lines are redirected to a file # with the following syntax, see Windows-bcc32.cmake for use IF(CMAKE_GENERATOR MATCHES "Borland") diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/Windows-g77.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/Windows-g77.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/Windows-g77.cmake 2004-10-22 02:34:02.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/Windows-g77.cmake 2006-01-03 02:37:53.000000000 +0800 @@ -3,6 +3,7 @@ SET(CMAKE_STATIC_LIBRARY_SUFFIX ".a") SET(CMAKE_SHARED_LIBRARY_PREFIX "lib") # lib SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") # .so +SET(CMAKE_EXECUTABLE_SUFFIX ".exe") # .exe SET(CMAKE_SHARED_MODULE_PREFIX "lib") # lib SET(CMAKE_SHARED_MODULE_SUFFIX ".dll") # .so SET(CMAKE_DL_LIBS "") diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/Windows-gcc.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/Windows-gcc.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/Windows-gcc.cmake 2005-10-25 03:43:52.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/Windows-gcc.cmake 2006-02-20 02:49:18.000000000 +0800 @@ -5,6 +5,9 @@ SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") # .so SET(CMAKE_SHARED_MODULE_PREFIX "lib") # lib SET(CMAKE_SHARED_MODULE_SUFFIX ".dll") # .so +SET(CMAKE_IMPORT_LIBRARY_PREFIX "lib") +SET(CMAKE_IMPORT_LIBRARY_SUFFIX ".dll.a") +SET(CMAKE_EXECUTABLE_SUFFIX ".exe") # .exe SET(CMAKE_DL_LIBS "") SET(CMAKE_SHARED_LIBRARY_C_FLAGS "") # -pic SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "") # -pic @@ -14,3 +17,18 @@ SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "") # : or empty SET(CMAKE_LIBRARY_PATH_FLAG "-L") SET(CMAKE_LINK_LIBRARY_FLAG "-l") + +IF(MINGW) + SET(CMAKE_FIND_LIBRARY_PREFIXES "lib" "") + SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ".dll.a" ".a") +ENDIF(MINGW) + +SET(CMAKE_C_CREATE_SHARED_MODULE + " -o ") +SET(CMAKE_CXX_CREATE_SHARED_MODULE + " -o ") + +SET(CMAKE_C_CREATE_SHARED_LIBRARY + " -o -Wl,--out-implib, ") +SET(CMAKE_CXX_CREATE_SHARED_LIBRARY + " -o -Wl,--out-implib, ") diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/Windows-g++.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/Windows-g++.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/Windows-g++.cmake 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/Windows-g++.cmake 2006-02-10 03:18:48.000000000 +0800 @@ -0,0 +1 @@ +INCLUDE(${CMAKE_ROOT}/Modules/Platform/Windows-gcc.cmake) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/WindowsPaths.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/WindowsPaths.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/WindowsPaths.cmake 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/WindowsPaths.cmake 2006-03-03 02:30:22.000000000 +0800 @@ -0,0 +1,3 @@ +SET(CMAKE_SYSTEM_INCLUDE_PATH ${CMAKE_SYSTEM_INCLUDE_PATH} "$ENV{ProgramFiles}") +SET(CMAKE_SYSTEM_LIBRARY_PATH ${CMAKE_SYSTEM_LIBRARY_PATH} "$ENV{ProgramFiles}") +SET(CMAKE_SYSTEM_PROGRAM_PATH ${CMAKE_SYSTEM_PROGRAM_PATH} "$ENV{ProgramFiles}") diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/Windows-wcl386.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/Windows-wcl386.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/Platform/Windows-wcl386.cmake 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Platform/Windows-wcl386.cmake 2006-02-19 04:37:22.000000000 +0800 @@ -0,0 +1,56 @@ +SET(CMAKE_LIBRARY_PATH_FLAG "libpath ") +SET(CMAKE_LINK_LIBRARY_FLAG "library ") + +IF(CMAKE_VERBOSE_MAKEFILE) + SET(CMAKE_WCL_QUIET) + SET(CMAKE_WLINK_QUIET) + SET(CMAKE_LIB_QUIET) +ELSE(CMAKE_VERBOSE_MAKEFILE) + SET(CMAKE_WCL_QUIET "-zq") + SET(CMAKE_WLINK_QUIET "option quiet") + SET(CMAKE_LIB_QUIET "-q") +ENDIF(CMAKE_VERBOSE_MAKEFILE) + +SET(CMAKE_BUILD_TYPE_INIT Debug) +SET (CMAKE_CXX_FLAGS_INIT "-w=3 -xs") +SET (CMAKE_CXX_FLAGS_DEBUG_INIT "-br -bm -d2") +SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-br -bm -os -dNDEBUG") +SET (CMAKE_CXX_FLAGS_RELEASE_INIT "-br -bm -ot -dNDEBUG") +SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-br -bm -d2 -ot -dNDEBUG") +SET (CMAKE_C_FLAGS_INIT "-w=3 ") +SET (CMAKE_C_FLAGS_DEBUG_INIT "-br -bm -od") +SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "-br -bm -os -dNDEBUG") +SET (CMAKE_C_FLAGS_RELEASE_INIT "-br -bm -ot -dNDEBUG") +SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-br -bm -ot -dNDEBUG") +SET (CMAKE_STANDARD_LIBRARIES "library clbrdll.lib library plbrdll.lib library kernel32.lib library user32.lib library gdi32.lib library winspool.lib library comdlg32.lib library advapi32.lib library shell32.lib library ole32.lib library oleaut32.lib library uuid.lib library odbc32.lib library odbccp32.lib" CACHE STRING + "Libraries linked by defalut with all applications.") + +SET(CMAKE_C_LINK_EXECUTABLE + "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name option caseexact file {} ${CMAKE_END_TEMP_FILE}") + +SET(CMAKE_CXX_LINK_EXECUTABLE ${CMAKE_C_LINK_EXECUTABLE}) + +# compile a C++ file into an object file +SET(CMAKE_CXX_COMPILE_OBJECT + " ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} -dWIN32 -fo -c -cc++ ${CMAKE_END_TEMP_FILE}") + +# compile a C file into an object file +SET(CMAKE_C_COMPILE_OBJECT + " ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} -dWIN32 -fo -c -cc ${CMAKE_END_TEMP_FILE}") + +SET(CMAKE_CXX_CREATE_SHARED_LIBRARY + "wlink ${CMAKE_START_TEMP_FILE} system nt_dll ${CMAKE_WLINK_QUIET} name option caseexact file {} " + "wlib -q -n -b + ${CMAKE_END_TEMP_FILE}") +SET(CMAKE_CXX_CREATE_SHARED_MODULE ${CMAKE_CXX_CREATE_SHARED_LIBRARY}) + +# create a C shared library +SET(CMAKE_C_CREATE_SHARED_LIBRARY ${CMAKE_CXX_CREATE_SHARED_LIBRARY}) + +# create a C shared module just copy the shared library rule +SET(CMAKE_C_CREATE_SHARED_MODULE ${CMAKE_C_CREATE_SHARED_LIBRARY}) + +# create a C++ static library +SET(CMAKE_CXX_CREATE_STATIC_LIBRARY "wlib ${CMAKE_LIB_QUIET} -n -b ") + +# create a C static library +SET(CMAKE_C_CREATE_STATIC_LIBRARY ${CMAKE_CXX_CREATE_STATIC_LIBRARY}) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/readme.txt /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/readme.txt --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/readme.txt 2002-09-06 23:00:51.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/readme.txt 2006-01-28 02:07:23.000000000 +0800 @@ -26,4 +26,50 @@ If you need other commands to do special things then it should still begin with XXX_. This gives a sort of namespace effect and keeps things tidy for the user. You should put comments describing all the exported settings, plus descriptions of any the users can use to control stuff. -You really should also provide backwards compatibility any old settings that were actually in use. Make sure you comment them as deprecated, so that no-one starts using them. \ No newline at end of file +You really should also provide backwards compatibility any old settings that were actually in use. Make sure you comment them as deprecated, so that no-one starts using them. + +To correctly document a module, create a comment block at the top with # comments. There are three types of comments that can be in the block: + +1. The brief description of the module, this is done by: +# - a small description + +2. A paragraph of text. This is done with all text that has a single +space between the # and the text. To create a new paragraph, just +put a # with no text on the line. + +3. A verbatim line. This is done with two spaces between the # and the text. + +For example: + +# - This is a cool module +# This module does really cool stuff. +# It can do even more than you think. +# +# It even needs to paragraphs to tell you about it. +# And it defines the following variables: +# VAR_COOL - this is greate isn't it? +# VAR_REALLY_COOL - cool right? +# + +To have a .cmake file in this directory NOT show up in the +modules documentation, you should start the file with a blank +line. + +A FindXXX.cmake module will typically be loaded by the command + + FIND_PACKAGE(XXX [QUIET] [REQUIRED [components...]]) + +If the QUIET option is given to the command it will set the variable +XXX_FIND_QUIETLY to true before loading the FindXXX.cmake module. If +this variable is set the module should not complain about not being +able to find the package and should never issue a FATAL_ERROR. If the +REQUIRED option is given to the command it will set the variable +XXX_FIND_REQUIRED to true before loading the FindXXX.cmake module. If +this variable is set the module should issue a FATAL_ERROR if the +package cannot be found. For each package-specific component, say +YYY, listed after the REQUIRED option a variable XXX_FIND_REQUIRED_YYY +to true. This can be used by the FindXXX.cmake module to determine +which sub-components of the package must be found. If neither the +QUIET nor REQUIRED options are given then the FindXXX.cmake module +should look for the package and complain without error if the module +is not found. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/TestBigEndian.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/TestBigEndian.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/TestBigEndian.cmake 2005-08-12 02:02:19.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/TestBigEndian.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,7 +1,7 @@ -# +# - Define macro to determine endian type # Check if the system is big endian or little endian -# -# VARIABLE - variable to store the result to +# TEST_BIG_ENDIAN(VARIABLE) +# VARIABLE - variable to store the result to # MACRO(TEST_BIG_ENDIAN VARIABLE) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/TestCXXAcceptsFlag.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/TestCXXAcceptsFlag.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/TestCXXAcceptsFlag.cmake 2005-08-12 02:02:19.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/TestCXXAcceptsFlag.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,9 +1,10 @@ -# +# - Test CXX compiler for a flag # Check if the CXX compiler accepts a flag # -# CHECK_FUNCTION_EXISTS - macro which checks if the function exists -# FLAG - the flags to try -# VARIABLE - variable to store the result +# Macro CHECK_CXX_ACCEPTS_FLAG(FLAGS VARIABLE) - +# checks if the function exists +# FLAGS - the flags to try +# VARIABLE - variable to store the result # MACRO(CHECK_CXX_ACCEPTS_FLAG FLAGS VARIABLE) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/TestForANSIForScope.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/TestForANSIForScope.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/TestForANSIForScope.cmake 2005-08-12 02:02:19.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/TestForANSIForScope.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,7 +1,6 @@ -# -# check if the compiler supports std:: on stl classes -# -# CMAKE_NO_STD_NAMESPACE - defined accoreding to the results +# - Check for ANSI for scope support +# Check if the compiler supports std:: on stl classes. +# CMAKE_NO_STD_NAMESPACE - holds result # IF("CMAKE_ANSI_FOR_SCOPE" MATCHES "^CMAKE_ANSI_FOR_SCOPE$") diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/TestForANSIStreamHeaders.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/TestForANSIStreamHeaders.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/TestForANSIStreamHeaders.cmake 2004-08-27 10:52:53.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/TestForANSIStreamHeaders.cmake 2005-12-16 03:17:43.000000000 +0800 @@ -1,7 +1,6 @@ -# +# - Test for compiler support of ANSI stream headers iostream, etc. # check if we they have the standard ansi stream files (without the .h) -# -# CMAKE_NO_ANSI_STREAM_HEADERS - defined accoreding to the results +# CMAKE_NO_ANSI_STREAM_HEADERS - defined by the results # INCLUDE(CheckIncludeFileCXX) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/TestForSSTREAM.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/TestForSSTREAM.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/TestForSSTREAM.cmake 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/TestForSSTREAM.cmake 2006-01-17 23:21:44.000000000 +0800 @@ -0,0 +1,29 @@ +# # - Test for std:: namespace support +# check if the compiler supports std:: on stl classes +# CMAKE_NO_STD_NAMESPACE - defined by the results +# +IF("CMAKE_HAS_ANSI_STRING_STREAM" MATCHES "^CMAKE_HAS_ANSI_STRING_STREAM$") + MESSAGE(STATUS "Check for sstream") + TRY_COMPILE(CMAKE_HAS_ANSI_STRING_STREAM ${CMAKE_BINARY_DIR} + ${CMAKE_ROOT}/Modules/TestForSSTREAM.cxx + OUTPUT_VARIABLE OUTPUT) + IF (CMAKE_HAS_ANSI_STRING_STREAM) + MESSAGE(STATUS "Check for sstream - found") + SET (CMAKE_NO_ANSI_STRING_STREAM 0 CACHE INTERNAL + "Does the compiler support sstream") + FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log + "Determining if the CXX compiler has sstream passed with " + "the following output:\n${OUTPUT}\n\n") + ELSE (CMAKE_HAS_ANSI_STRING_STREAM) + MESSAGE(STATUS "Check for sstream - not found") + SET (CMAKE_NO_ANSI_STRING_STREAM 1 CACHE INTERNAL + "Does the compiler support sstream") + FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log + "Determining if the CXX compiler has sstream failed with " + "the following output:\n${OUTPUT}\n\n") + ENDIF (CMAKE_HAS_ANSI_STRING_STREAM) +ENDIF("CMAKE_HAS_ANSI_STRING_STREAM" MATCHES "^CMAKE_HAS_ANSI_STRING_STREAM$") + + + + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/TestForSSTREAM.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/TestForSSTREAM.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/TestForSSTREAM.cxx 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/TestForSSTREAM.cxx 2006-01-17 23:21:44.000000000 +0800 @@ -0,0 +1,11 @@ +#include +int main(int, char*[]) +{ + std::ostringstream os; + os << "12345"; + if(os.str().size() == 5) + { + return 0; + } + return -1; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/TestForSTDNamespace.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/TestForSTDNamespace.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/TestForSTDNamespace.cmake 2005-08-12 02:02:19.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/TestForSTDNamespace.cmake 2005-12-16 03:17:43.000000000 +0800 @@ -1,7 +1,6 @@ -# +# - Test for std:: namespace support # check if the compiler supports std:: on stl classes -# -# CMAKE_NO_STD_NAMESPACE - defined accoreding to the results +# CMAKE_NO_STD_NAMESPACE - defined by the results # IF("CMAKE_STD_NAMESPACE" MATCHES "^CMAKE_STD_NAMESPACE$") MESSAGE(STATUS "Check for STD namespace") diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/UsePkgConfig.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/UsePkgConfig.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/UsePkgConfig.cmake 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/UsePkgConfig.cmake 2006-03-16 02:20:03.000000000 +0800 @@ -0,0 +1,46 @@ +# - pkg-config module for CMake +# +# Defines the following macros: +# +# PKGCONFIG(package includedir libdir linkflags cflags) +# +# Calling PKGCONFIG will fill the desired information into the 4 given arguments, +# e.g. PKGCONFIG(libart-2.0 LIBART_INCLUDE_DIR LIBART_LINK_DIR LIBART_LINK_FLAGS LIBART_CFLAGS) +# if pkg-config was NOT found or the specified software package doesn't exist, the +# variable will be empty when the function returns, otherwise they will contain the respective information +# + + + +FIND_PROGRAM(PKGCONFIG_EXECUTABLE NAMES pkg-config PATHS /usr/local/bin ) + +MACRO(PKGCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags) +# reset the variables at the beginning + SET(${_include_DIR}) + SET(${_link_DIR}) + SET(${_link_FLAGS}) + SET(${_cflags}) + + # if pkg-config has been found + IF(PKGCONFIG_EXECUTABLE) + + EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --exists RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull ) + + # and if the package of interest also exists for pkg-config, then get the information + IF(NOT _return_VALUE) + + EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable=includedir OUTPUT_VARIABLE ${_include_DIR} ) + + EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable=libdir OUTPUT_VARIABLE ${_link_DIR} ) + + EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --libs OUTPUT_VARIABLE ${_link_FLAGS} ) + + EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --cflags OUTPUT_VARIABLE ${_cflags} ) + + ENDIF(NOT _return_VALUE) + + ENDIF(PKGCONFIG_EXECUTABLE) + +ENDMACRO(PKGCONFIG _include_DIR _link_DIR _link_FLAGS _cflags) + +MARK_AS_ADVANCED(PKGCONFIG_EXECUTABLE) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/UseQt4.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/UseQt4.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/UseQt4.cmake 2005-09-16 04:38:36.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/UseQt4.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,10 +1,8 @@ -############################################################################# -# -# Sets up C and C++ to use Qt 4. It is assumed that FindQt.cmake -# has already been loaded. See FindQt.cmake for information on -# how to load Qt 4 into your CMake project. -# -############################################################################# +# - Use Module for QT4 +# Sets up C and C++ to use Qt 4. It is assumed that FindQt.cmake +# has already been loaded. See FindQt.cmake for information on +# how to load Qt 4 into your CMake project. + ADD_DEFINITIONS(${QT_DEFINITIONS}) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/UseSWIG.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/UseSWIG.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/UseSWIG.cmake 2005-09-09 02:59:57.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/UseSWIG.cmake 2005-12-16 03:17:43.000000000 +0800 @@ -1,18 +1,13 @@ -# -# SWIG module for CMake -# +# - SWIG module for CMake # Defines the following macros: -# # SWIG_ADD_MODULE(name language [ files ]) # - Define swig module with given name and specified language -# # SWIG_LINK_LIBRARIES(name [ libraries ]) # - Link libraries to swig module -# # All other macros are for internal use only. -# -# To get the actual name of the swig module, use: ${SWIG_MODULE_name_REAL_NAME}. -# Set Source files propertis such as CPLUSPLUS and SWIG_FLAGS to specify +# To get the actual name of the swig module, +# use: ${SWIG_MODULE_name_REAL_NAME}. +# Set Source files properties such as CPLUSPLUS and SWIG_FLAGS to specify # special behavior of SWIG. Also global CMAKE_SWIG_FLAGS can be used to add # special flags to all swig calls. # Another special variable is CMAKE_SWIG_OUTDIR, it allows one to specify @@ -137,20 +132,20 @@ ENDIF(SWIG_MODULE_${name}_EXTRA_FLAGS) # If CMAKE_SWIG_OUTDIR was specified then pass it to -outdir IF(CMAKE_SWIG_OUTDIR) - ADD_CUSTOM_COMMAND( - OUTPUT "${swig_generated_file_fullname}" - COMMAND "${SWIG_EXECUTABLE}" - ARGS "-${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}" - ${swig_source_file_flags} - ${CMAKE_SWIG_FLAGS} + ADD_CUSTOM_COMMAND( + OUTPUT "${swig_generated_file_fullname}" + COMMAND "${SWIG_EXECUTABLE}" + ARGS "-${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}" + ${swig_source_file_flags} + ${CMAKE_SWIG_FLAGS} -outdir ${CMAKE_SWIG_OUTDIR} - ${swig_special_flags} - ${swig_extra_flags} - ${swig_include_dirs} - -o "${swig_generated_file_fullname}" - "${swig_source_file_fullname}" - MAIN_DEPENDENCY "${swig_source_file_fullname}" - COMMENT "Swig source") + ${swig_special_flags} + ${swig_extra_flags} + ${swig_include_dirs} + -o "${swig_generated_file_fullname}" + "${swig_source_file_fullname}" + MAIN_DEPENDENCY "${swig_source_file_fullname}" + COMMENT "Swig source") ELSE(CMAKE_SWIG_OUTDIR) ADD_CUSTOM_COMMAND( OUTPUT "${swig_generated_file_fullname}" diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/UseVTK40.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/UseVTK40.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/UseVTK40.cmake 2004-08-27 10:52:53.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/UseVTK40.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,3 +1,5 @@ +# + # This is an implementation detail for using VTK 4.0 with the # FindVTK.cmake module. Do not include directly by name. This should # be included only when FindVTK.cmake sets the VTK_USE_FILE variable diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/UseVTKBuildSettings40.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/UseVTKBuildSettings40.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/UseVTKBuildSettings40.cmake 2002-12-05 23:47:18.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/UseVTKBuildSettings40.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,3 +1,5 @@ +# + # Implementation detail for FindVTK.cmake to let it provide a # VTK_BUILD_SETTINGS_FILE for VTK 4.0. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/UseVTKConfig40.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/UseVTKConfig40.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/UseVTKConfig40.cmake 2003-02-08 05:29:13.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/UseVTKConfig40.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1,3 +1,5 @@ +# + # This is an implementation detail for using VTK 4.0 with the # FindVTK.cmake module. Do not include directly. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/UsewxWidgets.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/UsewxWidgets.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/UsewxWidgets.cmake 2004-08-27 10:52:53.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/UsewxWidgets.cmake 2005-12-15 02:51:08.000000000 +0800 @@ -1 +1,4 @@ +# - Same as Use_wxWindows +# + INCLUDE(Use_wxWindows) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/Use_wxWindows.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Use_wxWindows.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/Use_wxWindows.cmake 2004-08-27 10:52:53.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/Use_wxWindows.cmake 2005-12-16 03:17:43.000000000 +0800 @@ -1,49 +1,43 @@ -## -## This convenience include finds if wxWindows is installed -## and set the appropriate libs, incdirs, flags etc. - -## author Jan Woetzel (07/2003) -## -## ----------------------------------------------------- -## USAGE: -## just include Use_wxWindows.cmake -## in your projects CMakeLists.txt -## INCLUDE(Use_wxWindows) -## -## if you are sure you need GL then -## SET(WXWINDOWS_USE_GL 1) -## *before* you include this file. -## -## ----------------------------------------------------- - - - -INCLUDE(FindwxWindows) - -IF(WXWINDOWS_FOUND) - - #MESSAGE("DBG Use_wxWindows.cmake: WXWINDOWS_INCLUDE_DIR=${WXWINDOWS_INCLUDE_DIR} WXWINDOWS_LINK_DIRECTORIES=${WXWINDOWS_LINK_DIRECTORIES} WXWINDOWS_LIBRARIES=${WXWINDOWS_LIBRARIES} CMAKE_WXWINDOWS_CXX_FLAGS=${CMAKE_WXWINDOWS_CXX_FLAGS} WXWINDOWS_DEFINITIONS=${WXWINDOWS_DEFINITIONS}") - - IF(WXWINDOWS_INCLUDE_DIR) - INCLUDE_DIRECTORIES(${WXWINDOWS_INCLUDE_DIR}) - ENDIF(WXWINDOWS_INCLUDE_DIR) - - IF(WXWINDOWS_LINK_DIRECTORIES) - LINK_DIRECTORIES(${WXWINDOWS_LINK_DIRECTORIES}) - ENDIF(WXWINDOWS_LINK_DIRECTORIES) - - IF(WXWINDOWS_LIBRARIES) - LINK_LIBRARIES(${WXWINDOWS_LIBRARIES}) - ENDIF(WXWINDOWS_LIBRARIES) - - IF (CMAKE_WXWINDOWS_CXX_FLAGS) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_WXWINDOWS_CXX_FLAGS}") - ENDIF(CMAKE_WXWINDOWS_CXX_FLAGS) - - IF(WXWINDOWS_DEFINITIONS) - ADD_DEFINITIONS(${WXWINDOWS_DEFINITIONS}) - ENDIF(WXWINDOWS_DEFINITIONS) - -ELSE(WXWINDOWS_FOUND) - MESSAGE(SEND_ERROR "wxWindows not found by Use_wxWindows.cmake") -ENDIF(WXWINDOWS_FOUND) +# - Find wxWindows installation +# +# This convenience include finds if wxWindows is installed +# and set the appropriate libs, incdirs, flags etc. +# INCLUDE_DIRECTORIES, LINK_DIRECTORIES and ADD_DEFINITIONS +# are called. +# author Jan Woetzel (07/2003) +# +# if you are sure you need GL then +# SET(WXWINDOWS_USE_GL 1) +# *before* you include this file. +# + + +INCLUDE(FindwxWindows) + +IF(WXWINDOWS_FOUND) + + #MESSAGE("DBG Use_wxWindows.cmake: WXWINDOWS_INCLUDE_DIR=${WXWINDOWS_INCLUDE_DIR} WXWINDOWS_LINK_DIRECTORIES=${WXWINDOWS_LINK_DIRECTORIES} WXWINDOWS_LIBRARIES=${WXWINDOWS_LIBRARIES} CMAKE_WXWINDOWS_CXX_FLAGS=${CMAKE_WXWINDOWS_CXX_FLAGS} WXWINDOWS_DEFINITIONS=${WXWINDOWS_DEFINITIONS}") + + IF(WXWINDOWS_INCLUDE_DIR) + INCLUDE_DIRECTORIES(${WXWINDOWS_INCLUDE_DIR}) + ENDIF(WXWINDOWS_INCLUDE_DIR) + + IF(WXWINDOWS_LINK_DIRECTORIES) + LINK_DIRECTORIES(${WXWINDOWS_LINK_DIRECTORIES}) + ENDIF(WXWINDOWS_LINK_DIRECTORIES) + + IF(WXWINDOWS_LIBRARIES) + LINK_LIBRARIES(${WXWINDOWS_LIBRARIES}) + ENDIF(WXWINDOWS_LIBRARIES) + + IF (CMAKE_WXWINDOWS_CXX_FLAGS) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_WXWINDOWS_CXX_FLAGS}") + ENDIF(CMAKE_WXWINDOWS_CXX_FLAGS) + + IF(WXWINDOWS_DEFINITIONS) + ADD_DEFINITIONS(${WXWINDOWS_DEFINITIONS}) + ENDIF(WXWINDOWS_DEFINITIONS) + +ELSE(WXWINDOWS_FOUND) + MESSAGE(SEND_ERROR "wxWindows not found by Use_wxWindows.cmake") +ENDIF(WXWINDOWS_FOUND) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Modules/VTKCompatibility.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/VTKCompatibility.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Modules/VTKCompatibility.cmake 2005-11-29 03:05:50.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Modules/VTKCompatibility.cmake 2006-03-14 02:11:50.000000000 +0800 @@ -10,3 +10,10 @@ SET(VTKFTGL_SOURCE_DIR "${VTK_SOURCE_DIR}/Utilities/ftgl" CACHE INTERNAL "") SET(VTKFREETYPE_SOURCE_DIR "${VTK_SOURCE_DIR}/Utilities/freetype" CACHE INTERNAL "") +SET(VTK_GLEXT_FILE "${VTK_SOURCE_DIR}/Utilities/ParseOGLExt/headers/glext.h" CACHE FILEPATH + "Location of the OpenGL extensions header file (glext.h).") +SET(VTK_GLXEXT_FILE "${VTK_SOURCE_DIR}/Utilities/ParseOGLExt/headers/glxext.h" CACHE FILEPATH + "Location of the GLX extensions header file (glxext.h).") +SET(VTK_WGLEXT_FILE "${VTK_SOURCE_DIR}/Utilities/ParseOGLExt/headers/wglext.h" CACHE FILEPATH + "Location of the WGL extensions header file (wglext.h).") + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddCustomCommandCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddCustomCommandCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddCustomCommandCommand.cxx 2005-08-12 02:02:19.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddCustomCommandCommand.cxx 2006-03-16 00:01:58.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmAddCustomCommandCommand.cxx,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:19 $ - Version: $Revision: 1.22.2.2 $ + Date: $Date: 2006/03/15 16:01:58 $ + Version: $Revision: 1.29 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -19,7 +19,8 @@ #include "cmTarget.h" // cmAddCustomCommandCommand -bool cmAddCustomCommandCommand::InitialPass(std::vector const& args) +bool cmAddCustomCommandCommand::InitialPass( + std::vector const& args) { /* Let's complain at the end of this function about the lack of a particular arg. For the moment, let's say that COMMAND, and either TARGET or SOURCE @@ -31,7 +32,8 @@ return false; } - std::string source, target, comment, output, main_dependency; + std::string source, target, comment, output, main_dependency, + working; std::vector depends, outputs; // Accumulate one command line at a time. @@ -41,7 +43,7 @@ cmCustomCommandLines commandLines; cmTarget::CustomCommandType cctype = cmTarget::POST_BUILD; - + enum tdoing { doing_source, doing_command, @@ -51,6 +53,7 @@ doing_output, doing_outputs, doing_comment, + doing_working_directory, doing_nothing }; @@ -107,6 +110,10 @@ { doing = doing_output; } + else if (copy == "WORKING_DIRECTORY") + { + doing = doing_working_directory; + } else if (copy == "MAIN_DEPENDENCY") { doing = doing_main_dependency; @@ -124,7 +131,7 @@ case doing_outputs: if (!cmSystemTools::FileIsFullPath(copy.c_str())) { - filename = m_Makefile->GetStartDirectory(); + filename = this->Makefile->GetStartDirectory(); filename += "/"; } filename += copy; @@ -141,6 +148,9 @@ switch (doing) { + case doing_working_directory: + working = copy; + break; case doing_source: source = copy; break; @@ -189,7 +199,8 @@ if(source.empty() && !target.empty() && !output.empty()) { - this->SetError("Wrong syntax. A TARGET and OUTPUT can not both be specified."); + this->SetError( + "Wrong syntax. A TARGET and OUTPUT can not both be specified."); return false; } @@ -202,27 +213,27 @@ this->SetError(msg.str().c_str()); return false; } - // Choose which mode of the command to use. if(source.empty() && output.empty()) { // Source is empty, use the target. std::vector no_depends; - m_Makefile->AddCustomCommandToTarget(target.c_str(), no_depends, + this->Makefile->AddCustomCommandToTarget(target.c_str(), no_depends, commandLines, cctype, - comment.c_str()); + comment.c_str(), working.c_str()); } else if(target.empty()) { // Target is empty, use the output. - m_Makefile->AddCustomCommandToOutput(output.c_str(), depends, + this->Makefile->AddCustomCommandToOutput(output.c_str(), depends, main_dependency.c_str(), - commandLines, comment.c_str()); + commandLines, comment.c_str(), + working.c_str()); } else { // Use the old-style mode for backward compatibility. - m_Makefile->AddCustomCommandOldStyle(target.c_str(), outputs, depends, + this->Makefile->AddCustomCommandOldStyle(target.c_str(), outputs, depends, source.c_str(), commandLines, comment.c_str()); } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddCustomCommandCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddCustomCommandCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddCustomCommandCommand.h 2005-02-23 01:10:43.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddCustomCommandCommand.h 2006-02-08 23:58:34.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmAddCustomCommandCommand.h,v $ Language: C++ - Date: $Date: 2005/02/22 17:10:43 $ - Version: $Revision: 1.20 $ + Date: $Date: 2006/02/08 15:58:34 $ + Version: $Revision: 1.21 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -71,6 +71,7 @@ " [COMMAND command2 [ARGS] [args2...] ...]\n" " [MAIN_DEPENDENCY depend]\n" " [DEPENDS [depends...]]\n" + " [WORKING_DIRECTORY dir]\n" " [COMMENT comment])\n" "This defines a new command that can be executed during the build " "process. Note that MAIN_DEPENDENCY is completely optional and is " @@ -89,6 +90,7 @@ " PRE_BUILD | PRE_LINK | POST_BUILD\n" " COMMAND command1 [ARGS] [args1...]\n" " [COMMAND command2 [ARGS] [args2...] ...]\n" + " [WORKING_DIRECTORY dir]\n" " [COMMENT comment])\n" "This defines a new command that will be associated with " "building the specified target. When the command will " @@ -98,7 +100,9 @@ " POST_BUILD - run after the target has been built\n" "Note that the PRE_BUILD option is only supported on Visual " "Studio 7 or later. For all other generators PRE_BUILD " - "will be treated as PRE_LINK."; + "will be treated as PRE_LINK." + "If WORKING_DIRECTORY is specified the command a cd \"dir\" is " + "done prior to running the command."; } cmTypeMacro(cmAddCustomCommandCommand, cmCommand); diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddCustomTargetCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddCustomTargetCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddCustomTargetCommand.cxx 2005-03-22 21:36:40.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddCustomTargetCommand.cxx 2006-03-16 00:01:58.000000000 +0800 @@ -3,21 +3,22 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmAddCustomTargetCommand.cxx,v $ Language: C++ - Date: $Date: 2005/03/22 13:36:40 $ - Version: $Revision: 1.17 $ + Date: $Date: 2006/03/15 16:01:58 $ + Version: $Revision: 1.21 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "cmAddCustomTargetCommand.h" // cmAddCustomTargetCommand -bool cmAddCustomTargetCommand::InitialPass(std::vector const& args) +bool cmAddCustomTargetCommand::InitialPass( + std::vector const& args) { if(args.size() < 1 ) { @@ -33,11 +34,13 @@ // Accumulate dependencies. std::vector depends; + std::string working_directory; // Keep track of parser state. enum tdoing { doing_command, - doing_depends + doing_depends, + doing_working_directory }; tdoing doing = doing_command; @@ -62,6 +65,10 @@ { doing = doing_depends; } + else if(copy == "WORKING_DIRECTORY") + { + doing = doing_working_directory; + } else if(copy == "COMMAND") { doing = doing_command; @@ -77,6 +84,9 @@ { switch (doing) { + case doing_working_directory: + working_directory = copy; + break; case doing_command: currentLine.push_back(copy); break; @@ -109,8 +119,9 @@ // Add the utility target to the makefile. const char* no_output = 0; - m_Makefile->AddUtilityCommand(args[0].c_str(), all, no_output, depends, - commandLines); + this->Makefile->AddUtilityCommand(args[0].c_str(), all, no_output, + working_directory.c_str(), depends, + commandLines); return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddCustomTargetCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddCustomTargetCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddCustomTargetCommand.h 2005-02-22 23:32:43.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddCustomTargetCommand.h 2006-02-08 23:58:34.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmAddCustomTargetCommand.h,v $ Language: C++ - Date: $Date: 2005/02/22 15:32:43 $ - Version: $Revision: 1.14 $ + Date: $Date: 2006/02/08 15:58:34 $ + Version: $Revision: 1.15 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -66,6 +66,7 @@ " ADD_CUSTOM_TARGET(Name [ALL] [command1 [args1...]]\n" " [COMMAND command2 [args2...] ...]\n" " [DEPENDS depend depend depend ... ])\n" + " [WORKING_DIRECTORY dir]\n" "Adds a target with the given name that executes the given commands " "every time the target is built. If the ALL option is specified " "it indicates that this target should be added to the default build " @@ -73,7 +74,9 @@ "The command and arguments are optional. If not specified, " "it will create an empty target. The ADD_DEPENDENCIES command can be " "used in conjunction with this command to drive custom target " - "generation. The command cannot be called ALL."; + "generation. The command cannot be called ALL. " + "If WORKING_DIRECTORY is set, then the command will be run in that " + "directory."; } cmTypeMacro(cmAddCustomTargetCommand, cmCommand); diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddDefinitionsCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddDefinitionsCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddDefinitionsCommand.cxx 2002-12-12 07:13:33.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddDefinitionsCommand.cxx 2006-03-16 00:01:58.000000000 +0800 @@ -3,21 +3,22 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmAddDefinitionsCommand.cxx,v $ Language: C++ - Date: $Date: 2002/12/11 23:13:33 $ - Version: $Revision: 1.11 $ + Date: $Date: 2006/03/15 16:01:58 $ + Version: $Revision: 1.13 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "cmAddDefinitionsCommand.h" // cmAddDefinitionsCommand -bool cmAddDefinitionsCommand::InitialPass(std::vector const& args) +bool cmAddDefinitionsCommand::InitialPass( + std::vector const& args) { // it is OK to have no arguments if(args.size() < 1 ) @@ -28,7 +29,7 @@ for(std::vector::const_iterator i = args.begin(); i != args.end(); ++i) { - m_Makefile->AddDefineFlag(i->c_str()); + this->Makefile->AddDefineFlag(i->c_str()); } return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddDefinitionsCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddDefinitionsCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddDefinitionsCommand.h 2005-03-18 23:41:40.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddDefinitionsCommand.h 2006-03-11 02:06:25.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmAddDefinitionsCommand.h,v $ Language: C++ - Date: $Date: 2005/03/18 15:41:40 $ - Version: $Revision: 1.10 $ + Date: $Date: 2006/03/10 18:06:25 $ + Version: $Revision: 1.11 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -22,8 +22,8 @@ /** \class cmAddDefinitionsCommand * \brief Specify a list of compiler defines * - * cmAddDefinitionsCommand specifies a list of compiler defines. These defines will - * be added to the compile command. + * cmAddDefinitionsCommand specifies a list of compiler defines. These defines + * will be added to the compile command. */ class cmAddDefinitionsCommand : public cmCommand { @@ -31,7 +31,7 @@ /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { return new cmAddDefinitionsCommand; } @@ -46,15 +46,15 @@ * The name of the command as specified in CMakeList.txt. */ virtual const char* GetName() {return "ADD_DEFINITIONS";} - + /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { return "Adds -D define flags to the command line of C and C++ compilers."; } - + /** * More documentation. */ @@ -67,7 +67,7 @@ "but the -D flag is accepted most C/C++ compilers. " "Other flags may not be as portable."; } - + cmTypeMacro(cmAddDefinitionsCommand, cmCommand); }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddDependenciesCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddDependenciesCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddDependenciesCommand.cxx 2002-12-12 07:13:33.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddDependenciesCommand.cxx 2006-03-16 00:01:58.000000000 +0800 @@ -3,21 +3,22 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmAddDependenciesCommand.cxx,v $ Language: C++ - Date: $Date: 2002/12/11 23:13:33 $ - Version: $Revision: 1.11 $ + Date: $Date: 2006/03/15 16:01:58 $ + Version: $Revision: 1.13 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "cmAddDependenciesCommand.h" // cmDependenciesCommand -bool cmAddDependenciesCommand::InitialPass(std::vector const& args) +bool cmAddDependenciesCommand::InitialPass( + std::vector const& args) { if(args.size() < 2 ) { @@ -27,7 +28,7 @@ std::string target_name = args[0]; - cmTargets &tgts = m_Makefile->GetTargets(); + cmTargets &tgts = this->Makefile->GetTargets(); if (tgts.find(target_name) != tgts.end()) { std::vector::const_iterator s = args.begin(); @@ -44,7 +45,7 @@ this->SetError(error.c_str()); return false; } - + return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddDependenciesCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddDependenciesCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddDependenciesCommand.h 2005-08-12 02:02:19.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddDependenciesCommand.h 2005-08-04 04:10:59.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmAddDependenciesCommand.h,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:19 $ - Version: $Revision: 1.7.8.1 $ + Date: $Date: 2005/08/03 20:10:59 $ + Version: $Revision: 1.8 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddExecutableCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddExecutableCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddExecutableCommand.cxx 2005-06-09 04:39:29.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddExecutableCommand.cxx 2006-03-16 00:01:58.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmAddExecutableCommand.cxx,v $ Language: C++ - Date: $Date: 2005/06/08 20:39:29 $ - Version: $Revision: 1.23 $ + Date: $Date: 2006/03/15 16:01:58 $ + Version: $Revision: 1.25 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -56,7 +56,7 @@ } std::vector srclists(s, args.end()); - cmTarget* tgt = m_Makefile->AddExecutable(exename.c_str(), srclists); + cmTarget* tgt = this->Makefile->AddExecutable(exename.c_str(), srclists); if ( use_win32 ) { tgt->SetProperty("WIN32_EXECUTABLE", "ON"); @@ -64,29 +64,6 @@ if ( use_macbundle) { tgt->SetProperty("MACOSX_BUNDLE", "ON"); -#ifdef __APPLE__ - std::string f1 = m_Makefile->GetModulesFile("MacOSXBundleInfo.plist.in"); - if ( f1.size() == 0 ) - { - this->SetError("could not find Mac OSX bundle template file."); - return false; - } - std::string macdir = m_Makefile->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH"); - if ( macdir.size() == 0 ) - { - macdir = m_Makefile->GetCurrentOutputDirectory(); - } - if(macdir.size() && macdir[macdir.size()-1] != '/') - { - macdir += "/"; - } - macdir += exename + ".app/Contents/"; - std::string f2 = macdir + "Info.plist"; - macdir += "MacOS"; - cmSystemTools::MakeDirectory(macdir.c_str()); - m_Makefile->AddDefinition("MACOSX_BUNDLE_EXECUTABLE_NAME", exename.c_str()); - m_Makefile->ConfigureFile(f1.c_str(), f2.c_str(), false, false, false); -#endif } return true; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddExecutableCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddExecutableCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddExecutableCommand.h 2004-04-29 01:40:58.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddExecutableCommand.h 2006-03-11 02:06:25.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmAddExecutableCommand.h,v $ Language: C++ - Date: $Date: 2004/04/28 17:40:58 $ - Version: $Revision: 1.13 $ + Date: $Date: 2006/03/10 18:06:25 $ + Version: $Revision: 1.14 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -31,7 +31,7 @@ /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { return new cmAddExecutableCommand; } @@ -50,11 +50,12 @@ /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { - return "Add an executable to the project using the specified source files."; + return + "Add an executable to the project using the specified source files."; } - + /** * More documentation. */ @@ -68,15 +69,15 @@ "specified.\n" "After specifying the executable name, WIN32 and/or MACOSX_BUNDLE can " "be specified. WIN32 indicates that the executable (when compiled on " - "windows) is a windows app (using WinMain) not a console app (using main). " - "The variable CMAKE_MFC_FLAG be used if the windows app uses MFC. " - "This variable can be set to the following values:\n" + "windows) is a windows app (using WinMain) not a console app " + "(using main). The variable CMAKE_MFC_FLAG be used if the windows app " + "uses MFC. This variable can be set to the following values:\n" " 0: Use Standard Windows Libraries\n" " 1: Use MFC in a Static Library \n" " 2: Use MFC in a Shared DLL \n" "MACOSX_BUNDLE indicates that when build on Mac OSX, executable should " - "be in the bundle form. The MACOSX_BUNDLE also allows several variables " - "to be specified:\n" + "be in the bundle form. The MACOSX_BUNDLE also allows several " + "variables to be specified:\n" " MACOSX_BUNDLE_INFO_STRING\n" " MACOSX_BUNDLE_ICON_FILE\n" " MACOSX_BUNDLE_GUI_IDENTIFIER\n" @@ -87,7 +88,7 @@ " MACOSX_BUNDLE_COPYRIGHT\n" ; } - + cmTypeMacro(cmAddExecutableCommand, cmCommand); }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddLibraryCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddLibraryCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddLibraryCommand.cxx 2005-06-10 22:08:41.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddLibraryCommand.cxx 2006-03-16 00:01:58.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmAddLibraryCommand.cxx,v $ Language: C++ - Date: $Date: 2005/06/10 14:08:41 $ - Version: $Revision: 1.23 $ + Date: $Date: 2006/03/15 16:01:58 $ + Version: $Revision: 1.24 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -27,11 +27,11 @@ // Library type defaults to value of BUILD_SHARED_LIBS, if it exists, // otherwise it defaults to static library. int shared = - !cmSystemTools::IsOff(m_Makefile->GetDefinition("BUILD_SHARED_LIBS")); + !cmSystemTools::IsOff(this->Makefile->GetDefinition("BUILD_SHARED_LIBS")); std::vector::const_iterator s = args.begin(); - m_LibName = *s; + this->LibName = *s; ++s; @@ -74,7 +74,7 @@ ++s; } - m_Makefile->AddLibrary(m_LibName.c_str(), shared, srclists); + this->Makefile->AddLibrary(this->LibName.c_str(), shared, srclists); return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddLibraryCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddLibraryCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddLibraryCommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddLibraryCommand.h 2006-03-16 00:01:58.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmAddLibraryCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.13.8.1 $ + Date: $Date: 2006/03/15 16:01:58 $ + Version: $Revision: 1.15 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -75,7 +75,7 @@ cmTypeMacro(cmAddLibraryCommand, cmCommand); private: - std::string m_LibName; + std::string LibName; }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddSubDirectoryCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddSubDirectoryCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddSubDirectoryCommand.cxx 2005-09-16 04:38:36.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddSubDirectoryCommand.cxx 2006-03-16 00:01:58.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmAddSubDirectoryCommand.cxx,v $ Language: C++ - Date: $Date: 2005/09/15 20:38:36 $ - Version: $Revision: 1.2.2.1 $ + Date: $Date: 2006/03/15 16:01:58 $ + Version: $Revision: 1.4 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -55,7 +55,7 @@ // check for relative arguments bool relativeSource = true; std::string binPath = binArg; - std::string srcPath = std::string(m_Makefile->GetCurrentDirectory()) + + std::string srcPath = std::string(this->Makefile->GetCurrentDirectory()) + "/" + srcArg; // if the path does not exist then the arg was relative if (!cmSystemTools::FileIsDirectory(srcPath.c_str())) @@ -77,11 +77,11 @@ // if the argument was provided then use it if (binArg.size()) { - if (!cmSystemTools::FileIsFullPath(binPath.c_str())) - { - binPath = std::string(m_Makefile->GetCurrentOutputDirectory()) + - "/" + binArg.c_str(); - } + if (!cmSystemTools::FileIsFullPath(binPath.c_str())) + { + binPath = std::string(this->Makefile->GetCurrentOutputDirectory()) + + "/" + binArg.c_str(); + } } // otherwise compute the binPath from the srcPath else @@ -89,7 +89,7 @@ // if the srcArg was relative then we just do the same for the binPath if (relativeSource) { - binPath = std::string(m_Makefile->GetCurrentOutputDirectory()) + + binPath = std::string(this->Makefile->GetCurrentOutputDirectory()) + "/" + srcArg; } // otherwise we try to remove the CurrentDirectory from the srcPath and @@ -101,18 +101,18 @@ // try replacing the home dir with the home output dir binPath = srcPath; if (!cmSystemTools::FindLastString(binPath.c_str(), - m_Makefile->GetHomeDirectory())) + this->Makefile->GetHomeDirectory())) { this->SetError("A full source directory was specified that is not in the source tree but no binary directory was specified. If you specify an out of tree source directory then you must provide the binary directory as well."); return false; } - cmSystemTools::ReplaceString(binPath,m_Makefile->GetHomeDirectory(), - m_Makefile->GetHomeOutputDirectory()); + cmSystemTools::ReplaceString(binPath,this->Makefile->GetHomeDirectory(), + this->Makefile->GetHomeOutputDirectory()); } } // now we have all the arguments - m_Makefile->AddSubDirectory(srcPath.c_str(), binPath.c_str(), + this->Makefile->AddSubDirectory(srcPath.c_str(), binPath.c_str(), intoplevel, false, true); return true; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddSubDirectoryCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddSubDirectoryCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddSubDirectoryCommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddSubDirectoryCommand.h 2005-11-16 23:16:57.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmAddSubDirectoryCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.3.2.2 $ + Date: $Date: 2005/11/16 15:16:57 $ + Version: $Revision: 1.5 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddTestCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddTestCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddTestCommand.cxx 2005-04-25 04:19:54.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddTestCommand.cxx 2006-03-16 00:01:58.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmAddTestCommand.cxx,v $ Language: C++ - Date: $Date: 2005/04/24 20:19:54 $ - Version: $Revision: 1.26 $ + Date: $Date: 2006/03/15 16:01:58 $ + Version: $Revision: 1.27 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -42,7 +42,7 @@ arguments.push_back(*it); } - cmTest* test = m_Makefile->CreateTest(args[0].c_str()); + cmTest* test = this->Makefile->CreateTest(args[0].c_str()); test->SetCommand(args[1].c_str()); test->SetArguments(arguments); diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddTestCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddTestCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAddTestCommand.h 2005-08-12 02:02:19.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAddTestCommand.h 2006-03-16 22:33:23.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmAddTestCommand.h,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:19 $ - Version: $Revision: 1.11.2.1 $ + Date: $Date: 2006/03/16 14:33:23 $ + Version: $Revision: 1.13 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -74,8 +74,6 @@ cmTypeMacro(cmAddTestCommand, cmCommand); -private: - std::string m_Test; }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmake.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmake.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmake.cxx 2005-10-31 23:01:20.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmake.cxx 2006-03-18 00:14:14.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmake.cxx,v $ Language: C++ - Date: $Date: 2005/10/31 15:01:20 $ - Version: $Revision: 1.209.2.5 $ + Date: $Date: 2006/03/17 16:14:14 $ + Version: $Revision: 1.242 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -22,6 +22,7 @@ #include "cmCommands.h" #include "cmCommand.h" #include "cmFileTimeComparison.h" +#include "cmGeneratedFileStream.h" #if defined(CMAKE_BUILD_WITH_CMAKE) # include "cmDependsFortran.h" // For -E cmake_copy_f90_mod callback. @@ -37,16 +38,23 @@ # endif #endif +#if defined(__MINGW32__) && !defined(CMAKE_BUILD_WITH_CMAKE) +# define CMAKE_BOOT_MINGW +#endif + // include the generator #if defined(_WIN32) && !defined(__CYGWIN__) -# include "cmGlobalVisualStudio6Generator.h" -# if !defined(__MINGW32__) +# if !defined(CMAKE_BOOT_MINGW) +# include "cmGlobalVisualStudio6Generator.h" # include "cmGlobalVisualStudio7Generator.h" # include "cmGlobalVisualStudio71Generator.h" # include "cmGlobalVisualStudio8Generator.h" +# include "cmGlobalBorlandMakefileGenerator.h" +# include "cmGlobalNMakeMakefileGenerator.h" +# include "cmGlobalWatcomWMakeGenerator.h" # endif -# include "cmGlobalBorlandMakefileGenerator.h" -# include "cmGlobalNMakeMakefileGenerator.h" +# include "cmGlobalMSYSMakefileGenerator.h" +# include "cmGlobalMinGWMakefileGenerator.h" # include "cmWin32ProcessExecution.h" #else #endif @@ -70,7 +78,7 @@ #include // auto_ptr -void cmNeedBackwardsCompatibility(const std::string& variable, +void cmNeedBackwardsCompatibility(const std::string& variable, int access_type, void* ) { #ifdef CMAKE_BUILD_WITH_CMAKE @@ -78,12 +86,14 @@ { std::string message = "An attempt was made to access a variable: "; message += variable; - message += " that has not been defined. Some variables were always defined " - "by CMake in versions prior to 1.6. To fix this you might need to set the " - "cache value of CMAKE_BACKWARDS_COMPATIBILITY to 1.4 or less. If you are " - "writing a CMakeList file, (or have already set " - "CMAKE_BACKWARDS_COMPATABILITY to 1.4 or less) then you probably need to " - "include a CMake module to test for the feature this variable defines."; + message += + " that has not been defined. Some variables were always defined " + "by CMake in versions prior to 1.6. To fix this you might need to set " + "the cache value of CMAKE_BACKWARDS_COMPATIBILITY to 1.4 or less. If " + "you are writing a CMakeList file, (or have already set " + "CMAKE_BACKWARDS_COMPATABILITY to 1.4 or less) then you probably need " + "to include a CMake module to test for the feature this variable " + "defines."; cmSystemTools::Error(message.c_str()); } #else @@ -94,10 +104,10 @@ cmake::cmake() { - m_DebugTryCompile = false; - m_ClearBuildSystem = false; - m_FileComparison = new cmFileTimeComparison; - + this->DebugTryCompile = false; + this->ClearBuildSystem = false; + this->FileComparison = new cmFileTimeComparison; + #ifdef __APPLE__ struct rlimit rlp; if(!getrlimit(RLIMIT_STACK, &rlp)) @@ -118,55 +128,57 @@ if(getenv("MAKEFLAGS")) { cmSystemTools::PutEnv("MAKEFLAGS="); - } - - m_Verbose = false; - m_InTryCompile = false; - m_CacheManager = new cmCacheManager; - m_GlobalGenerator = 0; - m_ProgressCallback = 0; - m_ProgressCallbackClientData = 0; - m_ScriptMode = false; + } + + this->Verbose = false; + this->InTryCompile = false; + this->CacheManager = new cmCacheManager; + this->GlobalGenerator = 0; + this->ProgressCallback = 0; + this->ProgressCallbackClientData = 0; + this->ScriptMode = false; #ifdef CMAKE_BUILD_WITH_CMAKE - m_VariableWatch = new cmVariableWatch; - m_VariableWatch->AddWatch("CMAKE_WORDS_BIGENDIAN", + this->VariableWatch = new cmVariableWatch; + this->VariableWatch->AddWatch("CMAKE_WORDS_BIGENDIAN", cmNeedBackwardsCompatibility); - m_VariableWatch->AddWatch("CMAKE_SIZEOF_INT", + this->VariableWatch->AddWatch("CMAKE_SIZEOF_INT", cmNeedBackwardsCompatibility); - m_VariableWatch->AddWatch("CMAKE_X_LIBS", + this->VariableWatch->AddWatch("CMAKE_X_LIBS", cmNeedBackwardsCompatibility); #endif this->AddDefaultGenerators(); this->AddDefaultCommands(); + // Make sure we can capture the build tool output. + cmSystemTools::EnableVSConsoleOutput(); } cmake::~cmake() { - delete m_CacheManager; - if (m_GlobalGenerator) + delete this->CacheManager; + if (this->GlobalGenerator) { - delete m_GlobalGenerator; - m_GlobalGenerator = 0; + delete this->GlobalGenerator; + this->GlobalGenerator = 0; } - for(RegisteredCommandsMap::iterator j = m_Commands.begin(); - j != m_Commands.end(); ++j) + for(RegisteredCommandsMap::iterator j = this->Commands.begin(); + j != this->Commands.end(); ++j) { delete (*j).second; } #ifdef CMAKE_BUILD_WITH_CMAKE - delete m_VariableWatch; + delete this->VariableWatch; #endif - delete m_FileComparison; + delete this->FileComparison; } void cmake::CleanupCommandsAndMacros() { std::vector commands; - for(RegisteredCommandsMap::iterator j = m_Commands.begin(); - j != m_Commands.end(); ++j) + for(RegisteredCommandsMap::iterator j = this->Commands.begin(); + j != this->Commands.end(); ++j) { if ( !j->second->IsA("cmMacroHelperCommand") ) { @@ -177,27 +189,27 @@ delete j->second; } } - m_Commands.erase(m_Commands.begin(), m_Commands.end()); + this->Commands.erase(this->Commands.begin(), this->Commands.end()); std::vector::iterator it; for ( it = commands.begin(); it != commands.end(); ++ it ) { - m_Commands[cmSystemTools::LowerCase((*it)->GetName())] = *it; + this->Commands[cmSystemTools::LowerCase((*it)->GetName())] = *it; } } bool cmake::CommandExists(const char* name) const { std::string sName = cmSystemTools::LowerCase(name); - return (m_Commands.find(sName) != m_Commands.end()); + return (this->Commands.find(sName) != this->Commands.end()); } -cmCommand *cmake::GetCommand(const char *name) +cmCommand *cmake::GetCommand(const char *name) { cmCommand* rm = 0; std::string sName = cmSystemTools::LowerCase(name); - RegisteredCommandsMap::iterator pos = m_Commands.find(sName); - if (pos != m_Commands.end()) + RegisteredCommandsMap::iterator pos = this->Commands.find(sName); + if (pos != this->Commands.end()) { rm = (*pos).second; } @@ -209,40 +221,40 @@ // if the command already exists, free the old one std::string sOldName = cmSystemTools::LowerCase(oldName); std::string sNewName = cmSystemTools::LowerCase(newName); - RegisteredCommandsMap::iterator pos = m_Commands.find(sOldName); - if ( pos == m_Commands.end() ) + RegisteredCommandsMap::iterator pos = this->Commands.find(sOldName); + if ( pos == this->Commands.end() ) { return; } cmCommand* cmd = pos->second; - pos = m_Commands.find(sNewName); - if (pos != m_Commands.end()) + pos = this->Commands.find(sNewName); + if (pos != this->Commands.end()) { delete pos->second; - m_Commands.erase(pos); + this->Commands.erase(pos); } - m_Commands.insert(RegisteredCommandsMap::value_type(sNewName, cmd)); - pos = m_Commands.find(sOldName); - m_Commands.erase(pos); + this->Commands.insert(RegisteredCommandsMap::value_type(sNewName, cmd)); + pos = this->Commands.find(sOldName); + this->Commands.erase(pos); } void cmake::AddCommand(cmCommand* wg) { std::string name = cmSystemTools::LowerCase(wg->GetName()); // if the command already exists, free the old one - RegisteredCommandsMap::iterator pos = m_Commands.find(name); - if (pos != m_Commands.end()) + RegisteredCommandsMap::iterator pos = this->Commands.find(name); + if (pos != this->Commands.end()) { delete pos->second; - m_Commands.erase(pos); + this->Commands.erase(pos); } - m_Commands.insert( RegisteredCommandsMap::value_type(name, wg)); + this->Commands.insert( RegisteredCommandsMap::value_type(name, wg)); } // Parse the args bool cmake::SetCacheArgs(const std::vector& args) -{ +{ for(unsigned int i=1; i < args.size(); ++i) { std::string arg = args[i]; @@ -258,7 +270,7 @@ if(cmCacheManager::ParseEntry(entry.c_str(), var, value, type) || cmCacheManager::ParseEntry(entry.c_str(), var, value)) { - this->m_CacheManager->AddCacheEntry(var.c_str(), value.c_str(), + this->CacheManager->AddCacheEntry(var.c_str(), value.c_str(), "No help, variable specified on the command line.", type); } @@ -268,7 +280,7 @@ << "Should be: VAR:type=value\n"; cmSystemTools::Error("No cmake scrpt provided."); return false; - } + } } else if(arg.find("-C",0) == 0) { @@ -289,7 +301,6 @@ cmSystemTools::Error("No cmake script provided."); return false; } - std::cerr << "Running cmake script file " << path.c_str() << "\n"; this->ReadListFile(path.c_str()); } } @@ -301,7 +312,7 @@ // if a generator was not yet created, temporarily create one cmGlobalGenerator *gg = this->GetGlobalGenerator(); bool created = false; - + // if a generator was not specified use a generic one if (!gg) { @@ -328,7 +339,7 @@ std::cerr << "Error processing file:" << path << "\n"; } } - + // free generic one if generated if (created) { @@ -369,12 +380,12 @@ } else if((i < args.size()-1) && (arg.find("--check-build-system",0) == 0)) { - m_CheckBuildSystem = args[++i]; - m_ClearBuildSystem = (atoi(args[++i].c_str()) > 0); + this->CheckBuildSystemArgument = args[++i]; + this->ClearBuildSystem = (atoi(args[++i].c_str()) > 0); } else if(arg.find("-V",0) == 0) { - m_Verbose = true; + this->Verbose = true; } else if(arg.find("-D",0) == 0) { @@ -389,6 +400,17 @@ // skip for now i++; } + else if(arg.find("--graphviz=",0) == 0) + { + std::string path = arg.substr(strlen("--graphviz=")); + path = cmSystemTools::CollapseFullPath(path.c_str()); + cmSystemTools::ConvertToUnixSlashes(path); + this->GraphVizFile = path; + if ( this->GraphVizFile.empty() ) + { + cmSystemTools::Error("No file specified for --graphviz"); + } + } else if(arg.find("--debug-trycompile",0) == 0) { std::cout << "debug trycompile on\n"; @@ -401,7 +423,7 @@ { value = args[++i]; } - cmGlobalGenerator* gen = + cmGlobalGenerator* gen = this->CreateGlobalGenerator(value.c_str()); if(!gen) { @@ -499,28 +521,29 @@ { cmCacheManager* cachem = this->GetCacheManager(); cmCacheManager::CacheIterator it = cachem->NewIterator(); - if(cachem->LoadCache(cachePath.c_str()) && it.Find("CMAKE_HOME_DIRECTORY")) + if(cachem->LoadCache(cachePath.c_str()) && + it.Find("CMAKE_HOME_DIRECTORY")) { - this->SetHomeOutputDirectory(cachePath.c_str()); - this->SetStartOutputDirectory(cachePath.c_str()); + this->SetHomeOutputDirectory(cachePath.c_str()); + this->SetStartOutputDirectory(cachePath.c_str()); this->SetHomeDirectory(it.GetValue()); this->SetStartDirectory(it.GetValue()); return; } } - + // If there is a CMakeLists.txt file, use it as the source tree. if(listPath.length() > 0) { this->SetHomeDirectory(listPath.c_str()); this->SetStartDirectory(listPath.c_str()); - + if(argIsFile) { // Source CMakeLists.txt file given. It was probably dropped // onto the executable in a GUI. Default to an in-source build. - this->SetHomeOutputDirectory(listPath.c_str()); - this->SetStartOutputDirectory(listPath.c_str()); + this->SetHomeOutputDirectory(listPath.c_str()); + this->SetStartOutputDirectory(listPath.c_str()); } else { @@ -528,11 +551,11 @@ // directory as build tree. std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); this->SetHomeOutputDirectory(cwd.c_str()); - this->SetStartOutputDirectory(cwd.c_str()); + this->SetStartOutputDirectory(cwd.c_str()); } return; } - + // We didn't find a CMakeLists.txt or CMakeCache.txt file from the // argument. Assume it is the path to the source tree, and use the // current working directory as the build tree. @@ -541,10 +564,11 @@ this->SetHomeDirectory(full.c_str()); this->SetStartDirectory(full.c_str()); this->SetHomeOutputDirectory(cwd.c_str()); - this->SetStartOutputDirectory(cwd.c_str()); + this->SetStartOutputDirectory(cwd.c_str()); } -// at the end of this CMAKE_ROOT and CMAKE_COMMAND should be added to the cache +// at the end of this CMAKE_ROOT and CMAKE_COMMAND should be added to the +// cache int cmake::AddCMakePaths(const char *arg0) { // Find our own executable. @@ -591,7 +615,7 @@ return 0; } // Save the value in the cache - this->m_CacheManager->AddCacheEntry + this->CacheManager->AddCacheEntry ("CMAKE_COMMAND",cMakeSelf.c_str(), "Path to CMake executable.", cmCacheManager::INTERNAL); @@ -607,17 +631,17 @@ "/ctest" + cmSystemTools::GetFilenameExtension(cMakeSelf); if(cmSystemTools::FileExists(ctestCommand.c_str())) { - this->m_CacheManager->AddCacheEntry + this->CacheManager->AddCacheEntry ("CMAKE_CTEST_COMMAND", ctestCommand.c_str(), "Path to ctest program executable.", cmCacheManager::INTERNAL); } if(cmSystemTools::FileExists(editCacheCommand.c_str())) { - this->m_CacheManager->AddCacheEntry + this->CacheManager->AddCacheEntry ("CMAKE_EDIT_COMMAND", editCacheCommand.c_str(), "Path to cache edit program executable.", cmCacheManager::INTERNAL); } - + // do CMAKE_ROOT, look for the environment variable first std::string cMakeRoot; std::string modules; @@ -631,14 +655,14 @@ // next try exe/.. cMakeRoot = cmSystemTools::GetProgramPath(cMakeSelf.c_str()); std::string::size_type slashPos = cMakeRoot.rfind("/"); - if(slashPos != std::string::npos) + if(slashPos != std::string::npos) { cMakeRoot = cMakeRoot.substr(0, slashPos); } // is there no Modules direcory there? - modules = cMakeRoot + "/Modules/CMake.cmake"; + modules = cMakeRoot + "/Modules/CMake.cmake"; } - + if (!cmSystemTools::FileExists(modules.c_str())) { // try exe/../share/cmake @@ -663,7 +687,7 @@ #endif if (!cmSystemTools::FileExists(modules.c_str())) { - // try + // try cMakeRoot = cmSystemTools::GetProgramPath(cMakeSelf.c_str()); cMakeRoot += CMAKE_DATA_DIR; modules = cMakeRoot + "/Modules/CMake.cmake"; @@ -673,18 +697,18 @@ // next try exe cMakeRoot = cmSystemTools::GetProgramPath(cMakeSelf.c_str()); // is there no Modules direcory there? - modules = cMakeRoot + "/Modules/CMake.cmake"; + modules = cMakeRoot + "/Modules/CMake.cmake"; } if (!cmSystemTools::FileExists(modules.c_str())) { // couldn't find modules cmSystemTools::Error("Could not find CMAKE_ROOT !!!\n" - "CMake has most likely not been installed correctly.\n" - "Modules directory not found in\n", - cMakeRoot.c_str()); + "CMake has most likely not been installed correctly.\n" + "Modules directory not found in\n", + cMakeRoot.c_str()); return 0; } - this->m_CacheManager->AddCacheEntry + this->CacheManager->AddCacheEntry ("CMAKE_ROOT", cMakeRoot.c_str(), "Path to CMake installation.", cmCacheManager::INTERNAL); @@ -702,37 +726,42 @@ cmOStringStream errorStream; #ifdef CMAKE_BUILD_WITH_CMAKE - errorStream + errorStream << "cmake version " << cmVersion::GetCMakeVersion() << "\n"; #else - errorStream + errorStream << "cmake bootstrap\n"; #endif - errorStream + errorStream << "Usage: " << program << " -E [command] [arguments ...]\n" << "Available commands: \n" << " chdir dir cmd [args]... - run command in a given directory\n" - << " copy file destination - copy file to destination (either file or directory)\n" - << " copy_if_different in-file out-file - copy file if input has changed\n" - << " copy_directory source destination - copy directory 'source' content to directory 'destination'\n" + << " copy file destination - copy file to destination (either file or " + "directory)\n" + << " copy_if_different in-file out-file - copy file if input has " + "changed\n" + << " copy_directory source destination - copy directory 'source' " + "content to directory 'destination'\n" + << " compare_files file1 file2 - check if file1 is same as file2\n" << " echo [string]... - displays arguments as text\n" + << " environment - display the current enviroment\n" << " remove file1 file2 ... - remove the file(s)\n" - << " time command [args] ... - run command and return elapsed time\n"; + << " tar [cxt][vfz] file.tar file/dir1 file/dir2 ... - create a tar.\n" + << " time command [args] ... - run command and return elapsed time\n" #if defined(_WIN32) && !defined(__CYGWIN__) - errorStream << " write_regv key value - write registry value\n" << " delete_regv key - delete registry value\n" - << " comspec - on windows 9x use this for RunCommand\n"; + << " comspec - on windows 9x use this for RunCommand\n" #else - errorStream - << " create_symlink old new - create a symbolic link new -> old\n"; + << " create_symlink old new - create a symbolic link new -> old\n" #endif + ; cmSystemTools::Error(errorStream.str().c_str()); } -int cmake::CMakeCommand(std::vector& args) +int cmake::ExecuteCMakeCommand(std::vector& args) { if (args.size() > 1) { @@ -751,7 +780,8 @@ // Copy file if different. if (args[1] == "copy_if_different" && args.size() == 4) { - if(!cmSystemTools::CopyFileIfDifferent(args[2].c_str(), args[3].c_str())) + if(!cmSystemTools::CopyFileIfDifferent(args[2].c_str(), + args[3].c_str())) { std::cerr << "Error copying file (if different) from \"" << args[2].c_str() << "\" to \"" << args[3].c_str() @@ -774,18 +804,46 @@ return 0; } + // Compare files + if (args[1] == "compare_files" && args.size() == 4) + { + if(cmSystemTools::FilesDiffer(args[2].c_str(), args[3].c_str())) + { + std::cerr << "Files \"" + << args[2].c_str() << "\" to \"" << args[3].c_str() + << "\" are different.\n"; + return 1; + } + return 0; + } + // Echo string else if (args[1] == "echo" ) { unsigned int cc; + const char* space = ""; for ( cc = 2; cc < args.size(); cc ++ ) { - std::cout << args[cc] << " "; + std::cout << space << args[cc]; + space = " "; } std::cout << std::endl; return 0; } + // Command to create a symbolic link. Fails on platforms not + // supporting them. + else if (args[1] == "environment" ) + { + std::vector env = cmSystemTools::GetEnvironmentVariables(); + std::vector::iterator it; + for ( it = env.begin(); it != env.end(); ++ it ) + { + std::cout << it->c_str() << std::endl; + } + return 0; + } + // Remove file else if (args[1] == "remove" && args.size() > 2) { @@ -818,17 +876,17 @@ time(&time_start); clock_start = clock(); - + cmSystemTools::RunSingleCommand(command.c_str()); clock_finish = clock(); time(&time_finish); double clocks_per_sec = (double)CLOCKS_PER_SEC; - std::cout << "Elapsed time: " + std::cout << "Elapsed time: " << (long)(time_finish - time_start) << " s. (time)" - << ", " - << (double)(clock_finish - clock_start) / clocks_per_sec + << ", " + << (double)(clock_finish - clock_start) / clocks_per_sec << " s. (clock)" << "\n"; return 0; @@ -856,11 +914,11 @@ } int retval = 0; int timeout = 0; - if ( cmSystemTools::RunSingleCommand(command.c_str(), 0, &retval, + if ( cmSystemTools::RunSingleCommand(command.c_str(), 0, &retval, directory.c_str(), true, timeout) ) { return retval; - } + } return 1; } @@ -932,9 +990,9 @@ { cmake cm; cmGlobalGenerator *ggd = cm.CreateGlobalGenerator(args[2].c_str()); - ggd->SetCMakeInstance(&cm); if (ggd) { + ggd->SetCMakeInstance(&cm); std::auto_ptr lgd(ggd->CreateLocalGenerator()); lgd->SetGlobalGenerator(ggd); return lgd->ScanDependencies(args)? 0 : 2; @@ -942,6 +1000,56 @@ return 1; } + // Tar files + else if (args[1] == "tar" && args.size() > 3) + { + std::string flags = args[2]; + std::string outFile = args[3]; + std::vector files; + for (std::string::size_type cc = 4; cc < args.size(); cc ++) + { + files.push_back(args[cc]); + } + bool gzip = false; + bool verbose = false; + if ( flags.find_first_of('z') != flags.npos ) + { + gzip = true; + } + if ( flags.find_first_of('v') != flags.npos ) + { + verbose = true; + } + + if ( flags.find_first_of('t') != flags.npos ) + { + if ( !cmSystemTools::ListTar(outFile.c_str(), files, gzip, verbose) ) + { + cmSystemTools::Error("Problem creating tar: ", outFile.c_str()); + return 1; + } + } + else if ( flags.find_first_of('c') != flags.npos ) + { + if ( !cmSystemTools::CreateTar( + outFile.c_str(), files, gzip, verbose) ) + { + cmSystemTools::Error("Problem creating tar: ", outFile.c_str()); + return 1; + } + } + else if ( flags.find_first_of('x') != flags.npos ) + { + if ( !cmSystemTools::ExtractTar( + outFile.c_str(), files, gzip, verbose) ) + { + cmSystemTools::Error("Problem extracting tar: ", outFile.c_str()); + return 1; + } + } + return 0; + } + #if defined(CMAKE_BUILD_WITH_CMAKE) // Internal CMake Fortran module support. else if (args[1] == "cmake_copy_f90_mod" && args.size() >= 4) @@ -954,7 +1062,7 @@ // Write registry value else if (args[1] == "write_regv" && args.size() > 3) { - return cmSystemTools::WriteRegistryValue(args[2].c_str(), + return cmSystemTools::WriteRegistryValue(args[2].c_str(), args[3].c_str()) ? 0 : 1; } @@ -983,8 +1091,8 @@ void cmake::GetRegisteredGenerators(std::vector& names) { - for(RegisteredGeneratorsMap::const_iterator i = m_Generators.begin(); - i != m_Generators.end(); ++i) + for(RegisteredGeneratorsMap::const_iterator i = this->Generators.begin(); + i != this->Generators.end(); ++i) { names.push_back(i->first); } @@ -992,8 +1100,8 @@ cmGlobalGenerator* cmake::CreateGlobalGenerator(const char* name) { - RegisteredGeneratorsMap::const_iterator i = m_Generators.find(name); - if(i != m_Generators.end()) + RegisteredGeneratorsMap::const_iterator i = this->Generators.find(name); + if(i != this->Generators.end()) { cmGlobalGenerator* generator = (i->second)(); generator->SetCMakeInstance(this); @@ -1005,64 +1113,64 @@ } } -void cmake::SetHomeDirectory(const char* dir) +void cmake::SetHomeDirectory(const char* dir) { - m_cmHomeDirectory = dir; - cmSystemTools::ConvertToUnixSlashes(m_cmHomeDirectory); + this->cmHomeDirectory = dir; + cmSystemTools::ConvertToUnixSlashes(this->cmHomeDirectory); } void cmake::SetHomeOutputDirectory(const char* lib) { - m_HomeOutputDirectory = lib; - cmSystemTools::ConvertToUnixSlashes(m_HomeOutputDirectory); + this->HomeOutputDirectory = lib; + cmSystemTools::ConvertToUnixSlashes(this->HomeOutputDirectory); } void cmake::SetGlobalGenerator(cmGlobalGenerator *gg) { // delete the old generator - if (m_GlobalGenerator) + if (this->GlobalGenerator) { - delete m_GlobalGenerator; + delete this->GlobalGenerator; // restore the original environment variables CXX and CC // Restor CC std::string env = "CC="; - if(m_CCEnvironment.size()) + if(this->CCEnvironment.size()) { - env += m_CCEnvironment; + env += this->CCEnvironment; } cmSystemTools::PutEnv(env.c_str()); env = "CXX="; - if(m_CXXEnvironment.size()) + if(this->CXXEnvironment.size()) { - env += m_CXXEnvironment; + env += this->CXXEnvironment; } cmSystemTools::PutEnv(env.c_str()); } // set the new - m_GlobalGenerator = gg; + this->GlobalGenerator = gg; // set the global flag for unix style paths on cmSystemTools as // soon as the generator is set. This allows gmake to be used // on windows. - cmSystemTools::SetForceUnixPaths(m_GlobalGenerator->GetForceUnixPaths()); + cmSystemTools::SetForceUnixPaths(this->GlobalGenerator->GetForceUnixPaths()); // Save the environment variables CXX and CC const char* cxx = getenv("CXX"); const char* cc = getenv("CC"); if(cxx) { - m_CXXEnvironment = cxx; + this->CXXEnvironment = cxx; } else { - m_CXXEnvironment = ""; + this->CXXEnvironment = ""; } if(cc) { - m_CCEnvironment = cc; + this->CCEnvironment = cc; } else { - m_CCEnvironment = ""; + this->CCEnvironment = ""; } // set the cmake instance just to be sure gg->SetCMakeInstance(this); @@ -1091,16 +1199,17 @@ err << "The source directory \"" << this->GetHomeDirectory() << "\" does not exist.\n"; } - err << "Specify --help for usage, or press the help button on the CMake GUI."; + err << "Specify --help for usage, or press the help button on the CMake " + "GUI."; cmSystemTools::Error(err.str().c_str()); return -2; } - + // do a sanity check on some values - if(m_CacheManager->GetCacheValue("CMAKE_HOME_DIRECTORY")) + if(this->CacheManager->GetCacheValue("CMAKE_HOME_DIRECTORY")) { std::string cacheStart = - m_CacheManager->GetCacheValue("CMAKE_HOME_DIRECTORY"); + this->CacheManager->GetCacheValue("CMAKE_HOME_DIRECTORY"); cacheStart += "/CMakeLists.txt"; std::string currentStart = this->GetHomeDirectory(); currentStart += "/CMakeLists.txt"; @@ -1130,7 +1239,7 @@ this->CleanupCommandsAndMacros(); int res = 0; - if ( !m_ScriptMode ) + if ( !this->ScriptMode ) { res = this->DoPreConfigureChecks(); } @@ -1140,46 +1249,51 @@ } if ( !res ) { - m_CacheManager->AddCacheEntry("CMAKE_HOME_DIRECTORY", - this->GetHomeDirectory(), - "Start directory with the top level CMakeLists.txt file for this project", - cmCacheManager::INTERNAL); + this->CacheManager->AddCacheEntry + ("CMAKE_HOME_DIRECTORY", + this->GetHomeDirectory(), + "Start directory with the top level CMakeLists.txt file for this " + "project", + cmCacheManager::INTERNAL); } - + // set the default BACKWARDS compatibility to the current version - if(!m_CacheManager->GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")) + if(!this->CacheManager->GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")) { char ver[256]; sprintf(ver,"%i.%i",cmMakefile::GetMajorVersion(), cmMakefile::GetMinorVersion()); - this->m_CacheManager->AddCacheEntry + this->CacheManager->AddCacheEntry ("CMAKE_BACKWARDS_COMPATIBILITY",ver, - "For backwards compatibility, what version of CMake commands and syntax should this version of CMake allow.", + "For backwards compatibility, what version of CMake commands and " + "syntax should this version of CMake allow.", cmCacheManager::STRING); - } - + } + // no generator specified on the command line - if(!m_GlobalGenerator) + if(!this->GlobalGenerator) { - const char* genName = m_CacheManager->GetCacheValue("CMAKE_GENERATOR"); + const char* genName = this->CacheManager->GetCacheValue("CMAKE_GENERATOR"); if(genName) { - m_GlobalGenerator = this->CreateGlobalGenerator(genName); + this->GlobalGenerator = this->CreateGlobalGenerator(genName); } - if(m_GlobalGenerator) + if(this->GlobalGenerator) { - // set the global flag for unix style paths on cmSystemTools as + // set the global flag for unix style paths on cmSystemTools as // soon as the generator is set. This allows gmake to be used // on windows. - cmSystemTools::SetForceUnixPaths(m_GlobalGenerator->GetForceUnixPaths()); + cmSystemTools::SetForceUnixPaths + (this->GlobalGenerator->GetForceUnixPaths()); } else { #if defined(__BORLANDC__) && defined(_WIN32) this->SetGlobalGenerator(new cmGlobalBorlandMakefileGenerator); -#elif defined(_WIN32) && !defined(__CYGWIN__) +#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW) std::string installedCompiler; - std::string mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup;Dbghelp_path]"; + std::string mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft" + "\\VisualStudio\\8.0\\Setup;Dbghelp_path]"; cmSystemTools::ExpandRegistryValues(mp); if (!(mp == "/registry")) { @@ -1187,7 +1301,8 @@ } else { - mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\7.1;InstallDir]"; + mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft" + "\\VisualStudio\\7.1;InstallDir]"; cmSystemTools::ExpandRegistryValues(mp); if (!(mp == "/registry")) { @@ -1195,7 +1310,8 @@ } else { - mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\7.0;InstallDir]"; + mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft" + "\\VisualStudio\\7.0;InstallDir]"; cmSystemTools::ExpandRegistryValues(mp); if (!(mp == "/registry")) { @@ -1207,7 +1323,8 @@ } } } - cmGlobalGenerator* gen = this->CreateGlobalGenerator(installedCompiler.c_str()); + cmGlobalGenerator* gen + = this->CreateGlobalGenerator(installedCompiler.c_str()); if(!gen) { gen = new cmGlobalNMakeMakefileGenerator; @@ -1217,20 +1334,20 @@ this->SetGlobalGenerator(new cmGlobalUnixMakefileGenerator3); #endif } - if(!m_GlobalGenerator) + if(!this->GlobalGenerator) { cmSystemTools::Error("Could not create generator"); return -1; } } - const char* genName = m_CacheManager->GetCacheValue("CMAKE_GENERATOR"); + const char* genName = this->CacheManager->GetCacheValue("CMAKE_GENERATOR"); if(genName) { - if(strcmp(m_GlobalGenerator->GetName(), genName) != 0) + if(strcmp(this->GlobalGenerator->GetName(), genName) != 0) { std::string message = "Error: generator : "; - message += m_GlobalGenerator->GetName(); + message += this->GlobalGenerator->GetName(); message += "\nDoes not match the generator used previously: "; message += genName; message += @@ -1240,73 +1357,84 @@ return -2; } } - if(!m_CacheManager->GetCacheValue("CMAKE_GENERATOR")) + if(!this->CacheManager->GetCacheValue("CMAKE_GENERATOR")) { - m_CacheManager->AddCacheEntry("CMAKE_GENERATOR", m_GlobalGenerator->GetName(), - "Name of generator.", - cmCacheManager::INTERNAL); + this->CacheManager->AddCacheEntry("CMAKE_GENERATOR", + this->GlobalGenerator->GetName(), + "Name of generator.", + cmCacheManager::INTERNAL); } // reset any system configuration information, except for when we are // InTryCompile. With TryCompile the system info is taken from the parent's // info to save time - if (!m_InTryCompile) + if (!this->InTryCompile) { - m_GlobalGenerator->ClearEnabledLanguages(); + this->GlobalGenerator->ClearEnabledLanguages(); } - + this->CleanupWrittenFiles(); // Truncate log files - if (!m_InTryCompile) + if (!this->InTryCompile) { this->TruncateOutputLog("CMakeOutput.log"); this->TruncateOutputLog("CMakeError.log"); } // actually do the configure - m_GlobalGenerator->Configure(); + this->GlobalGenerator->Configure(); // Before saving the cache // if the project did not define one of the entries below, add them now // so users can edit the values in the cache: // LIBRARY_OUTPUT_PATH // EXECUTABLE_OUTPUT_PATH - if(!m_CacheManager->GetCacheValue("LIBRARY_OUTPUT_PATH")) + if(!this->CacheManager->GetCacheValue("LIBRARY_OUTPUT_PATH")) { - m_CacheManager->AddCacheEntry("LIBRARY_OUTPUT_PATH", "", - "Single output directory for building all libraries.", - cmCacheManager::PATH); + this->CacheManager->AddCacheEntry + ("LIBRARY_OUTPUT_PATH", "", + "Single output directory for building all libraries.", + cmCacheManager::PATH); } - if(!m_CacheManager->GetCacheValue("EXECUTABLE_OUTPUT_PATH")) + if(!this->CacheManager->GetCacheValue("EXECUTABLE_OUTPUT_PATH")) { - m_CacheManager->AddCacheEntry("EXECUTABLE_OUTPUT_PATH", "", - "Single output directory for building all executables.", - cmCacheManager::PATH); + this->CacheManager->AddCacheEntry + ("EXECUTABLE_OUTPUT_PATH", "", + "Single output directory for building all executables.", + cmCacheManager::PATH); } - if(!m_CacheManager->GetCacheValue("CMAKE_USE_RELATIVE_PATHS")) + if(!this->CacheManager->GetCacheValue("CMAKE_USE_RELATIVE_PATHS")) { - m_CacheManager->AddCacheEntry("CMAKE_USE_RELATIVE_PATHS", false, - "If true, cmake will use relative paths in makefiles and projects."); + this->CacheManager->AddCacheEntry + ("CMAKE_USE_RELATIVE_PATHS", false, + "If true, cmake will use relative paths in makefiles and projects."); cmCacheManager::CacheIterator it = - m_CacheManager->GetCacheIterator("CMAKE_USE_RELATIVE_PATHS"); + this->CacheManager->GetCacheIterator("CMAKE_USE_RELATIVE_PATHS"); if ( !it.PropertyExists("ADVANCED") ) { it.SetProperty("ADVANCED", "1"); } - } - + } + if(cmSystemTools::GetFatalErrorOccured() && - (!this->m_CacheManager->GetCacheValue("CMAKE_MAKE_PROGRAM") || - cmSystemTools::IsOff(this->m_CacheManager->GetCacheValue("CMAKE_MAKE_PROGRAM")))) + (!this->CacheManager->GetCacheValue("CMAKE_MAKE_PROGRAM") || + cmSystemTools::IsOff(this->CacheManager-> + GetCacheValue("CMAKE_MAKE_PROGRAM")))) { // We must have a bad generator selection. Wipe the cache entry so the // user can select another. - m_CacheManager->RemoveCacheEntry("CMAKE_GENERATOR"); + this->CacheManager->RemoveCacheEntry("CMAKE_GENERATOR"); + } + // only save the cache if there were no fatal errors + if ( !this->ScriptMode && !cmSystemTools::GetFatalErrorOccured() ) + { + this->CacheManager->SaveCache(this->GetHomeOutputDirectory()); } - if ( !m_ScriptMode ) + if ( !this->GraphVizFile.empty() ) { - this->m_CacheManager->SaveCache(this->GetHomeOutputDirectory()); + std::cout << "Generate graphviz: " << this->GraphVizFile << std::endl; + this->GenerateGraphViz(this->GraphVizFile.c_str()); } if(cmSystemTools::GetErrorOccuredFlag()) { @@ -1317,13 +1445,16 @@ bool cmake::CacheVersionMatches() { - const char* majv = m_CacheManager->GetCacheValue("CMAKE_CACHE_MAJOR_VERSION"); - const char* minv = m_CacheManager->GetCacheValue("CMAKE_CACHE_MINOR_VERSION"); - const char* relv = m_CacheManager->GetCacheValue("CMAKE_CACHE_RELEASE_VERSION"); + const char* majv = + this->CacheManager->GetCacheValue("CMAKE_CACHE_MAJOR_VERSION"); + const char* minv = + this->CacheManager->GetCacheValue("CMAKE_CACHE_MINOR_VERSION"); + const char* relv = + this->CacheManager->GetCacheValue("CMAKE_CACHE_RELEASE_VERSION"); bool cacheSameCMake = false; - if(majv && + if(majv && atoi(majv) == static_cast(cmMakefile::GetMajorVersion()) - && minv && + && minv && atoi(minv) == static_cast(cmMakefile::GetMinorVersion()) && relv && (strcmp(relv, cmMakefile::GetReleaseVersion()) == 0)) { @@ -1364,19 +1495,23 @@ CMakeCommandUsage(args[0].c_str()); return -1; } - + // set the cmake command - m_CMakeCommand = args[0]; + this->CMakeCommand = args[0]; - if ( !m_ScriptMode ) + if ( !this->ScriptMode ) { // load the cache if(this->LoadCache() < 0) { - cmSystemTools::Error("Error executing cmake::LoadCache(). Aborting.\n"); + cmSystemTools::Error("Error executing cmake::LoadCache(). Aborting.\n"); return -1; } } + else + { + this->AddCMakePaths(this->CMakeCommand.c_str()); + } // Add any cache args if ( !this->SetCacheArgs(args) ) @@ -1386,7 +1521,7 @@ } // In script mode we terminate after running the script. - if(m_ScriptMode) + if(this->ScriptMode) { if(cmSystemTools::GetErrorOccuredFlag()) { @@ -1414,7 +1549,7 @@ { return 0; } - + // If we are doing global generate, we better set start and start // output directory to the root of the project. std::string oldstartdir = this->GetStartDirectory(); @@ -1422,7 +1557,7 @@ this->SetStartDirectory(this->GetHomeDirectory()); this->SetStartOutputDirectory(this->GetHomeOutputDirectory()); int ret = this->Configure(); - if (ret || m_ScriptMode) + if (ret || this->ScriptMode) { return ret; } @@ -1442,11 +1577,11 @@ int cmake::Generate() { - if(!m_GlobalGenerator) + if(!this->GlobalGenerator) { return -1; } - m_GlobalGenerator->Generate(); + this->GlobalGenerator->Generate(); if(cmSystemTools::GetErrorOccuredFlag()) { return -1; @@ -1454,33 +1589,33 @@ return 0; } -unsigned int cmake::GetMajorVersion() -{ +unsigned int cmake::GetMajorVersion() +{ return cmMakefile::GetMajorVersion(); } unsigned int cmake::GetMinorVersion() -{ +{ return cmMakefile::GetMinorVersion(); } const char *cmake::GetReleaseVersion() -{ +{ return cmMakefile::GetReleaseVersion(); } -void cmake::AddCacheEntry(const char* key, const char* value, - const char* helpString, +void cmake::AddCacheEntry(const char* key, const char* value, + const char* helpString, int type) { - m_CacheManager->AddCacheEntry(key, value, - helpString, - cmCacheManager::CacheEntryType(type)); + this->CacheManager->AddCacheEntry(key, value, + helpString, + cmCacheManager::CacheEntryType(type)); } const char* cmake::GetCacheDefinition(const char* name) const { - return m_CacheManager->GetCacheValue(name); + return this->CacheManager->GetCacheValue(name); } int cmake::DumpDocumentationToFile(std::ostream& f) @@ -1496,8 +1631,8 @@ f << "\n"; f << "

Documentation for commands of CMake " << tmp << "

\n"; f << "
    \n"; - for(RegisteredCommandsMap::iterator j = m_Commands.begin(); - j != m_Commands.end(); ++j) + for(RegisteredCommandsMap::iterator j = this->Commands.begin(); + j != this->Commands.end(); ++j) { name = (*j).second->GetName(); terse = (*j).second->GetTerseDocumentation(); @@ -1527,29 +1662,35 @@ void cmake::AddDefaultGenerators() { #if defined(_WIN32) && !defined(__CYGWIN__) - m_Generators[cmGlobalVisualStudio6Generator::GetActualName()] = +# if !defined(CMAKE_BOOT_MINGW) + this->Generators[cmGlobalVisualStudio6Generator::GetActualName()] = &cmGlobalVisualStudio6Generator::New; -#if !defined(__MINGW32__) - m_Generators[cmGlobalVisualStudio7Generator::GetActualName()] = + this->Generators[cmGlobalVisualStudio7Generator::GetActualName()] = &cmGlobalVisualStudio7Generator::New; - m_Generators[cmGlobalVisualStudio71Generator::GetActualName()] = + this->Generators[cmGlobalVisualStudio71Generator::GetActualName()] = &cmGlobalVisualStudio71Generator::New; - m_Generators[cmGlobalVisualStudio8Generator::GetActualName()] = + this->Generators[cmGlobalVisualStudio8Generator::GetActualName()] = &cmGlobalVisualStudio8Generator::New; -#endif - m_Generators[cmGlobalBorlandMakefileGenerator::GetActualName()] = + this->Generators[cmGlobalBorlandMakefileGenerator::GetActualName()] = &cmGlobalBorlandMakefileGenerator::New; - m_Generators[cmGlobalNMakeMakefileGenerator::GetActualName()] = + this->Generators[cmGlobalNMakeMakefileGenerator::GetActualName()] = &cmGlobalNMakeMakefileGenerator::New; + this->Generators[cmGlobalWatcomWMakeGenerator::GetActualName()] = + &cmGlobalWatcomWMakeGenerator::New; +# endif + this->Generators[cmGlobalMSYSMakefileGenerator::GetActualName()] = + &cmGlobalMSYSMakefileGenerator::New; + this->Generators[cmGlobalMinGWMakefileGenerator::GetActualName()] = + &cmGlobalMinGWMakefileGenerator::New; #endif - m_Generators[cmGlobalUnixMakefileGenerator3::GetActualName()] = + this->Generators[cmGlobalUnixMakefileGenerator3::GetActualName()] = &cmGlobalUnixMakefileGenerator3::New; #ifdef CMAKE_USE_XCODE - m_Generators[cmGlobalXCodeGenerator::GetActualName()] = + this->Generators[cmGlobalXCodeGenerator::GetActualName()] = &cmGlobalXCodeGenerator::New; #endif #ifdef CMAKE_USE_KDEVELOP - m_Generators[cmGlobalKdevelopGenerator::GetActualName()] = + this->Generators[cmGlobalKdevelopGenerator::GetActualName()] = &cmGlobalKdevelopGenerator::New; #endif } @@ -1557,64 +1698,71 @@ int cmake::LoadCache() { // could we not read the cache - if (!m_CacheManager->LoadCache(this->GetHomeOutputDirectory())) + if (!this->CacheManager->LoadCache(this->GetHomeOutputDirectory())) { // if it does exist, but isn;t readable then warn the user std::string cacheFile = this->GetHomeOutputDirectory(); cacheFile += "/CMakeCache.txt"; if(cmSystemTools::FileExists(cacheFile.c_str())) { - cmSystemTools::Error("There is a CMakeCache.txt file for the current binary tree but cmake does not have permission to read it. Please check the permissions of the directory you are trying to run CMake on."); + cmSystemTools::Error( + "There is a CMakeCache.txt file for the current binary tree but " + "cmake does not have permission to read it. Please check the " + "permissions of the directory you are trying to run CMake on."); return -1; } } - if (m_CMakeCommand.size() < 2) + if (this->CMakeCommand.size() < 2) { - cmSystemTools::Error("cmake command was not specified prior to loading the cache in cmake.cxx"); + cmSystemTools::Error( + "cmake command was not specified prior to loading the cache in " + "cmake.cxx"); return -1; } - + // setup CMAKE_ROOT and CMAKE_COMMAND - if(!this->AddCMakePaths(m_CMakeCommand.c_str())) + if(!this->AddCMakePaths(this->CMakeCommand.c_str())) { return -3; - } + } // set the default BACKWARDS compatibility to the current version - if(!m_CacheManager->GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")) + if(!this->CacheManager->GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")) { char ver[256]; sprintf(ver,"%i.%i",cmMakefile::GetMajorVersion(), cmMakefile::GetMinorVersion()); - this->m_CacheManager->AddCacheEntry + this->CacheManager->AddCacheEntry ("CMAKE_BACKWARDS_COMPATIBILITY",ver, - "For backwards compatibility, what version of CMake commands and syntax should this version of CMake allow.", + "For backwards compatibility, what version of CMake commands and " + "syntax should this version of CMake allow.", cmCacheManager::STRING); } - + return 0; } -void cmake::SetProgressCallback(ProgressCallback f, void *cd) +void cmake::SetProgressCallback(ProgressCallbackType f, void *cd) { - m_ProgressCallback = f; - m_ProgressCallbackClientData = cd; + this->ProgressCallback = f; + this->ProgressCallbackClientData = cd; } void cmake::UpdateProgress(const char *msg, float prog) { - if(m_ProgressCallback && !m_InTryCompile) + if(this->ProgressCallback && !this->InTryCompile) { - (*m_ProgressCallback)(msg, prog, m_ProgressCallbackClientData); + (*this->ProgressCallback)(msg, prog, this->ProgressCallbackClientData); return; } } -void cmake::GetCommandDocumentation(std::vector& v) const +void cmake::GetCommandDocumentation( + std::vector& v) const { - for(RegisteredCommandsMap::const_iterator j = m_Commands.begin(); - j != m_Commands.end(); ++j) + for(RegisteredCommandsMap::const_iterator j = this->Commands.begin(); + j != this->Commands.end(); ++j) { cmDocumentationEntry e = { @@ -1630,8 +1778,8 @@ void cmake::GetGeneratorDocumentation(std::vector& v) { - for(RegisteredGeneratorsMap::const_iterator i = m_Generators.begin(); - i != m_Generators.end(); ++i) + for(RegisteredGeneratorsMap::const_iterator i = this->Generators.begin(); + i != this->Generators.end(); ++i) { cmDocumentationEntry e; cmGlobalGenerator* generator = (i->second)(); @@ -1645,31 +1793,32 @@ void cmake::AddWrittenFile(const char* file) { - m_WrittenFiles.insert(file); + this->WrittenFiles.insert(file); } bool cmake::HasWrittenFile(const char* file) { - return m_WrittenFiles.find(file) != m_WrittenFiles.end(); + return this->WrittenFiles.find(file) != this->WrittenFiles.end(); } void cmake::CleanupWrittenFiles() { - m_WrittenFiles.clear(); + this->WrittenFiles.clear(); } void cmake::UpdateConversionPathTable() { // Update the path conversion table with any specified file: const char* tablepath = - m_CacheManager->GetCacheValue("CMAKE_PATH_TRANSLATION_FILE"); + this->CacheManager->GetCacheValue("CMAKE_PATH_TRANSLATION_FILE"); if(tablepath) { std::ifstream table( tablepath ); if(!table) { - cmSystemTools::Error("CMAKE_PATH_TRANSLATION_FILE set to ", tablepath, ". CMake can not open file."); + cmSystemTools::Error("CMAKE_PATH_TRANSLATION_FILE set to ", tablepath, + ". CMake can not open file."); cmSystemTools::ReportLastSystemError("CMake can not open file."); } else @@ -1695,13 +1844,13 @@ // does not then we need to check the integrity here. // If no file is provided for the check, we have to rerun. - if(m_CheckBuildSystem.size() == 0) + if(this->CheckBuildSystemArgument.size() == 0) { return 1; } // If the file provided does not exist, we have to rerun. - if(!cmSystemTools::FileExists(m_CheckBuildSystem.c_str())) + if(!cmSystemTools::FileExists(this->CheckBuildSystemArgument.c_str())) { return 1; } @@ -1714,7 +1863,7 @@ std::auto_ptr lg(gg.CreateLocalGenerator()); lg->SetGlobalGenerator(&gg); cmMakefile* mf = lg->GetMakefile(); - if(!mf->ReadListFile(0, m_CheckBuildSystem.c_str()) || + if(!mf->ReadListFile(0, this->CheckBuildSystemArgument.c_str()) || cmSystemTools::GetErrorOccuredFlag()) { // There was an error reading the file. Just rerun. @@ -1742,8 +1891,8 @@ out != outputs.end(); ++out) { int result = 0; - if(!m_FileComparison->FileTimeCompare(out->c_str(), - dep->c_str(), &result) || + if(!this->FileComparison->FileTimeCompare(out->c_str(), + dep->c_str(), &result) || result < 0) { return 1; @@ -1767,7 +1916,7 @@ { std::auto_ptr lgd(ggd->CreateLocalGenerator()); lgd->SetGlobalGenerator(ggd); - lgd->CheckDependencies(mf, verbose, m_ClearBuildSystem); + lgd->CheckDependencies(mf, verbose, this->ClearBuildSystem); } // No need to rerun. @@ -1785,7 +1934,7 @@ { return; } - if ( !m_CacheManager->GetCacheValue("CMAKE_CACHEFILE_DIR") ) + if ( !this->CacheManager->GetCacheValue("CMAKE_CACHEFILE_DIR") ) { cmSystemTools::RemoveFile(fullPath.c_str()); return; @@ -1799,3 +1948,354 @@ } } +inline std::string removeQuotes(const std::string& s) +{ + if(s[0] == '\"' && s[s.size()-1] == '\"') + { + return s.substr(1, s.size()-2); + } + return s; +} + +const char* cmake::GetCTestCommand() +{ + if ( !this->CTestCommand.empty() ) + { + return this->CTestCommand.c_str(); + } + + cmMakefile* mf + = this->GetGlobalGenerator()->GetLocalGenerator(0)->GetMakefile(); +#ifdef CMAKE_BUILD_WITH_CMAKE + this->CTestCommand = mf->GetRequiredDefinition("CMAKE_COMMAND"); + this->CTestCommand = removeQuotes(this->CTestCommand); + this->CTestCommand = cmSystemTools::GetFilenamePath(this->CTestCommand.c_str()); + this->CTestCommand += "/"; + this->CTestCommand += "ctest"; + this->CTestCommand += cmSystemTools::GetExecutableExtension(); + if(!cmSystemTools::FileExists(this->CTestCommand.c_str())) + { + this->CTestCommand = mf->GetRequiredDefinition("CMAKE_COMMAND"); + this->CTestCommand = cmSystemTools::GetFilenamePath(this->CTestCommand.c_str()); + this->CTestCommand += "/Debug/"; + this->CTestCommand += "ctest"; + this->CTestCommand += cmSystemTools::GetExecutableExtension(); + } + if(!cmSystemTools::FileExists(this->CTestCommand.c_str())) + { + this->CTestCommand = mf->GetRequiredDefinition("CMAKE_COMMAND"); + this->CTestCommand = cmSystemTools::GetFilenamePath(this->CTestCommand.c_str()); + this->CTestCommand += "/Release/"; + this->CTestCommand += "ctest"; + this->CTestCommand += cmSystemTools::GetExecutableExtension(); + } +#else + // Only for bootstrap + this->CTestCommand += mf->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH"); + this->CTestCommand += "/ctest"; + this->CTestCommand += cmSystemTools::GetExecutableExtension(); +#endif + if ( this->CTestCommand.empty() ) + { + cmSystemTools::Error("Cannot find the CTest executable"); + this->CTestCommand = "CTEST-COMMAND-NOT-FOUND"; + } + return this->CTestCommand.c_str(); +} + +const char* cmake::GetCPackCommand() +{ + if ( !this->CPackCommand.empty() ) + { + return this->CPackCommand.c_str(); + } + + cmMakefile* mf + = this->GetGlobalGenerator()->GetLocalGenerator(0)->GetMakefile(); + +#ifdef CMAKE_BUILD_WITH_CMAKE + this->CPackCommand = mf->GetRequiredDefinition("CMAKE_COMMAND"); + this->CPackCommand = removeQuotes(this->CPackCommand); + this->CPackCommand = cmSystemTools::GetFilenamePath(this->CPackCommand.c_str()); + this->CPackCommand += "/"; + this->CPackCommand += "cpack"; + this->CPackCommand += cmSystemTools::GetExecutableExtension(); + if(!cmSystemTools::FileExists(this->CPackCommand.c_str())) + { + this->CPackCommand = mf->GetRequiredDefinition("CMAKE_COMMAND"); + this->CPackCommand = cmSystemTools::GetFilenamePath(this->CPackCommand.c_str()); + this->CPackCommand += "/Debug/"; + this->CPackCommand += "cpack"; + this->CPackCommand += cmSystemTools::GetExecutableExtension(); + } + if(!cmSystemTools::FileExists(this->CPackCommand.c_str())) + { + this->CPackCommand = mf->GetRequiredDefinition("CMAKE_COMMAND"); + this->CPackCommand = cmSystemTools::GetFilenamePath(this->CPackCommand.c_str()); + this->CPackCommand += "/Release/"; + this->CPackCommand += "cpack"; + this->CPackCommand += cmSystemTools::GetExecutableExtension(); + } + if (!cmSystemTools::FileExists(this->CPackCommand.c_str())) + { + cmSystemTools::Error("Cannot find the CPack executable"); + this->CPackCommand = "CPACK-COMMAND-NOT-FOUND"; + } +#else + // Only for bootstrap + this->CPackCommand += mf->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH"); + this->CPackCommand += "/cpack"; + this->CPackCommand += cmSystemTools::GetExecutableExtension(); +#endif + return this->CPackCommand.c_str(); +} + +void cmake::GenerateGraphViz(const char* fileName) +{ + cmGeneratedFileStream str(fileName); + if ( !str ) + { + return; + } + cmake cm; + cmGlobalGenerator ggi; + ggi.SetCMakeInstance(&cm); + std::auto_ptr lg(ggi.CreateLocalGenerator()); + lg->SetGlobalGenerator(&ggi); + cmMakefile *mf = lg->GetMakefile(); + + std::string infile = this->GetHomeOutputDirectory(); + infile += "/CMakeGraphVizOptions.cmake"; + if ( !cmSystemTools::FileExists(infile.c_str()) ) + { + infile = this->GetHomeDirectory(); + infile += "/CMakeGraphVizOptions.cmake"; + if ( !cmSystemTools::FileExists(infile.c_str()) ) + { + infile = ""; + } + } + + if ( !infile.empty() ) + { + if ( !mf->ReadListFile(0, infile.c_str()) ) + { + cmSystemTools::Error("Problem opening GraphViz options file: ", + infile.c_str()); + return; + } + std::cout << "Read GraphViz options file: " << infile.c_str() + << std::endl; + } + +#define __set_if_not_set(var, value, cmakeDefinition) \ + const char* var = mf->GetDefinition(cmakeDefinition); \ + if ( !var ) \ + { \ + var = value; \ + } + __set_if_not_set(graphType, "digraph", "GRAPHVIZ_GRAPH_TYPE"); + __set_if_not_set(graphName, "GG", "GRAPHVIZ_GRAPH_NAME"); + __set_if_not_set(graphHeader, "node [\n fontsize = \"12\"\n];", + "GRAPHVIZ_GRAPH_HEADER"); + __set_if_not_set(graphNodePrefix, "node", "GRAPHVIZ_NODE_PREFIX"); + const char* ignoreTargets = mf->GetDefinition("GRAPHVIZ_IGNORE_TARGETS"); + std::set ignoreTargetsSet; + if ( ignoreTargets ) + { + std::vector ignoreTargetsVector; + cmSystemTools::ExpandListArgument(ignoreTargets,ignoreTargetsVector); + std::vector::iterator itvIt; + for ( itvIt = ignoreTargetsVector.begin(); + itvIt != ignoreTargetsVector.end(); + ++ itvIt ) + { + ignoreTargetsSet.insert(itvIt->c_str()); + } + } + + str << graphType << " " << graphName << " {" << std::endl; + str << graphHeader << std::endl; + + cmGlobalGenerator* gg = this->GetGlobalGenerator(); + std::vector localGenerators; + gg->GetLocalGenerators(localGenerators); + std::vector::iterator lit; + // for target deps + // 1 - cmake target + // 2 - external target + // 0 - no deps + std::map targetDeps; + std::map targetPtrs; + std::map targetNamesNodes; + char tgtName[100]; + int cnt = 0; + // First pass get the list of all cmake targets + for ( lit = localGenerators.begin(); lit != localGenerators.end(); ++ lit ) + { + cmTargets* targets = &((*lit)->GetMakefile()->GetTargets()); + cmTargets::iterator tit; + for ( tit = targets->begin(); tit != targets->end(); ++ tit ) + { + const char* realTargetName = tit->first.c_str(); + if ( ignoreTargetsSet.find(realTargetName) != ignoreTargetsSet.end() ) + { + // Skip ignored targets + continue; + } + //std::cout << "Found target: " << tit->first.c_str() << std::endl; + sprintf(tgtName, "%s%d", graphNodePrefix, cnt++); + targetNamesNodes[realTargetName] = tgtName; + targetPtrs[realTargetName] = &tit->second; + //str << " \"" << tgtName << "\" [ label=\"" << tit->first.c_str() + //<< "\" shape=\"box\"];" << std::endl; + } + } + // Ok, now find all the stuff we link to that is not in cmake + for ( lit = localGenerators.begin(); lit != localGenerators.end(); ++ lit ) + { + cmTargets* targets = &((*lit)->GetMakefile()->GetTargets()); + cmTargets::iterator tit; + for ( tit = targets->begin(); tit != targets->end(); ++ tit ) + { + const cmTarget::LinkLibraryVectorType* ll + = &(tit->second.GetOriginalLinkLibraries()); + cmTarget::LinkLibraryVectorType::const_iterator llit; + const char* realTargetName = tit->first.c_str(); + if ( ignoreTargetsSet.find(realTargetName) != ignoreTargetsSet.end() ) + { + // Skip ignored targets + continue; + } + if ( ll->size() > 0 ) + { + targetDeps[realTargetName] = 1; + } + for ( llit = ll->begin(); llit != ll->end(); ++ llit ) + { + const char* libName = llit->first.c_str(); + std::map::iterator tarIt + = targetNamesNodes.find(libName); + if ( ignoreTargetsSet.find(libName) != ignoreTargetsSet.end() ) + { + // Skip ignored targets + continue; + } + if ( tarIt == targetNamesNodes.end() ) + { + sprintf(tgtName, "%s%d", graphNodePrefix, cnt++); + targetDeps[libName] = 2; + targetNamesNodes[libName] = tgtName; + //str << " \"" << tgtName << "\" [ label=\"" << libName + //<< "\" shape=\"ellipse\"];" << std::endl; + } + else + { + std::map::iterator depIt + = targetDeps.find(libName); + if ( depIt == targetDeps.end() ) + { + targetDeps[libName] = 1; + } + } + } + } + } + + // Write out nodes + std::map::iterator depIt; + for ( depIt = targetDeps.begin(); depIt != targetDeps.end(); ++ depIt ) + { + const char* newTargetName = depIt->first.c_str(); + std::map::iterator tarIt + = targetNamesNodes.find(newTargetName); + if ( tarIt == targetNamesNodes.end() ) + { + // We should not be here. + std::cout << __LINE__ << " Cannot find library: " << newTargetName + << " even though it was added in the previous pass" << std::endl; + abort(); + } + + str << " \"" << tarIt->second.c_str() << "\" [ label=\"" + << newTargetName << "\" shape=\""; + if ( depIt->second == 1 ) + { + std::map::iterator tarTypeIt= targetPtrs.find( + newTargetName); + if ( tarTypeIt == targetPtrs.end() ) + { + // We should not be here. + std::cout << __LINE__ << " Cannot find library: " << newTargetName + << " even though it was added in the previous pass" << std::endl; + abort(); + } + cmTarget* tg = tarTypeIt->second; + switch ( tg->GetType() ) + { + case cmTarget::EXECUTABLE: + str << "house"; + break; + case cmTarget::STATIC_LIBRARY: + str << "diamond"; + break; + case cmTarget::SHARED_LIBRARY: + str << "polygon"; + break; + case cmTarget::MODULE_LIBRARY: + str << "octagon"; + break; + default: + str << "box"; + } + } + else + { + str << "ellipse"; + } + str << "\"];" << std::endl; + } + + // Now generate the connectivity + for ( lit = localGenerators.begin(); lit != localGenerators.end(); ++ lit ) + { + cmTargets* targets = &((*lit)->GetMakefile()->GetTargets()); + cmTargets::iterator tit; + for ( tit = targets->begin(); tit != targets->end(); ++ tit ) + { + std::map::iterator dependIt + = targetDeps.find(tit->first.c_str()); + if ( dependIt == targetDeps.end() ) + { + continue; + } + std::map::iterator cmakeTarIt + = targetNamesNodes.find(tit->first.c_str()); + const cmTarget::LinkLibraryVectorType* ll + = &(tit->second.GetOriginalLinkLibraries()); + cmTarget::LinkLibraryVectorType::const_iterator llit; + for ( llit = ll->begin(); llit != ll->end(); ++ llit ) + { + const char* libName = llit->first.c_str(); + std::map::iterator tarIt + = targetNamesNodes.find(libName); + if ( tarIt == targetNamesNodes.end() ) + { + // We should not be here. + std::cout << __LINE__ << " Cannot find library: " << libName + << " even though it was added in the previous pass" << std::endl; + abort(); + } + str << " \"" << cmakeTarIt->second.c_str() << "\" -> \"" + << tarIt->second.c_str() << "\"" << std::endl; + } + } + } + + // TODO: Use dotted or something for external libraries + //str << " \"node0\":f4 -> \"node12\"[color=\"#0000ff\" style=dotted]" + //<< std::endl; + // + str << "}" << std::endl; +} + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmake.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmake.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmake.h 2005-10-17 20:49:40.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmake.h 2006-03-16 00:02:07.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmake.h,v $ Language: C++ - Date: $Date: 2005/10/17 12:49:40 $ - Version: $Revision: 1.57.2.3 $ + Date: $Date: 2006/03/15 16:02:07 $ + Version: $Revision: 1.65 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -78,12 +78,12 @@ void SetHomeDirectory(const char* dir); const char* GetHomeDirectory() const { - return m_cmHomeDirectory.c_str(); + return this->cmHomeDirectory.c_str(); } void SetHomeOutputDirectory(const char* lib); const char* GetHomeOutputDirectory() const { - return m_HomeOutputDirectory.c_str(); + return this->HomeOutputDirectory.c_str(); } //@} @@ -97,21 +97,21 @@ */ void SetStartDirectory(const char* dir) { - m_cmStartDirectory = dir; - cmSystemTools::ConvertToUnixSlashes(m_cmStartDirectory); + this->cmStartDirectory = dir; + cmSystemTools::ConvertToUnixSlashes(this->cmStartDirectory); } const char* GetStartDirectory() const { - return m_cmStartDirectory.c_str(); + return this->cmStartDirectory.c_str(); } void SetStartOutputDirectory(const char* lib) { - m_StartOutputDirectory = lib; - cmSystemTools::ConvertToUnixSlashes(m_StartOutputDirectory); + this->StartOutputDirectory = lib; + cmSystemTools::ConvertToUnixSlashes(this->StartOutputDirectory); } const char* GetStartOutputDirectory() const { - return m_StartOutputDirectory.c_str(); + return this->StartOutputDirectory.c_str(); } //@} @@ -161,7 +161,7 @@ cmGlobalGenerator* CreateGlobalGenerator(const char* name); ///! Return the global generator assigned to this instance of cmake - cmGlobalGenerator* GetGlobalGenerator() { return m_GlobalGenerator; }; + cmGlobalGenerator* GetGlobalGenerator() { return this->GlobalGenerator; }; ///! Return the global generator assigned to this instance of cmake void SetGlobalGenerator(cmGlobalGenerator *); @@ -170,10 +170,10 @@ void GetRegisteredGenerators(std::vector& names); ///! get the cmCachemManager used by this invocation of cmake - cmCacheManager *GetCacheManager() { return m_CacheManager; } + cmCacheManager *GetCacheManager() { return this->CacheManager; } ///! set the cmake command this instance of cmake should use - void SetCMakeCommand(const char* cmd) { m_CMakeCommand = cmd; } + void SetCMakeCommand(const char* cmd) { this->CMakeCommand = cmd; } /** * Given a variable name, return its value (as a string). @@ -187,7 +187,7 @@ * Execute commands during the build process. Supports options such * as echo, remove file etc. */ - static int CMakeCommand(std::vector&); + static int ExecuteCMakeCommand(std::vector&); /** * Add a command to this cmake instance @@ -201,7 +201,7 @@ cmCommand *GetCommand(const char *name); /** Get list of all commands */ - RegisteredCommandsMap* GetCommands() { return &m_Commands; } + RegisteredCommandsMap* GetCommands() { return &this->Commands; } /** Check if a command exists. */ bool CommandExists(const char* name) const; @@ -210,15 +210,16 @@ void SetArgs(const std::vector&); ///! Is this cmake running as a result of a TRY_COMPILE command - bool GetIsInTryCompile() { return m_InTryCompile; } + bool GetIsInTryCompile() { return this->InTryCompile; } ///! Is this cmake running as a result of a TRY_COMPILE command - void SetIsInTryCompile(bool i) { m_InTryCompile = i; } + void SetIsInTryCompile(bool i) { this->InTryCompile = i; } ///! Parse command line arguments that might set cache values bool SetCacheArgs(const std::vector&); - typedef void (*ProgressCallback)(const char*msg, float progress, void *); + typedef void (*ProgressCallbackType) + (const char*msg, float progress, void *); /** * Set the function used by GUI's to receive progress updates * Function gets passed: message as a const char*, a progress @@ -226,14 +227,14 @@ * number provided may be negative in cases where a message is * to be displayed without any progress percentage. */ - void SetProgressCallback(ProgressCallback f, void* clientData=0); + void SetProgressCallback(ProgressCallbackType f, void* clientData=0); ///! this is called by generators to update the progress void UpdateProgress(const char *msg, float prog); ///! Get the variable watch object - cmVariableWatch* GetVariableWatch() { return m_VariableWatch; } + cmVariableWatch* GetVariableWatch() { return this->VariableWatch; } void GetCommandDocumentation(std::vector&) const; void GetGeneratorDocumentation(std::vector&); @@ -246,12 +247,12 @@ * and no cache. Also, language are not enabled, so add_executable and things * do not do anything. */ - void SetScriptMode(bool mode) { m_ScriptMode = mode; } - bool GetScriptMode() { return m_ScriptMode; } + void SetScriptMode(bool mode) { this->ScriptMode = mode; } + bool GetScriptMode() { return this->ScriptMode; } ///! Debug the try compile stuff by not delelting the files - bool GetDebugTryCompile(){return m_DebugTryCompile;} - void DebugTryCompileOn(){m_DebugTryCompile = true;} + bool GetDebugTryCompile(){return this->DebugTryCompile;} + void DebugTryCompileOn(){this->DebugTryCompile = true;} ///! Get the list of files written by CMake using FILE(WRITE / WRITE_FILE void AddWrittenFile(const char* file); @@ -266,24 +267,32 @@ /** * Get the file comparison class */ - cmFileTimeComparison* GetFileComparison() { return m_FileComparison; } + cmFileTimeComparison* GetFileComparison() { return this->FileComparison; } + + /** + * Get the path to ctest + */ + const char* GetCTestCommand(); + const char* GetCPackCommand(); + const char* GetCMakeCommand() { return this->CMakeCommand.c_str(); } protected: typedef cmGlobalGenerator* (*CreateGeneratorFunctionType)(); - typedef std::map RegisteredGeneratorsMap; - RegisteredCommandsMap m_Commands; - RegisteredGeneratorsMap m_Generators; + typedef std::map RegisteredGeneratorsMap; + RegisteredCommandsMap Commands; + RegisteredGeneratorsMap Generators; void AddDefaultCommands(); void AddDefaultGenerators(); - cmGlobalGenerator *m_GlobalGenerator; - cmCacheManager *m_CacheManager; - std::string m_cmHomeDirectory; - std::string m_HomeOutputDirectory; - std::string m_cmStartDirectory; - std::string m_StartOutputDirectory; + cmGlobalGenerator *GlobalGenerator; + cmCacheManager *CacheManager; + std::string cmHomeDirectory; + std::string HomeOutputDirectory; + std::string cmStartDirectory; + std::string StartOutputDirectory; - std::set m_WrittenFiles; + std::set WrittenFiles; ///! return true if the same cmake was used to make the cache. bool CacheVersionMatches(); @@ -304,22 +313,27 @@ //! Make sure all commands are what they say they are and there is no macros. void CleanupCommandsAndMacros(); + + void GenerateGraphViz(const char* fileName); - cmVariableWatch* m_VariableWatch; + cmVariableWatch* VariableWatch; private: - ProgressCallback m_ProgressCallback; - void* m_ProgressCallbackClientData; - bool m_Verbose; - bool m_InTryCompile; - bool m_ScriptMode; - std::string m_CMakeCommand; - std::string m_CXXEnvironment; - std::string m_CCEnvironment; - std::string m_CheckBuildSystem; - bool m_ClearBuildSystem; - bool m_DebugTryCompile; - cmFileTimeComparison* m_FileComparison; + ProgressCallbackType ProgressCallback; + void* ProgressCallbackClientData; + bool Verbose; + bool InTryCompile; + bool ScriptMode; + std::string CMakeCommand; + std::string CXXEnvironment; + std::string CCEnvironment; + std::string CheckBuildSystemArgument; + std::string CTestCommand; + std::string CPackCommand; + bool ClearBuildSystem; + bool DebugTryCompile; + cmFileTimeComparison* FileComparison; + std::string GraphVizFile; void UpdateConversionPathTable(); }; @@ -350,7 +364,7 @@ {0, \ "CMake is a cross-platform build system generator. Projects " \ "specify their build process with platform-independent CMake listfiles " \ - "included in each directory of a source tree with the name CMakeLists.txt. " \ + "included in each directory of a source tree with the name CMakeLists.txt. "\ "Users build a project by using CMake to generate a build system " \ "for a native tool on their platform.", 0} #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CMakeLists.txt /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CMakeLists.txt --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CMakeLists.txt 2005-11-29 04:57:28.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CMakeLists.txt 2006-03-12 22:43:30.000000000 +0800 @@ -1,10 +1,16 @@ CMAKE_MINIMUM_REQUIRED(VERSION 1.5) +INCLUDE_REGULAR_EXPRESSION("^.*$") + # configure the .h file CONFIGURE_FILE( "${CMake_SOURCE_DIR}/Source/cmConfigure.cmake.h.in" "${CMake_BINARY_DIR}/Source/cmConfigure.h" ) +CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Source/CPack/cmCPackConfigure.h.in" + "${CMake_BINARY_DIR}/Source/CPack/cmCPackConfigure.h" + ) # add the include path to find the .h INCLUDE_DIRECTORIES( @@ -12,6 +18,7 @@ "${CMake_SOURCE_DIR}/Source" ${CMAKE_ZLIB_INCLUDES} ${CMAKE_EXPAT_INCLUDES} + ${CMAKE_TAR_INCLUDES} ) # let cmake know it is supposed to use it @@ -21,6 +28,7 @@ "Regenerate YACC and LEXX files" OFF) MARK_AS_ADVANCED(CMAKE_REGENERATE_YACCLEX) IF(CMAKE_REGENERATE_YACCLEX) + SET(parsersLexers cmCommandArgument cmExpr) FIND_PROGRAM(YACC_EXECUTABLE NAMES yacc bison PATHS /usr/bin @@ -36,7 +44,7 @@ SET(BISON_FLAGS "--yacc") ENDIF(YACC_EXECUTABLE MATCHES "bison") SET(yacc_files) - FOREACH(name cmCommandArgument) + FOREACH(name ${parsersLexers}) SET(src "${CMAKE_CURRENT_SOURCE_DIR}/${name}Parser.y") SET(dst "${CMAKE_CURRENT_BINARY_DIR}/${name}Parser.cxx") SET(hdr "${CMAKE_CURRENT_BINARY_DIR}/${name}ParserTokens.h") @@ -51,7 +59,7 @@ ENDIF(YACC_EXECUTABLE) IF(FLEX_EXECUTABLE) SET(lex_files) - FOREACH(name cmCommandArgument) + FOREACH(name ${parsersLexers}) SET(src "${CMAKE_CURRENT_SOURCE_DIR}/${name}Lexer.in.l") SET(dst "${CMAKE_CURRENT_BINARY_DIR}/${name}Lexer.cxx") SET(hdr "${CMAKE_CURRENT_BINARY_DIR}/${name}Lexer.h") @@ -98,12 +106,23 @@ cmDocumentation.cxx cmDynamicLoader.cxx cmDynamicLoader.h + cmExprLexer.cxx + cmExprParser.cxx + cmExprParserHelper.cxx cmGeneratedFileStream.cxx cmGlob.cxx cmGlobalGenerator.cxx cmGlobalGenerator.h cmGlobalUnixMakefileGenerator3.cxx cmGlobalUnixMakefileGenerator3.h + cmInstallGenerator.h + cmInstallGenerator.cxx + cmInstallFilesGenerator.h + cmInstallFilesGenerator.cxx + cmInstallScriptGenerator.h + cmInstallScriptGenerator.cxx + cmInstallTargetGenerator.h + cmInstallTargetGenerator.cxx cmListFileCache.cxx cmListFileCache.h cmListFileLexer.c @@ -114,6 +133,10 @@ cmMakeDepend.h cmMakefile.cxx cmMakefile.h + cmMakefileTargetGenerator.cxx + cmMakefileExecutableTargetGenerator.cxx + cmMakefileLibraryTargetGenerator.cxx + cmMakefileUtilityTargetGenerator.cxx cmOrderLinkDirectories.cxx cmFileTimeComparison.cxx cmFileTimeComparison.h @@ -163,40 +186,43 @@ IF(NOT UNIX) SET(SRCS ${SRCS} cmGlobalBorlandMakefileGenerator.cxx - cmGlobalNMakeMakefileGenerator.cxx - cmGlobalVisualStudio6Generator.cxx - cmLocalVisualStudio6Generator.cxx cmGlobalBorlandMakefileGenerator.h + cmGlobalMSYSMakefileGenerator.cxx + cmGlobalMinGWMakefileGenerator.cxx + cmGlobalNMakeMakefileGenerator.cxx cmGlobalNMakeMakefileGenerator.h + cmGlobalVisualStudio6Generator.cxx cmGlobalVisualStudio6Generator.h + cmGlobalVisualStudio71Generator.cxx + cmGlobalVisualStudio71Generator.h + cmGlobalVisualStudio7Generator.cxx + cmGlobalVisualStudio7Generator.h + cmGlobalVisualStudio8Generator.cxx + cmGlobalVisualStudio8Generator.h + cmGlobalWatcomWMakeGenerator.cxx + cmLocalVisualStudio6Generator.cxx cmLocalVisualStudio6Generator.h + cmLocalVisualStudio7Generator.cxx + cmLocalVisualStudio7Generator.h cmWin32ProcessExecution.cxx cmWin32ProcessExecution.h ) - IF(NOT MINGW) - SET(SRCS ${SRCS} - cmGlobalVisualStudio71Generator.h - cmGlobalVisualStudio8Generator.h - cmGlobalVisualStudio7Generator.h - cmLocalVisualStudio7Generator.h - cmGlobalVisualStudio8Generator.cxx - cmGlobalVisualStudio71Generator.cxx - cmGlobalVisualStudio7Generator.cxx - cmLocalVisualStudio7Generator.cxx) - ENDIF(NOT MINGW) ENDIF(NOT UNIX) ENDIF (WIN32) # create a library used by the command line and the GUI ADD_LIBRARY(CMakeLib ${SRCS}) -TARGET_LINK_LIBRARIES(CMakeLib cmsys ${CMAKE_EXPAT_LIBRARIES} ${CMAKE_ZLIB_LIBRARIES}) -IF (UNIX) +TARGET_LINK_LIBRARIES(CMakeLib cmsys ${CMAKE_EXPAT_LIBRARIES} ${CMAKE_ZLIB_LIBRARIES} ${CMAKE_TAR_LIBRARIES}) + +# On UNIX platforms we need the dl libraries for loading plugins. +IF(UNIX) TARGET_LINK_LIBRARIES(CMakeLib ${CMAKE_DL_LIBS}) -ENDIF (UNIX) -IF(CMAKE_BUILD_ON_VISUAL_STUDIO) - # On Visual Studio we need rpcrt4.lib for cmVisualStudio7 generator. - TARGET_LINK_LIBRARIES(CMakeLib rpcrt4.lib) -ENDIF(CMAKE_BUILD_ON_VISUAL_STUDIO) +ENDIF(UNIX) + +# On some platforms we need the rpcrt4 library for the VS 7 generators. +IF(CMAKE_BUILD_ON_VISUAL_STUDIO OR MINGW) + TARGET_LINK_LIBRARIES(CMakeLib rpcrt4) +ENDIF(CMAKE_BUILD_ON_VISUAL_STUDIO OR MINGW) # # CTestLib @@ -238,6 +264,22 @@ ADD_LIBRARY(CTestLib ${CMTEST_SRCS}) TARGET_LINK_LIBRARIES(CTestLib CMakeLib ${CMAKE_CURL_LIBRARIES} ${CMAKE_XMLRPC_LIBRARIES}) +# +# Sources for CPack +# +SET(CPACK_SRCS + CPack/cmCPackGenerators.cxx + CPack/cmCPackSTGZGenerator.cxx + CPack/cmCPackTGZGenerator.cxx + CPack/cmCPackNSISGenerator.cxx + CPack/cmCPackPackageMakerGenerator.cxx + CPack/cmCPackGenericGenerator.cxx + CPack/cmCPackLog.cxx + ) +# Build CPackLib +ADD_LIBRARY(CPackLib ${CPACK_SRCS}) +TARGET_LINK_LIBRARIES(CPackLib CMakeLib) + # Build CMake executable ADD_EXECUTABLE(cmake cmakemain.cxx) TARGET_LINK_LIBRARIES(cmake CMakeLib) @@ -256,19 +298,20 @@ ADD_EXECUTABLE(ctest ctest.cxx) TARGET_LINK_LIBRARIES(ctest CTestLib) +# Build CPack executable +ADD_EXECUTABLE(cpack CPack/cpack.cxx) +TARGET_LINK_LIBRARIES(cpack CPackLib) + # Curses GUI -IF (UNIX) - INCLUDE (${CMake_SOURCE_DIR}/Modules/FindCurses.cmake OPTIONAL) - IF (CURSES_LIBRARY) - INCLUDE(${CMake_SOURCE_DIR}/Source/CursesDialog/CMakeLists.txt) - ENDIF (CURSES_LIBRARY) -ENDIF (UNIX) +IF(BUILD_CursesDialog) + INCLUDE(${CMake_SOURCE_DIR}/Source/CursesDialog/CMakeLists.txt) +ENDIF(BUILD_CursesDialog) # MFC GUI # MFC libraries are only available on Visual Studio -IF(CMAKE_BUILD_ON_VISUAL_STUDIO) +IF(BUILD_MFCDialog) SUBDIRS(MFCDialog) -ENDIF(CMAKE_BUILD_ON_VISUAL_STUDIO) +ENDIF(BUILD_MFCDialog) # WX Widgets GUI OPTION(CMAKE_BUILD_WX_DIALOG "Build wxWidgets dialog for CMake" FALSE) @@ -283,6 +326,15 @@ ENDIF (NOT DART_ROOT) IF(BUILD_TESTING) + SET(CMAKE_TEST_GENERATOR "" CACHE STRING "Generator used when running tests") + SET(CMAKE_TEST_MAKEPROGRAM "" CACHE FILEPATH "Generator used when running tests") + IF(NOT CMAKE_TEST_GENERATOR) + SET(CMAKE_TEST_GENERATOR "${CMAKE_GENERATOR}") + SET(CMAKE_TEST_MAKEPROGRAM "${MAKEPROGRAM}") + ELSE(NOT CMAKE_TEST_GENERATOR) + SET(CMAKE_TEST_DIFFERENT_GENERATOR TRUE) + ENDIF(NOT CMAKE_TEST_GENERATOR) + # This variable is set by cmake, however to # test cmake we want to make sure that # the ctest from this cmake is used for testing @@ -299,31 +351,53 @@ "${CMake_SOURCE_DIR}/Tests/CommandLineTest" "${CMake_BINARY_DIR}/Tests/CommandLineTest" --build-two-config - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-project CommandLineTest --test-command CommandLineTest) + ADD_TEST(TarTest ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/TarTest" + "${CMake_BINARY_DIR}/Tests/TarTest" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project TestTar + --test-command TestTarExec) + ADD_TEST(CustomCommand ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/CustomCommand" "${CMake_BINARY_DIR}/Tests/CustomCommand" --build-two-config - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project CustomCommand - --build-makeprogram ${MAKEPROGRAM} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-exe-dir "${CMake_BINARY_DIR}/Tests/CustomCommand/bin" --test-command CustomCommand ) + ADD_TEST(CustomCommandWorkingDirectory ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/CustomCommandWorkingDirectory" + "${CMake_BINARY_DIR}/Tests/CustomCommandWorkingDirectory" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project TestWorkingDir + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/CustomCommandWorkingDirectory" + --test-command working + ) + ADD_TEST(FindPackageTest ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/FindPackageTest" "${CMake_BINARY_DIR}/Tests/FindPackageTest" --build-two-config - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project FindPackageTest - --build-makeprogram ${MAKEPROGRAM} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --test-command FindPackageTest) ADD_TEST(SystemInformation ${CMAKE_CTEST_COMMAND} @@ -331,9 +405,9 @@ "${CMake_SOURCE_DIR}/Tests/SystemInformation" "${CMake_BINARY_DIR}/Tests/SystemInformation" --build-two-config - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project DumpInformation - --build-makeprogram ${MAKEPROGRAM} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --test-command DumpInformation) ADD_TEST(StringFileTest ${CMAKE_CTEST_COMMAND} @@ -341,18 +415,28 @@ "${CMake_SOURCE_DIR}/Tests/StringFileTest" "${CMake_BINARY_DIR}/Tests/StringFileTest" --build-two-config - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project StringFileTest - --build-makeprogram ${MAKEPROGRAM} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --test-command StringFileTest) + ADD_TEST(MathTest ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/MathTest" + "${CMake_BINARY_DIR}/Tests/MathTest" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project MathTest + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --test-command MathTestExec) + ADD_TEST(TryCompile ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/TryCompile" "${CMake_BINARY_DIR}/Tests/TryCompile" - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project TryCompile - --build-makeprogram ${MAKEPROGRAM} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-two-config --test-command TryCompile) @@ -360,9 +444,9 @@ --build-and-test "${CMake_SOURCE_DIR}/Tests/Simple" "${CMake_BINARY_DIR}/Tests/Simple" - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project Simple - --build-makeprogram ${MAKEPROGRAM} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-two-config --test-command simple) @@ -370,9 +454,9 @@ # --build-and-test # "${CMake_SOURCE_DIR}/Tests/SameName" # "${CMake_BINARY_DIR}/Tests/SameName" -# --build-generator ${CMAKE_GENERATOR} +# --build-generator ${CMAKE_TEST_GENERATOR} # --build-project SameName -# --build-makeprogram ${MAKEPROGRAM} +# --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} # --build-two-config # --test-command # "${CMake_BINARY_DIR}/Tests/SameName/Exe1/mytest2") @@ -381,9 +465,9 @@ --build-and-test "${CMake_SOURCE_DIR}/Tests/OutOfSource" "${CMake_BINARY_DIR}/Tests/OutOfSource" - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project OutOfSource - --build-makeprogram ${MAKEPROGRAM} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-two-config --test-command "${CMake_BINARY_DIR}/Tests/OutOfSource/SubDir/OutOfSourceSubdir/simple") @@ -392,9 +476,9 @@ --build-and-test "${CMake_SOURCE_DIR}/Tests/PreOrder" "${CMake_BINARY_DIR}/Tests/PreOrder" - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project PreOrder - --build-makeprogram ${MAKEPROGRAM} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-two-config --test-command simple) @@ -402,9 +486,9 @@ --build-and-test "${CMake_SOURCE_DIR}/Tests/COnly" "${CMake_BINARY_DIR}/Tests/COnly" - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project conly - --build-makeprogram ${MAKEPROGRAM} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-two-config --test-command conly) @@ -412,9 +496,9 @@ --build-and-test "${CMake_SOURCE_DIR}/Tests/MacroTest" "${CMake_BINARY_DIR}/Tests/MacroTest" - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project littleMacroTest - --build-makeprogram ${MAKEPROGRAM} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-two-config --test-command miniMacroTest) @@ -424,33 +508,33 @@ --build-and-test "${CMake_SOURCE_DIR}/Tests/SimpleInstall" "${CMake_BINARY_DIR}/Tests/SimpleInstall" - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project TestSimpleInstall - --build-makeprogram ${MAKEPROGRAM} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-two-config --build-options "-DCMAKE_INSTALL_PREFIX:PATH=${SimpleInstallInstallDir}" - --test-command ${SimpleInstallInstallDir}/bin/SimpleInstallExe) + --test-command ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstallExe) ADD_TEST(SimpleInstall-Stage2 ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/SimpleInstallS2" "${CMake_BINARY_DIR}/Tests/SimpleInstallS2" - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project TestSimpleInstall - --build-makeprogram ${MAKEPROGRAM} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-two-config --build-options "-DCMAKE_INSTALL_PREFIX:PATH=${SimpleInstallInstallDir}" "-DSTAGE2:BOOL=1" - --test-command ${SimpleInstallInstallDir}/bin/SimpleInstallS2) + --test-command ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstallS2) ADD_TEST(X11 ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/X11" "${CMake_BINARY_DIR}/Tests/X11" - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project UseX11 - --build-makeprogram ${MAKEPROGRAM} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-two-config --test-command UseX11) @@ -458,9 +542,9 @@ --build-and-test "${CMake_SOURCE_DIR}/Tests/LoadCommand" "${CMake_BINARY_DIR}/Tests/LoadCommand" - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project LoadedCommand - --build-makeprogram ${MAKEPROGRAM} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-two-config --test-command LoadedCommand) @@ -468,9 +552,9 @@ --build-and-test "${CMake_SOURCE_DIR}/Tests/LoadCommandOneConfig" "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig" - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project LoadedCommand - --build-makeprogram ${MAKEPROGRAM} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --test-command LoadedCommand ) @@ -485,10 +569,12 @@ "${CMake_SOURCE_DIR}/Tests/Complex" "${CMake_BINARY_DIR}/Tests/Complex" --build-two-config - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project complex - --build-makeprogram ${MAKEPROGRAM} - --build-exe-dir "${CMake_BINARY_DIR}/Tests/Complex/bin" + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/Complex/bin" + --build-options + -DCMAKE_TEST_DIFFERENT_GENERATOR:BOOL=${CMAKE_TEST_DIFFERENT_GENERATOR} --test-command complex ) @@ -496,19 +582,21 @@ --build-and-test "${CMake_SOURCE_DIR}/Tests/ComplexOneConfig" "${CMake_BINARY_DIR}/Tests/ComplexOneConfig" - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project complex - --build-makeprogram ${MAKEPROGRAM} - --build-exe-dir "${CMake_BINARY_DIR}/Tests/ComplexOneConfig/bin" + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/ComplexOneConfig/bin" + --build-options + -DCMAKE_TEST_DIFFERENT_GENERATOR:BOOL=${CMAKE_TEST_DIFFERENT_GENERATOR} --test-command complex) # ADD_TEST(complexRelativePaths ${CMAKE_CTEST_COMMAND} # --build-and-test # "${CMake_SOURCE_DIR}/Tests/ComplexRelativePaths" # "${CMake_BINARY_DIR}/Tests/ComplexRelativePaths" -# --build-generator ${CMAKE_GENERATOR} +# --build-generator ${CMAKE_TEST_GENERATOR} # --build-project complex -# --build-makeprogram ${MAKEPROGRAM} +# --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} # --build-exe-dir "${CMake_BINARY_DIR}/Tests/ComplexRelativePaths/bin" # --build-options -DCMAKE_USE_RELATIVE_PATHS:BOOL=ON # --test-command complex) @@ -519,9 +607,9 @@ --build-and-test "${CMake_SOURCE_DIR}/Example" "${CMake_BINARY_DIR}/Example" - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project HELLO - --build-makeprogram ${MAKEPROGRAM} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-exe-dir "${CMake_BINARY_DIR}/Example/Demo" --test-command helloDemo ) @@ -531,8 +619,8 @@ "${CMake_SOURCE_DIR}/Tests/Tutorial/Step1" "${CMake_BINARY_DIR}/Tests/Tutorial/Step1" --build-two-config - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-project Tutorial --test-command Tutorial 25.0) @@ -541,8 +629,8 @@ "${CMake_SOURCE_DIR}/Tests/Tutorial/Step2" "${CMake_BINARY_DIR}/Tests/Tutorial/Step2" --build-two-config - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-project Tutorial --test-command Tutorial 25.0) @@ -551,8 +639,8 @@ "${CMake_SOURCE_DIR}/Tests/Tutorial/Step3" "${CMake_BINARY_DIR}/Tests/Tutorial/Step3" --build-two-config - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-project Tutorial --test-command Tutorial 25.0) @@ -561,8 +649,8 @@ "${CMake_SOURCE_DIR}/Tests/Tutorial/Step4" "${CMake_BINARY_DIR}/Tests/Tutorial/Step4" --build-two-config - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-project Tutorial --test-command Tutorial 25.0) @@ -571,8 +659,8 @@ "${CMake_SOURCE_DIR}/Tests/Tutorial/Step5" "${CMake_BINARY_DIR}/Tests/Tutorial/Step5" --build-two-config - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-project Tutorial --test-command Tutorial 25.0) @@ -580,9 +668,9 @@ --build-and-test "${CMake_SOURCE_DIR}/Tests/Testing" "${CMake_BINARY_DIR}/Tests/Testing" - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project testing - --build-makeprogram ${MAKEPROGRAM} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-exe-dir "${CMake_BINARY_DIR}/Tests/Testing/bin" --test-command testing ) @@ -591,9 +679,9 @@ --build-and-test "${CMake_SOURCE_DIR}/Tests/Wrapping" "${CMake_BINARY_DIR}/Tests/Wrapping" - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project wrapping - --build-makeprogram ${MAKEPROGRAM} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin" --test-command wrapping ) @@ -610,9 +698,9 @@ --build-and-test "${CMake_SOURCE_DIR}/Tests/Wrapping" "${CMake_BINARY_DIR}/Tests/Wrapping" - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project Wrapping - --build-makeprogram ${MAKEPROGRAM} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin" --test-command qtwrapping ) @@ -622,8 +710,8 @@ --build-and-test "${CMake_SOURCE_DIR}/Tests/TestDriver" "${CMake_BINARY_DIR}/Tests/TestDriver" - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin" --build-project TestDriverTest --test-command TestDriverTest test1 @@ -633,8 +721,8 @@ --build-and-test "${CMake_SOURCE_DIR}/Tests/TestDriver" "${CMake_BINARY_DIR}/Tests/TestDriver" - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin" --build-project TestDriverTest --test-command TestDriverTest test2 @@ -644,8 +732,8 @@ --build-and-test "${CMake_SOURCE_DIR}/Tests/TestDriver" "${CMake_BINARY_DIR}/Tests/TestDriver" - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin" --build-project TestDriverTest --test-command TestDriverTest subdir/test3 @@ -657,8 +745,8 @@ "${CMake_BINARY_DIR}/Tests/Dependency/WithLibOut" --build-exe-dir "${CMake_BINARY_DIR}/Tests/Dependency/WithLibOut/Exec" --build-project Dependency - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-options -DLIBRARY_OUTPUT_PATH:PATH=${CMake_BINARY_DIR}/Tests/Dependency/WithLibOut/Lib --test-command exec @@ -670,8 +758,8 @@ "${CMake_SOURCE_DIR}/Tests/Dependency" "${CMake_BINARY_DIR}/Tests/Dependency/WOLibOut" --build-exe-dir "${CMake_BINARY_DIR}/Tests/Dependency/WOLibOut/Exec" - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-project Dependency --test-command exec ) @@ -681,8 +769,8 @@ "${CMake_SOURCE_DIR}/Tests/Dependency" "${CMake_BINARY_DIR}/Tests/Dependency/WithLibOut" --build-exe-dir "${CMake_BINARY_DIR}/Tests/Dependency/WithLibOut/Exec2" - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-project Dependency --build-options -DLIBRARY_OUTPUT_PATH:PATH=${CMake_BINARY_DIR}/Tests/Dependency/WithLibOut/Lib @@ -694,8 +782,8 @@ "${CMake_SOURCE_DIR}/Tests/Dependency" "${CMake_BINARY_DIR}/Tests/Dependency/WithLibOut" --build-exe-dir "${CMake_BINARY_DIR}/Tests/Dependency/WithLibOut/Exec3" - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-project Dependency --build-options -DLIBRARY_OUTPUT_PATH:PATH=${CMake_BINARY_DIR}/Tests/Dependency/WithLibOut/Lib @@ -706,8 +794,8 @@ "${CMake_SOURCE_DIR}/Tests/Dependency" "${CMake_BINARY_DIR}/Tests/Dependency/WithLibOut" --build-exe-dir "${CMake_BINARY_DIR}/Tests/Dependency/WithLibOut/Exec4" - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-project Dependency --build-options -DLIBRARY_OUTPUT_PATH:PATH=${CMake_BINARY_DIR}/Tests/Dependency/WithLibOut/Lib @@ -720,8 +808,8 @@ "${CMake_BINARY_DIR}/Tests/Jump/WithLibOut" --build-exe-dir "${CMake_BINARY_DIR}/Tests/Jump/WithLibOut/Executable" --build-project Jump - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-options -DLIBRARY_OUTPUT_PATH:PATH=${CMake_BINARY_DIR}/Tests/Jump/WithLibOut/Lib --test-command jumpExecutable @@ -734,8 +822,8 @@ --build-exe-dir "${CMake_BINARY_DIR}/Tests/Jump/NoLibOut/Executable" --build-run-dir "${CMake_BINARY_DIR}/Tests/Jump/NoLibOut/Executable" --build-project Jump - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --test-command jumpExecutable ) @@ -744,8 +832,8 @@ "${CMake_SOURCE_DIR}/Tests/LinkLine" "${CMake_BINARY_DIR}/Tests/LinkLine" --build-exe-dir "${CMake_BINARY_DIR}/Tests/LinkLine" - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-project Linkline --test-command Exec ) @@ -754,8 +842,8 @@ --build-and-test "${CMake_SOURCE_DIR}/Tests/LinkLineOrder" "${CMake_BINARY_DIR}/Tests/LinkLineOrder" - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-exe-dir "${CMake_BINARY_DIR}/Tests/LinkLineOrder" --build-project LinkLineOrder --test-command Exec1 @@ -766,8 +854,8 @@ "${CMake_SOURCE_DIR}/Tests/LinkLineOrder" "${CMake_BINARY_DIR}/Tests/LinkLineOrder" --build-exe-dir "${CMake_BINARY_DIR}/Tests/LinkLineOrder" - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-project LinkLineOrder --test-command Exec2 ) @@ -776,23 +864,26 @@ --build-and-test "${CMake_SOURCE_DIR}/Tests/ExternalOBJ" "${CMake_BINARY_DIR}/Tests/ExternalOBJ" - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project ExternalOBJ - --build-makeprogram ${MAKEPROGRAM} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-exe-dir "${CMake_BINARY_DIR}/ExternalOBJ" --test-command executable ) - ADD_TEST(kwsys ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Source/kwsys" - "${CMake_BINARY_DIR}/Tests/kwsys" - --build-exe-dir "${CMake_BINARY_DIR}/Tests/kwsys" - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} - --build-project kwsys - --test-command testIOS - ) + IF(NOT CMAKE_TEST_DIFFERENT_GENERATOR) + ADD_TEST(kwsys ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Source/kwsys" + "${CMake_BINARY_DIR}/Tests/kwsys" + --build-exe-dir "${CMake_BINARY_DIR}/Tests/kwsys" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project kwsys + --test-command testIOS + ) + ENDIF(NOT CMAKE_TEST_DIFFERENT_GENERATOR) + IF (WIN32) ADD_TEST(SubDir ${CMAKE_CTEST_COMMAND} @@ -800,8 +891,8 @@ "${CMake_SOURCE_DIR}/Tests/SubDir" "${CMake_BINARY_DIR}/Tests/SubDir" --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubDir/Executable" - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-project SUBDIR --test-command test "${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere" @@ -813,8 +904,8 @@ "${CMake_SOURCE_DIR}/Tests/SubDir" "${CMake_BINARY_DIR}/Tests/SubDir" --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubDir/Executable" - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-project SUBDIR --test-command test "${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere" @@ -822,48 +913,54 @@ ) ENDIF (WIN32) - IF("${CMAKE_GENERATOR}" MATCHES "Makefile") + IF("${CMAKE_TEST_GENERATOR}" MATCHES "Makefile") ADD_TEST(MakeClean ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/MakeClean" "${CMake_BINARY_DIR}/Tests/MakeClean" - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project MakeClean - --build-makeprogram ${MAKEPROGRAM} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-exe-dir "${CMake_BINARY_DIR}/MakeClean" --test-command check_clean ) - ENDIF("${CMAKE_GENERATOR}" MATCHES "Makefile") + ENDIF("${CMAKE_TEST_GENERATOR}" MATCHES "Makefile") - IF(${CMAKE_GENERATOR} MATCHES "Visual Studio") + IF(${CMAKE_TEST_GENERATOR} MATCHES "Visual Studio") ADD_TEST(VSExternalInclude ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/VSExternalInclude" "${CMake_BINARY_DIR}/Tests/VSExternalInclude" --build-two-config - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project VSExternalInclude - --build-makeprogram ${MAKEPROGRAM} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --test-command VSExternalInclude) - ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio") + ENDIF(${CMAKE_TEST_GENERATOR} MATCHES "Visual Studio") IF (APPLE AND CMAKE_COMPILER_IS_GNUCXX) + SET(BundleTestInstallDir + "${CMake_BINARY_DIR}/Tests/BundleTest/InstallDirectory") ADD_TEST(BundleTest ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/BundleTest" "${CMake_BINARY_DIR}/Tests/BundleTest" --build-two-config - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-project BundleTest - --test-command BundleTest.app/Contents/MacOS/BundleTest) + --build-target install +# --build-target package + --build-options "-DCMAKE_INSTALL_PREFIX:PATH=${BundleTestInstallDir}" + --test-command + ${BundleTestInstallDir}/Application/BundleTestExe.app/Contents/MacOS/BundleTestExe) ADD_TEST(objc++ ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/ObjC++" "${CMake_BINARY_DIR}/Tests/ObjC++" - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-project objc++ --test-command objc++ ) @@ -890,9 +987,9 @@ ) ENDIF (CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS) - IF("${CMAKE_GENERATOR}" MATCHES Xcode) + IF("${CMAKE_TEST_GENERATOR}" MATCHES Xcode) SET(CMAKE_SKIP_BOOTSTRAP_TEST 1) - ENDIF("${CMAKE_GENERATOR}" MATCHES Xcode) + ENDIF("${CMAKE_TEST_GENERATOR}" MATCHES Xcode) IF(EXISTS "${CMAKE_BINARY_DIR}/CMakeLists.txt") # If there is CMakeLists.txt in the binary tree, assume in-source build SET(CMAKE_SKIP_BOOTSTRAP_TEST 1) @@ -905,11 +1002,11 @@ --build-nocmake --build-noclean --build-makeprogram ${CMake_SOURCE_DIR}/bootstrap - --build-generator "${CMAKE_GENERATOR}" + --build-generator "${CMAKE_TEST_GENERATOR}" --test-command ${CMake_BINARY_DIR}/Tests/BootstrapTest/Bootstrap.cmk/cmake) ENDIF(UNIX AND CMAKE_RUN_LONG_TESTS AND NOT CMAKE_SKIP_BOOTSTRAP_TEST) - IF(CMAKE_GENERATOR MATCHES "Makefiles") + IF(CMAKE_TEST_GENERATOR MATCHES "Makefiles") # see if we can find a fortran compiler on the machine # if so, add the fortran test and see if it works. SET(CMAKE_Fortran_COMPILER_LIST ifort ifc efc f95 pgf95 @@ -922,9 +1019,9 @@ --build-and-test "${CMake_SOURCE_DIR}/Tests/Fortran" "${CMake_BINARY_DIR}/Tests/Fortran" - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project testf - --build-makeprogram ${MAKEPROGRAM} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-two-config --test-command testf) ENDIF(CMAKE_Fortran_COMPILER_FULLPATH) @@ -942,25 +1039,25 @@ --build-and-test "${CMake_SOURCE_DIR}/Tests/Java" "${CMake_BINARY_DIR}/Tests/Java" - --build-generator ${CMAKE_GENERATOR} + --build-generator ${CMAKE_TEST_GENERATOR} --build-project hello - --build-makeprogram ${MAKEPROGRAM} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-two-config --build-run-dir "${CMake_BINARY_DIR}/Tests/Java/" --test-command ${JAVA_RUNTIME} -classpath hello.jar HelloWorld) ENDIF("${JNI_FILE}" MATCHES "JDK1_2") ENDIF(JNI_H) ENDIF(JAVA_COMPILE AND JAVA_RUNTIME AND JAVA_ARCHIVE AND NOT MINGW) - ENDIF(CMAKE_GENERATOR MATCHES "Makefiles") - + ENDIF(CMAKE_TEST_GENERATOR MATCHES "Makefiles") + IF (CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE OR WXWINDOWS_INCLUDE_DIR) # Will be set if the wxwindows gui is on ADD_TEST(UseWX ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/UseWX" "${CMake_BINARY_DIR}/Tests/UseWX" - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${MAKEPROGRAM} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-exe-dir ${CMake_BINARY_DIR}/Tests/UseWX --build-project UsewxWindows --build-options -DCMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE:FILEPATH=${CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE} @@ -988,4 +1085,5 @@ INSTALL_TARGETS(/bin cmake) INSTALL_TARGETS(/bin ctest) +INSTALL_TARGETS(/bin cpack) INSTALL_FILES(${CMAKE_DATA_DIR}/include cmCPluginAPI.h) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmakemain.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmakemain.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmakemain.cxx 2005-10-07 03:28:33.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmakemain.cxx 2006-03-17 00:01:05.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmakemain.cxx,v $ Language: C++ - Date: $Date: 2005/10/06 19:28:33 $ - Version: $Revision: 1.41.2.1 $ + Date: $Date: 2006/03/16 16:01:05 $ + Version: $Revision: 1.47 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -17,10 +17,10 @@ #include "cmakewizard.h" #include "cmake.h" #include "cmCacheManager.h" -#include "cmDynamicLoader.h" #include "cmListFileCache.h" #ifdef CMAKE_BUILD_WITH_CMAKE +#include "cmDynamicLoader.h" #include "cmDocumentation.h" //---------------------------------------------------------------------------- @@ -76,13 +76,20 @@ "Only load the cache. Do not actually run configure and generate steps."}, {"-P ", "Process script mode.", "Process the given cmake file as a script written in the CMake language. " - "No configure or generate step is performed and the cache is not modified."}, + "No configure or generate step is performed and the cache is not" + " modified."}, {"--help-command cmd [file]", "Print help for a single command and exit.", "Full documentation specific to the given command is displayed."}, {"--help-command-list [file]", "List available listfile commands and exit.", "The list contains all commands for which help may be obtained by using " "the --help-command argument followed by a command name. If a file is " "specified, the help is written into it."}, + {"--help-module module [file]", "Print help for a single module and exit.", + "Full documentation specific to the given module is displayed."}, + {"--help-module-list [file]", "List available modules and exit.", + "The list contains all modules for which help may be obtained by using " + "the --help-module argument followed by a module name. If a file is " + "specified, the help is written into it."}, {0,0,0} }; @@ -115,7 +122,6 @@ #ifdef CMAKE_BUILD_WITH_CMAKE cmDynamicLoader::FlushCache(); #endif - cmListFileCache::ClearCache(); return ret; } @@ -128,7 +134,8 @@ if ( cmSystemTools::GetCurrentWorkingDirectory().size() == 0 ) { - std::cerr << "Current working directory cannot be established." << std::endl; + std::cerr << "Current working directory cannot be established." + << std::endl; nocwd = 1; } @@ -168,7 +175,9 @@ #else if ( nocwd || ac == 1 ) { - std::cout << "Bootstrap CMake should not be used outside CMake build process." << std::endl; + std::cout << + "Bootstrap CMake should not be used outside CMake build process." + << std::endl; return 0; } #endif @@ -234,7 +243,7 @@ if(command) { - int ret = cmake::CMakeCommand(args); + int ret = cmake::ExecuteCMakeCommand(args); return ret; } if (wiz) @@ -248,7 +257,8 @@ int res = cm.Run(args, view_only); if ( list_cached || list_all_cached ) { - cmCacheManager::CacheIterator it = cm.GetCacheManager()->GetCacheIterator(); + cmCacheManager::CacheIterator it = + cm.GetCacheManager()->GetCacheIterator(); std::cout << "-- Cache values" << std::endl; for ( it.Begin(); !it.IsAtEnd(); it.Next() ) { @@ -263,7 +273,8 @@ { std::cout << "// " << it.GetProperty("HELPSTRING") << std::endl; } - std::cout << it.GetName() << ":" << cmCacheManager::TypeToString(it.GetType()) + std::cout << it.GetName() << ":" << + cmCacheManager::TypeToString(it.GetType()) << "=" << it.GetValue() << std::endl; if ( list_help ) { diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmakewizard.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmakewizard.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmakewizard.cxx 2004-09-30 04:07:07.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmakewizard.cxx 2006-03-16 00:02:07.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmakewizard.cxx,v $ Language: C++ - Date: $Date: 2004/09/29 20:07:07 $ - Version: $Revision: 1.21 $ + Date: $Date: 2006/03/15 16:02:07 $ + Version: $Revision: 1.23 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -20,11 +20,12 @@ cmakewizard::cmakewizard() { - m_ShowAdvanced = false; + this->ShowAdvanced = false; } - -void cmakewizard::AskUser(const char* key, cmCacheManager::CacheIterator& iter) + +void cmakewizard::AskUser(const char* key, + cmCacheManager::CacheIterator& iter) { printf("Variable Name: %s\n", key); const char* helpstring = iter.GetProperty("HELPSTRING"); @@ -34,7 +35,7 @@ char buffer[4096]; buffer[0] = 0; fgets(buffer, sizeof(buffer)-1, stdin); - + if(strlen(buffer) > 0) { std::string sbuffer = buffer; @@ -44,7 +45,7 @@ { value = sbuffer.substr(0, pos+1); } - + if ( value.size() > 0 ) { if(iter.GetType() == cmCacheManager::PATH || @@ -67,7 +68,7 @@ bool cmakewizard::AskAdvanced() { - printf("Would you like to see advanced options? [No]:"); + printf("Would you like to see advanced options? [No]:"); char buffer[4096]; buffer[0] = 0; fgets(buffer, sizeof(buffer)-1, stdin); @@ -91,7 +92,7 @@ int cmakewizard::RunWizard(std::vector const& args) { - m_ShowAdvanced = this->AskAdvanced(); + this->ShowAdvanced = this->AskAdvanced(); cmSystemTools::DisableRunCommandOutput(); cmake make; make.SetArgs(args); @@ -105,7 +106,8 @@ { asked = false; // run cmake - this->ShowMessage("Please wait while cmake processes CMakeLists.txt files....\n"); + this->ShowMessage( + "Please wait while cmake processes CMakeLists.txt files....\n"); make.Configure(); this->ShowMessage("\n"); @@ -115,9 +117,9 @@ cmCacheManager::CacheIterator i = cachem->NewIterator(); // iterate over all entries in the cache for(;!i.IsAtEnd(); i.Next()) - { + { std::string key = i.GetName(); - if( i.GetType() == cmCacheManager::INTERNAL || + if( i.GetType() == cmCacheManager::INTERNAL || i.GetType() == cmCacheManager::STATIC || i.GetType() == cmCacheManager::UNINITIALIZED ) { @@ -128,7 +130,7 @@ std::string& e = askedCache.find(key)->second; if(e != i.GetValue()) { - if(m_ShowAdvanced || !i.GetPropertyAsBool("ADVANCED")) + if(this->ShowAdvanced || !i.GetPropertyAsBool("ADVANCED")) { this->AskUser(key.c_str(), i); asked = true; @@ -137,7 +139,7 @@ } else { - if(m_ShowAdvanced || !i.GetPropertyAsBool("ADVANCED")) + if(this->ShowAdvanced || !i.GetPropertyAsBool("ADVANCED")) { this->AskUser(key.c_str(), i); asked = true; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmakewizard.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmakewizard.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmakewizard.h 2005-04-26 23:15:33.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmakewizard.h 2006-03-16 00:02:08.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmakewizard.h,v $ Language: C++ - Date: $Date: 2005/04/26 15:15:33 $ - Version: $Revision: 1.13 $ + Date: $Date: 2006/03/15 16:02:08 $ + Version: $Revision: 1.14 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -42,6 +42,6 @@ int RunWizard(std::vectorconst& args); private: - bool m_ShowAdvanced; + bool ShowAdvanced; }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAuxSourceDirectoryCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAuxSourceDirectoryCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmAuxSourceDirectoryCommand.cxx 2005-04-06 02:48:25.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmAuxSourceDirectoryCommand.cxx 2006-03-16 00:01:58.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmAuxSourceDirectoryCommand.cxx,v $ Language: C++ - Date: $Date: 2005/04/05 18:48:25 $ - Version: $Revision: 1.19 $ + Date: $Date: 2006/03/15 16:01:58 $ + Version: $Revision: 1.20 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -30,13 +30,13 @@ std::string sourceListValue; std::string templateDirectory = args[0]; - m_Makefile->AddExtraDirectory(templateDirectory.c_str()); - std::string tdir = m_Makefile->GetCurrentDirectory(); + this->Makefile->AddExtraDirectory(templateDirectory.c_str()); + std::string tdir = this->Makefile->GetCurrentDirectory(); tdir += "/"; tdir += templateDirectory; // was the list already populated - const char *def = m_Makefile->GetDefinition(args[1].c_str()); + const char *def = this->Makefile->GetDefinition(args[1].c_str()); if (def) { sourceListValue = def; @@ -58,9 +58,9 @@ file = file.substr(0, dotpos); // Process only source files if( file.size() != 0 - && std::find( m_Makefile->GetSourceExtensions().begin(), - m_Makefile->GetSourceExtensions().end(), ext ) - != m_Makefile->GetSourceExtensions().end() ) + && std::find( this->Makefile->GetSourceExtensions().begin(), + this->Makefile->GetSourceExtensions().end(), ext ) + != this->Makefile->GetSourceExtensions().end() ) { std::string fullname = templateDirectory; fullname += "/"; @@ -68,11 +68,11 @@ // add the file as a class file so // depends can be done cmSourceFile cmfile; - cmfile.SetName(fullname.c_str(), m_Makefile->GetCurrentDirectory(), - m_Makefile->GetSourceExtensions(), - m_Makefile->GetHeaderExtensions()); + cmfile.SetName(fullname.c_str(), this->Makefile->GetCurrentDirectory(), + this->Makefile->GetSourceExtensions(), + this->Makefile->GetHeaderExtensions()); cmfile.SetProperty("ABSTRACT","0"); - m_Makefile->AddSource(cmfile); + this->Makefile->AddSource(cmfile); if (sourceListValue.size() > 0) { sourceListValue += ";"; @@ -84,7 +84,7 @@ } } } - m_Makefile->AddDefinition(args[1].c_str(), sourceListValue.c_str()); + this->Makefile->AddDefinition(args[1].c_str(), sourceListValue.c_str()); return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmBootstrapCommands.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmBootstrapCommands.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmBootstrapCommands.cxx 2005-03-18 23:41:40.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmBootstrapCommands.cxx 2006-03-03 02:30:22.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmBootstrapCommands.cxx,v $ Language: C++ - Date: $Date: 2005/03/18 15:41:40 $ - Version: $Revision: 1.2 $ + Date: $Date: 2006/03/02 18:30:22 $ + Version: $Revision: 1.5 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -37,6 +37,7 @@ #include "cmEndForEachCommand.cxx" #include "cmEndIfCommand.cxx" #include "cmExecProgramCommand.cxx" +#include "cmFindBase.cxx" #include "cmFileCommand.cxx" #include "cmFindFileCommand.cxx" #include "cmFindLibraryCommand.cxx" @@ -44,8 +45,10 @@ #include "cmFindPathCommand.cxx" #include "cmFindProgramCommand.cxx" #include "cmForEachCommand.cxx" +#include "cmGetCMakePropertyCommand.cxx" #include "cmGetFilenameComponentCommand.cxx" #include "cmGetSourceFilePropertyCommand.cxx" +#include "cmGetTargetPropertyCommand.cxx" #include "cmIfCommand.cxx" #include "cmIncludeCommand.cxx" #include "cmIncludeDirectoryCommand.cxx" @@ -101,8 +104,10 @@ commands.push_back(new cmFindPathCommand); commands.push_back(new cmFindProgramCommand); commands.push_back(new cmForEachCommand); + commands.push_back(new cmGetCMakePropertyCommand); commands.push_back(new cmGetFilenameComponentCommand); commands.push_back(new cmGetSourceFilePropertyCommand); + commands.push_back(new cmGetTargetPropertyCommand); commands.push_back(new cmIfCommand); commands.push_back(new cmIncludeCommand); commands.push_back(new cmIncludeDirectoryCommand); diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmBuildCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmBuildCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmBuildCommand.cxx 2005-05-10 22:10:51.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmBuildCommand.cxx 2006-03-16 00:01:58.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmBuildCommand.cxx,v $ Language: C++ - Date: $Date: 2005/05/10 14:10:51 $ - Version: $Revision: 1.18 $ + Date: $Date: 2006/03/15 16:01:58 $ + Version: $Revision: 1.21 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -29,49 +29,18 @@ } const char* define = args[0].c_str(); const char* cacheValue - = m_Makefile->GetDefinition(define); + = this->Makefile->GetDefinition(define); std::string makeprogram = args[1]; - std::string makecommand - = m_Makefile->GetLocalGenerator()->GetGlobalGenerator()->GenerateBuildCommand( - makeprogram.c_str(), m_Makefile->GetProjectName(), 0, "Release", true); -#if 0 - std::string makecommand; - if(makeprogram.find("msdev") != std::string::npos || - makeprogram.find("MSDEV") != std::string::npos ) - { - makecommand = "\""; - makecommand += makeprogram; - makecommand += "\""; - makecommand += " "; - makecommand += m_Makefile->GetProjectName(); - makecommand += ".dsw /MAKE \"ALL_BUILD - Release\" "; - } - else if (makeprogram.find("devenv") != std::string::npos || - makeprogram.find("DEVENV") != std::string::npos ) - { - makecommand = "\""; - makecommand += makeprogram; - makecommand += "\""; - makecommand += " "; - makecommand += m_Makefile->GetProjectName(); - makecommand += ".sln /build Release /project ALL_BUILD"; - } - else if (makeprogram.find("xcodebuild") != std::string::npos) - { - makecommand += makeprogram; - } - else - { - makecommand = makeprogram; - makecommand += " -i"; - } - std::cerr << "-- Compare: " << makecommand.c_str() << " and " << makecmd.c_str() << ": " << (makecmd == makecommand) << std::endl; -#endif + std::string makecommand = this->Makefile->GetLocalGenerator() + ->GetGlobalGenerator()->GenerateBuildCommand + (makeprogram.c_str(), this->Makefile->GetProjectName(), 0, + 0, "Release", true); + if(cacheValue) { return true; } - m_Makefile->AddCacheDefinition(define, + this->Makefile->AddCacheDefinition(define, makecommand.c_str(), "Command used to build entire project " "from the command line.", diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmBuildNameCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmBuildNameCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmBuildNameCommand.cxx 2003-08-04 10:33:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmBuildNameCommand.cxx 2006-03-16 00:01:58.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmBuildNameCommand.cxx,v $ Language: C++ - Date: $Date: 2003/08/04 02:33:00 $ - Version: $Revision: 1.17 $ + Date: $Date: 2006/03/15 16:01:58 $ + Version: $Revision: 1.18 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -26,7 +26,7 @@ this->SetError("called with incorrect number of arguments"); return false; } - const char* cacheValue = m_Makefile->GetDefinition(args[0].c_str()); + const char* cacheValue = this->Makefile->GetDefinition(args[0].c_str()); if(cacheValue) { // do we need to correct the value? @@ -37,7 +37,7 @@ cmSystemTools::ReplaceString(cv,"/", "_"); cmSystemTools::ReplaceString(cv,"(", "_"); cmSystemTools::ReplaceString(cv,")", "_"); - m_Makefile->AddCacheDefinition(args[0].c_str(), + this->Makefile->AddCacheDefinition(args[0].c_str(), cv.c_str(), "Name of build.", cmCacheManager::STRING); @@ -47,7 +47,7 @@ std::string buildname = "WinNT"; - if(m_Makefile->GetDefinition("UNIX")) + if(this->Makefile->GetDefinition("UNIX")) { buildname = ""; cmSystemTools::RunSingleCommand("uname -a", &buildname); @@ -62,7 +62,7 @@ } } std::string compiler = "${CMAKE_CXX_COMPILER}"; - m_Makefile->ExpandVariablesInString ( compiler ); + this->Makefile->ExpandVariablesInString ( compiler ); buildname += "-"; buildname += cmSystemTools::GetFilenameName(compiler); cmSystemTools::ReplaceString(buildname, @@ -72,7 +72,7 @@ cmSystemTools::ReplaceString(buildname, ")", "_"); - m_Makefile->AddCacheDefinition(args[0].c_str(), + this->Makefile->AddCacheDefinition(args[0].c_str(), buildname.c_str(), "Name of build.", cmCacheManager::STRING); diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmBuildNameCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmBuildNameCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmBuildNameCommand.h 2005-10-25 03:43:52.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmBuildNameCommand.h 2006-03-11 02:06:25.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmBuildNameCommand.h,v $ Language: C++ - Date: $Date: 2005/10/24 19:43:52 $ - Version: $Revision: 1.9.2.1 $ + Date: $Date: 2006/03/10 18:06:25 $ + Version: $Revision: 1.12 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -22,7 +22,7 @@ /** \class cmBuildNameCommand * \brief BuildName a CMAKE variable * - * cmBuildNameCommand sets a variable to a value with expansion. + * cmBuildNameCommand sets a variable to a value with expansion. */ class cmBuildNameCommand : public cmCommand { @@ -30,7 +30,7 @@ /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { return new cmBuildNameCommand; } @@ -42,18 +42,24 @@ virtual bool InitialPass(std::vector const& args); /** + * This determines if the command is invoked when in script mode. + */ + virtual bool IsScriptable() { return true; } + + /** * The name of the command as specified in CMakeList.txt. */ virtual const char* GetName() {return "BUILD_NAME";} - + /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { - return "Deprecated. Use ${CMAKE_SYSTEM} and ${CMAKE_CXX_COMPILER} instead."; + return + "Deprecated. Use ${CMAKE_SYSTEM} and ${CMAKE_CXX_COMPILER} instead."; } - + /** * More documentation. */ @@ -65,7 +71,7 @@ "and compiler settings. These values are now available through the " "CMAKE_SYSTEM and CMAKE_CXX_COMPILER variables."; } - + cmTypeMacro(cmBuildNameCommand, cmCommand); }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCacheManager.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCacheManager.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCacheManager.cxx 2005-08-12 02:02:19.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCacheManager.cxx 2006-03-16 00:01:59.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCacheManager.cxx,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:19 $ - Version: $Revision: 1.85.2.1 $ + Date: $Date: 2006/03/15 16:01:59 $ + Version: $Revision: 1.91 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -19,6 +19,8 @@ #include "cmSystemTools.h" #include "cmCacheManager.h" #include "cmMakefile.h" +#include "cmGlob.h" +#include #include @@ -26,7 +28,7 @@ # include #endif // _WIN32 -const char* cmCacheManagerTypes[] = +const char* cmCacheManagerTypes[] = { "BOOL", "PATH", "FILEPATH", @@ -78,14 +80,16 @@ return this->LoadCache(path, internal, emptySet, emptySet); } -bool cmCacheManager::ParseEntry(const char* entry, +bool cmCacheManager::ParseEntry(const char* entry, std::string& var, std::string& value) { // input line is: key:type=value - static cmsys::RegularExpression reg("^([^:]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); + static cmsys::RegularExpression reg( + "^([^:]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); // input line is: "key":type=value - static cmsys::RegularExpression regQuoted("^\"([^\"]*)\"=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); + static cmsys::RegularExpression regQuoted( + "^\"([^\"]*)\"=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); bool flag = false; if(regQuoted.find(entry)) { @@ -102,27 +106,29 @@ // if value is enclosed in single quotes ('foo') then remove them // it is used to enclose trailing space or tab - if (flag && + if (flag && value.size() >= 2 && - value[0] == '\'' && - value[value.size() - 1] == '\'') + value[0] == '\'' && + value[value.size() - 1] == '\'') { - value = value.substr(1, + value = value.substr(1, value.size() - 2); } return flag; } -bool cmCacheManager::ParseEntry(const char* entry, +bool cmCacheManager::ParseEntry(const char* entry, std::string& var, std::string& value, CacheEntryType& type) { // input line is: key:type=value - static cmsys::RegularExpression reg("^([^:]*):([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); + static cmsys::RegularExpression reg( + "^([^:]*):([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); // input line is: "key":type=value - static cmsys::RegularExpression regQuoted("^\"([^\"]*)\":([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); + static cmsys::RegularExpression regQuoted( + "^\"([^\"]*)\":([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); bool flag = false; if(regQuoted.find(entry)) { @@ -141,18 +147,32 @@ // if value is enclosed in single quotes ('foo') then remove them // it is used to enclose trailing space or tab - if (flag && + if (flag && value.size() >= 2 && - value[0] == '\'' && - value[value.size() - 1] == '\'') + value[0] == '\'' && + value[value.size() - 1] == '\'') { - value = value.substr(1, + value = value.substr(1, value.size() - 2); } return flag; } +void cmCacheManager::CleanCMakeFiles(const char* path) +{ + std::string glob = path; + glob += "/CMakeFiles/*.cmake"; + cmGlob globIt; + globIt.FindFiles(glob); + std::vector files = globIt.GetFiles(); + for(std::vector::iterator i = files.begin(); + i != files.end(); ++i) + { + cmSystemTools::RemoveFile(i->c_str()); + } +} + bool cmCacheManager::LoadCache(const char* path, bool internal, std::set& excludes, @@ -163,8 +183,14 @@ // clear the old cache, if we are reading in internal values if ( internal ) { - m_Cache.clear(); + this->Cache.clear(); } + if(!cmSystemTools::FileExists(cacheFile.c_str())) + { + this->CleanCMakeFiles(path); + return false; + } + std::ifstream fin(cacheFile.c_str()); if(!fin) { @@ -194,7 +220,7 @@ } while(realbuffer[0] == '/' && realbuffer[1] == '/') { - e.m_Properties["HELPSTRING"] += &realbuffer[2]; + e.Properties["HELPSTRING"] += &realbuffer[2]; cmSystemTools::GetLineFromStream(fin, buffer); realbuffer = buffer.c_str(); if(!fin) @@ -202,7 +228,7 @@ continue; } } - if(cmCacheManager::ParseEntry(realbuffer, entryKey, e.m_Value, e.m_Type)) + if(cmCacheManager::ParseEntry(realbuffer, entryKey, e.Value, e.Type)) { if ( excludes.find(entryKey) == excludes.end() ) { @@ -210,7 +236,7 @@ // If the entry is not internal to the cache being loaded // or if it is in the list of internal entries to be // imported, load it. - if ( internal || (e.m_Type != INTERNAL) || + if ( internal || (e.Type != INTERNAL) || (includes.find(entryKey) != includes.end()) ) { // If we are loading the cache from another project, @@ -218,26 +244,28 @@ // not visible in the gui if (!internal) { - e.m_Type = INTERNAL; - e.m_Properties["HELPSTRING"] = "DO NOT EDIT, "; - e.m_Properties["HELPSTRING"] += entryKey; - e.m_Properties["HELPSTRING"] += " loaded from external file. " + e.Type = INTERNAL; + e.Properties["HELPSTRING"] = "DO NOT EDIT, "; + e.Properties["HELPSTRING"] += entryKey; + e.Properties["HELPSTRING"] += " loaded from external file. " "To change this value edit this file: "; - e.m_Properties["HELPSTRING"] += path; - e.m_Properties["HELPSTRING"] += "/CMakeCache.txt" ; + e.Properties["HELPSTRING"] += path; + e.Properties["HELPSTRING"] += "/CMakeCache.txt" ; } - if ( e.m_Type == cmCacheManager::INTERNAL && + if ( e.Type == cmCacheManager::INTERNAL && (entryKey.size() > strlen("-ADVANCED")) && - strcmp(entryKey.c_str() + (entryKey.size() - strlen("-ADVANCED")), - "-ADVANCED") == 0 ) + strcmp(entryKey.c_str() + (entryKey.size() - + strlen("-ADVANCED")), "-ADVANCED") == 0 ) { - std::string value = e.m_Value; - std::string akey = entryKey.substr(0, (entryKey.size() - strlen("-ADVANCED"))); - cmCacheManager::CacheIterator it = this->GetCacheIterator(akey.c_str()); + std::string value = e.Value; + std::string akey = + entryKey.substr(0, (entryKey.size() - strlen("-ADVANCED"))); + cmCacheManager::CacheIterator it = + this->GetCacheIterator(akey.c_str()); if ( it.IsAtEnd() ) { - e.m_Type = cmCacheManager::UNINITIALIZED; - m_Cache[akey] = e; + e.Type = cmCacheManager::UNINITIALIZED; + this->Cache[akey] = e; } if (!it.Find(akey.c_str())) { @@ -245,18 +273,20 @@ } it.SetProperty("ADVANCED", value.c_str()); } - else if ( e.m_Type == cmCacheManager::INTERNAL && + else if ( e.Type == cmCacheManager::INTERNAL && (entryKey.size() > strlen("-MODIFIED")) && - strcmp(entryKey.c_str() + (entryKey.size() - strlen("-MODIFIED")), - "-MODIFIED") == 0 ) + strcmp(entryKey.c_str() + (entryKey.size() - + strlen("-MODIFIED")), "-MODIFIED") == 0 ) { - std::string value = e.m_Value; - std::string akey = entryKey.substr(0, (entryKey.size() - strlen("-MODIFIED"))); - cmCacheManager::CacheIterator it = this->GetCacheIterator(akey.c_str()); + std::string value = e.Value; + std::string akey = + entryKey.substr(0, (entryKey.size() - strlen("-MODIFIED"))); + cmCacheManager::CacheIterator it = + this->GetCacheIterator(akey.c_str()); if ( it.IsAtEnd() ) { - e.m_Type = cmCacheManager::UNINITIALIZED; - m_Cache[akey] = e; + e.Type = cmCacheManager::UNINITIALIZED; + this->Cache[akey] = e; } if (!it.Find(akey.c_str())) { @@ -266,8 +296,8 @@ } else { - e.m_Initialized = true; - m_Cache[entryKey] = e; + e.Initialized = true; + this->Cache[entryKey] = e; } } } @@ -288,7 +318,7 @@ this->AddCacheEntry("CMAKE_CACHE_MAJOR_VERSION", "0", "Major version of cmake used to create the " "current loaded cache", cmCacheManager::INTERNAL); - + } // check to make sure the cache directory has not // been moved @@ -300,27 +330,27 @@ currentcwd += "/CMakeCache.txt"; oldcwd += "/CMakeCache.txt"; if(!cmSystemTools::SameFile(oldcwd.c_str(), currentcwd.c_str())) - { - std::string message = + { + std::string message = std::string("The current CMakeCache.txt directory ") + - currentcwd + std::string(" is different than the directory ") + + currentcwd + std::string(" is different than the directory ") + std::string(this->GetCacheValue("CMAKE_CACHEFILE_DIR")) + std::string(" where CMackeCache.txt was created. This may result " "in binaries being created in the wrong place. If you " "are not sure, reedit the CMakeCache.txt"); - cmSystemTools::Error(message.c_str()); + cmSystemTools::Error(message.c_str()); } } return true; } -bool cmCacheManager::SaveCache(cmMakefile* mf) +bool cmCacheManager::SaveCache(cmMakefile* mf) { return this->SaveCache(mf->GetHomeOutputDirectory()); } -bool cmCacheManager::SaveCache(const char* path) +bool cmCacheManager::SaveCache(const char* path) { std::string cacheFile = path; cacheFile += "/CMakeCache.txt"; @@ -328,14 +358,14 @@ tempFile += ".tmp"; std::ofstream fout(tempFile.c_str()); if(!fout) - { - cmSystemTools::Error("Unable to open cache file for save. ", + { + cmSystemTools::Error("Unable to open cache file for save. ", cacheFile.c_str()); cmSystemTools::ReportLastSystemError(""); return false; } // before writing the cache, update the version numbers - // to the + // to the char temp[1024]; sprintf(temp, "%d", cmMakefile::GetMinorVersion()); this->AddCacheEntry("CMAKE_CACHE_MINOR_VERSION", temp, @@ -346,7 +376,8 @@ "Major version of cmake used to create the " "current loaded cache", cmCacheManager::INTERNAL); - this->AddCacheEntry("CMAKE_CACHE_RELEASE_VERSION", cmMakefile::GetReleaseVersion(), + this->AddCacheEntry("CMAKE_CACHE_RELEASE_VERSION", + cmMakefile::GetReleaseVersion(), "Major version of cmake used to create the " "current loaded cache", cmCacheManager::INTERNAL); @@ -364,14 +395,26 @@ " was created", cmCacheManager::INTERNAL); fout << "# This is the CMakeCache file.\n" - << "# For build in directory: " << currentcwd << "\n" - << "# You can edit this file to change values found and used by cmake.\n" - << "# If you do not want to change any of the values, simply exit the editor.\n" - << "# If you do want to change a value, simply edit, save, and exit the editor.\n" + << "# For build in directory: " << currentcwd << "\n"; + cmCacheManager::CacheEntry* cmakeCacheEntry + = this->GetCacheEntry("CMAKE_COMMAND"); + if ( cmakeCacheEntry ) + { + fout << "# It was generated by CMake: " << + cmakeCacheEntry->Value << std::endl; + } + + fout << "# You can edit this file to change values found and used by cmake." + << std::endl + << "# If you do not want to change any of the values, simply exit the " + "editor." << std::endl + << "# If you do want to change a value, simply edit, save, and exit " + "the editor." << std::endl << "# The syntax for the file is as follows:\n" << "# KEY:TYPE=VALUE\n" << "# KEY is the name of a variable in the cache.\n" - << "# TYPE is a hint to GUI's for the type of VALUE, DO NOT EDIT TYPE!.\n" + << "# TYPE is a hint to GUI's for the type of VALUE, DO NOT EDIT " + "TYPE!." << std::endl << "# VALUE is the current value for the KEY.\n\n"; fout << "########################\n"; @@ -379,16 +422,16 @@ fout << "########################\n"; fout << "\n"; - for( std::map::const_iterator i = m_Cache.begin(); - i != m_Cache.end(); ++i) + for( std::map::const_iterator i = this->Cache.begin(); + i != this->Cache.end(); ++i) { const CacheEntry& ce = (*i).second; - CacheEntryType t = ce.m_Type; - if(t == cmCacheManager::UNINITIALIZED || !ce.m_Initialized) + CacheEntryType t = ce.Type; + if(t == cmCacheManager::UNINITIALIZED || !ce.Initialized) { /* // This should be added in, but is not for now. - cmSystemTools::Error("Cache entry \"", (*i).first.c_str(), + cmSystemTools::Error("Cache entry \"", (*i).first.c_str(), "\" is uninitialized"); */ } @@ -396,8 +439,8 @@ { // Format is key:type=value std::map::const_iterator it = - ce.m_Properties.find("HELPSTRING"); - if ( it == ce.m_Properties.end() ) + ce.Properties.find("HELPSTRING"); + if ( it == ce.Properties.end() ) { cmCacheManager::OutputHelpString(fout, "Missing description"); } @@ -406,7 +449,7 @@ cmCacheManager::OutputHelpString(fout, it->second); } std::string key; - // support : in key name by double quoting + // support : in key name by double quoting if((*i).first.find(':') != std::string::npos || (*i).first.find("//") == 0) { @@ -421,15 +464,15 @@ fout << key.c_str() << ":" << cmCacheManagerTypes[t] << "="; // if value has trailing space or tab, enclose it in single quotes - if (ce.m_Value.size() && - (ce.m_Value[ce.m_Value.size() - 1] == ' ' || - ce.m_Value[ce.m_Value.size() - 1] == '\t')) + if (ce.Value.size() && + (ce.Value[ce.Value.size() - 1] == ' ' || + ce.Value[ce.Value.size() - 1] == '\t')) { - fout << '\'' << ce.m_Value << '\''; + fout << '\'' << ce.Value << '\''; } else { - fout << ce.m_Value; + fout << ce.Value; } fout << "\n\n"; } @@ -463,7 +506,7 @@ helpstring += i.GetName(); rkey += "-ADVANCED"; cmCacheManager::OutputHelpString(fout, helpstring.c_str()); - // support : in key name by double quoting + // support : in key name by double quoting if(rkey.find(':') != std::string::npos || rkey.find("//") == 0) { @@ -491,7 +534,7 @@ helpstring += i.GetName(); rkey += "-MODIFIED"; cmCacheManager::OutputHelpString(fout, helpstring.c_str()); - // support : in key name by double quoting + // support : in key name by double quoting if(rkey.find(':') != std::string::npos || rkey.find("//") == 0) { @@ -522,7 +565,7 @@ helpstring = ""; } cmCacheManager::OutputHelpString(fout, helpstring.c_str()); - // support : in key name by double quoting + // support : in key name by double quoting if(rkey.find(':') != std::string::npos || rkey.find("//") == 0) { @@ -539,7 +582,7 @@ // if value has trailing space or tab, enclose it in single quotes std::string value = i.GetValue(); if (value.size() && - (value[value.size() - 1] == ' ' || + (value[value.size() - 1] == ' ' || value[value.size() - 1] == '\t')) { fout << '\'' << value << '\''; @@ -548,7 +591,7 @@ { fout << value; } - fout << "\n"; + fout << "\n"; } } fout << "\n"; @@ -563,23 +606,44 @@ std::ofstream checkCache(checkCacheFile.c_str()); if(!checkCache) { - cmSystemTools::Error("Unable to open check cache file for write. ", + cmSystemTools::Error("Unable to open check cache file for write. ", checkCacheFile.c_str()); return false; } - checkCache << "# This file is generated by cmake for dependency checking of the CMakeCache.txt file\n"; + checkCache << "# This file is generated by cmake for dependency checking " + "of the CMakeCache.txt file\n"; return true; } -bool cmCacheManager::DeleteCache(const char* path) +bool cmCacheManager::DeleteCache(const char* path) { std::string cacheFile = path; + cmSystemTools::ConvertToUnixSlashes(cacheFile); + std::string cmakeFiles = cacheFile; cacheFile += "/CMakeCache.txt"; cmSystemTools::RemoveFile(cacheFile.c_str()); + // now remove the files in the CMakeFiles directory + // this cleans up language cache files + cmsys::Directory dir; + cmakeFiles += "/CMakeFiles"; + dir.Load(cmakeFiles.c_str()); + for (unsigned long fileNum = 0; + fileNum < dir.GetNumberOfFiles(); + ++fileNum) + { + if(!cmSystemTools:: + FileIsDirectory(dir.GetFile(fileNum))) + { + std::string fullPath = cmakeFiles; + fullPath += "/"; + fullPath += dir.GetFile(fileNum); + cmSystemTools::RemoveFile(fullPath.c_str()); + } + } return true; } -void cmCacheManager::OutputHelpString(std::ofstream& fout, +void cmCacheManager::OutputHelpString(std::ofstream& fout, const std::string& helpString) { std::string::size_type end = helpString.size(); @@ -615,10 +679,10 @@ void cmCacheManager::RemoveCacheEntry(const char* key) { - CacheEntryMap::iterator i = m_Cache.find(key); - if(i != m_Cache.end()) + CacheEntryMap::iterator i = this->Cache.find(key); + if(i != this->Cache.end()) { - m_Cache.erase(i); + this->Cache.erase(i); } else { @@ -629,26 +693,27 @@ cmCacheManager::CacheEntry *cmCacheManager::GetCacheEntry(const char* key) { - CacheEntryMap::iterator i = m_Cache.find(key); - if(i != m_Cache.end()) + CacheEntryMap::iterator i = this->Cache.find(key); + if(i != this->Cache.end()) { return &i->second; } return 0; } -cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator(const char *key) +cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator( + const char *key) { return CacheIterator(*this, key); } const char* cmCacheManager::GetCacheValue(const char* key) const { - CacheEntryMap::const_iterator i = m_Cache.find(key); - if(i != m_Cache.end() && - i->second.m_Initialized) + CacheEntryMap::const_iterator i = this->Cache.find(key); + if(i != this->Cache.end() && + i->second.Initialized) { - return i->second.m_Value.c_str(); + return i->second.Value.c_str(); } return 0; } @@ -658,53 +723,56 @@ { out << "=================================================" << std::endl; out << "CMakeCache Contents:" << std::endl; - for(std::map::const_iterator i = m_Cache.begin(); - i != m_Cache.end(); ++i) + for(std::map::const_iterator i = this->Cache.begin(); + i != this->Cache.end(); ++i) { - if((*i).second.m_Type != INTERNAL) + if((*i).second.Type != INTERNAL) { - out << (*i).first.c_str() << " = " << (*i).second.m_Value.c_str() << std::endl; + out << (*i).first.c_str() << " = " << (*i).second.Value.c_str() + << std::endl; } } out << "\n\n"; - out << "To change values in the CMakeCache, \nedit CMakeCache.txt in your output directory.\n"; + out << "To change values in the CMakeCache, " + << std::endl << "edit CMakeCache.txt in your output directory.\n"; out << "=================================================" << std::endl; } -void cmCacheManager::AddCacheEntry(const char* key, - const char* value, +void cmCacheManager::AddCacheEntry(const char* key, + const char* value, const char* helpString, CacheEntryType type) { - CacheEntry& e = m_Cache[key]; + CacheEntry& e = this->Cache[key]; if ( value ) { - e.m_Value = value; - e.m_Initialized = true; + e.Value = value; + e.Initialized = true; } - else + else { - e.m_Value = ""; + e.Value = ""; } - e.m_Type = type; + e.Type = type; // make sure we only use unix style paths if(type == FILEPATH || type == PATH) { - cmSystemTools::ConvertToUnixSlashes(e.m_Value); + cmSystemTools::ConvertToUnixSlashes(e.Value); } if ( helpString ) { - e.m_Properties["HELPSTRING"] = helpString; + e.Properties["HELPSTRING"] = helpString; } - else + else { - e.m_Properties["HELPSTRING"] = "(This variable does not exists and should not be used)"; + e.Properties["HELPSTRING"] = + "(This variable does not exists and should not be used)"; } - m_Cache[key] = e; + this->Cache[key] = e; } -void cmCacheManager::AddCacheEntry(const char* key, bool v, +void cmCacheManager::AddCacheEntry(const char* key, bool v, const char* helpString) { if(v) @@ -719,25 +787,25 @@ bool cmCacheManager::CacheIterator::IsAtEnd() const { - return m_Position == m_Container.m_Cache.end(); + return this->Position == this->Container.Cache.end(); } -void cmCacheManager::CacheIterator::Begin() +void cmCacheManager::CacheIterator::Begin() { - m_Position = m_Container.m_Cache.begin(); + this->Position = this->Container.Cache.begin(); } bool cmCacheManager::CacheIterator::Find(const char* key) { - m_Position = m_Container.m_Cache.find(key); + this->Position = this->Container.Cache.find(key); return !this->IsAtEnd(); } -void cmCacheManager::CacheIterator::Next() +void cmCacheManager::CacheIterator::Next() { if (!this->IsAtEnd()) { - ++m_Position; + ++this->Position; } } @@ -750,16 +818,17 @@ CacheEntry* entry = &this->GetEntry(); if ( value ) { - entry->m_Value = value; - entry->m_Initialized = true; + entry->Value = value; + entry->Initialized = true; } else { - entry->m_Value = ""; + entry->Value = ""; } } -const char* cmCacheManager::CacheIterator::GetProperty(const char* property) const +const char* cmCacheManager::CacheIterator::GetProperty( + const char* property) const { // make sure it is not at the end if (this->IsAtEnd()) @@ -769,21 +838,21 @@ if ( !strcmp(property, "TYPE") || !strcmp(property, "VALUE") ) { - cmSystemTools::Error("Property \"", property, + cmSystemTools::Error("Property \"", property, "\" cannot be accessed through the GetProperty()"); return 0; } const CacheEntry* ent = &this->GetEntry(); std::map::const_iterator it = - ent->m_Properties.find(property); - if ( it == ent->m_Properties.end() ) + ent->Properties.find(property); + if ( it == ent->Properties.end() ) { return 0; } return it->second.c_str(); } -void cmCacheManager::CacheIterator::SetProperty(const char* p, const char* v) +void cmCacheManager::CacheIterator::SetProperty(const char* p, const char* v) { // make sure it is not at the end if (this->IsAtEnd()) @@ -793,37 +862,39 @@ if ( !strcmp(p, "TYPE") || !strcmp(p, "VALUE") ) { - cmSystemTools::Error("Property \"", p, + cmSystemTools::Error("Property \"", p, "\" cannot be accessed through the SetProperty()"); return; } CacheEntry* ent = &this->GetEntry(); - ent->m_Properties[p] = v; + ent->Properties[p] = v; } + bool cmCacheManager::CacheIterator::GetValueAsBool() const { - return cmSystemTools::IsOn(this->GetEntry().m_Value.c_str()); + return cmSystemTools::IsOn(this->GetEntry().Value.c_str()); } -bool cmCacheManager::CacheIterator::GetPropertyAsBool(const char* property) const +bool cmCacheManager::CacheIterator::GetPropertyAsBool( + const char* property) const { // make sure it is not at the end if (this->IsAtEnd()) { return false; } - + if ( !strcmp(property, "TYPE") || !strcmp(property, "VALUE") ) { - cmSystemTools::Error("Property \"", property, - "\" cannot be accessed through the GetPropertyAsBool()"); + cmSystemTools::Error("Property \"", property, + "\" cannot be accessed through the GetPropertyAsBool()"); return false; } const CacheEntry* ent = &this->GetEntry(); std::map::const_iterator it = - ent->m_Properties.find(property); - if ( it == ent->m_Properties.end() ) + ent->Properties.find(property); + if ( it == ent->Properties.end() ) { return false; } @@ -831,7 +902,7 @@ } -void cmCacheManager::CacheIterator::SetProperty(const char* p, bool v) +void cmCacheManager::CacheIterator::SetProperty(const char* p, bool v) { // make sure it is not at the end if (this->IsAtEnd()) @@ -841,12 +912,12 @@ if ( !strcmp(p, "TYPE") || !strcmp(p, "VALUE") ) { - cmSystemTools::Error("Property \"", p, + cmSystemTools::Error("Property \"", p, "\" cannot be accessed through the SetProperty()"); return; } CacheEntry* ent = &this->GetEntry(); - ent->m_Properties[p] = v ? "ON" : "OFF"; + ent->Properties[p] = v ? "ON" : "OFF"; } bool cmCacheManager::CacheIterator::PropertyExists(const char* property) const @@ -859,14 +930,14 @@ if ( !strcmp(property, "TYPE") || !strcmp(property, "VALUE") ) { - cmSystemTools::Error("Property \"", property, - "\" cannot be accessed through the PropertyExists()"); + cmSystemTools::Error("Property \"", property, + "\" cannot be accessed through the PropertyExists()"); return false; } const CacheEntry* ent = &this->GetEntry(); std::map::const_iterator it = - ent->m_Properties.find(property); - if ( it == ent->m_Properties.end() ) + ent->Properties.find(property); + if ( it == ent->Properties.end() ) { return false; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCacheManager.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCacheManager.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCacheManager.h 2004-09-30 04:07:07.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCacheManager.h 2006-03-16 00:01:59.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCacheManager.h,v $ Language: C++ - Date: $Date: 2004/09/29 20:07:07 $ - Version: $Revision: 1.42 $ + Date: $Date: 2006/03/15 16:01:59 $ + Version: $Revision: 1.45 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -31,16 +31,17 @@ public: class CacheIterator; friend class cmCacheManager::CacheIterator; - enum CacheEntryType{ BOOL=0, PATH, FILEPATH, STRING, INTERNAL,STATIC, UNINITIALIZED }; + enum CacheEntryType{ BOOL=0, PATH, FILEPATH, STRING, INTERNAL,STATIC, + UNINITIALIZED }; private: struct CacheEntry { - std::string m_Value; - CacheEntryType m_Type; - std::map m_Properties; - bool m_Initialized; - CacheEntry() : m_Value(""), m_Type(UNINITIALIZED), m_Initialized(false) + std::string Value; + CacheEntryType Type; + std::map Properties; + bool Initialized; + CacheEntry() : Value(""), Type(UNINITIALIZED), Initialized(false) {} }; @@ -53,23 +54,23 @@ bool IsAtEnd() const; void Next(); const char *GetName() const { - return m_Position->first.c_str(); } + return this->Position->first.c_str(); } const char* GetProperty(const char*) const ; bool GetPropertyAsBool(const char*) const ; bool PropertyExists(const char*) const; void SetProperty(const char* property, const char* value); void SetProperty(const char* property, bool value); - const char* GetValue() const { return this->GetEntry().m_Value.c_str(); } + const char* GetValue() const { return this->GetEntry().Value.c_str(); } bool GetValueAsBool() const; void SetValue(const char*); - CacheEntryType GetType() const { return this->GetEntry().m_Type; } - bool Initialized() { return this->GetEntry().m_Initialized; } - cmCacheManager &m_Container; - std::map::iterator m_Position; - CacheIterator(cmCacheManager &cm) : m_Container(cm) { + CacheEntryType GetType() const { return this->GetEntry().Type; } + bool Initialized() { return this->GetEntry().Initialized; } + cmCacheManager &Container; + std::map::iterator Position; + CacheIterator(cmCacheManager &cm) : Container(cm) { this->Begin(); } - CacheIterator(cmCacheManager &cm, const char* key) : m_Container(cm) + CacheIterator(cmCacheManager &cm, const char* key) : Container(cm) { if ( key ) { @@ -77,8 +78,8 @@ } } private: - CacheEntry const& GetEntry() const { return m_Position->second; } - CacheEntry& GetEntry() { return m_Position->second; } + CacheEntry const& GetEntry() const { return this->Position->second; } + CacheEntry& GetEntry() { return this->Position->second; } }; ///! return an iterator to iterate through the cache map @@ -125,7 +126,7 @@ ///! Get the number of entries in the cache int GetSize() { - return static_cast(m_Cache.size()); } + return static_cast(this->Cache.size()); } ///! Break up a line like VAR:type="value" into var, type and value static bool ParseEntry(const char* entry, @@ -150,12 +151,14 @@ ///! Get a cache entry object for a key CacheEntry *GetCacheEntry(const char *key); - + ///! Clean out the CMakeFiles directory if no CMakeCache.txt + void CleanCMakeFiles(const char* path); + private: typedef std::map CacheEntryMap; static void OutputHelpString(std::ofstream& fout, const std::string& helpString); - CacheEntryMap m_Cache; + CacheEntryMap Cache; // Only cmake and cmMakefile should be able to add cache values // the commands should never use the cmCacheManager directly friend class cmMakefile; // allow access to add cache values diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCMakeMinimumRequired.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCMakeMinimumRequired.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCMakeMinimumRequired.cxx 2005-06-17 21:49:06.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCMakeMinimumRequired.cxx 2006-03-16 00:01:59.000000000 +0800 @@ -3,52 +3,123 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCMakeMinimumRequired.cxx,v $ Language: C++ - Date: $Date: 2005/06/17 13:49:06 $ - Version: $Revision: 1.8 $ + Date: $Date: 2006/03/15 16:01:59 $ + Version: $Revision: 1.11 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "cmCMakeMinimumRequired.h" +#include "cmVersion.h" + // cmCMakeMinimumRequired bool cmCMakeMinimumRequired::InitialPass(std::vector const& args) { - if(args.size() != 2) + // Process arguments. + std::string version_string; + bool doing_version = false; + bool fatal_error = false; + for(unsigned int i=0; i < args.size(); ++i) + { + if(args[i] == "VERSION") + { + doing_version = true; + } + else if(args[i] == "FATAL_ERROR") + { + if(doing_version) + { + this->SetError("called with no value for VERSION."); + return false; + } + doing_version = false; + fatal_error = true; + } + else if(doing_version) + { + doing_version = false; + version_string = args[i]; + } + else + { + cmOStringStream e; + e << "called with unknown argument \"" << args[i].c_str() << "\"."; + this->SetError(e.str().c_str()); + return false; + } + } + if(doing_version) { - this->SetError("called with incorrect number of arguments"); + this->SetError("called with no value for VERSION."); return false; } - if(args[0] == "VERSION") + + // Make sure there was a version to check. + if(version_string.empty()) { - m_Makefile->AddDefinition("CMAKE_MINIMUM_REQUIRED_VERSION", args[1].c_str()); + return true; } - float version = float(m_Makefile->GetMajorVersion()); - version += (float(m_Makefile->GetMinorVersion()) * (float).1); - version += (float(m_Makefile->GetPatchVersion()) * (float).01); - float reqVersion = 0; - int major=0; - int minor=0; - int patch=0; - - int res=sscanf(args[1].c_str(), "%d.%d.%d", &major, &minor, &patch); - if (res==3) - reqVersion=float(major)+0.1*float(minor)+0.01*float(patch); - else if (res==2) - reqVersion=float(major)+0.1*float(minor); - if(reqVersion > version) + // Save the required version string. + this->Makefile->AddDefinition("CMAKE_MINIMUM_REQUIRED_VERSION", + version_string.c_str()); + + + // Get the current version number. + int current_major = this->Makefile->GetMajorVersion(); + int current_minor = this->Makefile->GetMinorVersion(); + int current_patch = this->Makefile->GetPatchVersion(); + + // Parse the required version number. If no patch-level is given + // use zero. + int required_major = 0; + int required_minor = 0; + int required_patch = 0; + if(sscanf(version_string.c_str(), "%d.%d.%d", + &required_major, &required_minor, &required_patch) < 2) { - cmOStringStream str; - str << "WARNING: This project requires version: " << args[1].c_str() << " of cmake.\n" - << "You are running version: " << version; - cmSystemTools::Message(str.str().c_str()); + cmOStringStream e; + e << "could not parse VERSION \"" << version_string.c_str() << "\"."; + this->SetError(e.str().c_str()); + return false; } + + // Compare the version numbers. + if(current_major < required_major || + current_major == required_major && + current_minor < required_minor || + current_major == required_major && + current_minor == required_minor && + current_patch < required_patch) + { + // The current version is too low. + cmOStringStream e; + if(!fatal_error) + { + e << "WARNING: "; + } + e << "This project requires version " << version_string.c_str() + << " of CMake. " + << "You are running version " + << current_major << "." << current_minor << "." << current_patch + << ".\n"; + if(fatal_error) + { + cmSystemTools::Error(e.str().c_str()); + cmSystemTools::SetFatalErrorOccured(); + } + else + { + cmSystemTools::Message(e.str().c_str()); + } + } + return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCMakeMinimumRequired.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCMakeMinimumRequired.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCMakeMinimumRequired.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCMakeMinimumRequired.h 2006-02-15 06:16:14.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCMakeMinimumRequired.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.6.2.1 $ + Date: $Date: 2006/02/14 22:16:14 $ + Version: $Revision: 1.8 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -65,11 +65,12 @@ virtual const char* GetFullDocumentation() { return - " CMAKE_MINIMUM_REQUIRED(VERSION versionNumber)\n" + " CMAKE_MINIMUM_REQUIRED(VERSION versionNumber [FATAL_ERROR])\n" "Let cmake know that the project requires a certain version of a " "cmake, or newer. CMake will also try to be backwards compatible to " "the version of cmake specified, if a newer version of cmake is " - "running."; + "running. If FATAL_ERROR is given then failure to meet the " + "requirements will be considered an error instead of a warning."; } cmTypeMacro(cmCMakeMinimumRequired, cmCommand); diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCommandArgumentLexer.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCommandArgumentLexer.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCommandArgumentLexer.cxx 2005-06-18 03:50:08.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCommandArgumentLexer.cxx 2006-03-16 00:01:59.000000000 +0800 @@ -435,8 +435,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCommandArgumentLexer.cxx,v $ Language: C++ - Date: $Date: 2005/06/17 19:50:08 $ - Version: $Revision: 1.3 $ + Date: $Date: 2006/03/15 16:01:59 $ + Version: $Revision: 1.4 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -829,7 +829,7 @@ { //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); - yylvalp->str = yyextra->m_DCURLYVariable; + yylvalp->str = yyextra->DCURLYVariable; return cal_DCURLY; } case 4: @@ -838,7 +838,7 @@ { //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); - yylvalp->str = yyextra->m_RCURLYVariable; + yylvalp->str = yyextra->RCURLYVariable; return cal_RCURLY; } case 5: @@ -847,7 +847,7 @@ { //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); - yylvalp->str = yyextra->m_ATVariable; + yylvalp->str = yyextra->ATVariable; return cal_AT; } case 6: @@ -882,7 +882,7 @@ { //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); - yylvalp->str = yyextra->m_DOLLARVariable; + yylvalp->str = yyextra->DOLLARVariable; return cal_DOLLAR; } case 10: @@ -890,7 +890,7 @@ { //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); - yylvalp->str = yyextra->m_LCURLYVariable; + yylvalp->str = yyextra->LCURLYVariable; return cal_LCURLY; } case 11: @@ -898,7 +898,7 @@ { //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); - yylvalp->str = yyextra->m_BSLASHVariable; + yylvalp->str = yyextra->BSLASHVariable; return cal_BSLASH; } case 12: @@ -1093,10 +1093,10 @@ else { - size_t num_to_read = + size_t nuto_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - while ( num_to_read <= 0 ) + while ( nuto_read <= 0 ) { /* Not enough room in the buffer - grow it. */ /* just a shorter name for the current buffer */ @@ -1128,17 +1128,17 @@ yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + nuto_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; } - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; + if ( nuto_read > YY_READ_BUF_SIZE ) + nuto_read = YY_READ_BUF_SIZE; /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, num_to_read ); + yyg->yy_n_chars, nuto_read ); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; } @@ -1539,7 +1539,7 @@ */ static void cmCommandArgument_yyensure_buffer_stack (yyscan_t yyscanner) { - int num_to_alloc; + int nuto_alloc; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!yyg->yy_buffer_stack) { @@ -1548,14 +1548,14 @@ * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ - num_to_alloc = 1; + nuto_alloc = 1; yyg->yy_buffer_stack = (struct yy_buffer_state**)cmCommandArgument_yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) + (nuto_alloc * sizeof(struct yy_buffer_state*) , yyscanner); - memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + memset(yyg->yy_buffer_stack, 0, nuto_alloc * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_max = nuto_alloc; yyg->yy_buffer_stack_top = 0; return; } @@ -1565,15 +1565,15 @@ /* Increase the buffer to prepare for a possible push. */ int grow_size = 8 /* arbitrary grow size */; - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + nuto_alloc = yyg->yy_buffer_stack_max + grow_size; yyg->yy_buffer_stack = (struct yy_buffer_state**)cmCommandArgument_yyrealloc (yyg->yy_buffer_stack, - num_to_alloc * sizeof(struct yy_buffer_state*) + nuto_alloc * sizeof(struct yy_buffer_state*) , yyscanner); /* zero only the new slots.*/ memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_max = nuto_alloc; } } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCommandArgumentLexer.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCommandArgumentLexer.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCommandArgumentLexer.h 2005-06-13 22:01:20.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCommandArgumentLexer.h 2006-03-11 02:54:57.000000000 +0800 @@ -189,16 +189,24 @@ #endif /* !YY_STRUCT_YY_BUFFER_STATE */ void cmCommandArgument_yyrestart (FILE *input_file ,yyscan_t yyscanner ); -void cmCommandArgument_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmCommandArgument_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); -void cmCommandArgument_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void cmCommandArgument_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void cmCommandArgument_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +void cmCommandArgument_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , + yyscan_t yyscanner ); +YY_BUFFER_STATE cmCommandArgument_yy_create_buffer (FILE *file,int size , + yyscan_t yyscanner ); +void cmCommandArgument_yy_delete_buffer (YY_BUFFER_STATE b , + yyscan_t yyscanner ); +void cmCommandArgument_yy_flush_buffer (YY_BUFFER_STATE b , + yyscan_t yyscanner ); +void cmCommandArgument_yypush_buffer_state (YY_BUFFER_STATE new_buffer , + yyscan_t yyscanner ); void cmCommandArgument_yypop_buffer_state (yyscan_t yyscanner ); -YY_BUFFER_STATE cmCommandArgument_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmCommandArgument_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmCommandArgument_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); +YY_BUFFER_STATE cmCommandArgument_yy_scan_buffer (char *base,yy_size_t size , + yyscan_t yyscanner ); +YY_BUFFER_STATE cmCommandArgument_yy_scan_string (yyconst char *yy_str , + yyscan_t yyscanner ); +YY_BUFFER_STATE cmCommandArgument_yy_scan_bytes (yyconst char *bytes,int len , + yyscan_t yyscanner ); void *cmCommandArgument_yyalloc (yy_size_t ,yyscan_t yyscanner ); void *cmCommandArgument_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); @@ -231,7 +239,8 @@ YY_EXTRA_TYPE cmCommandArgument_yyget_extra (yyscan_t yyscanner ); -void cmCommandArgument_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); +void cmCommandArgument_yyset_extra (YY_EXTRA_TYPE user_defined , + yyscan_t yyscanner ); FILE *cmCommandArgument_yyget_in (yyscan_t yyscanner ); @@ -294,7 +303,8 @@ #define YY_DECL int cmCommandArgument_yylex (yyscan_t yyscanner) #endif /* !YY_DECL */ -/* yy_get_previous_state - get the state just before the EOB char was reached */ +/* yy_get_previous_state - get the state just before + the EOB char was reached */ #undef YY_NEW_FILE #undef YY_FLUSH_BUFFER diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCommandArgumentParser.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCommandArgumentParser.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCommandArgumentParser.cxx 2005-06-13 22:27:05.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCommandArgumentParser.cxx 2006-03-17 03:44:13.000000000 +0800 @@ -1,7 +1,7 @@ -/* A Bison parser, made by GNU Bison 1.875d. */ +/* A Bison parser, made by GNU Bison 2.1. */ /* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,8 +15,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ /* As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. @@ -36,6 +36,9 @@ /* Identify Bison output. */ #define YYBISON 1 +/* Bison version. */ +#define YYBISON_VERSION "2.1" + /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -45,8 +48,7 @@ /* Using locations. */ #define YYLSP_NEEDED 0 -/* If NAME_PREFIX is specified substitute the variables and functions - names. */ +/* Substitute the variable and function names. */ #define yyparse cmCommandArgument_yyparse #define yylex cmCommandArgument_yylex #define yyerror cmCommandArgument_yyerror @@ -75,6 +77,7 @@ cal_ATNAME = 268 }; #endif +/* Tokens. */ #define cal_NCURLY 258 #define cal_DCURLY 259 #define cal_DOLLAR 260 @@ -91,15 +94,15 @@ /* Copy the first part of user declarations. */ - +#line 1 "cmCommandArgumentParser.y" /*========================================================================= Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCommandArgumentParser.cxx,v $ Language: C++ - Date: $Date: 2005/06/13 14:27:05 $ - Version: $Revision: 1.2 $ + Date: $Date: 2006/03/16 19:44:13 $ + Version: $Revision: 1.5 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -119,7 +122,6 @@ Modify cmCommandArgumentParser.cxx: - remove TABs - - add __HP_aCC to the #if test for yyerrorlab warning suppression */ @@ -131,6 +133,13 @@ cmCommandArgumentError(yyscanner, x) #define yyGetParser (cmCommandArgument_yyget_extra(yyscanner)) +/* Make sure the parser uses standard memory allocation. The default + generated parser malloc/free declarations do not work on all + platforms. */ +#include +#define YYMALLOC malloc +#define YYFREE free + /*-------------------------------------------------------------------------*/ #include "cmCommandArgumentParserHelper.h" /* Interface to parser object. */ #include "cmCommandArgumentLexer.h" /* Interface to lexer object. */ @@ -170,6 +179,11 @@ # define YYERROR_VERBOSE 0 #endif +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) typedef int YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -182,30 +196,49 @@ /* Copy the second part of user declarations. */ -/* Line 214 of yacc.c. */ - +/* Line 219 of yacc.c. */ +#line 195 "cmCommandArgumentParser.cxx" -#if ! defined (yyoverflow) || YYERROR_VERBOSE +#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) +# define YYSIZE_T __SIZE_TYPE__ +#endif +#if ! defined (YYSIZE_T) && defined (size_t) +# define YYSIZE_T size_t +#endif +#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus)) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int +#endif -# ifndef YYFREE -# define YYFREE free +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif # endif -# ifndef YYMALLOC -# define YYMALLOC malloc +# ifndef YY_ +# define YY_(msgid) msgid # endif +#endif + +#if ! defined (yyoverflow) || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ # ifdef YYSTACK_USE_ALLOCA # if YYSTACK_USE_ALLOCA -# define YYSTACK_ALLOC alloca -# endif -# else -# if defined (alloca) || defined (_ALLOCA_H) -# define YYSTACK_ALLOC alloca -# else # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca +# else +# define YYSTACK_ALLOC alloca +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYINCLUDED_STDLIB_H +# endif # endif # endif # endif @@ -213,20 +246,46 @@ # ifdef YYSTACK_ALLOC /* Pacify GCC's `empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) -# else -# if defined (__STDC__) || defined (__cplusplus) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */ # endif +# else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1) +# endif +# ifdef __cplusplus +extern "C" { +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \ + && (defined (__STDC__) || defined (__cplusplus))) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \ + && (defined (__STDC__) || defined (__cplusplus))) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifdef __cplusplus +} +# endif # endif #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ #if (! defined (yyoverflow) \ && (! defined (__cplusplus) \ - || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) + || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc @@ -241,7 +300,7 @@ /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ + ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) /* Copy COUNT objects from FROM to TO. The source and destination do @@ -251,13 +310,13 @@ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else -# define YYCOPY(To, From, Count) \ - do \ - { \ - register YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ while (0) # endif # endif @@ -267,15 +326,15 @@ elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ while (0) #endif @@ -304,7 +363,7 @@ #define YYUNDEFTOK 2 #define YYMAXUTOK 268 -#define YYTRANSLATE(YYX) \ +#define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ @@ -368,14 +427,14 @@ }; #endif -#if YYDEBUG || YYERROR_VERBOSE -/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - "$end", "error", "$undefined", "cal_NCURLY", "cal_DCURLY", "cal_DOLLAR", - "cal_LCURLY", "cal_RCURLY", "cal_NAME", "cal_BSLASH", "cal_SYMBOL", - "cal_AT", "cal_ERROR", "cal_ATNAME", "$accept", "Start", + "$end", "error", "$undefined", "cal_NCURLY", "cal_DCURLY", "\"$\"", + "\"{\"", "\"}\"", "cal_NAME", "\"\\\\\"", "cal_SYMBOL", "\"@\"", + "cal_ERROR", "cal_ATNAME", "$accept", "Start", "GoalWithOptionalBackSlash", "Goal", "String", "OuterText", "Variable", "MultipleIds", "ID", 0 }; @@ -467,71 +526,88 @@ 21, 0, 9, 17, 7, 21, 7 }; -#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) -# define YYSIZE_T __SIZE_TYPE__ -#endif -#if ! defined (YYSIZE_T) && defined (size_t) -# define YYSIZE_T size_t -#endif -#if ! defined (YYSIZE_T) -# if defined (__STDC__) || defined (__cplusplus) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -#endif -#if ! defined (YYSIZE_T) -# define YYSIZE_T unsigned int -#endif - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ -#define YYFAIL goto yyerrlab +#define YYFAIL goto yyerrlab #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror ("syntax error: cannot back up");\ - YYERROR; \ - } \ +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ while (0) -#define YYTERROR 1 -#define YYERRCODE 256 -/* YYLLOC_DEFAULT -- Compute the default location (before the actions - are run). */ +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) #ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - ((Current).first_line = (Rhs)[1].first_line, \ - (Current).first_column = (Rhs)[1].first_column, \ - (Current).last_line = (Rhs)[N].last_line, \ - (Current).last_column = (Rhs)[N].last_column) +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (N) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (0) #endif + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + /* YYLEX -- calling `yylex' with the right arguments. */ #ifdef YYLEX_PARAM @@ -548,27 +624,21 @@ # define YYFPRINTF fprintf # endif -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (0) - -# define YYDSYMPRINT(Args) \ -do { \ - if (yydebug) \ - yysymprint Args; \ +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ } while (0) -# define YYDSYMPRINTF(Title, Token, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yysymprint (stderr, \ - Token, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yysymprint (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ } while (0) /*------------------------------------------------------------------. @@ -592,10 +662,10 @@ YYFPRINTF (stderr, "\n"); } -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ } while (0) @@ -613,19 +683,19 @@ #endif { int yyi; - unsigned int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ", yyrule - 1, yylno); /* Print the symbols being reduced, and their result. */ for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) - YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); - YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); + YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]); } -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (Rule); \ +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (Rule); \ } while (0) /* Nonzero means print parse trace. It is left uninitialized so that @@ -633,15 +703,14 @@ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) -# define YYDSYMPRINT(Args) -# define YYDSYMPRINTF(Title, Token, Value, Location) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH +#ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif @@ -649,13 +718,9 @@ if the built-in stack extension method is used). Do not make this value too large; the results are undefined if - SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ -#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 -# undef YYMAXDEPTH -#endif - #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif @@ -677,7 +742,7 @@ const char *yystr; # endif { - register const char *yys = yystr; + const char *yys = yystr; while (*yys++ != '\0') continue; @@ -702,8 +767,8 @@ const char *yysrc; # endif { - register char *yyd = yydest; - register const char *yys = yysrc; + char *yyd = yydest; + const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; @@ -713,7 +778,55 @@ # endif # endif -#endif /* !YYERROR_VERBOSE */ +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + size_t yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +#endif /* YYERROR_VERBOSE */ @@ -737,15 +850,15 @@ (void) yyvaluep; if (yytype < YYNTOKENS) - { - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); -# ifdef YYPRINT - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# endif - } + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); else YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif switch (yytype) { default: @@ -761,10 +874,11 @@ #if defined (__STDC__) || defined (__cplusplus) static void -yydestruct (int yytype, YYSTYPE *yyvaluep) +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) #else static void -yydestruct (yytype, yyvaluep) +yydestruct (yymsg, yytype, yyvaluep) + const char *yymsg; int yytype; YYSTYPE *yyvaluep; #endif @@ -772,6 +886,10 @@ /* Pacify ``unused variable'' warnings. */ (void) yyvaluep; + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + switch (yytype) { @@ -820,25 +938,25 @@ #else int yyparse () - + ; #endif #endif { - /* The lookahead symbol. */ + /* The look-ahead symbol. */ int yychar; -/* The semantic value of the lookahead symbol. */ +/* The semantic value of the look-ahead symbol. */ YYSTYPE yylval; /* Number of syntax errors so far. */ int yynerrs; - register int yystate; - register int yyn; + int yystate; + int yyn; int yyresult; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; - /* Lookahead token as an internal (translated) token number. */ + /* Look-ahead token as an internal (translated) token number. */ int yytoken = 0; /* Three stacks and their tools: @@ -852,12 +970,12 @@ /* The state stack. */ short int yyssa[YYINITDEPTH]; short int *yyss = yyssa; - register short int *yyssp; + short int *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs = yyvsa; - register YYSTYPE *yyvsp; + YYSTYPE *yyvsp; @@ -879,7 +997,7 @@ yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack @@ -889,7 +1007,6 @@ yyssp = yyss; yyvsp = yyvs; - goto yysetstate; /*------------------------------------------------------------. @@ -911,49 +1028,49 @@ #ifdef yyoverflow { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - short int *yyss1 = yyss; - - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow ("parser stack overflow", - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + short int *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); + &yystacksize); - yyss = yyss1; - yyvs = yyvs1; + yyss = yyss1; + yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE - goto yyoverflowlab; + goto yyexhaustedlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) - goto yyoverflowlab; + goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; + yystacksize = YYMAXDEPTH; { - short int *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyoverflowlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); + short int *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); # undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ @@ -963,10 +1080,10 @@ YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) - YYABORT; + YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); @@ -979,18 +1096,18 @@ yybackup: /* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ +/* Read a look-ahead token if we need one and don't already have one. */ /* yyresume: */ - /* First try to decide what to do without reference to lookahead token. */ + /* First try to decide what to do without reference to look-ahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a lookahead token if don't already have one. */ + /* Not known => get a look-ahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); @@ -1005,7 +1122,7 @@ else { yytoken = YYTRANSLATE (yychar); - YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to @@ -1017,7 +1134,7 @@ if (yyn <= 0) { if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; + goto yyerrlab; yyn = -yyn; goto yyreduce; } @@ -1025,8 +1142,8 @@ if (yyn == YYFINAL) YYACCEPT; - /* Shift the lookahead token. */ - YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) @@ -1076,153 +1193,154 @@ switch (yyn) { case 2: - +#line 96 "cmCommandArgumentParser.y" { - yyval.str = 0; - yyGetParser->SetResult(yyvsp[0].str); + (yyval.str) = 0; + yyGetParser->SetResult((yyvsp[0].str)); } break; case 3: - +#line 103 "cmCommandArgumentParser.y" { - yyval.str = yyvsp[0].str; + (yyval.str) = (yyvsp[0].str); } break; case 4: - +#line 108 "cmCommandArgumentParser.y" { - yyval.str = yyGetParser->CombineUnions(yyvsp[-1].str, yyvsp[0].str); + (yyval.str) = yyGetParser->CombineUnions((yyvsp[-1].str), (yyvsp[0].str)); } break; case 5: - +#line 113 "cmCommandArgumentParser.y" { - yyval.str = 0; + (yyval.str) = 0; } break; case 6: - +#line 118 "cmCommandArgumentParser.y" { - yyval.str = yyGetParser->CombineUnions(yyvsp[-1].str, yyvsp[0].str); + (yyval.str) = yyGetParser->CombineUnions((yyvsp[-1].str), (yyvsp[0].str)); } break; case 7: - +#line 124 "cmCommandArgumentParser.y" { - yyval.str = yyvsp[0].str; + (yyval.str) = (yyvsp[0].str); } break; case 8: - +#line 129 "cmCommandArgumentParser.y" { - yyval.str = yyvsp[0].str; + (yyval.str) = (yyvsp[0].str); } break; case 9: - +#line 135 "cmCommandArgumentParser.y" { - yyval.str = yyvsp[0].str; + (yyval.str) = (yyvsp[0].str); } break; case 10: - +#line 140 "cmCommandArgumentParser.y" { - yyval.str = yyvsp[0].str; + (yyval.str) = (yyvsp[0].str); } break; case 11: - +#line 145 "cmCommandArgumentParser.y" { - yyval.str = yyvsp[0].str; + (yyval.str) = (yyvsp[0].str); } break; case 12: - +#line 150 "cmCommandArgumentParser.y" { - yyval.str = yyvsp[0].str; + (yyval.str) = (yyvsp[0].str); } break; case 13: - +#line 155 "cmCommandArgumentParser.y" { - yyval.str = yyvsp[0].str; + (yyval.str) = (yyvsp[0].str); } break; case 14: - +#line 160 "cmCommandArgumentParser.y" { - yyval.str = yyvsp[0].str; + (yyval.str) = (yyvsp[0].str); } break; case 15: - +#line 166 "cmCommandArgumentParser.y" { - yyval.str = yyGetParser->ExpandSpecialVariable(yyvsp[-2].str,yyvsp[-1].str); + (yyval.str) = yyGetParser->ExpandSpecialVariable((yyvsp[-2].str),(yyvsp[-1].str)); //std::cerr << __LINE__ << " here: [" << $1 << "] [" << $2 << "] [" << $3 << "]" << std::endl; } break; case 16: - +#line 172 "cmCommandArgumentParser.y" { - yyval.str = yyGetParser->ExpandVariable(yyvsp[-1].str); + (yyval.str) = yyGetParser->ExpandVariable((yyvsp[-1].str)); //std::cerr << __LINE__ << " here: [" << $1 << "] [" << $2 << "] [" << $3 << "]" << std::endl; } break; case 17: - +#line 178 "cmCommandArgumentParser.y" { - yyval.str = yyGetParser->ExpandVariable(yyvsp[0].str); + (yyval.str) = yyGetParser->ExpandVariable((yyvsp[0].str)); } break; case 18: - +#line 183 "cmCommandArgumentParser.y" { - yyval.str = 0; + (yyval.str) = 0; } break; case 19: - +#line 188 "cmCommandArgumentParser.y" { - yyval.str = yyGetParser->CombineUnions(yyvsp[-1].str, yyvsp[0].str); + (yyval.str) = yyGetParser->CombineUnions((yyvsp[-1].str), (yyvsp[0].str)); } break; case 20: - +#line 194 "cmCommandArgumentParser.y" { - yyval.str = yyvsp[0].str; + (yyval.str) = (yyvsp[0].str); } break; case 21: - +#line 199 "cmCommandArgumentParser.y" { - yyval.str = yyvsp[0].str; + (yyval.str) = (yyvsp[0].str); } break; + default: break; } -/* Line 1010 of yacc.c. */ - +/* Line 1126 of yacc.c. */ +#line 1338 "cmCommandArgumentParser.cxx" yyvsp -= yylen; yyssp -= yylen; @@ -1260,95 +1378,129 @@ yyn = yypact[yystate]; if (YYPACT_NINF < yyn && yyn < YYLAST) - { - YYSIZE_T yysize = 0; - int yytype = YYTRANSLATE (yychar); - const char* yyprefix; - char *yymsg; - int yyx; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 0; - - yyprefix = ", expecting "; - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { - yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); - yycount += 1; - if (yycount == 5) - { - yysize = 0; - break; - } + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + char *yymsg = 0; +# define YYERROR_VERBOSE_ARGS_MAXIMUM 5 + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +#if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +#endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= yysize1 < yysize; + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= yysize1 < yysize; + yysize = yysize1; + + if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM) + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yymsg; + int yyi = 0; + while ((*yyp = *yyf)) + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + yyerror (yymsg); + YYSTACK_FREE (yymsg); + } + else + { + yyerror (YY_("syntax error")); + goto yyexhaustedlab; + } } - yysize += (sizeof ("syntax error, unexpected ") - + yystrlen (yytname[yytype])); - yymsg = (char *) YYSTACK_ALLOC (yysize); - if (yymsg != 0) - { - char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); - yyp = yystpcpy (yyp, yytname[yytype]); - - if (yycount < 5) - { - yyprefix = ", expecting "; - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - yyp = yystpcpy (yyp, yyprefix); - yyp = yystpcpy (yyp, yytname[yyx]); - yyprefix = " or "; - } - } - yyerror (yymsg); - YYSTACK_FREE (yymsg); - } - else - yyerror ("syntax error; also virtual memory exhausted"); - } else #endif /* YYERROR_VERBOSE */ - yyerror ("syntax error"); + yyerror (YY_("syntax error")); } if (yyerrstatus == 3) { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ if (yychar <= YYEOF) { - /* If at end of input, pop the error token, - then the rest of the stack, then return failure. */ - if (yychar == YYEOF) - for (;;) - { - YYPOPSTACK; - if (yyssp == yyss) - YYABORT; - YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); - yydestruct (yystos[*yyssp], yyvsp); - } + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; } else - { - YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); - yydestruct (yytoken, &yylval); - yychar = YYEMPTY; - - } + { + yydestruct ("Error: discarding", yytoken, &yylval); + yychar = YYEMPTY; + } } - /* Else will try to reuse lookahead token after shifting the error + /* Else will try to reuse look-ahead token after shifting the error token. */ goto yyerrlab1; @@ -1358,14 +1510,13 @@ `---------------------------------------------------*/ yyerrorlab: -#if defined (__GNUC__) || defined (__HP_aCC) - /* Pacify GCC when the user code never invokes YYERROR and the label - yyerrorlab therefore never appears in user code. */ + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ if (0) goto yyerrorlab; -#endif - yyvsp -= yylen; +yyvsp -= yylen; yyssp -= yylen; yystate = *yyssp; goto yyerrlab1; @@ -1375,28 +1526,28 @@ | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ + yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) - YYABORT; + YYABORT; + - YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); - yydestruct (yystos[yystate], yyvsp); + yydestruct ("Error: popping", yystos[yystate], yyvsp); YYPOPSTACK; yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -1405,11 +1556,12 @@ if (yyn == YYFINAL) YYACCEPT; - YYDPRINTF ((stderr, "Shifting error token, ")); - *++yyvsp = yylval; + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + yystate = yyn; goto yynewstate; @@ -1429,16 +1581,25 @@ goto yyreturn; #ifndef yyoverflow -/*----------------------------------------------. -| yyoverflowlab -- parser overflow comes here. | -`----------------------------------------------*/ -yyoverflowlab: - yyerror ("parser stack overflow"); +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK; + } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); @@ -1447,7 +1608,7 @@ } - +#line 204 "cmCommandArgumentParser.y" /* End of grammar */ @@ -1456,5 +1617,3 @@ { yyGetParser->Error(message); } - - diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCommandArgumentParserHelper.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCommandArgumentParserHelper.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCommandArgumentParserHelper.cxx 2005-09-16 04:38:36.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCommandArgumentParserHelper.cxx 2006-03-16 00:01:59.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCommandArgumentParserHelper.cxx,v $ Language: C++ - Date: $Date: 2005/09/15 20:38:36 $ - Version: $Revision: 1.9.2.1 $ + Date: $Date: 2006/03/15 16:01:59 $ + Version: $Revision: 1.11 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -25,18 +25,18 @@ // cmCommandArgumentParserHelper::cmCommandArgumentParserHelper() { - m_FileLine = -1; - m_FileName = 0; + this->FileLine = -1; + this->FileName = 0; - m_EmptyVariable[0] = 0; - strcpy(m_DCURLYVariable, "${"); - strcpy(m_RCURLYVariable, "}"); - strcpy(m_ATVariable, "@"); - strcpy(m_DOLLARVariable, "$"); - strcpy(m_LCURLYVariable, "{"); - strcpy(m_BSLASHVariable, "\\"); + this->EmptyVariable[0] = 0; + strcpy(this->DCURLYVariable, "${"); + strcpy(this->RCURLYVariable, "}"); + strcpy(this->ATVariable, "@"); + strcpy(this->DOLLARVariable, "$"); + strcpy(this->LCURLYVariable, "{"); + strcpy(this->BSLASHVariable, "\\"); - m_NoEscapeMode = false; + this->NoEscapeMode = false; } @@ -47,19 +47,19 @@ void cmCommandArgumentParserHelper::SetLineFile(long line, const char* file) { - m_FileLine = line; - m_FileName = file; + this->FileLine = line; + this->FileName = file; } char* cmCommandArgumentParserHelper::AddString(const char* str) { if ( !str || !*str ) { - return m_EmptyVariable; + return this->EmptyVariable; } char* stVal = new char[strlen(str)+1]; strcpy(stVal, str); - m_Variables.push_back(stVal); + this->Variables.push_back(stVal); return stVal; } @@ -74,7 +74,7 @@ char *ptr = getenv(var); if (ptr) { - if (m_EscapeQuotes) + if (this->EscapeQuotes) { return this->AddString(cmSystemTools::EscapeQuotes(ptr).c_str()); } @@ -83,7 +83,7 @@ return ptr; } } - return m_EmptyVariable; + return this->EmptyVariable; } cmSystemTools::Error("Key ", key, " is not used yet. For now only $ENV{..} is allowed"); return 0; @@ -91,18 +91,18 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var) { - if(m_FileName && strcmp(var, "CMAKE_CURRENT_LIST_FILE") == 0) + if(this->FileName && strcmp(var, "CMAKE_CURRENT_LIST_FILE") == 0) { - return this->AddString(m_FileName); + return this->AddString(this->FileName); } - else if(m_FileLine >= 0 && strcmp(var, "CMAKE_CURRENT_LIST_LINE") == 0) + else if(this->FileLine >= 0 && strcmp(var, "CMAKE_CURRENT_LIST_LINE") == 0) { cmOStringStream ostr; - ostr << m_FileLine; + ostr << this->FileLine; return this->AddString(ostr.str().c_str()); } - const char* value = m_Makefile->GetDefinition(var); - if (m_EscapeQuotes && value) + const char* value = this->Makefile->GetDefinition(var); + if (this->EscapeQuotes && value) { return this->AddString(cmSystemTools::EscapeQuotes(value).c_str()); } @@ -123,7 +123,7 @@ char* out = new char [ len ]; strcpy(out, in1); strcat(out, in2); - m_Variables.push_back(out); + this->Variables.push_back(out); return out; } @@ -142,13 +142,13 @@ pt->str = new char[ len + 1 ]; strncpy(pt->str, str, len); pt->str[len] = 0; - m_Variables.push_back(pt->str); + this->Variables.push_back(pt->str); // std::cout << (void*) pt->str << " " << pt->str << " JPAllocateParserType" << std::endl; } bool cmCommandArgumentParserHelper::HandleEscapeSymbol(cmCommandArgumentParserHelper::ParserType* pt, char symbol) { - if ( m_NoEscapeMode ) + if ( this->NoEscapeMode ) { char buffer[3]; buffer[0] = '\\'; @@ -207,7 +207,7 @@ this->InputBufferPos = 0; this->CurrentLine = 0; - m_Result = ""; + this->Result = ""; yyscan_t yyscanner; cmCommandArgument_yylex_init(&yyscanner); @@ -225,7 +225,7 @@ if ( Verbose ) { - std::cerr << "Expanding [" << str << "] produced: [" << m_Result.c_str() << "]" << std::endl; + std::cerr << "Expanding [" << str << "] produced: [" << this->Result.c_str() << "]" << std::endl; } return 1; } @@ -233,13 +233,13 @@ void cmCommandArgumentParserHelper::CleanupParser() { std::vector::iterator sit; - for ( sit = m_Variables.begin(); - sit != m_Variables.end(); + for ( sit = this->Variables.begin(); + sit != this->Variables.end(); ++ sit ) { delete [] *sit; } - m_Variables.erase(m_Variables.begin(), m_Variables.end()); + this->Variables.erase(this->Variables.begin(), this->Variables.end()); } int cmCommandArgumentParserHelper::LexInput(char* buf, int maxlen) @@ -283,21 +283,21 @@ } std::cerr << "]" << std::endl; */ - m_Error = ostr.str(); + this->ErrorString = ostr.str(); } void cmCommandArgumentParserHelper::SetMakefile(const cmMakefile* mf) { - m_Makefile = mf; + this->Makefile = mf; } void cmCommandArgumentParserHelper::SetResult(const char* value) { if ( !value ) { - m_Result = ""; + this->Result = ""; return; } - m_Result = value; + this->Result = value; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCommandArgumentParserHelper.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCommandArgumentParserHelper.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCommandArgumentParserHelper.h 2005-06-18 03:50:08.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCommandArgumentParserHelper.h 2006-03-16 00:01:59.000000000 +0800 @@ -3,18 +3,18 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCommandArgumentParserHelper.h,v $ Language: C++ - Date: $Date: 2005/06/17 19:50:08 $ - Version: $Revision: 1.6 $ + Date: $Date: 2006/03/15 16:01:59 $ + Version: $Revision: 1.8 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef cmCommandArgumentParserHelper_h +#ifndef cmCommandArgumentParserHelper_h #define cmCommandArgumentParserHelper_h #include "cmStandardIncludes.h" @@ -22,7 +22,8 @@ #define YYSTYPE cmCommandArgumentParserHelper::ParserType #define YYSTYPE_IS_DECLARED #define YY_EXTRA_TYPE cmCommandArgumentParserHelper* -#define YY_DECL int cmCommandArgument_yylex(YYSTYPE* yylvalp, yyscan_t yyscanner) +#define YY_DECL int cmCommandArgument_yylex(YYSTYPE* yylvalp,\ + yyscan_t yyscanner) /** \class cmCommandArgumentParserHelper * \brief Helper class for parsing java source files @@ -45,9 +46,10 @@ int ParseString(const char* str, int verb); // For the lexer: - void AllocateParserType(cmCommandArgumentParserHelper::ParserType* pt, + void AllocateParserType(cmCommandArgumentParserHelper::ParserType* pt, const char* str, int len = 0); - bool HandleEscapeSymbol(cmCommandArgumentParserHelper::ParserType* pt, char symbol); + bool HandleEscapeSymbol(cmCommandArgumentParserHelper::ParserType* pt, + char symbol); int LexInput(char* buf, int maxlen); void Error(const char* str); @@ -61,21 +63,20 @@ void SetMakefile(const cmMakefile* mf); - std::string& GetResult() { return m_Result; } + std::string& GetResult() { return this->Result; } void SetLineFile(long line, const char* file); - void SetEscapeQuotes(bool b) { m_EscapeQuotes = b; } - void SetNoEscapeMode(bool b) { m_NoEscapeMode = b; } + void SetEscapeQuotes(bool b) { this->EscapeQuotes = b; } + void SetNoEscapeMode(bool b) { this->NoEscapeMode = b; } - const char* GetError() { return m_Error.c_str(); } - - char m_EmptyVariable[1]; - char m_DCURLYVariable[3]; - char m_RCURLYVariable[3]; - char m_ATVariable[3]; - char m_DOLLARVariable[3]; - char m_LCURLYVariable[3]; - char m_BSLASHVariable[3]; + const char* GetError() { return this->ErrorString.c_str(); } + char EmptyVariable[1]; + char DCURLYVariable[3]; + char RCURLYVariable[3]; + char ATVariable[3]; + char DOLLARVariable[3]; + char LCURLYVariable[3]; + char BSLASHVariable[3]; private: cmStdString::size_type InputBufferPos; @@ -92,14 +93,14 @@ void CleanupParser(); - std::vector m_Variables; - const cmMakefile* m_Makefile; - std::string m_Result; - const char* m_FileName; - long m_FileLine; - bool m_EscapeQuotes; - std::string m_Error; - bool m_NoEscapeMode; + std::vector Variables; + const cmMakefile* Makefile; + std::string Result; + const char* FileName; + long FileLine; + bool EscapeQuotes; + std::string ErrorString; + bool NoEscapeMode; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCommandArgumentParserTokens.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCommandArgumentParserTokens.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCommandArgumentParserTokens.h 2005-06-13 22:01:20.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCommandArgumentParserTokens.h 2006-03-17 00:57:36.000000000 +0800 @@ -1,7 +1,7 @@ -/* A Bison parser, made by GNU Bison 1.875d. */ +/* A Bison parser, made by GNU Bison 2.1. */ /* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,8 +15,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ /* As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. @@ -42,6 +42,7 @@ cal_ATNAME = 268 }; #endif +/* Tokens. */ #define cal_NCURLY 258 #define cal_DCURLY 259 #define cal_DOLLAR 260 diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCommandArgumentParser.y /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCommandArgumentParser.y --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCommandArgumentParser.y 2005-06-13 22:27:05.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCommandArgumentParser.y 2006-03-17 03:44:13.000000000 +0800 @@ -4,8 +4,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCommandArgumentParser.y,v $ Language: C++ - Date: $Date: 2005/06/13 14:27:05 $ - Version: $Revision: 1.4 $ + Date: $Date: 2006/03/16 19:44:13 $ + Version: $Revision: 1.6 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -25,7 +25,6 @@ Modify cmCommandArgumentParser.cxx: - remove TABs - - add __HP_aCC to the #if test for yyerrorlab warning suppression */ @@ -37,6 +36,13 @@ cmCommandArgumentError(yyscanner, x) #define yyGetParser (cmCommandArgument_yyget_extra(yyscanner)) +/* Make sure the parser uses standard memory allocation. The default + generated parser malloc/free declarations do not work on all + platforms. */ +#include +#define YYMALLOC malloc +#define YYFREE free + /*-------------------------------------------------------------------------*/ #include "cmCommandArgumentParserHelper.h" /* Interface to parser object. */ #include "cmCommandArgumentLexer.h" /* Interface to lexer object. */ @@ -76,13 +82,13 @@ /* Tokens */ %token cal_NCURLY %token cal_DCURLY -%token cal_DOLLAR -%token cal_LCURLY -%token cal_RCURLY +%token cal_DOLLAR "$" +%token cal_LCURLY "{" +%token cal_RCURLY "}" %token cal_NAME -%token cal_BSLASH +%token cal_BSLASH "\\" %token cal_SYMBOL -%token cal_AT +%token cal_AT "@" %token cal_ERROR %token cal_ATNAME diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCommand.h 2005-06-18 01:04:55.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCommand.h 2006-03-16 00:01:59.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCommand.h,v $ Language: C++ - Date: $Date: 2005/06/17 17:04:55 $ - Version: $Revision: 1.22 $ + Date: $Date: 2006/03/15 16:01:59 $ + Version: $Revision: 1.23 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -40,7 +40,7 @@ * Construct the command. By default it is enabled with no makefile. */ cmCommand() - {m_Makefile = 0; m_Enabled = true;} + {this->Makefile = 0; this->Enabled = true;} /** * Need virtual destructor to destroy real command type. @@ -51,8 +51,8 @@ * Specify the makefile. */ void SetMakefile(cmMakefile*m) - {m_Makefile = m; } - cmMakefile* GetMakefile() { return m_Makefile; } + {this->Makefile = m; } + cmMakefile* GetMakefile() { return this->Makefile; } /** * This is called by the cmMakefile when the command is first @@ -62,7 +62,7 @@ virtual bool InvokeInitialPass(const std::vector& args) { std::vector expandedArguments; - m_Makefile->ExpandArguments(args, expandedArguments); + this->Makefile->ExpandArguments(args, expandedArguments); return this->InitialPass(expandedArguments); } @@ -120,37 +120,37 @@ * Enable the command. */ void EnabledOn() - {m_Enabled = true;} + {this->Enabled = true;} /** * Disable the command. */ void EnabledOff() - {m_Enabled = false;} + {this->Enabled = false;} /** * Query whether the command is enabled. */ bool GetEnabled() - {return m_Enabled;} + {return this->Enabled;} /** * Disable or enable the command. */ void SetEnabled(bool enabled) - {m_Enabled = enabled;} + {this->Enabled = enabled;} /** * Return the last error string. */ const char* GetError() { - if(m_Error.length() == 0) + if(this->Error.length() == 0) { - m_Error = this->GetName(); - m_Error += " unknown error."; + this->Error = this->GetName(); + this->Error += " unknown error."; } - return m_Error.c_str(); + return this->Error.c_str(); } /** @@ -158,17 +158,17 @@ */ void SetError(const char* e) { - m_Error = this->GetName(); - m_Error += " "; - m_Error += e; + this->Error = this->GetName(); + this->Error += " "; + this->Error += e; } protected: - cmMakefile* m_Makefile; + cmMakefile* Makefile; private: - bool m_Enabled; - std::string m_Error; + bool Enabled; + std::string Error; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCommands.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCommands.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCommands.cxx 2005-08-12 02:02:19.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCommands.cxx 2006-02-27 23:58:20.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCommands.cxx,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:19 $ - Version: $Revision: 1.93.2.1 $ + Date: $Date: 2006/02/27 15:58:20 $ + Version: $Revision: 1.101 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -18,17 +18,18 @@ #if defined(CMAKE_BUILD_WITH_CMAKE) #include "cmAuxSourceDirectoryCommand.cxx" #include "cmEndWhileCommand.cxx" +#include "cmExecuteProcessCommand.cxx" #include "cmExportLibraryDependencies.cxx" #include "cmEnableLanguageCommand.cxx" #include "cmFLTKWrapUICommand.cxx" -#include "cmGetCMakePropertyCommand.cxx" #include "cmGetDirectoryPropertyCommand.cxx" -#include "cmGetTargetPropertyCommand.cxx" #include "cmGetTestPropertyCommand.cxx" -#include "cmITKWrapTclCommand.cxx" #include "cmIncludeExternalMSProjectCommand.cxx" +#include "cmInstallCommand.cxx" #include "cmLinkLibrariesCommand.cxx" +#include "cmListCommand.cxx" #include "cmLoadCacheCommand.cxx" +#include "cmMathCommand.cxx" #include "cmOutputRequiredFilesCommand.cxx" #include "cmRemoveCommand.cxx" #include "cmSetDirectoryPropertiesCommand.cxx" @@ -61,17 +62,18 @@ commands.push_back(new cmAuxSourceDirectoryCommand); commands.push_back(new cmEnableLanguageCommand); commands.push_back(new cmEndWhileCommand); + commands.push_back(new cmExecuteProcessCommand); commands.push_back(new cmExportLibraryDependenciesCommand); commands.push_back(new cmFLTKWrapUICommand); - commands.push_back(new cmGetCMakePropertyCommand); commands.push_back(new cmGetDirectoryPropertyCommand); - commands.push_back(new cmGetTargetPropertyCommand); commands.push_back(new cmGetTestPropertyCommand); - commands.push_back(new cmITKWrapTclCommand); commands.push_back(new cmIncludeExternalMSProjectCommand); + commands.push_back(new cmInstallCommand); commands.push_back(new cmLinkLibrariesCommand); + commands.push_back(new cmListCommand); commands.push_back(new cmLoadCacheCommand); commands.push_back(new cmLoadCommandCommand); + commands.push_back(new cmMathCommand); commands.push_back(new cmOutputRequiredFilesCommand); commands.push_back(new cmRemoveCommand); commands.push_back(new cmSetDirectoryPropertiesCommand); diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmConfigure.cmake.h.in /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmConfigure.cmake.h.in --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmConfigure.cmake.h.in 2004-02-16 23:48:54.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmConfigure.cmake.h.in 2006-03-17 06:09:08.000000000 +0800 @@ -11,8 +11,3 @@ #define CMake_VERSION_PATCH @CMake_VERSION_PATCH@ #define CMAKE_DATA_DIR "@CMAKE_DATA_DIR@" - -#define CMAKE_SHARED_LIBRARY_PREFIX "@CMAKE_SHARED_LIBRARY_PREFIX@" -#define CMAKE_SHARED_MODULE_PREFIX "@CMAKE_SHARED_MODULE_PREFIX@" -#define CMAKE_SHARED_LIBRARY_SUFFIX "@CMAKE_SHARED_LIBRARY_SUFFIX@" -#define CMAKE_SHARED_MODULE_SUFFIX "@CMAKE_SHARED_MODULE_SUFFIX@" diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmConfigureFileCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmConfigureFileCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmConfigureFileCommand.cxx 2005-07-08 04:01:35.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmConfigureFileCommand.cxx 2006-03-16 00:01:59.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmConfigureFileCommand.cxx,v $ Language: C++ - Date: $Date: 2005/07/07 20:01:35 $ - Version: $Revision: 1.25 $ + Date: $Date: 2006/03/15 16:01:59 $ + Version: $Revision: 1.26 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -26,47 +26,47 @@ this->SetError("called with incorrect number of arguments, expected 2"); return false; } - m_InputFile = args[0]; - m_OuputFile = args[1]; - m_CopyOnly = false; - m_EscapeQuotes = false; + this->InputFile = args[0]; + this->OuputFile = args[1]; + this->CopyOnly = false; + this->EscapeQuotes = false; // for CMake 2.0 and earlier CONFIGURE_FILE defaults to the FinalPass, // after 2.0 it only does InitialPass - m_Immediate = false; + this->Immediate = false; const char* versionValue - = m_Makefile->GetRequiredDefinition("CMAKE_BACKWARDS_COMPATIBILITY"); + = this->Makefile->GetRequiredDefinition("CMAKE_BACKWARDS_COMPATIBILITY"); if (atof(versionValue) > 2.0) { - m_Immediate = true; + this->Immediate = true; } - m_AtOnly = false; + this->AtOnly = false; for(unsigned int i=2;i < args.size();++i) { if(args[i] == "COPYONLY") { - m_CopyOnly = true; + this->CopyOnly = true; } else if(args[i] == "ESCAPE_QUOTES") { - m_EscapeQuotes = true; + this->EscapeQuotes = true; } else if(args[i] == "@ONLY") { - m_AtOnly = true; + this->AtOnly = true; } else if(args[i] == "IMMEDIATE") { - m_Immediate = true; + this->Immediate = true; } } // If we were told to copy the file immediately, then do it on the // first pass (now). - if(m_Immediate) + if(this->Immediate) { if ( !this->ConfigureFile() ) { @@ -80,7 +80,7 @@ void cmConfigureFileCommand::FinalPass() { - if(!m_Immediate) + if(!this->Immediate) { this->ConfigureFile(); } @@ -88,18 +88,18 @@ int cmConfigureFileCommand::ConfigureFile() { - std::string inFile = m_InputFile; + std::string inFile = this->InputFile; if (!cmSystemTools::FileIsFullPath(inFile.c_str())) { - inFile = m_Makefile->GetStartDirectory(); + inFile = this->Makefile->GetStartDirectory(); inFile += "/"; - inFile += m_InputFile; + inFile += this->InputFile; } - return m_Makefile->ConfigureFile(inFile.c_str(), - m_OuputFile.c_str(), - m_CopyOnly, - m_AtOnly, - m_EscapeQuotes); + return this->Makefile->ConfigureFile(inFile.c_str(), + this->OuputFile.c_str(), + this->CopyOnly, + this->AtOnly, + this->EscapeQuotes); } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmConfigureFileCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmConfigureFileCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmConfigureFileCommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmConfigureFileCommand.h 2006-03-16 00:01:59.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmConfigureFileCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.15.2.1 $ + Date: $Date: 2006/03/15 16:01:59 $ + Version: $Revision: 1.19 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -81,12 +81,12 @@ private: int ConfigureFile(); - std::string m_InputFile; - std::string m_OuputFile; - bool m_CopyOnly; - bool m_EscapeQuotes; - bool m_Immediate; - bool m_AtOnly; + std::string InputFile; + std::string OuputFile; + bool CopyOnly; + bool EscapeQuotes; + bool Immediate; + bool AtOnly; }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCPluginAPI.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCPluginAPI.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCPluginAPI.cxx 2005-02-22 23:32:43.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCPluginAPI.cxx 2006-03-16 00:01:59.000000000 +0800 @@ -3,18 +3,18 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCPluginAPI.cxx,v $ Language: C++ - Date: $Date: 2005/02/22 15:32:43 $ - Version: $Revision: 1.25 $ + Date: $Date: 2006/03/15 16:01:59 $ + Version: $Revision: 1.29 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -/* +/* this file contains the implementation of the C API to CMake. Generally these routines just manipulate arguments and then call the associated methods on the CMake classes. */ @@ -24,20 +24,20 @@ #include "cmSourceFile.h" -extern "C" +extern "C" { - -void *cmGetClientData(void *info) + +void CCONV *cmGetClientData(void *info) { return ((cmLoadedCommandInfo *)info)->ClientData; } -void cmSetClientData(void *info, void *cd) +void CCONV cmSetClientData(void *info, void *cd) { ((cmLoadedCommandInfo *)info)->ClientData = cd; } -void cmSetError(void *info, const char *err) +void CCONV cmSetError(void *info, const char *err) { if (((cmLoadedCommandInfo *)info)->Error) { @@ -46,40 +46,39 @@ ((cmLoadedCommandInfo *)info)->Error = strdup(err); } -unsigned int cmGetCacheMajorVersion(void *arg) +unsigned int CCONV cmGetCacheMajorVersion(void *arg) { cmMakefile *mf = static_cast(arg); return mf->GetCacheMajorVersion(); } -unsigned int cmGetCacheMinorVersion(void *arg) +unsigned int CCONV cmGetCacheMinorVersion(void *arg) { cmMakefile *mf = static_cast(arg); return mf->GetCacheMinorVersion(); } -unsigned int cmGetMajorVersion(void *) +unsigned int CCONV cmGetMajorVersion(void *) { return cmMakefile::GetMajorVersion(); } -unsigned int cmGetMinorVersion(void *) +unsigned int CCONV cmGetMinorVersion(void *) { return cmMakefile::GetMinorVersion(); } -void cmAddDefinition(void *arg, const char* name, const char* value) +void CCONV cmAddDefinition(void *arg, const char* name, const char* value) { cmMakefile *mf = static_cast(arg); mf->AddDefinition(name,value); } /* Add a definition to this makefile and the global cmake cache. */ -void cmAddCacheDefinition(void *arg, const char* name, const char* value, - const char* doc, - int type) +void CCONV cmAddCacheDefinition(void *arg, const char* name, + const char* value, const char* doc, int type) { cmMakefile *mf = static_cast(arg); - + switch (type) { case CM_CACHE_BOOL: @@ -109,75 +108,76 @@ } } -const char* cmGetProjectName(void *arg) +const char* CCONV cmGetProjectName(void *arg) { cmMakefile *mf = static_cast(arg); return mf->GetProjectName(); } -const char* cmGetHomeDirectory(void *arg) +const char* CCONV cmGetHomeDirectory(void *arg) { cmMakefile *mf = static_cast(arg); return mf->GetHomeDirectory(); } -const char* cmGetHomeOutputDirectory(void *arg) +const char* CCONV cmGetHomeOutputDirectory(void *arg) { cmMakefile *mf = static_cast(arg); return mf->GetHomeOutputDirectory(); } -const char* cmGetStartDirectory(void *arg) +const char* CCONV cmGetStartDirectory(void *arg) { cmMakefile *mf = static_cast(arg); return mf->GetStartDirectory(); } -const char* cmGetStartOutputDirectory(void *arg) +const char* CCONV cmGetStartOutputDirectory(void *arg) { cmMakefile *mf = static_cast(arg); return mf->GetStartOutputDirectory(); } -const char* cmGetCurrentDirectory(void *arg) +const char* CCONV cmGetCurrentDirectory(void *arg) { cmMakefile *mf = static_cast(arg); return mf->GetCurrentDirectory(); } -const char* cmGetCurrentOutputDirectory(void *arg) +const char* CCONV cmGetCurrentOutputDirectory(void *arg) { cmMakefile *mf = static_cast(arg); return mf->GetCurrentOutputDirectory(); } -const char* cmGetDefinition(void *arg,const char*def) +const char* CCONV cmGetDefinition(void *arg,const char*def) { cmMakefile *mf = static_cast(arg); return mf->GetDefinition(def); } -int cmIsOn(void *arg, const char* name) +int CCONV cmIsOn(void *arg, const char* name) { cmMakefile *mf = static_cast(arg); return static_cast(mf->IsOn(name)); } /** Check if a command exists. */ -int cmCommandExists(void *arg, const char* name) +int CCONV cmCommandExists(void *arg, const char* name) { cmMakefile *mf = static_cast(arg); return static_cast(mf->CommandExists(name)); } -void cmAddDefineFlag(void *arg, const char* definition) +void CCONV cmAddDefineFlag(void *arg, const char* definition) { cmMakefile *mf = static_cast(arg); mf->AddDefineFlag(definition); } -void cmAddLinkDirectoryForTarget(void *arg, const char *tgt, const char* d) +void CCONV cmAddLinkDirectoryForTarget(void *arg, const char *tgt, + const char* d) { cmMakefile *mf = static_cast(arg); mf->AddLinkDirectoryForTarget(tgt,d); } -void cmAddExecutable(void *arg, const char *exename, +void CCONV cmAddExecutable(void *arg, const char *exename, int numSrcs, const char **srcs, int win32) { cmMakefile *mf = static_cast(arg); @@ -194,7 +194,7 @@ } } -void cmAddUtilityCommand(void *arg, const char* utilityName, +void CCONV cmAddUtilityCommand(void *arg, const char* utilityName, const char* command, const char* arguments, int all, @@ -240,9 +240,9 @@ // Pass the call to the makefile instance. mf->AddUtilityCommand(utilityName, (all ? true : false), - output, depends2, commandLines); + output, 0, depends2, commandLines); } -void cmAddCustomCommand(void *arg, const char* source, +void CCONV cmAddCustomCommand(void *arg, const char* source, const char* command, int numArgs, const char **args, int numDepends, const char **depends, @@ -287,7 +287,7 @@ commandLines, no_comment); } -void cmAddCustomCommandToOutput(void *arg, const char* output, +void CCONV cmAddCustomCommandToOutput(void *arg, const char* output, const char* command, int numArgs, const char **args, const char* main_dependency, @@ -319,11 +319,12 @@ // Pass the call to the makefile instance. const char* no_comment = 0; + const char* no_working_dir = 0; mf->AddCustomCommandToOutput(output, depends2, main_dependency, - commandLines, no_comment); + commandLines, no_comment, no_working_dir); } -void cmAddCustomCommandToTarget(void *arg, const char* target, +void CCONV cmAddCustomCommandToTarget(void *arg, const char* target, const char* command, int numArgs, const char **args, int commandType) @@ -362,15 +363,16 @@ // Pass the call to the makefile instance. std::vector no_depends; const char* no_comment = 0; + const char* no_working_dir = 0; mf->AddCustomCommandToTarget(target, no_depends, commandLines, - cctype, no_comment); + cctype, no_comment, no_working_dir); } -void cmAddLinkLibraryForTarget(void *arg, const char *tgt, const char*value, - int libtype) +void CCONV cmAddLinkLibraryForTarget(void *arg, const char *tgt, + const char*value, int libtype) { cmMakefile *mf = static_cast(arg); - + switch (libtype) { case CM_LIBRARY_GENERAL: @@ -385,7 +387,7 @@ } } -void cmAddLibrary(void *arg, const char *libname, int shared, +void CCONV cmAddLibrary(void *arg, const char *libname, int shared, int numSrcs, const char **srcs) { cmMakefile *mf = static_cast(arg); @@ -398,13 +400,13 @@ mf->AddLibrary(libname, (shared ? true : false), srcs2); } -char *cmExpandVariablesInString(void *arg, const char *source, +char CCONV *cmExpandVariablesInString(void *arg, const char *source, int escapeQuotes, int atOnly) { cmMakefile *mf = static_cast(arg); std::string barf = source; - std::string result = - mf->ExpandVariablesInString(barf, + std::string result = + mf->ExpandVariablesInString(barf, (escapeQuotes ? true : false), (atOnly ? true : false)); char *res = static_cast(malloc(result.size() + 1)); @@ -417,22 +419,22 @@ } -int cmExecuteCommand(void *arg, const char *name, +int CCONV cmExecuteCommand(void *arg, const char *name, int numArgs, const char **args) { cmMakefile *mf = static_cast(arg); cmListFileFunction lff; - lff.m_Name = name; + lff.Name = name; for(int i = 0; i < numArgs; ++i) { // Assume all arguments are quoted. - lff.m_Arguments.push_back(cmListFileArgument(args[i], true, - "[CMake-Plugin]", 0)); + lff.Arguments.push_back(cmListFileArgument(args[i], true, + "[CMake-Plugin]", 0)); } return mf->ExecuteCommand(lff); } -void cmExpandSourceListArguments(void *arg, +void CCONV cmExpandSourceListArguments(void *arg, int numArgs, const char **args, int *resArgc, @@ -462,7 +464,7 @@ *resArgv = resargv; } -void cmFreeArguments(int argc, char **argv) +void CCONV cmFreeArguments(int argc, char **argv) { int i; for (i = 0; i < argc; ++i) @@ -475,7 +477,7 @@ } } -int cmGetTotalArgumentSize(int argc, char **argv) +int CCONV cmGetTotalArgumentSize(int argc, char **argv) { int i; int result = 0; @@ -489,13 +491,13 @@ return result; } -void *cmGetSource(void *arg, const char *name) +void CCONV *cmGetSource(void *arg, const char *name) { cmMakefile *mf = static_cast(arg); return (void *)mf->GetSource(name); } -void * cmAddSource(void *arg, void *arg2) +void * CCONV cmAddSource(void *arg, void *arg2) { cmMakefile *mf = static_cast(arg); cmSourceFile *sf = static_cast(arg2); @@ -503,54 +505,55 @@ } -void * cmCreateSourceFile() +void * CCONV cmCreateSourceFile() { return (void *)(new cmSourceFile); } -void cmDestroySourceFile(void *arg) +void CCONV cmDestroySourceFile(void *arg) { cmSourceFile *sf = static_cast(arg); delete sf; } -const char *cmSourceFileGetSourceName(void *arg) +const char * CCONV cmSourceFileGetSourceName(void *arg) { cmSourceFile *sf = static_cast(arg); return sf->GetSourceName().c_str(); } -const char *cmSourceFileGetFullPath(void *arg) +const char * CCONV cmSourceFileGetFullPath(void *arg) { cmSourceFile *sf = static_cast(arg); return sf->GetFullPath().c_str(); } -const char *cmSourceFileGetProperty(void *arg,const char *prop) +const char * CCONV cmSourceFileGetProperty(void *arg,const char *prop) { cmSourceFile *sf = static_cast(arg); return sf->GetProperty(prop); } -int cmSourceFileGetPropertyAsBool(void *arg,const char *prop) +int CCONV cmSourceFileGetPropertyAsBool(void *arg,const char *prop) { cmSourceFile *sf = static_cast(arg); return (sf->GetPropertyAsBool(prop) ? 1: 0); } -void cmSourceFileSetProperty(void *arg,const char *prop, const char *val) +void CCONV cmSourceFileSetProperty(void *arg,const char *prop, + const char *val) { cmSourceFile *sf = static_cast(arg); sf->SetProperty(prop,val); } -void cmSourceFileAddDepend(void *arg, const char *depend) +void CCONV cmSourceFileAddDepend(void *arg, const char *depend) { cmSourceFile *sf = static_cast(arg); sf->GetDepends().push_back(depend); } -void cmSourceFileSetName(void *arg, const char* name, const char* dir, +void CCONV cmSourceFileSetName(void *arg, const char* name, const char* dir, int numSourceExtensions, const char **sourceExtensions, int numHeaderExtensions, @@ -571,7 +574,7 @@ sf->SetName(name,dir, srcs, hdrs); } -void cmSourceFileSetName2(void *arg, const char* name, const char* dir, +void CCONV cmSourceFileSetName2(void *arg, const char* name, const char* dir, const char *ext, int headerFileOnly) { cmSourceFile *sf = static_cast(arg); @@ -579,47 +582,47 @@ } -char *cmGetFilenameWithoutExtension(const char *name) +char * CCONV cmGetFilenameWithoutExtension(const char *name) { std::string sres = cmSystemTools::GetFilenameWithoutExtension(name); - char *result = (char *)malloc(sres.size()+1); + char *result = (char *)malloc(sres.size()+1); strcpy(result,sres.c_str()); return result; } -char *cmGetFilenamePath(const char *name) +char * CCONV cmGetFilenamePath(const char *name) { std::string sres = cmSystemTools::GetFilenamePath(name); - char *result = (char *)malloc(sres.size()+1); + char *result = (char *)malloc(sres.size()+1); strcpy(result,sres.c_str()); return result; } -char *cmCapitalized(const char *name) +char * CCONV cmCapitalized(const char *name) { std::string sres = cmSystemTools::Capitalized(name); - char *result = (char *)malloc(sres.size()+1); + char *result = (char *)malloc(sres.size()+1); strcpy(result,sres.c_str()); return result; } -void cmCopyFileIfDifferent(const char *name1, const char *name2) +void CCONV cmCopyFileIfDifferent(const char *name1, const char *name2) { cmSystemTools::CopyFileIfDifferent(name1,name2); } -void cmRemoveFile(const char *name) +void CCONV cmRemoveFile(const char *name) { cmSystemTools::RemoveFile(name); } -void cmDisplayStatus(void *arg, const char* message) +void CCONV cmDisplayStatus(void *arg, const char* message) { cmMakefile *mf = static_cast(arg); mf->DisplayStatus(message, -1); } -void cmFree(void *data) +void CCONV cmFree(void *data) { free(data); } @@ -659,7 +662,7 @@ cmGetStartDirectory, cmGetStartOutputDirectory, cmIsOn, - + cmAddSource, cmCreateSourceFile, cmDestroySourceFile, @@ -672,7 +675,7 @@ cmSourceFileSetName, cmSourceFileSetName2, cmSourceFileSetProperty, - + cmCapitalized, cmCopyFileIfDifferent, cmGetFilenameWithoutExtension, diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCPluginAPI.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCPluginAPI.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCPluginAPI.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCPluginAPI.h 2006-03-11 02:06:25.000000000 +0800 @@ -3,41 +3,46 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCPluginAPI.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.19.2.2 $ + Date: $Date: 2006/03/10 18:06:25 $ + Version: $Revision: 1.23 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ /* This header file defines the API that loadable commands can use. In many - of these commands C++ instances of cmMakefile of cmSourceFile are passed - in as arguments or returned. In these cases they are passed as a void * - argument. In the function prototypes mf is used to represent a makefile - and sf is used to represent a source file. The functions are grouped - loosely into four groups 1) Utility 2) cmMakefile 3) cmSourceFile 4) - cmSystemTools. Within each grouping functions are listed alphabetically */ + of these commands C++ instances of cmMakefile of cmSourceFile are passed + in as arguments or returned. In these cases they are passed as a void * + argument. In the function prototypes mf is used to represent a makefile + and sf is used to represent a source file. The functions are grouped + loosely into four groups 1) Utility 2) cmMakefile 3) cmSourceFile 4) + cmSystemTools. Within each grouping functions are listed alphabetically */ /*=========================================================================*/ #ifndef cmCPluginAPI_h #define cmCPluginAPI_h #define CMAKE_VERSION_MAJOR 2 -#define CMAKE_VERSION_MINOR 2 +#define CMAKE_VERSION_MINOR 3 #ifdef __cplusplus extern "C" { #endif - + +#ifdef __WATCOMC__ +#define CCONV __cdecl +#else +#define CCONV +#endif /*========================================================================= this is the structure of function entry points that a plugin may call. This structure must be kept in sync with the static decaled at the bottom of cmCPLuginAPI.cxx =========================================================================*/ -typedef struct +typedef struct { /*========================================================================= Here we define the set of functions that a plugin may call. The first goup @@ -46,132 +51,136 @@ /* set/Get the ClientData in the cmLoadedCommandInfo structure, this is how information is passed from the InitialPass to FInalPass for commands that need a FinalPass and need information from the InitialPass */ - void *(*GetClientData) (void *info); + void *(CCONV *GetClientData) (void *info); /* return the summed size in characters of all the arguments */ - int (*GetTotalArgumentSize) (int argc, char **argv); + int (CCONV *GetTotalArgumentSize) (int argc, char **argv); /* free all the memory associated with an argc, argv pair */ - void (*FreeArguments) (int argc, char **argv); + void (CCONV *FreeArguments) (int argc, char **argv); /* set/Get the ClientData in the cmLoadedCommandInfo structure, this is how information is passed from the InitialPass to FInalPass for commands that need a FinalPass and need information from the InitialPass */ - void (*SetClientData) (void *info, void *cd); + void (CCONV *SetClientData) (void *info, void *cd); /* when an error occurs, call this function to set the error string */ - void (*SetError) (void *info, const char *err); - + void (CCONV *SetError) (void *info, const char *err); + /*========================================================================= The following functions all directly map to methods in the cmMakefile class. See cmMakefile.h for descriptions of what each method does. All of these methods take the void * makefile pointer as their first argument. =========================================================================*/ - void (*AddCacheDefinition) (void *mf, const char* name, - const char* value, + void (CCONV *AddCacheDefinition) (void *mf, const char* name, + const char* value, const char* doc, int cachetype); - void (*AddCustomCommand) (void *mf, const char* source, + void (CCONV *AddCustomCommand) (void *mf, const char* source, const char* command, int numArgs, const char **args, int numDepends, const char **depends, int numOutputs, const char **outputs, const char *target); - void (*AddDefineFlag) (void *mf, const char* definition); - void (*AddDefinition) (void *mf, const char* name, const char* value); - void (*AddExecutable) (void *mf, const char *exename, + void (CCONV *AddDefineFlag) (void *mf, const char* definition); + void (CCONV *AddDefinition) (void *mf, const char* name, + const char* value); + void (CCONV *AddExecutable) (void *mf, const char *exename, int numSrcs, const char **srcs, int win32); - void (*AddLibrary) (void *mf, const char *libname, + void (CCONV *AddLibrary) (void *mf, const char *libname, int shared, int numSrcs, const char **srcs); - void (*AddLinkDirectoryForTarget) (void *mf, const char *tgt, + void (CCONV *AddLinkDirectoryForTarget) (void *mf, const char *tgt, const char* d); - void (*AddLinkLibraryForTarget) (void *mf, const char *tgt, + void (CCONV *AddLinkLibraryForTarget) (void *mf, const char *tgt, const char *libname, int libtype); - void (*AddUtilityCommand) (void *mf, const char* utilityName, + void (CCONV *AddUtilityCommand) (void *mf, const char* utilityName, const char *command, const char *arguments, int all, int numDepends, const char **depends, int numOutputs, const char **outputs); - int (*CommandExists) (void *mf, const char* name); - int (*ExecuteCommand) (void *mf, const char *name, + int (CCONV *CommandExists) (void *mf, const char* name); + int (CCONV *ExecuteCommand) (void *mf, const char *name, int numArgs, const char **args); - void (*ExpandSourceListArguments) (void *mf,int argc, const char **argv, + void (CCONV *ExpandSourceListArguments) (void *mf,int argc, + const char **argv, int *resArgc, char ***resArgv, unsigned int startArgumentIndex); - char *(*ExpandVariablesInString) (void *mf, const char *source, + char *(CCONV *ExpandVariablesInString) (void *mf, const char *source, int escapeQuotes, int atOnly); - unsigned int (*GetCacheMajorVersion) (void *mf); - unsigned int (*GetCacheMinorVersion) (void *mf); - const char* (*GetCurrentDirectory) (void *mf); - const char* (*GetCurrentOutputDirectory) (void *mf); - const char* (*GetDefinition) (void *mf, const char *def); - const char* (*GetHomeDirectory) (void *mf); - const char* (*GetHomeOutputDirectory) (void *mf); - unsigned int (*GetMajorVersion) (void *mf); - unsigned int (*GetMinorVersion) (void *mf); - const char* (*GetProjectName) (void *mf); - const char* (*GetStartDirectory) (void *mf); - const char* (*GetStartOutputDirectory) (void *mf); - int (*IsOn) (void *mf, const char* name); - - + unsigned int (CCONV *GetCacheMajorVersion) (void *mf); + unsigned int (CCONV *GetCacheMinorVersion) (void *mf); + const char* (CCONV *GetCurrentDirectory) (void *mf); + const char* (CCONV *GetCurrentOutputDirectory) (void *mf); + const char* (CCONV *GetDefinition) (void *mf, const char *def); + const char* (CCONV *GetHomeDirectory) (void *mf); + const char* (CCONV *GetHomeOutputDirectory) (void *mf); + unsigned int (CCONV *GetMajorVersion) (void *mf); + unsigned int (CCONV *GetMinorVersion) (void *mf); + const char* (CCONV *GetProjectName) (void *mf); + const char* (CCONV *GetStartDirectory) (void *mf); + const char* (CCONV *GetStartOutputDirectory) (void *mf); + int (CCONV *IsOn) (void *mf, const char* name); + + /*========================================================================= The following functions are designed to operate or manipulate cmSourceFiles. Please see cmSourceFile.h for additional information on many of these methods. Some of these methods are in cmMakefile.h. =========================================================================*/ - void *(*AddSource) (void *mf, void *sf); - void *(*CreateSourceFile) (); - void (*DestroySourceFile) (void *sf); - void *(*GetSource) (void *mf, const char* sourceName); - void (*SourceFileAddDepend) (void *sf, const char *depend); - const char *(*SourceFileGetProperty) (void *sf, const char *prop); - int (*SourceFileGetPropertyAsBool) (void *sf, const char *prop); - const char *(*SourceFileGetSourceName) (void *sf); - const char *(*SourceFileGetFullPath) (void *sf); - void (*SourceFileSetName) (void *sf, const char* name, const char* dir, + void *(CCONV *AddSource) (void *mf, void *sf); + void *(CCONV *CreateSourceFile) (); + void (CCONV *DestroySourceFile) (void *sf); + void *(CCONV *GetSource) (void *mf, const char* sourceName); + void (CCONV *SourceFileAddDepend) (void *sf, const char *depend); + const char *(CCONV *SourceFileGetProperty) (void *sf, const char *prop); + int (CCONV *SourceFileGetPropertyAsBool) (void *sf, const char *prop); + const char *(CCONV *SourceFileGetSourceName) (void *sf); + const char *(CCONV *SourceFileGetFullPath) (void *sf); + void (CCONV *SourceFileSetName) (void *sf, const char* name, + const char* dir, int numSourceExtensions, const char **sourceExtensions, int numHeaderExtensions, const char **headerExtensions); - void (*SourceFileSetName2) (void *sf, const char* name, const char* dir, + void (CCONV *SourceFileSetName2) (void *sf, const char* name, + const char* dir, const char *ext, int headerFileOnly); - void (*SourceFileSetProperty) (void *sf, const char *prop, + void (CCONV *SourceFileSetProperty) (void *sf, const char *prop, const char *value); - - + + /*========================================================================= The following methods are from cmSystemTools.h see that file for specific documentation on each method. =========================================================================*/ - char *(*Capitalized)(const char *); - void (*CopyFileIfDifferent)(const char *f1, const char *f2); - char *(*GetFilenameWithoutExtension)(const char *); - char *(*GetFilenamePath)(const char *); - void (*RemoveFile)(const char *f1); - void (*Free)(void *); - + char *(CCONV *Capitalized)(const char *); + void (CCONV *CopyFileIfDifferent)(const char *f1, const char *f2); + char *(CCONV *GetFilenameWithoutExtension)(const char *); + char *(CCONV *GetFilenamePath)(const char *); + void (CCONV *RemoveFile)(const char *f1); + void (CCONV *Free)(void *); + /*========================================================================= The following are new functions added after 1.6 =========================================================================*/ - void (*AddCustomCommandToOutput) (void *mf, const char* output, + void (CCONV *AddCustomCommandToOutput) (void *mf, const char* output, const char* command, int numArgs, const char **args, const char* main_dependency, int numDepends, const char **depends); - void (*AddCustomCommandToTarget) (void *mf, const char* target, + void (CCONV *AddCustomCommandToTarget) (void *mf, const char* target, const char* command, int numArgs, const char **args, int commandType); - + /* display status information */ - void (*DisplaySatus) (void *info, const char *message); + void (CCONV *DisplaySatus) (void *info, const char *message); - /* this is the end of the C function stub API structure */ + /* this is the end of the C function stub API structure */ } cmCAPI; - + /*========================================================================= CM_PLUGIN_EXPORT should be used by plugins =========================================================================*/ #ifdef _WIN32 #define CM_PLUGIN_EXPORT __declspec( dllexport ) #else -#define CM_PLUGIN_EXPORT +#define CM_PLUGIN_EXPORT #endif /*========================================================================= @@ -198,16 +207,16 @@ #define CM_PRE_BUILD 0 #define CM_PRE_LINK 1 #define CM_POST_BUILD 2 - + /*========================================================================= Finally we define the key data structures and function prototypes =========================================================================*/ - typedef const char* (*CM_DOC_FUNCTION)(); - typedef int (*CM_INITIAL_PASS_FUNCTION)(void *info, void *mf, + typedef const char* (CCONV *CM_DOC_FUNCTION)(); + typedef int (CCONV *CM_INITIAL_PASS_FUNCTION)(void *info, void *mf, int argc, char *[]); - typedef void (*CM_FINAL_PASS_FUNCTION)(void *info, void *mf); - typedef void (*CM_DESTRUCTOR_FUNCTION)(void *info); - + typedef void (CCONV *CM_FINAL_PASS_FUNCTION)(void *info, void *mf); + typedef void (CCONV *CM_DESTRUCTOR_FUNCTION)(void *info); + typedef struct { unsigned long reserved1; /* Reserved for future use. DO NOT USE. */ unsigned long reserved2; /* Reserved for future use. DO NOT USE. */ @@ -217,14 +226,14 @@ CM_FINAL_PASS_FUNCTION FinalPass; CM_DESTRUCTOR_FUNCTION Destructor; CM_DOC_FUNCTION GetTerseDocumentation; - CM_DOC_FUNCTION GetFullDocumentation; + CM_DOC_FUNCTION GetFullDocumentation; const char *Name; char *Error; void *ClientData; } cmLoadedCommandInfo; - typedef void (*CM_INIT_FUNCTION)(cmLoadedCommandInfo *); - + typedef void (CCONV *CM_INIT_FUNCTION)(cmLoadedCommandInfo *); + #ifdef __cplusplus } #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCreateTestSourceList.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCreateTestSourceList.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCreateTestSourceList.cxx 2004-08-12 04:58:09.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCreateTestSourceList.cxx 2006-03-16 00:01:59.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCreateTestSourceList.cxx,v $ Language: C++ - Date: $Date: 2004/08/11 20:58:09 $ - Version: $Revision: 1.38 $ + Date: $Date: 2006/03/15 16:01:59 $ + Version: $Revision: 1.40 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -26,7 +26,7 @@ return false; } - + std::vector::const_iterator i = args.begin(); std::string extraInclude; std::string function; @@ -63,7 +63,7 @@ } } i = tests.begin(); - + // Name of the source list const char* sourceList = i->c_str(); @@ -73,26 +73,28 @@ // make sure they specified an extension if (cmSystemTools::GetFilenameExtension(*i).size() < 2) { - this->SetError("You must specify a file extenion for the test driver file."); + this->SetError( + "You must specify a file extenion for the test driver file."); return false; } - std::string driver = m_Makefile->GetCurrentOutputDirectory(); + std::string driver = this->Makefile->GetCurrentOutputDirectory(); driver += "/"; driver += *i; ++i; - std::string configFile = - m_Makefile->GetRequiredDefinition("CMAKE_ROOT"); + std::string configFile = + this->Makefile->GetRequiredDefinition("CMAKE_ROOT"); + configFile += "/Templates/TestDriver.cxx.in"; // Create the test driver file - + std::vector::const_iterator testsBegin = i; std::vector tests_func_name; // The rest of the arguments consist of a list of test source files. - // Sadly, they can be in directories. Let's find a unique function + // Sadly, they can be in directories. Let's find a unique function // name for the corresponding test, and push it to the tests_func_name - // list. + // list. // For the moment: // - replace spaces ' ', ':' and '/' with underscores '_' std::string forwardDeclareCode; @@ -105,7 +107,7 @@ std::string func_name; if (cmSystemTools::GetFilenamePath(*i).size() > 0) { - func_name = cmSystemTools::GetFilenamePath(*i) + "/" + + func_name = cmSystemTools::GetFilenamePath(*i) + "/" + cmSystemTools::GetFilenameWithoutLastExtension(*i); } else @@ -121,7 +123,7 @@ forwardDeclareCode += func_name; forwardDeclareCode += "(int, char*[]);\n"; } - + std::string functionMapCode; int numTests = 0; std::vector::iterator j; @@ -130,7 +132,7 @@ std::string func_name; if (cmSystemTools::GetFilenamePath(*i).size() > 0) { - func_name = cmSystemTools::GetFilenamePath(*i) + "/" + + func_name = cmSystemTools::GetFilenamePath(*i) + "/" + cmSystemTools::GetFilenameWithoutLastExtension(*i); } else @@ -149,16 +151,21 @@ } if(extraInclude.size()) { - m_Makefile->AddDefinition("CMAKE_TESTDRIVER_EXTRA_INCLUDES", extraInclude.c_str()); + this->Makefile->AddDefinition("CMAKE_TESTDRIVER_EXTRA_INCLUDES", + extraInclude.c_str()); } if(function.size()) { - m_Makefile->AddDefinition("CMAKE_TESTDRIVER_ARGVC_FUNCTION", function.c_str()); + this->Makefile->AddDefinition("CMAKE_TESTDRIVER_ARGVC_FUNCTION", + function.c_str()); } - m_Makefile->AddDefinition("CMAKE_FORWARD_DECLARE_TESTS", forwardDeclareCode.c_str()); - m_Makefile->AddDefinition("CMAKE_FUNCTION_TABLE_ENTIRES", functionMapCode.c_str()); + this->Makefile->AddDefinition("CMAKE_FORWARD_DECLARE_TESTS", + forwardDeclareCode.c_str()); + this->Makefile->AddDefinition("CMAKE_FUNCTION_TABLE_ENTIRES", + functionMapCode.c_str()); bool res = true; - if ( !m_Makefile->ConfigureFile(configFile.c_str(), driver.c_str(), false, true, false) ) + if ( !this->Makefile->ConfigureFile(configFile.c_str(), driver.c_str(), + false, true, false) ) { res = false; } @@ -166,29 +173,29 @@ // Create the source list cmSourceFile cfile; std::string sourceListValue; - + cfile.SetProperty("ABSTRACT","0"); - cfile.SetName(cmSystemTools::GetFilenameWithoutExtension(args[1]).c_str(), - m_Makefile->GetCurrentOutputDirectory(), - cmSystemTools::GetFilenameExtension(args[1]).c_str()+1, + cfile.SetName(cmSystemTools::GetFilenameWithoutExtension(args[1]).c_str(), + this->Makefile->GetCurrentOutputDirectory(), + cmSystemTools::GetFilenameExtension(args[1]).c_str()+1, false); - m_Makefile->AddSource(cfile); + this->Makefile->AddSource(cfile); sourceListValue = args[1]; - + for(i = testsBegin; i != tests.end(); ++i) { cmSourceFile icfile; icfile.SetProperty("ABSTRACT","0"); - icfile.SetName(i->c_str(), - m_Makefile->GetCurrentDirectory(), - m_Makefile->GetSourceExtensions(), - m_Makefile->GetHeaderExtensions()); - m_Makefile->AddSource(icfile); + icfile.SetName(i->c_str(), + this->Makefile->GetCurrentDirectory(), + this->Makefile->GetSourceExtensions(), + this->Makefile->GetHeaderExtensions()); + this->Makefile->AddSource(icfile); sourceListValue += ";"; sourceListValue += *i; } - m_Makefile->AddDefinition(sourceList, sourceListValue.c_str()); + this->Makefile->AddDefinition(sourceList, sourceListValue.c_str()); return res; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCreateTestSourceList.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCreateTestSourceList.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCreateTestSourceList.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCreateTestSourceList.h 2005-11-16 23:31:45.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCreateTestSourceList.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.9.2.1 $ + Date: $Date: 2005/11/16 15:31:45 $ + Version: $Revision: 1.10 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCTest.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCTest.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCTest.cxx 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCTest.cxx 2006-03-16 00:01:59.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTest.cxx,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.275.2.3 $ + Date: $Date: 2006/03/15 16:01:59 $ + Version: $Revision: 1.291 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include @@ -52,7 +52,7 @@ #define DEBUGERR std::cerr << __LINE__ << " "; std::cerr //---------------------------------------------------------------------- -struct tm* cmCTest::GetNightlyTime(std::string str, +struct tm* cmCTest::GetNightlyTime(std::string str, bool tomorrowtag) { struct tm* lctime; @@ -81,7 +81,8 @@ // time of the current open dashboard ntime -= dayLength; cmCTestLog(this, DEBUG, "Pick yesterday" << std::endl); - cmCTestLog(this, DEBUG, " Future time, subtract day: " << ntime << std::endl); + cmCTestLog(this, DEBUG, " Future time, subtract day: " << ntime + << std::endl); } while ( tctime > (ntime + dayLength) ) { @@ -123,7 +124,7 @@ struct tm* t = localtime(¤ttime); //return ::CleanString(ctime(¤ttime)); char current_time[1024]; - if ( m_ShortDateFormat ) + if ( this->ShortDateFormat ) { strftime(current_time, 1000, "%b %d %H:%M %Z", t); } @@ -145,7 +146,8 @@ for ( ;*pos; ++pos) { char ch = *pos; - if ( (ch > 126 || ch < 32) && ch != 9 && ch != 10 && ch != 13 && ch != '\r' ) + if ( (ch > 126 || ch < 32) && ch != 9 && + ch != 10 && ch != 13 && ch != '\r' ) { char buffer[33]; sprintf(buffer, "<%d>", (int)ch); @@ -179,6 +181,10 @@ } } } + if ( result.size() == 0 ) + { + return ""; + } return std::string(&*result.begin(), result.size()); } @@ -194,7 +200,7 @@ ch == '&' || ch == '%' || ch == '+' || - ch == '=' || + ch == '=' || ch == '@' ) && ch != 9 ) { @@ -210,58 +216,61 @@ } //---------------------------------------------------------------------- -cmCTest::cmCTest() -{ - m_SubmitIndex = 0; - m_ForceNewCTestProcess = false; - m_TomorrowTag = false; - m_Verbose = false; - m_Debug = false; - m_ShowLineNumbers = false; - m_Quiet = false; - m_ExtraVerbose = false; - m_ProduceXML = false; - m_ShowOnly = false; - m_RunConfigurationScript = false; - m_TestModel = cmCTest::EXPERIMENTAL; - m_InteractiveDebugMode = true; - m_TimeOut = 0; - m_CompressXMLFiles = false; - m_CTestConfigFile = ""; - m_OutputLogFile = 0; - m_OutputLogFileLastTag = -1; - m_SuppressUpdatingCTestConfiguration = false; - m_DartVersion = 1; +cmCTest::cmCTest() +{ + this->SubmitIndex = 0; + this->ForceNewCTestProcess = false; + this->TomorrowTag = false; + this->Verbose = false; + this->Debug = false; + this->ShowLineNumbers = false; + this->Quiet = false; + this->ExtraVerbose = false; + this->ProduceXML = false; + this->ShowOnly = false; + this->RunConfigurationScript = false; + this->TestModel = cmCTest::EXPERIMENTAL; + this->InteractiveDebugMode = true; + this->TimeOut = 0; + this->CompressXMLFiles = false; + this->CTestConfigFile = ""; + this->OutputLogFile = 0; + this->OutputLogFileLastTag = -1; + this->SuppressUpdatingCTestConfiguration = false; + this->DartVersion = 1; - int cc; + int cc; for ( cc=0; cc < cmCTest::LAST_TEST; cc ++ ) { - m_Tests[cc] = 0; + this->Tests[cc] = 0; } - m_ShortDateFormat = true; + this->ShortDateFormat = true; - m_TestingHandlers["build"] = new cmCTestBuildHandler; - m_TestingHandlers["buildtest"] = new cmCTestBuildAndTestHandler; - m_TestingHandlers["coverage"] = new cmCTestCoverageHandler; - m_TestingHandlers["script"] = new cmCTestScriptHandler; - m_TestingHandlers["test"] = new cmCTestTestHandler; - m_TestingHandlers["update"] = new cmCTestUpdateHandler; - m_TestingHandlers["configure"] = new cmCTestConfigureHandler; - m_TestingHandlers["memcheck"] = new cmCTestMemCheckHandler; - m_TestingHandlers["submit"] = new cmCTestSubmitHandler; + this->TestingHandlers["build"] = new cmCTestBuildHandler; + this->TestingHandlers["buildtest"] = new cmCTestBuildAndTestHandler; + this->TestingHandlers["coverage"] = new cmCTestCoverageHandler; + this->TestingHandlers["script"] = new cmCTestScriptHandler; + this->TestingHandlers["test"] = new cmCTestTestHandler; + this->TestingHandlers["update"] = new cmCTestUpdateHandler; + this->TestingHandlers["configure"] = new cmCTestConfigureHandler; + this->TestingHandlers["memcheck"] = new cmCTestMemCheckHandler; + this->TestingHandlers["submit"] = new cmCTestSubmitHandler; cmCTest::t_TestingHandlers::iterator it; - for ( it = m_TestingHandlers.begin(); it != m_TestingHandlers.end(); ++ it ) + for ( it = this->TestingHandlers.begin(); it != this->TestingHandlers.end(); ++ it ) { it->second->SetCTestInstance(this); } + + // Make sure we can capture the build tool output. + cmSystemTools::EnableVSConsoleOutput(); } //---------------------------------------------------------------------- -cmCTest::~cmCTest() -{ +cmCTest::~cmCTest() +{ cmCTest::t_TestingHandlers::iterator it; - for ( it = m_TestingHandlers.begin(); it != m_TestingHandlers.end(); ++ it ) + for ( it = this->TestingHandlers.begin(); it != this->TestingHandlers.end(); ++ it ) { delete it->second; it->second = 0; @@ -270,47 +279,53 @@ } //---------------------------------------------------------------------- -int cmCTest::Initialize(const char* binary_dir, bool new_tag, bool verbose_tag) +int cmCTest::Initialize(const char* binary_dir, bool new_tag, + bool verbose_tag) { - if(!m_InteractiveDebugMode) + cmCTestLog(this, DEBUG, "Here: " << __LINE__ << std::endl); + if(!this->InteractiveDebugMode) { this->BlockTestErrorDiagnostics(); } - - m_BinaryDir = binary_dir; - cmSystemTools::ConvertToUnixSlashes(m_BinaryDir); + + this->BinaryDir = binary_dir; + cmSystemTools::ConvertToUnixSlashes(this->BinaryDir); this->UpdateCTestConfiguration(); - if ( m_ProduceXML ) + cmCTestLog(this, DEBUG, "Here: " << __LINE__ << std::endl); + if ( this->ProduceXML ) { + cmCTestLog(this, DEBUG, "Here: " << __LINE__ << std::endl); cmCTestLog(this, OUTPUT, " Site: " << this->GetCTestConfiguration("Site") << std::endl - << " Build name: " << this->GetCTestConfiguration("BuildName") << std::endl - ); + << " Build name: " << this->GetCTestConfiguration("BuildName") + << std::endl); cmCTestLog(this, DEBUG, "Produce XML is on" << std::endl); if ( this->GetCTestConfiguration("NightlyStartTime").empty() ) { cmCTestLog(this, DEBUG, "No nightly start time" << std::endl); + cmCTestLog(this, DEBUG, "Here: " << __LINE__ << std::endl); return 0; } } - if ( !this->ReadCustomConfigurationFileTree(m_BinaryDir.c_str()) ) + if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str()) ) { - cmCTestLog(this, DEBUG, "Cannot find custom configuration file tree" << std::endl); + cmCTestLog(this, DEBUG, "Cannot find custom configuration file tree" + << std::endl); return 0; } - if ( m_ProduceXML ) + if ( this->ProduceXML ) { - std::string testingDir = m_BinaryDir + "/Testing"; + std::string testingDir = this->BinaryDir + "/Testing"; if ( cmSystemTools::FileExists(testingDir.c_str()) ) { if ( !cmSystemTools::FileIsDirectory(testingDir.c_str()) ) { - cmCTestLog(this, ERROR_MESSAGE, "File " << testingDir << " is in the place of the testing directory" - << std::endl); + cmCTestLog(this, ERROR_MESSAGE, "File " << testingDir + << " is in the place of the testing directory" << std::endl); return 0; } } @@ -318,8 +333,8 @@ { if ( !cmSystemTools::MakeDirectory(testingDir.c_str()) ) { - cmCTestLog(this, ERROR_MESSAGE, "Cannot create directory " << testingDir - << std::endl); + cmCTestLog(this, ERROR_MESSAGE, "Cannot create directory " + << testingDir << std::endl); return 0; } } @@ -327,7 +342,7 @@ std::ifstream tfin(tagfile.c_str()); std::string tag; time_t tctime = time(0); - if ( m_TomorrowTag ) + if ( this->TomorrowTag ) { tctime += ( 24 * 60 * 60 ); } @@ -350,20 +365,24 @@ std::string tagmode; if ( cmSystemTools::GetLineFromStream(tfin, tagmode) ) { - if ( tagmode.size() > 4 && !( m_Tests[cmCTest::START_TEST] || m_Tests[ALL_TEST] )) + if ( tagmode.size() > 4 && !( this->Tests[cmCTest::START_TEST] || + this->Tests[ALL_TEST] )) { - m_TestModel = cmCTest::GetTestModelFromString(tagmode.c_str()); + this->TestModel = cmCTest::GetTestModelFromString(tagmode.c_str()); } } tfin.close(); } - if ( tag.size() == 0 || new_tag || m_Tests[cmCTest::START_TEST] || m_Tests[ALL_TEST]) + if ( tag.size() == 0 || new_tag || this->Tests[cmCTest::START_TEST] || + this->Tests[ALL_TEST]) { - cmCTestLog(this, DEBUG, "TestModel: " << this->GetTestModelString() << std::endl); - cmCTestLog(this, DEBUG, "TestModel: " << m_TestModel << std::endl); - if ( m_TestModel == cmCTest::NIGHTLY ) + cmCTestLog(this, DEBUG, "TestModel: " << this->GetTestModelString() + << std::endl); + cmCTestLog(this, DEBUG, "TestModel: " << this->TestModel << std::endl); + if ( this->TestModel == cmCTest::NIGHTLY ) { - lctime = this->GetNightlyTime(this->GetCTestConfiguration("NightlyStartTime"), m_TomorrowTag); + lctime = this->GetNightlyTime( + this->GetCTestConfiguration("NightlyStartTime"), this->TomorrowTag); } char datestring[100]; sprintf(datestring, "%04d%02d%02d-%02d%02d", @@ -382,11 +401,11 @@ ofs.close(); if ( verbose_tag ) { - cmCTestLog(this, OUTPUT, "Create new tag: " << tag << " - " + cmCTestLog(this, OUTPUT, "Create new tag: " << tag << " - " << this->GetTestModelString() << std::endl); } } - m_CurrentTag = tag; + this->CurrentTag = tag; } return 1; } @@ -394,15 +413,16 @@ //---------------------------------------------------------------------- bool cmCTest::InitializeFromCommand(cmCTestCommand* command, bool first) { - if ( !first && !m_CurrentTag.empty() ) + if ( !first && !this->CurrentTag.empty() ) { return true; } - std::string src_dir = this->GetCTestConfiguration("SourceDirectory").c_str(); + std::string src_dir + = this->GetCTestConfiguration("SourceDirectory").c_str(); std::string bld_dir = this->GetCTestConfiguration("BuildDirectory").c_str(); - m_DartVersion = 1; - m_SubmitFiles.clear(); + this->DartVersion = 1; + this->SubmitFiles.clear(); cmMakefile* mf = command->GetMakefile(); std::string fname = src_dir; @@ -410,8 +430,9 @@ cmSystemTools::ConvertToUnixSlashes(fname); if ( cmSystemTools::FileExists(fname.c_str()) ) { - cmCTestLog(this, OUTPUT, " Reading ctest configuration file: " << fname.c_str() << std::endl); - bool readit = mf->ReadListFile(mf->GetCurrentListFile(), + cmCTestLog(this, OUTPUT, " Reading ctest configuration file: " + << fname.c_str() << std::endl); + bool readit = mf->ReadListFile(mf->GetCurrentListFile(), fname.c_str() ); if(!readit) { @@ -423,24 +444,30 @@ } else if ( !first ) { - cmCTestLog(this, WARNING, "Cannot locate CTest configuration: " << fname.c_str() << std::endl); + cmCTestLog(this, WARNING, "Cannot locate CTest configuration: " + << fname.c_str() << std::endl); } else { - cmCTestLog(this, HANDLER_OUTPUT, " Cannot locate CTest configuration: " << fname.c_str() << std::endl + cmCTestLog(this, HANDLER_OUTPUT, " Cannot locate CTest configuration: " + << fname.c_str() << std::endl << " Delay the initialization of CTest" << std::endl); } - this->SetCTestConfigurationFromCMakeVariable(mf, "NightlyStartTime", "CTEST_NIGHTLY_START_TIME"); + this->SetCTestConfigurationFromCMakeVariable(mf, "NightlyStartTime", + "CTEST_NIGHTLY_START_TIME"); this->SetCTestConfigurationFromCMakeVariable(mf, "Site", "CTEST_SITE"); - this->SetCTestConfigurationFromCMakeVariable(mf, "BuildName", "CTEST_BUILD_NAME"); + this->SetCTestConfigurationFromCMakeVariable(mf, "BuildName", + "CTEST_BUILD_NAME"); const char* dartVersion = mf->GetDefinition("CTEST_DART_SERVER_VERSION"); if ( dartVersion ) { - m_DartVersion = atoi(dartVersion); - if ( m_DartVersion < 0 ) + this->DartVersion = atoi(dartVersion); + if ( this->DartVersion < 0 ) { - cmCTestLog(this, ERROR_MESSAGE, "Invalid Dart server version: " << dartVersion << ". Please specify the version number." << std::endl); + cmCTestLog(this, ERROR_MESSAGE, "Invalid Dart server version: " + << dartVersion << ". Please specify the version number." + << std::endl); return false; } } @@ -453,7 +480,8 @@ } return false; } - cmCTestLog(this, OUTPUT, " Use " << this->GetTestModelString() << " tag: " << this->GetCurrentTag() << std::endl); + cmCTestLog(this, OUTPUT, " Use " << this->GetTestModelString() + << " tag: " << this->GetCurrentTag() << std::endl); return true; } @@ -461,25 +489,26 @@ //---------------------------------------------------------------------- bool cmCTest::UpdateCTestConfiguration() { - if ( m_SuppressUpdatingCTestConfiguration ) + if ( this->SuppressUpdatingCTestConfiguration ) { return true; } - std::string fileName = m_CTestConfigFile; + std::string fileName = this->CTestConfigFile; if ( fileName.empty() ) { - fileName = m_BinaryDir + "/DartConfiguration.tcl"; + fileName = this->BinaryDir + "/DartConfiguration.tcl"; if ( !cmSystemTools::FileExists(fileName.c_str()) ) { - fileName = m_BinaryDir + "/CTestConfiguration.ini"; + fileName = this->BinaryDir + "/CTestConfiguration.ini"; } } if ( !cmSystemTools::FileExists(fileName.c_str()) ) { // No need to exit if we are not producing XML - if ( m_ProduceXML ) + if ( this->ProduceXML ) { - cmCTestLog(this, ERROR_MESSAGE, "Cannot find file: " << fileName.c_str() << std::endl); + cmCTestLog(this, ERROR_MESSAGE, "Cannot find file: " << fileName.c_str() + << std::endl); return false; } } @@ -521,15 +550,17 @@ continue; } std::string key = line.substr(0, cpos); - std::string value = cmCTest::CleanString(line.substr(cpos+1, line.npos)); - m_CTestConfiguration[key] = value; + std::string value + = cmCTest::CleanString(line.substr(cpos+1, line.npos)); + this->CTestConfiguration[key] = value; } fin.close(); } - m_TimeOut = atoi(this->GetCTestConfiguration("TimeOut").c_str()); - if ( m_ProduceXML ) + this->TimeOut = atoi(this->GetCTestConfiguration("TimeOut").c_str()); + if ( this->ProduceXML ) { - m_CompressXMLFiles = cmSystemTools::IsOn(this->GetCTestConfiguration("CompressSubmission").c_str()); + this->CompressXMLFiles = cmSystemTools::IsOn( + this->GetCTestConfiguration("CompressSubmission").c_str()); } return true; } @@ -540,15 +571,15 @@ cmSystemTools::PutEnv("DART_TEST_FROM_DART=1"); cmSystemTools::PutEnv("DASHBOARD_TEST_FROM_CTEST=" CMake_VERSION); #if defined(_WIN32) - SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX); + SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX); #endif } //---------------------------------------------------------------------- void cmCTest::SetTestModel(int mode) { - m_InteractiveDebugMode = false; - m_TestModel = mode; + this->InteractiveDebugMode = false; + this->TestModel = mode; } //---------------------------------------------------------------------- @@ -556,49 +587,50 @@ { if ( cmSystemTools::LowerCase(ttype) == "all" ) { - m_Tests[cmCTest::ALL_TEST] = 1; + this->Tests[cmCTest::ALL_TEST] = 1; } else if ( cmSystemTools::LowerCase(ttype) == "start" ) { - m_Tests[cmCTest::START_TEST] = 1; + this->Tests[cmCTest::START_TEST] = 1; } else if ( cmSystemTools::LowerCase(ttype) == "update" ) { - m_Tests[cmCTest::UPDATE_TEST] = 1; + this->Tests[cmCTest::UPDATE_TEST] = 1; } else if ( cmSystemTools::LowerCase(ttype) == "configure" ) { - m_Tests[cmCTest::CONFIGURE_TEST] = 1; + this->Tests[cmCTest::CONFIGURE_TEST] = 1; } else if ( cmSystemTools::LowerCase(ttype) == "build" ) { - m_Tests[cmCTest::BUILD_TEST] = 1; + this->Tests[cmCTest::BUILD_TEST] = 1; } else if ( cmSystemTools::LowerCase(ttype) == "test" ) { - m_Tests[cmCTest::TEST_TEST] = 1; + this->Tests[cmCTest::TEST_TEST] = 1; } else if ( cmSystemTools::LowerCase(ttype) == "coverage" ) { - m_Tests[cmCTest::COVERAGE_TEST] = 1; + this->Tests[cmCTest::COVERAGE_TEST] = 1; } else if ( cmSystemTools::LowerCase(ttype) == "memcheck" ) { - m_Tests[cmCTest::MEMCHECK_TEST] = 1; + this->Tests[cmCTest::MEMCHECK_TEST] = 1; } else if ( cmSystemTools::LowerCase(ttype) == "notes" ) { - m_Tests[cmCTest::NOTES_TEST] = 1; + this->Tests[cmCTest::NOTES_TEST] = 1; } else if ( cmSystemTools::LowerCase(ttype) == "submit" ) { - m_Tests[cmCTest::SUBMIT_TEST] = 1; + this->Tests[cmCTest::SUBMIT_TEST] = 1; } else { if ( report ) { - cmCTestLog(this, ERROR_MESSAGE, "Don't know about test \"" << ttype << "\" yet..." << std::endl); + cmCTestLog(this, ERROR_MESSAGE, "Don't know about test \"" << ttype + << "\" yet..." << std::endl); } return false; } @@ -611,11 +643,11 @@ } //---------------------------------------------------------------------- -bool cmCTest::OpenOutputFile(const std::string& path, +bool cmCTest::OpenOutputFile(const std::string& path, const std::string& name, cmGeneratedFileStream& stream, bool compress) { - std::string testingDir = m_BinaryDir + "/Testing"; + std::string testingDir = this->BinaryDir + "/Testing"; if ( path.size() > 0 ) { testingDir += "/" + path; @@ -624,7 +656,7 @@ { if ( !cmSystemTools::FileIsDirectory(testingDir.c_str()) ) { - cmCTestLog(this, ERROR_MESSAGE, "File " << testingDir + cmCTestLog(this, ERROR_MESSAGE, "File " << testingDir << " is in the place of the testing directory" << std::endl); return false; @@ -643,12 +675,13 @@ stream.Open(filename.c_str()); if( !stream ) { - cmCTestLog(this, ERROR_MESSAGE, "Problem opening file: " << filename << std::endl); + cmCTestLog(this, ERROR_MESSAGE, "Problem opening file: " << filename + << std::endl); return false; } if ( compress ) { - if ( m_CompressXMLFiles ) + if ( this->CompressXMLFiles ) { stream.SetCompression(true); } @@ -657,7 +690,7 @@ } //---------------------------------------------------------------------- -bool cmCTest::AddIfExists(tm_SetOfStrings& files, const char* file) +bool cmCTest::AddIfExists(SetOfStrings& files, const char* file) { if ( this->CTestFileExists(file) ) { @@ -682,7 +715,7 @@ //---------------------------------------------------------------------- bool cmCTest::CTestFileExists(const std::string& filename) { - std::string testingDir = m_BinaryDir + "/Testing/" + m_CurrentTag + "/" + + std::string testingDir = this->BinaryDir + "/Testing/" + this->CurrentTag + "/" + filename; return cmSystemTools::FileExists(testingDir.c_str()); } @@ -690,8 +723,8 @@ //---------------------------------------------------------------------- cmCTestGenericHandler* cmCTest::GetInitializedHandler(const char* handler) { - cmCTest::t_TestingHandlers::iterator it = m_TestingHandlers.find(handler); - if ( it == m_TestingHandlers.end() ) + cmCTest::t_TestingHandlers::iterator it = this->TestingHandlers.find(handler); + if ( it == this->TestingHandlers.end() ) { return 0; } @@ -702,8 +735,8 @@ //---------------------------------------------------------------------- cmCTestGenericHandler* cmCTest::GetHandler(const char* handler) { - cmCTest::t_TestingHandlers::iterator it = m_TestingHandlers.find(handler); - if ( it == m_TestingHandlers.end() ) + cmCTest::t_TestingHandlers::iterator it = this->TestingHandlers.find(handler); + if ( it == this->TestingHandlers.end() ) { return 0; } @@ -719,7 +752,7 @@ return -1; } handler->Initialize(); - return handler->ProcessHandler(); + return handler->ProcessHandler(); } //---------------------------------------------------------------------- @@ -730,36 +763,39 @@ int cc; int update_count = 0; + cmCTestLog(this, OUTPUT, "Start processing tests" << std::endl); + for ( cc = 0; cc < LAST_TEST; cc ++ ) { - if ( m_Tests[cc] ) + if ( this->Tests[cc] ) { notest = false; break; } } - if ( m_Tests[UPDATE_TEST] || m_Tests[ALL_TEST] ) + if ( this->Tests[UPDATE_TEST] || this->Tests[ALL_TEST] ) { cmCTestGenericHandler* uphandler = this->GetHandler("update"); - uphandler->SetOption("SourceDirectory", this->GetCTestConfiguration("SourceDirectory").c_str()); - update_count = uphandler->ProcessHandler(); + uphandler->SetOption("SourceDirectory", + this->GetCTestConfiguration("SourceDirectory").c_str()); + update_count = uphandler->ProcessHandler(); if ( update_count < 0 ) { res |= cmCTest::UPDATE_ERRORS; } } - if ( m_TestModel == cmCTest::CONTINUOUS && !update_count ) + if ( this->TestModel == cmCTest::CONTINUOUS && !update_count ) { return 0; } - if ( m_Tests[CONFIGURE_TEST] || m_Tests[ALL_TEST] ) + if ( this->Tests[CONFIGURE_TEST] || this->Tests[ALL_TEST] ) { if (this->GetHandler("configure")->ProcessHandler() < 0) { res |= cmCTest::CONFIGURE_ERRORS; } } - if ( m_Tests[BUILD_TEST] || m_Tests[ALL_TEST] ) + if ( this->Tests[BUILD_TEST] || this->Tests[ALL_TEST] ) { this->UpdateCTestConfiguration(); if (this->GetHandler("build")->ProcessHandler() < 0) @@ -767,7 +803,7 @@ res |= cmCTest::BUILD_ERRORS; } } - if ( m_Tests[TEST_TEST] || m_Tests[ALL_TEST] || notest ) + if ( this->Tests[TEST_TEST] || this->Tests[ALL_TEST] || notest ) { this->UpdateCTestConfiguration(); if (this->GetHandler("test")->ProcessHandler() < 0) @@ -775,7 +811,7 @@ res |= cmCTest::TEST_ERRORS; } } - if ( m_Tests[COVERAGE_TEST] || m_Tests[ALL_TEST] ) + if ( this->Tests[COVERAGE_TEST] || this->Tests[ALL_TEST] ) { this->UpdateCTestConfiguration(); if (this->GetHandler("coverage")->ProcessHandler() < 0) @@ -783,7 +819,7 @@ res |= cmCTest::COVERAGE_ERRORS; } } - if ( m_Tests[MEMCHECK_TEST] || m_Tests[ALL_TEST] ) + if ( this->Tests[MEMCHECK_TEST] || this->Tests[ALL_TEST] ) { this->UpdateCTestConfiguration(); if (this->GetHandler("memcheck")->ProcessHandler() < 0) @@ -793,7 +829,7 @@ } if ( !notest ) { - std::string notes_dir = m_BinaryDir + "/Testing/Notes"; + std::string notes_dir = this->BinaryDir + "/Testing/Notes"; if ( cmSystemTools::FileIsDirectory(notes_dir.c_str()) ) { cmsys::Directory d; @@ -806,25 +842,25 @@ if ( cmSystemTools::FileExists(fullname.c_str()) && !cmSystemTools::FileIsDirectory(fullname.c_str()) ) { - if ( m_NotesFiles.size() > 0 ) + if ( this->NotesFiles.size() > 0 ) { - m_NotesFiles += ";"; + this->NotesFiles += ";"; } - m_NotesFiles += fullname; - m_Tests[NOTES_TEST] = 1; + this->NotesFiles += fullname; + this->Tests[NOTES_TEST] = 1; } } } } - if ( m_Tests[NOTES_TEST] || m_Tests[ALL_TEST] ) + if ( this->Tests[NOTES_TEST] || this->Tests[ALL_TEST] ) { this->UpdateCTestConfiguration(); - if ( m_NotesFiles.size() ) + if ( this->NotesFiles.size() ) { - this->GenerateNotesFile(m_NotesFiles.c_str()); + this->GenerateNotesFile(this->NotesFiles.c_str()); } } - if ( m_Tests[SUBMIT_TEST] || m_Tests[ALL_TEST] ) + if ( this->Tests[SUBMIT_TEST] || this->Tests[ALL_TEST] ) { this->UpdateCTestConfiguration(); if (this->GetHandler("submit")->ProcessHandler() < 0) @@ -834,7 +870,8 @@ } if ( res != 0 ) { - cmCTestLog(this, ERROR_MESSAGE, "Errors while running CTest" << std::endl); + cmCTestLog(this, ERROR_MESSAGE, "Errors while running CTest" + << std::endl); } return res; } @@ -842,7 +879,7 @@ //---------------------------------------------------------------------- std::string cmCTest::GetTestModelString() { - switch ( m_TestModel ) + switch ( this->TestModel ) { case cmCTest::NIGHTLY: return "Nightly"; @@ -908,7 +945,7 @@ cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, " \"" << *ait << "\""); } cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, std::endl); - + // Now create process object cmsysProcess* cp = cmsysProcess_New(); cmsysProcess_SetCommand(cp, &*argv.begin()); @@ -968,22 +1005,25 @@ if(result == cmsysProcess_State_Exited) { *retVal = cmsysProcess_GetExitValue(cp); - cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Command exited with the value: " << *retVal << std::endl); + cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Command exited with the value: " + << *retVal << std::endl); } else if(result == cmsysProcess_State_Exception) { *retVal = cmsysProcess_GetExitException(cp); - cmCTestLog(this, WARNING, "There was an exception: " << *retVal << std::endl); + cmCTestLog(this, WARNING, "There was an exception: " << *retVal + << std::endl); } else if(result == cmsysProcess_State_Expired) { cmCTestLog(this, WARNING, "There was a timeout" << std::endl); - } + } else if(result == cmsysProcess_State_Error) { *output += "\n*** ERROR executing: "; *output += cmsysProcess_GetErrorString(cp); - cmCTestLog(this, ERROR_MESSAGE, "There was an error: " << cmsysProcess_GetErrorString(cp) << std::endl); + cmCTestLog(this, ERROR_MESSAGE, "There was an error: " + << cmsysProcess_GetErrorString(cp) << std::endl); } cmsysProcess_Delete(cp); @@ -997,16 +1037,16 @@ //###################################################################### //---------------------------------------------------------------------- -int cmCTest::RunTest(std::vector argv, +int cmCTest::RunTest(std::vector argv, std::string* output, int *retVal, std::ostream* log) { - if(cmSystemTools::SameFile(argv[0], m_CTestSelf.c_str()) && - !m_ForceNewCTestProcess) + if(cmSystemTools::SameFile(argv[0], this->CTestSelf.c_str()) && + !this->ForceNewCTestProcess) { cmCTest inst; - inst.m_ConfigType = m_ConfigType; - inst.m_TimeOut = m_TimeOut; + inst.ConfigType = this->ConfigType; + inst.TimeOut = this->TimeOut; std::vector args; for(unsigned int i =0; i < argv.size(); ++i) { @@ -1020,15 +1060,16 @@ *log << "* Run internal CTest" << std::endl; } std::string oldpath = cmSystemTools::GetCurrentWorkingDirectory(); - + *retVal = inst.Run(args, output); if ( *log ) { *log << output->c_str(); } cmSystemTools::ChangeDirectory(oldpath.c_str()); - - cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Internal cmCTest object used to run test." << std::endl + + cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, + "Internal cmCTest object used to run test." << std::endl << *output << std::endl); return cmsysProcess_State_Exited; } @@ -1045,7 +1086,7 @@ { cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1); } - cmsysProcess_SetTimeout(cp, m_TimeOut); + cmsysProcess_SetTimeout(cp, this->TimeOut); cmsysProcess_Execute(cp); char* data; @@ -1068,7 +1109,8 @@ { output->append(&*tempOutput.begin(), tempOutput.size()); } - cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "-- Process completed" << std::endl); + cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "-- Process completed" + << std::endl); int result = cmsysProcess_GetState(cp); @@ -1082,14 +1124,16 @@ std::string outerr = "\n*** Exception executing: "; outerr += cmsysProcess_GetExceptionString(cp); *output += outerr; - cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, outerr.c_str() << std::endl << std::flush); + cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, outerr.c_str() << std::endl + << std::flush); } else if(result == cmsysProcess_State_Error) { std::string outerr = "\n*** ERROR executing: "; outerr += cmsysProcess_GetErrorString(cp); *output += outerr; - cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, outerr.c_str() << std::endl << std::flush); + cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, outerr.c_str() << std::endl + << std::flush); } cmsysProcess_Delete(cp); @@ -1101,7 +1145,7 @@ { ostr << "\n" << "GetCTestConfiguration("BuildName") - << "\" BuildStamp=\"" << m_CurrentTag << "-" + << "\" BuildStamp=\"" << this->CurrentTag << "-" << this->GetTestModelString() << "\" Name=\"" << this->GetCTestConfiguration("Site") << "\" Generator=\"ctest" << cmVersion::GetCMakeVersion() @@ -1115,13 +1159,17 @@ } //---------------------------------------------------------------------- -int cmCTest::GenerateCTestNotesOutput(std::ostream& os, const cmCTest::tm_VectorOfStrings& files) +int cmCTest::GenerateCTestNotesOutput(std::ostream& os, + const cmCTest::VectorOfStrings& files) { - cmCTest::tm_VectorOfStrings::const_iterator it; + cmCTest::VectorOfStrings::const_iterator it; os << "\n" - << " \"?>\n" - << "GetCTestConfiguration("BuildName") << "\" BuildStamp=\"" - << m_CurrentTag << "-" << this->GetTestModelString() << "\" Name=\"" + << " \"?>\n" + << "GetCTestConfiguration("BuildName") + << "\" BuildStamp=\"" + << this->CurrentTag << "-" << this->GetTestModelString() << "\" Name=\"" << this->GetCTestConfiguration("Site") << "\" Generator=\"ctest" << cmVersion::GetCMakeVersion() << "\">\n" @@ -1147,7 +1195,8 @@ else { os << "Problem reading file: " << it->c_str() << std::endl; - cmCTestLog(this, ERROR_MESSAGE, "Problem reading file: " << it->c_str() << " while creating notes" << std::endl); + cmCTestLog(this, ERROR_MESSAGE, "Problem reading file: " << it->c_str() + << " while creating notes" << std::endl); } os << "\n" << "" << std::endl; @@ -1161,7 +1210,7 @@ int cmCTest::GenerateNotesFile(const std::vector &files) { cmGeneratedFileStream ofs; - if ( !this->OpenOutputFile(m_CurrentTag, "Notes.xml", ofs) ) + if ( !this->OpenOutputFile(this->CurrentTag, "Notes.xml", ofs) ) { cmCTestLog(this, ERROR_MESSAGE, "Cannot open notes file" << std::endl); return 1; @@ -1202,7 +1251,8 @@ { if ( !cmSystemTools::FileExists(it->c_str()) ) { - cmCTestLog(this, ERROR_MESSAGE, "Cannot find extra file: " << it->c_str() << " to submit." + cmCTestLog(this, ERROR_MESSAGE, "Cannot find extra file: " + << it->c_str() << " to submit." << std::endl;); return false; } @@ -1233,36 +1283,10 @@ } //---------------------------------------------------------------------- -bool cmCTest::CheckArgument(const std::string& arg, const char* varg1, const char* varg2) +bool cmCTest::CheckArgument(const std::string& arg, const char* varg1, + const char* varg2) { - cmOStringStream ostr; - ostr << varg1; - if ( varg2 ) - { - ostr << ", " << varg2; - } - - size_t minlen = arg.size(); - size_t lenvarg = strlen(varg1); - if ( lenvarg < minlen ) - { - minlen = lenvarg; - } - if ( strncmp(arg.c_str(), varg1, minlen) == 0 ) - { - return true; - } - if ( ! varg2 ) - { - return false; - } - minlen = arg.size(); - lenvarg = strlen(varg2); - if ( lenvarg < minlen ) - { - minlen = lenvarg; - } - if ( strncmp(arg.c_str(), varg2, minlen) == 0 ) + if ( varg1 && arg == varg1 || varg2 && arg == varg2 ) { return true; } @@ -1282,48 +1306,50 @@ if(this->CheckArgument(arg, "--ctest-config") && i < args.size() - 1) { i++; - this->m_CTestConfigFile= args[i]; + this->CTestConfigFile= args[i]; } - if(this->CheckArgument(arg, "-C", "--build-config") && i < args.size() - 1) + if(this->CheckArgument(arg, "-C", "--build-config") && + i < args.size() - 1) { i++; - this->m_ConfigType = args[i]; - cmSystemTools::ReplaceString(this->m_ConfigType, ".\\", ""); + this->ConfigType = args[i]; + cmSystemTools::ReplaceString(this->ConfigType, ".\\", ""); } if(this->CheckArgument(arg, "--debug")) { - this->m_Debug = true; + this->Debug = true; } if(this->CheckArgument(arg, "--show-line-numbers")) { - this->m_ShowLineNumbers = true; + this->ShowLineNumbers = true; } if(this->CheckArgument(arg, "-Q", "--quiet")) { - this->m_Quiet = true; + this->Quiet = true; } if(this->CheckArgument(arg, "-V", "--verbose")) { - this->m_Verbose = true; + this->Verbose = true; } if(this->CheckArgument(arg, "-VV", "--extra-verbose")) { - this->m_ExtraVerbose = true; - this->m_Verbose = true; + this->ExtraVerbose = true; + this->Verbose = true; } if(this->CheckArgument(arg, "-N", "--show-only")) { - this->m_ShowOnly = true; + this->ShowOnly = true; } if(this->CheckArgument(arg, "-S", "--script") && i < args.size() - 1 ) { - this->m_RunConfigurationScript = true; + this->RunConfigurationScript = true; i++; - cmCTestScriptHandler* ch = static_cast(this->GetHandler("script")); + cmCTestScriptHandler* ch + = static_cast(this->GetHandler("script")); ch->AddConfigurationScript(args[i].c_str()); } @@ -1335,29 +1361,30 @@ if(this->CheckArgument(arg, "--tomorrow-tag")) { - m_TomorrowTag = true; + this->TomorrowTag = true; } if(this->CheckArgument(arg, "--force-new-ctest-process")) { - m_ForceNewCTestProcess = true; + this->ForceNewCTestProcess = true; } - if(this->CheckArgument(arg, "--interactive-debug-mode") && i < args.size() - 1 ) + if(this->CheckArgument(arg, "--interactive-debug-mode") && + i < args.size() - 1 ) { i++; - m_InteractiveDebugMode = cmSystemTools::IsOn(args[i].c_str()); + this->InteractiveDebugMode = cmSystemTools::IsOn(args[i].c_str()); } if(this->CheckArgument(arg, "--submit-index") && i < args.size() - 1 ) { i++; - m_SubmitIndex = atoi(args[i].c_str()); - if ( m_SubmitIndex < 0 ) + this->SubmitIndex = atoi(args[i].c_str()); + if ( this->SubmitIndex < 0 ) { - m_SubmitIndex = 0; + this->SubmitIndex = 0; } } if(this->CheckArgument(arg, "-D", "--dashboard") && i < args.size() - 1 ) { - this->m_ProduceXML = true; + this->ProduceXML = true; i++; std::string targ = args[i]; if ( targ == "Experimental" ) @@ -1431,7 +1458,7 @@ { this->SetTestModel(cmCTest::CONTINUOUS); this->SetTest("Update"); - } + } else if ( targ == "ContinuousConfigure" ) { this->SetTestModel(cmCTest::CONTINUOUS); @@ -1539,29 +1566,38 @@ else { performSomeTest = false; - cmCTestLog(this, ERROR_MESSAGE, "CTest -D called with incorrect option: " << targ << std::endl); + cmCTestLog(this, ERROR_MESSAGE, + "CTest -D called with incorrect option: " << targ << std::endl); cmCTestLog(this, ERROR_MESSAGE, "Available options are:" << std::endl << " " << ctestExec << " -D Continuous" << std::endl - << " " << ctestExec << " -D Continuous(Start|Update|Configure|Build)" << std::endl - << " " << ctestExec << " -D Continuous(Test|Coverage|MemCheck|Submit)" << std::endl + << " " << ctestExec + << " -D Continuous(Start|Update|Configure|Build)" << std::endl + << " " << ctestExec + << " -D Continuous(Test|Coverage|MemCheck|Submit)" << std::endl << " " << ctestExec << " -D Experimental" << std::endl - << " " << ctestExec << " -D Experimental(Start|Update|Configure|Build)" << std::endl - << " " << ctestExec << " -D Experimental(Test|Coverage|MemCheck|Submit)" << std::endl + << " " << ctestExec + << " -D Experimental(Start|Update|Configure|Build)" << std::endl + << " " << ctestExec + << " -D Experimental(Test|Coverage|MemCheck|Submit)" << std::endl << " " << ctestExec << " -D Nightly" << std::endl - << " " << ctestExec << " -D Nightly(Start|Update|Configure|Build)" << std::endl - << " " << ctestExec << " -D Nightly(Test|Coverage|MemCheck|Submit)" << std::endl + << " " << ctestExec + << " -D Nightly(Start|Update|Configure|Build)" << std::endl + << " " << ctestExec + << " -D Nightly(Test|Coverage|MemCheck|Submit)" << std::endl << " " << ctestExec << " -D NightlyMemoryCheck" << std::endl); } } - if(this->CheckArgument(arg, "-T", "--test-action") && (i < args.size() -1) ) + if(this->CheckArgument(arg, "-T", "--test-action") && + (i < args.size() -1) ) { - this->m_ProduceXML = true; + this->ProduceXML = true; i++; if ( !this->SetTest(args[i].c_str(), false) ) { performSomeTest = false; - cmCTestLog(this, ERROR_MESSAGE, "CTest -T called with incorrect option: " + cmCTestLog(this, ERROR_MESSAGE, + "CTest -T called with incorrect option: " << args[i].c_str() << std::endl); cmCTestLog(this, ERROR_MESSAGE, "Available options are:" << std::endl << " " << ctestExec << " -T all" << std::endl @@ -1577,7 +1613,8 @@ } } - if(this->CheckArgument(arg, "-M", "--test-model") && (i < args.size() -1) ) + if(this->CheckArgument(arg, "-M", "--test-model") && + (i < args.size() -1) ) { i++; std::string const& str = args[i]; @@ -1596,7 +1633,9 @@ else { performSomeTest = false; - cmCTestLog(this, ERROR_MESSAGE, "CTest -M called with incorrect option: " << str.c_str() << std::endl); + cmCTestLog(this, ERROR_MESSAGE, + "CTest -M called with incorrect option: " << str.c_str() + << std::endl); cmCTestLog(this, ERROR_MESSAGE, "Available options are:" << std::endl << " " << ctestExec << " -M Continuous" << std::endl << " " << ctestExec << " -M Experimental" << std::endl @@ -1604,25 +1643,30 @@ } } - if(this->CheckArgument(arg, "-I", "--tests-information") && i < args.size() - 1) + if(this->CheckArgument(arg, "-I", "--tests-information") && + i < args.size() - 1) { i++; - this->GetHandler("test")->SetOption("TestsToRunInformation", args[i].c_str()); - } + this->GetHandler("test")->SetOption("TestsToRunInformation", + args[i].c_str()); + } if(this->CheckArgument(arg, "-U", "--union")) - { + { this->GetHandler("test")->SetOption("UseUnion", "true"); - } - if(this->CheckArgument(arg, "-R", "--tests-regex") && i < args.size() - 1) - { - i++; - this->GetHandler("test")->SetOption("IncludeRegularExpression", args[i].c_str()); - } + } + if(this->CheckArgument(arg, "-R", "--tests-regex") && i < args.size() - 1) + { + i++; + this->GetHandler("test")->SetOption("IncludeRegularExpression", + args[i].c_str()); + } - if(this->CheckArgument(arg, "-E", "--exclude-regex") && i < args.size() - 1) - { + if(this->CheckArgument(arg, "-E", "--exclude-regex") && + i < args.size() - 1) + { i++; - this->GetHandler("test")->SetOption("ExcludeRegularExpression", args[i].c_str()); + this->GetHandler("test")->SetOption("ExcludeRegularExpression", + args[i].c_str()); } if(this->CheckArgument(arg, "--overwrite") && i < args.size() - 1) @@ -1632,14 +1676,14 @@ } if(this->CheckArgument(arg, "-A", "--add-notes") && i < args.size() - 1) { - this->m_ProduceXML = true; + this->ProduceXML = true; this->SetTest("Notes"); i++; this->SetNotesFiles(args[i].c_str()); } if(this->CheckArgument(arg, "--extra-submit") && i < args.size() - 1) { - this->m_ProduceXML = true; + this->ProduceXML = true; this->SetTest("Submit"); i++; if ( !this->SubmitExtraFiles(args[i].c_str()) ) @@ -1653,37 +1697,33 @@ cmakeAndTest = true; } cmCTest::t_TestingHandlers::iterator it; - for ( it = m_TestingHandlers.begin(); it != m_TestingHandlers.end(); ++ it ) + for ( it = this->TestingHandlers.begin(); + it != this->TestingHandlers.end(); + ++ it ) { if ( !it->second->ProcessCommandLineArguments(arg, i, args) ) { - cmCTestLog(this, ERROR_MESSAGE, "Problem parsing command line arguments within a handler"); + cmCTestLog(this, ERROR_MESSAGE, + "Problem parsing command line arguments within a handler"); return 0; } } } // default to the build type of ctest itself - if(m_ConfigType.size() == 0) + if(this->ConfigType.size() == 0) { #ifdef CMAKE_INTDIR - m_ConfigType = CMAKE_INTDIR; + this->ConfigType = CMAKE_INTDIR; #endif } if(cmakeAndTest) { - m_Verbose = true; - cmCTestBuildAndTestHandler* handler = + this->Verbose = true; + cmCTestBuildAndTestHandler* handler = static_cast(this->GetHandler("buildtest")); int retv = handler->ProcessHandler(); - /* - cmSystemTools::ResetErrorOccuredFlag(); - cmListFileCache::ClearCache(); - int retv = this->RunCMakeAndTest(output); - cmSystemTools::ResetErrorOccuredFlag(); - cmListFileCache::ClearCache(); - */ *output = handler->GetOutput(); #ifdef CMAKE_BUILD_WITH_CMAKE cmDynamicLoader::FlushCache(); @@ -1695,31 +1735,43 @@ { int res; // call process directory - if (this->m_RunConfigurationScript) + if (this->RunConfigurationScript) { + if ( this->ExtraVerbose ) + { + cmCTestLog(this, OUTPUT, "* Extra verbosity turned on" << std::endl); + } cmCTest::t_TestingHandlers::iterator it; - for ( it = m_TestingHandlers.begin(); it != m_TestingHandlers.end(); ++ it ) + for ( it = this->TestingHandlers.begin(); + it != this->TestingHandlers.end(); + ++ it ) { - it->second->SetVerbose(this->m_ExtraVerbose); - it->second->SetSubmitIndex(m_SubmitIndex); + it->second->SetVerbose(this->ExtraVerbose); + it->second->SetSubmitIndex(this->SubmitIndex); } - this->GetHandler("script")->SetVerbose(m_Verbose); + this->GetHandler("script")->SetVerbose(this->Verbose); res = this->GetHandler("script")->ProcessHandler(); } else { - m_ExtraVerbose = m_Verbose; - m_Verbose = true; + this->ExtraVerbose = this->Verbose; + this->Verbose = true; cmCTest::t_TestingHandlers::iterator it; - for ( it = m_TestingHandlers.begin(); it != m_TestingHandlers.end(); ++ it ) - { - it->second->SetVerbose(this->m_Verbose); - it->second->SetSubmitIndex(m_SubmitIndex); - } - if ( !this->Initialize(cmSystemTools::GetCurrentWorkingDirectory().c_str()) ) + for ( it = this->TestingHandlers.begin(); + it != this->TestingHandlers.end(); + ++ it ) + { + it->second->SetVerbose(this->Verbose); + it->second->SetSubmitIndex(this->SubmitIndex); + } + cmCTestLog(this, DEBUG, "Here: " << __LINE__ << std::endl); + if ( !this->Initialize( + cmSystemTools::GetCurrentWorkingDirectory().c_str()) ) { + cmCTestLog(this, DEBUG, "Here: " << __LINE__ << std::endl); res = 12; - cmCTestLog(this, ERROR_MESSAGE, "Problem initializing the dashboard." << std::endl); + cmCTestLog(this, ERROR_MESSAGE, "Problem initializing the dashboard." + << std::endl); } else { @@ -1737,18 +1789,18 @@ { // Find our own executable. std::vector failures; - m_CTestSelf = arg0; - cmSystemTools::ConvertToUnixSlashes(m_CTestSelf); - failures.push_back(m_CTestSelf); - m_CTestSelf = cmSystemTools::FindProgram(m_CTestSelf.c_str()); - if(!cmSystemTools::FileExists(m_CTestSelf.c_str())) + this->CTestSelf = arg0; + cmSystemTools::ConvertToUnixSlashes(this->CTestSelf); + failures.push_back(this->CTestSelf); + this->CTestSelf = cmSystemTools::FindProgram(this->CTestSelf.c_str()); + if(!cmSystemTools::FileExists(this->CTestSelf.c_str())) { - failures.push_back(m_CTestSelf); - m_CTestSelf = "/usr/local/bin/ctest"; + failures.push_back(this->CTestSelf); + this->CTestSelf = "/usr/local/bin/ctest"; } - if(!cmSystemTools::FileExists(m_CTestSelf.c_str())) + if(!cmSystemTools::FileExists(this->CTestSelf.c_str())) { - failures.push_back(m_CTestSelf); + failures.push_back(this->CTestSelf); cmOStringStream msg; msg << "CTEST can not find the command line program ctest.\n"; msg << " argv[0] = \"" << arg0 << "\"\n"; @@ -1762,31 +1814,31 @@ } std::string dir; std::string file; - if(cmSystemTools::SplitProgramPath(m_CTestSelf.c_str(), + if(cmSystemTools::SplitProgramPath(this->CTestSelf.c_str(), dir, file, true)) { - m_CMakeSelf = dir += "/cmake"; - m_CMakeSelf += cmSystemTools::GetExecutableExtension(); - if(cmSystemTools::FileExists(m_CMakeSelf.c_str())) + this->CMakeSelf = dir += "/cmake"; + this->CMakeSelf += cmSystemTools::GetExecutableExtension(); + if(cmSystemTools::FileExists(this->CMakeSelf.c_str())) { return; } } - failures.push_back(m_CMakeSelf); + failures.push_back(this->CMakeSelf); #ifdef CMAKE_BUILD_DIR std::string intdir = "."; #ifdef CMAKE_INTDIR intdir = CMAKE_INTDIR; #endif - m_CMakeSelf = CMAKE_BUILD_DIR; - m_CMakeSelf += "/bin/"; - m_CMakeSelf += intdir; - m_CMakeSelf += "/cmake"; - m_CMakeSelf += cmSystemTools::GetExecutableExtension(); + this->CMakeSelf = CMAKE_BUILD_DIR; + this->CMakeSelf += "/bin/"; + this->CMakeSelf += intdir; + this->CMakeSelf += "/cmake"; + this->CMakeSelf += cmSystemTools::GetExecutableExtension(); #endif - if(!cmSystemTools::FileExists(m_CMakeSelf.c_str())) + if(!cmSystemTools::FileExists(this->CMakeSelf.c_str())) { - failures.push_back(m_CMakeSelf); + failures.push_back(this->CMakeSelf); cmOStringStream msg; msg << "CTEST can not find the command line program cmake.\n"; msg << " argv[0] = \"" << arg0 << "\"\n"; @@ -1807,14 +1859,14 @@ { return; } - m_NotesFiles = notes; + this->NotesFiles = notes; } //---------------------------------------------------------------------- int cmCTest::ReadCustomConfigurationFileTree(const char* dir) { - tm_VectorOfStrings dirs; - tm_VectorOfStrings ndirs; + VectorOfStrings dirs; + VectorOfStrings ndirs; cmake cm; cmGlobalGenerator gg; gg.SetCMakeInstance(&cm); @@ -1832,25 +1884,28 @@ for ( fileIt = files.begin(); fileIt != files.end(); ++ fileIt ) { - cmCTestLog(this, DEBUG, "* Read custom CTest configuration file: " << fileIt->c_str() << std::endl); + cmCTestLog(this, DEBUG, "* Read custom CTest configuration file: " + << fileIt->c_str() << std::endl); if ( !lg->GetMakefile()->ReadListFile(0, fileIt->c_str()) || cmSystemTools::GetErrorOccuredFlag() ) { - cmCTestLog(this, ERROR_MESSAGE, "Problem reading custom configuration: " << fileIt->c_str() << std::endl); + cmCTestLog(this, ERROR_MESSAGE, "Problem reading custom configuration: " + << fileIt->c_str() << std::endl); } } cmCTest::t_TestingHandlers::iterator it; - for ( it = m_TestingHandlers.begin(); it != m_TestingHandlers.end(); ++ it ) + for ( it = this->TestingHandlers.begin(); it != this->TestingHandlers.end(); ++ it ) { it->second->PopulateCustomVectors(mf); } - + return 1; } //---------------------------------------------------------------------- -void cmCTest::PopulateCustomVector(cmMakefile* mf, const char* def, tm_VectorOfStrings& vec) +void cmCTest::PopulateCustomVector(cmMakefile* mf, const char* def, + VectorOfStrings& vec) { if ( !def) { @@ -1889,7 +1944,8 @@ //---------------------------------------------------------------------- std::string cmCTest::GetShortPathToFile(const char* cfname) { - const std::string& sourceDir = this->GetCTestConfiguration("SourceDirectory"); + const std::string& sourceDir + = this->GetCTestConfiguration("SourceDirectory"); const std::string& buildDir = this->GetCTestConfiguration("BuildDirectory"); std::string fname = cmSystemTools::CollapseFullPath(cfname); @@ -1943,17 +1999,18 @@ //---------------------------------------------------------------------- std::string cmCTest::GetCTestConfiguration(const char *name) { - if ( m_CTestConfigurationOverwrites.find(name) != m_CTestConfigurationOverwrites.end() ) + if ( this->CTestConfigurationOverwrites.find(name) != + this->CTestConfigurationOverwrites.end() ) { - return m_CTestConfigurationOverwrites[name]; + return this->CTestConfigurationOverwrites[name]; } - return m_CTestConfiguration[name]; + return this->CTestConfiguration[name]; } //---------------------------------------------------------------------- void cmCTest::EmptyCTestConfiguration() { - m_CTestConfiguration.clear(); + this->CTestConfiguration.clear(); } //---------------------------------------------------------------------- @@ -1965,53 +2022,53 @@ } if ( !value ) { - m_CTestConfiguration.erase(name); + this->CTestConfiguration.erase(name); return; } - m_CTestConfiguration[name] = value; + this->CTestConfiguration[name] = value; } - + //---------------------------------------------------------------------- std::string cmCTest::GetCurrentTag() { - return m_CurrentTag; + return this->CurrentTag; } //---------------------------------------------------------------------- std::string cmCTest::GetBinaryDir() { - return m_BinaryDir; + return this->BinaryDir; } //---------------------------------------------------------------------- std::string cmCTest::GetConfigType() { - return m_ConfigType; + return this->ConfigType; } //---------------------------------------------------------------------- bool cmCTest::GetShowOnly() { - return m_ShowOnly; + return this->ShowOnly; } //---------------------------------------------------------------------- void cmCTest::SetProduceXML(bool v) { - m_ProduceXML = v; + this->ProduceXML = v; } //---------------------------------------------------------------------- bool cmCTest::GetProduceXML() { - return m_ProduceXML; + return this->ProduceXML; } //---------------------------------------------------------------------- void cmCTest::AddSubmitFile(const char* name) { - m_SubmitFiles.insert(name); + this->SubmitFiles.insert(name); } //---------------------------------------------------------------------- @@ -2022,18 +2079,20 @@ if ( epos == overStr.npos ) { cmCTestLog(this, ERROR_MESSAGE, - "CTest configuration overwrite specified in the wrong format." << std::endl + "CTest configuration overwrite specified in the wrong format." + << std::endl << "Valid format is: --overwrite key=value" << std::endl << "The specified was: --overwrite " << overStr.c_str() << std::endl); return; } std::string key = overStr.substr(0, epos); std::string value = overStr.substr(epos+1, overStr.npos); - m_CTestConfigurationOverwrites[key] = value; + this->CTestConfigurationOverwrites[key] = value; } //---------------------------------------------------------------------- -bool cmCTest::SetCTestConfigurationFromCMakeVariable(cmMakefile* mf, const char* dconfig, const char* cmake_var) +bool cmCTest::SetCTestConfigurationFromCMakeVariable(cmMakefile* mf, + const char* dconfig, const char* cmake_var) { const char* ctvar; ctvar = mf->GetDefinition(cmake_var); @@ -2046,10 +2105,10 @@ } bool cmCTest::RunCommand( - const char* command, + const char* command, std::string* stdOut, std::string* stdErr, - int *retVal, + int *retVal, const char* dir, double timeout) { @@ -2059,7 +2118,7 @@ { return false; } - + std::vector argv; for(std::vector::const_iterator a = args.begin(); a != args.end(); ++a) @@ -2080,7 +2139,7 @@ } cmsysProcess_SetTimeout(cp, timeout); cmsysProcess_Execute(cp); - + std::vector tempOutput; std::vector tempError; char* data; @@ -2101,16 +2160,17 @@ default: done = true; } - if ( (res == cmsysProcess_Pipe_STDOUT || res == cmsysProcess_Pipe_STDERR) && m_ExtraVerbose ) + if ( (res == cmsysProcess_Pipe_STDOUT || + res == cmsysProcess_Pipe_STDERR) && this->ExtraVerbose ) { cmSystemTools::Stdout(data, length); } } - + cmsysProcess_WaitForExit(cp, 0); stdOut->append(&*tempOutput.begin(), tempOutput.size()); stdErr->append(&*tempError.begin(), tempError.size()); - + bool result = true; if(cmsysProcess_GetState(cp) == cmsysProcess_State_Exited) { @@ -2147,7 +2207,7 @@ stdErr->append(error_str, strlen(error_str)); result = false; } - + cmsysProcess_Delete(cp); return result; } @@ -2155,19 +2215,19 @@ //---------------------------------------------------------------------- void cmCTest::SetOutputLogFileName(const char* name) { - if ( m_OutputLogFile) + if ( this->OutputLogFile) { - delete m_OutputLogFile; - m_OutputLogFile= 0; + delete this->OutputLogFile; + this->OutputLogFile= 0; } if ( name ) { - m_OutputLogFile = new cmGeneratedFileStream(name); + this->OutputLogFile = new cmGeneratedFileStream(name); } } //---------------------------------------------------------------------- -static const char* cmCTestStringLogType[] = +static const char* cmCTestStringLogType[] = { "DEBUG", "OUTPUT", @@ -2187,7 +2247,7 @@ #endif #define cmCTestLogOutputFileLine(stream) \ - if ( m_ShowLineNumbers ) \ + if ( this->ShowLineNumbers ) \ { \ (stream) << std::endl << file << ":" << line << " "; \ } @@ -2198,41 +2258,42 @@ { return; } - if ( m_OutputLogFile ) + if ( this->OutputLogFile ) { bool display = true; - if ( logType == cmCTest::DEBUG && !m_Debug ) { display = false; } - if ( logType == cmCTest::HANDLER_VERBOSE_OUTPUT && !m_Debug && !m_ExtraVerbose ) { display = false; } + if ( logType == cmCTest::DEBUG && !this->Debug ) { display = false; } + if ( logType == cmCTest::HANDLER_VERBOSE_OUTPUT && !this->Debug && + !this->ExtraVerbose ) { display = false; } if ( display ) { - cmCTestLogOutputFileLine(*m_OutputLogFile); - if ( logType != m_OutputLogFileLastTag ) + cmCTestLogOutputFileLine(*this->OutputLogFile); + if ( logType != this->OutputLogFileLastTag ) { - *m_OutputLogFile << "["; + *this->OutputLogFile << "["; if ( logType >= OTHER || logType < 0 ) { - *m_OutputLogFile << "OTHER"; + *this->OutputLogFile << "OTHER"; } else { - *m_OutputLogFile << cmCTestStringLogType[logType]; + *this->OutputLogFile << cmCTestStringLogType[logType]; } - *m_OutputLogFile << "] " << std::endl << std::flush; + *this->OutputLogFile << "] " << std::endl << std::flush; } - *m_OutputLogFile << msg << std::flush; - if ( logType != m_OutputLogFileLastTag ) + *this->OutputLogFile << msg << std::flush; + if ( logType != this->OutputLogFileLastTag ) { - *m_OutputLogFile << std::endl << std::flush; - m_OutputLogFileLastTag = logType; + *this->OutputLogFile << std::endl << std::flush; + this->OutputLogFileLastTag = logType; } } } - if ( !m_Quiet ) + if ( !this->Quiet ) { switch ( logType ) { case DEBUG: - if ( m_Debug ) + if ( this->Debug ) { cmCTestLogOutputFileLine(std::cout); std::cout << msg; @@ -2240,7 +2301,7 @@ } break; case OUTPUT: case HANDLER_OUTPUT: - if ( m_Debug || m_Verbose ) + if ( this->Debug || this->Verbose ) { cmCTestLogOutputFileLine(std::cout); std::cout << msg; @@ -2248,7 +2309,7 @@ } break; case HANDLER_VERBOSE_OUTPUT: - if ( m_Debug || m_ExtraVerbose ) + if ( this->Debug || this->ExtraVerbose ) { cmCTestLogOutputFileLine(std::cout); std::cout << msg; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCTest.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCTest.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCTest.h 2005-08-12 02:02:19.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCTest.h 2006-03-16 00:01:59.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTest.h,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:19 $ - Version: $Revision: 1.81.2.1 $ + Date: $Date: 2006/03/15 16:01:59 $ + Version: $Revision: 1.88 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -32,7 +32,8 @@ do { \ cmOStringStream cmCTestLog_msg; \ cmCTestLog_msg << msg; \ - (ctSelf)->Log(cmCTest::logType, __FILE__, __LINE__, cmCTestLog_msg.str().c_str());\ + (ctSelf)->Log(cmCTest::logType, __FILE__, __LINE__,\ + cmCTestLog_msg.str().c_str());\ } while ( 0 ) #ifdef cerr @@ -48,16 +49,17 @@ class cmCTest { public: - typedef std::vector tm_VectorOfStrings; - typedef std::set tm_SetOfStrings; + typedef std::vector VectorOfStrings; + typedef std::set SetOfStrings; ///! Process Command line arguments int Run(std::vectorconst&, std::string* output = 0); - + /** * Initialize and finalize testing */ - int Initialize(const char* binary_dir, bool new_tag = false, bool verbose_tag = true); + int Initialize(const char* binary_dir, bool new_tag = false, + bool verbose_tag = true); bool InitializeFromCommand(cmCTestCommand* command, bool first = false); void Finalize(); @@ -76,14 +78,14 @@ /* * A utility function that returns the nightly time */ - struct tm* GetNightlyTime(std::string str, + struct tm* GetNightlyTime(std::string str, bool tomorrowtag); - + /* * Is the tomorrow tag set? */ - bool GetTomorrowTag() { return m_TomorrowTag; }; - + bool GetTomorrowTag() { return this->TomorrowTag; }; + /** * Try to run tests of the project */ @@ -91,14 +93,14 @@ ///! what is the configuraiton type, e.g. Debug, Release etc. std::string GetConfigType(); - double GetTimeOut() { return m_TimeOut; } - void SetTimeOut(double t) { m_TimeOut = t; } - + double GetTimeOut() { return this->TimeOut; } + void SetTimeOut(double t) { this->TimeOut = t; } + /** * Check if CTest file exists */ bool CTestFileExists(const std::string& filename); - bool AddIfExists(tm_SetOfStrings& files, const char* file); + bool AddIfExists(SetOfStrings& files, const char* file); /** * Set the cmake test @@ -109,33 +111,34 @@ * Set the cmake test mode (experimental, nightly, continuous). */ void SetTestModel(int mode); - int GetTestModel() { return m_TestModel; }; - + int GetTestModel() { return this->TestModel; }; + std::string GetTestModelString(); static int GetTestModelFromString(const char* str); static std::string CleanString(const std::string& str); std::string GetCTestConfiguration(const char *name); void SetCTestConfiguration(const char *name, const char* value); void EmptyCTestConfiguration(); - + /** * constructor and destructor */ cmCTest(); ~cmCTest(); - + //! Set the notes files to be created. void SetNotesFiles(const char* notes); - static void PopulateCustomVector(cmMakefile* mf, const char* definition, - tm_VectorOfStrings& vec); - static void PopulateCustomInteger(cmMakefile* mf, const char* def, int& val); + static void PopulateCustomVector(cmMakefile* mf, const char* definition, + VectorOfStrings& vec); + static void PopulateCustomInteger(cmMakefile* mf, const char* def, + int& val); ///! Get the current time as string std::string CurrentTime(); - + ///! Open file in the output directory and set the stream - bool OpenOutputFile(const std::string& path, + bool OpenOutputFile(const std::string& path, const std::string& name, cmGeneratedFileStream& stream, bool compress = false); @@ -147,7 +150,7 @@ bool GetShowOnly(); /** - * Run a single executable command and put the stdout and stderr + * Run a single executable command and put the stdout and stderr * in output. * * If verbose is false, no user-viewable output from the program @@ -157,19 +160,19 @@ * timeout expires. Timeout is specified in seconds. * * Argument retVal should be a pointer to the location where the - * exit code will be stored. If the retVal is not specified and - * the program exits with a code other than 0, then the this + * exit code will be stored. If the retVal is not specified and + * the program exits with a code other than 0, then the this * function will return false. * * If the command has spaces in the path the caller MUST call * cmSystemTools::ConvertToRunCommandPath on the command before passing * it into this function or it will not work. The command must be correctly - * escaped for this to with spaces. + * escaped for this to with spaces. */ bool RunCommand(const char* command, std::string* stdOut, std::string* stdErr, int* retVal = 0, const char* dir = 0, double timeout = 0.0); - + //! Start CTest XML output file void StartXML(std::ostream& ostr); @@ -179,7 +182,7 @@ //! Run command specialized for make and configure. Returns process status // and retVal is return value or exception. int RunMakeCommand(const char* command, std::string* output, - int* retVal, const char* dir, int timeout, + int* retVal, const char* dir, int timeout, std::ofstream& ofs); /* @@ -189,14 +192,14 @@ //! Get the path to the build tree std::string GetBinaryDir(); - + //! Get the short path to the file. This means if the file is in binary or //source directory, it will become /.../relative/path/to/file std::string GetShortPathToFile(const char* fname); //! Get the path to CTest - const char* GetCTestExecutable() { return m_CTestSelf.c_str(); } - const char* GetCMakeExecutable() { return m_CMakeSelf.c_str(); } + const char* GetCTestExecutable() { return this->CTestSelf.c_str(); } + const char* GetCMakeExecutable() { return this->CMakeSelf.c_str(); } enum { EXPERIMENTAL, @@ -221,15 +224,16 @@ //! Run command specialized for tests. Returns process status and retVal is // return value or exception. - int RunTest(std::vector args, std::string* output, int *retVal, + int RunTest(std::vector args, std::string* output, int *retVal, std::ostream* logfile); /** - * Execute handler and return its result. If the handler fails, it returns negative value. + * Execute handler and return its result. If the handler fails, it returns + * negative value. */ int ExecuteHandler(const char* handler); - /* + /* * Get the handler object */ cmCTestGenericHandler* GetHandler(const char* handler); @@ -238,16 +242,17 @@ /* * Set the CTest variable from CMake variable */ - bool SetCTestConfigurationFromCMakeVariable(cmMakefile* mf, const char* dconfig, const char* cmake_var); + bool SetCTestConfigurationFromCMakeVariable(cmMakefile* mf, + const char* dconfig, const char* cmake_var); //! Make string safe to be send as an URL static std::string MakeURLSafe(const std::string&); - //! Should ctect configuration be updated. When using new style ctest script, - // this should be true. + //! Should ctect configuration be updated. When using new style ctest + // script, this should be true. void SetSuppressUpdatingCTestConfiguration(bool val) { - m_SuppressUpdatingCTestConfiguration = val; + this->SuppressUpdatingCTestConfiguration = val; } //! Add overwrite to ctest configuration. @@ -279,29 +284,29 @@ void Log(int logType, const char* file, int line, const char* msg); //! Get the version of dart server - int GetDartVersion() { return m_DartVersion; } + int GetDartVersion() { return this->DartVersion; } //! Add file to be submitted void AddSubmitFile(const char* name); - tm_SetOfStrings* GetSubmitFiles() { return &m_SubmitFiles; } + SetOfStrings* GetSubmitFiles() { return &this->SubmitFiles; } private: - std::string m_ConfigType; - bool m_Verbose; - bool m_ExtraVerbose; - bool m_ProduceXML; + std::string ConfigType; + bool Verbose; + bool ExtraVerbose; + bool ProduceXML; - bool m_ForceNewCTestProcess; + bool ForceNewCTestProcess; - bool m_RunConfigurationScript; + bool RunConfigurationScript; int GenerateNotesFile(const char* files); // these are helper classes typedef std::map t_TestingHandlers; - t_TestingHandlers m_TestingHandlers; - - bool m_ShowOnly; + t_TestingHandlers TestingHandlers; + + bool ShowOnly; enum { FIRST_TEST = 0, @@ -317,75 +322,78 @@ ALL_TEST = 10, LAST_TEST = 11 }; - + //! Map of configuration properties - typedef std::map tm_CTestConfigurationMap; + typedef std::map CTestConfigurationMap; - std::string m_CTestConfigFile; - tm_CTestConfigurationMap m_CTestConfiguration; - tm_CTestConfigurationMap m_CTestConfigurationOverwrites; - int m_Tests[LAST_TEST]; - - std::string m_CurrentTag; - bool m_TomorrowTag; + std::string CTestConfigFile; + CTestConfigurationMap CTestConfiguration; + CTestConfigurationMap CTestConfigurationOverwrites; + int Tests[LAST_TEST]; - int m_TestModel; + std::string CurrentTag; + bool TomorrowTag; - double m_TimeOut; + int TestModel; - int m_CompatibilityMode; + double TimeOut; + + int CompatibilityMode; // information for the --build-and-test options - std::string m_CMakeSelf; - std::string m_CTestSelf; - std::string m_BinaryDir; + std::string CMakeSelf; + std::string CTestSelf; + std::string BinaryDir; + + std::string NotesFiles; - std::string m_NotesFiles; - int ReadCustomConfigurationFileTree(const char* dir); - bool m_InteractiveDebugMode; + bool InteractiveDebugMode; - bool m_ShortDateFormat; + bool ShortDateFormat; + + bool CompressXMLFiles; - bool m_CompressXMLFiles; - void BlockTestErrorDiagnostics(); - + //! Reread the configuration file bool UpdateCTestConfiguration(); //! Create not from files. - int GenerateCTestNotesOutput(std::ostream& os, const tm_VectorOfStrings& files); + int GenerateCTestNotesOutput(std::ostream& os, + const VectorOfStrings& files); ///! Find the running cmake void FindRunningCMake(const char* arg0); //! Check if the argument is the one specified - bool CheckArgument(const std::string& arg, const char* varg1, const char* varg2 = 0); + bool CheckArgument(const std::string& arg, const char* varg1, + const char* varg2 = 0); + + bool SuppressUpdatingCTestConfiguration; - bool m_SuppressUpdatingCTestConfiguration; + bool Debug; + bool ShowLineNumbers; + bool Quiet; - bool m_Debug; - bool m_ShowLineNumbers; - bool m_Quiet; + int DartVersion; - int m_DartVersion; + std::set SubmitFiles; - std::set m_SubmitFiles; + int SubmitIndex; - int m_SubmitIndex; - - cmGeneratedFileStream* m_OutputLogFile; - int m_OutputLogFileLastTag; + cmGeneratedFileStream* OutputLogFile; + int OutputLogFileLastTag; }; class cmCTestLogWrite { public: - cmCTestLogWrite(const char* data, size_t length) : Data(data), Length(length) {} + cmCTestLogWrite(const char* data, size_t length) + : Data(data), Length(length) {} const char* Data; size_t Length; @@ -393,6 +401,10 @@ inline std::ostream& operator<< (std::ostream& os, const cmCTestLogWrite& c) { + if (!c.Length) + { + return os; + } os.write(c.Data, c.Length); os.flush(); return os; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCustomCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCustomCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCustomCommand.cxx 2005-08-12 02:02:19.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCustomCommand.cxx 2006-03-16 00:01:59.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCustomCommand.cxx,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:19 $ - Version: $Revision: 1.11.2.1 $ + Date: $Date: 2006/03/15 16:01:59 $ + Version: $Revision: 1.16 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -19,49 +19,65 @@ //---------------------------------------------------------------------------- cmCustomCommand::cmCustomCommand() { + this->Used = false; } //---------------------------------------------------------------------------- cmCustomCommand::cmCustomCommand(const cmCustomCommand& r): - m_Output(r.m_Output), - m_Depends(r.m_Depends), - m_CommandLines(r.m_CommandLines), - m_Comment(r.m_Comment) + Output(r.Output), + Depends(r.Depends), + CommandLines(r.CommandLines), + Comment(r.Comment), + WorkingDirectory(r.WorkingDirectory) { + this->Used = false; } //---------------------------------------------------------------------------- cmCustomCommand::cmCustomCommand(const char* output, const std::vector& depends, const cmCustomCommandLines& commandLines, - const char* comment): - m_Output(output?output:""), - m_Depends(depends), - m_CommandLines(commandLines), - m_Comment(comment?comment:"") + const char* comment, + const char* workingDirectory): + Output(output?output:""), + Depends(depends), + CommandLines(commandLines), + Comment(comment?comment:""), + WorkingDirectory(workingDirectory?workingDirectory:"") { + this->Used = false; } //---------------------------------------------------------------------------- const char* cmCustomCommand::GetOutput() const { - return m_Output.c_str(); + return this->Output.c_str(); +} + +//---------------------------------------------------------------------------- +const char* cmCustomCommand::GetWorkingDirectory() const +{ + if(this->WorkingDirectory.size() == 0) + { + return 0; + } + return this->WorkingDirectory.c_str(); } //---------------------------------------------------------------------------- const std::vector& cmCustomCommand::GetDepends() const { - return m_Depends; + return this->Depends; } //---------------------------------------------------------------------------- const cmCustomCommandLines& cmCustomCommand::GetCommandLines() const { - return m_CommandLines; + return this->CommandLines; } //---------------------------------------------------------------------------- const char* cmCustomCommand::GetComment() const { - return m_Comment.c_str(); + return this->Comment.c_str(); } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCustomCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCustomCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmCustomCommand.h 2005-08-12 02:02:19.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmCustomCommand.h 2006-03-16 00:01:59.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCustomCommand.h,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:19 $ - Version: $Revision: 1.12.2.1 $ + Date: $Date: 2006/03/15 16:01:59 $ + Version: $Revision: 1.16 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -35,11 +35,15 @@ cmCustomCommand(const char* output, const std::vector& depends, const cmCustomCommandLines& commandLines, - const char* comment); + const char* comment, + const char* workingDirectory); /** Get the output file produced by the command. */ const char* GetOutput() const; + /** Get the working directory. */ + const char* GetWorkingDirectory() const; + /** Get the vector that holds the list of dependencies. */ const std::vector& GetDepends() const; @@ -49,11 +53,17 @@ /** Get the comment string for the command. */ const char* GetComment() const; + /** set get the used status of the command */ + void SetUsed() { this->Used = true;}; + bool IsUsed() { return this->Used;}; + private: - std::string m_Output; - std::vector m_Depends; - cmCustomCommandLines m_CommandLines; - std::string m_Comment; + std::string Output; + std::vector Depends; + cmCustomCommandLines CommandLines; + std::string Comment; + std::string WorkingDirectory; + bool Used; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmData.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmData.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmData.h 2002-10-24 06:03:26.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmData.h 2006-03-16 22:33:23.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmData.h,v $ Language: C++ - Date: $Date: 2002/10/23 22:03:26 $ - Version: $Revision: 1.3 $ + Date: $Date: 2006/03/16 14:33:23 $ + Version: $Revision: 1.4 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -31,13 +31,13 @@ class cmData { public: - cmData(const char* name): m_Name(name) {} + cmData(const char* name): Name(name) {} virtual ~cmData() {} const std::string& GetName() const - { return m_Name; } + { return this->Name; } protected: - std::string m_Name; + std::string Name; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsC.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsC.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsC.cxx 2005-10-17 20:49:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsC.cxx 2006-03-16 22:33:23.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDependsC.cxx,v $ Language: C++ - Date: $Date: 2005/10/17 12:49:39 $ - Version: $Revision: 1.8.2.3 $ + Date: $Date: 2006/03/16 14:33:23 $ + Version: $Revision: 1.21 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -18,11 +18,12 @@ #include "cmSystemTools.h" #include "cmFileTimeComparison.h" + #include // isspace //---------------------------------------------------------------------------- cmDependsC::cmDependsC(): - m_IncludePath(0), m_GeneratedFiles(0) + IncludePath(0), GeneratedFiles(0) { } @@ -30,23 +31,33 @@ // yummy look at all those constructor arguments cmDependsC::cmDependsC(std::vector const& includes, const char* scanRegex, const char* complainRegex, - std::set const& generatedFiles): - m_IncludePath(&includes), - m_IncludeRegexLine("^[ \t]*#[ \t]*include[ \t]*[<\"]([^\">]+)([\">])"), - m_IncludeRegexScan(scanRegex), - m_IncludeRegexComplain(complainRegex), - m_GeneratedFiles(&generatedFiles) + std::set const& generatedFiles, + const cmStdString& cacheFileName): + IncludePath(&includes), + IncludeRegexLine("^[ \t]*#[ \t]*include[ \t]*[<\"]([^\">]+)([\">])"), + IncludeRegexScan(scanRegex), + IncludeRegexComplain(complainRegex), + GeneratedFiles(&generatedFiles), + CacheFileName(cacheFileName) { + this->ReadCacheFile(); } //---------------------------------------------------------------------------- cmDependsC::~cmDependsC() { + this->WriteCacheFile(); + + for (std::map::iterator it= + this->fileCache.begin(); it!=this->fileCache.end(); ++it) + { + delete it->second; + } } //---------------------------------------------------------------------------- -bool cmDependsC::WriteDependencies(const char *src, - const char *obj, std::ostream& os) +bool cmDependsC::WriteDependencies(const char *src, const char *obj, + std::ostream& makeDepends, std::ostream& internalDepends) { // Make sure this is a scanning instance. if(!src || src[0] == '\0') @@ -59,7 +70,7 @@ cmSystemTools::Error("Cannot scan dependencies without an object file."); return false; } - if(!m_IncludePath) + if(!this->IncludePath) { cmSystemTools::Error("Cannot scan dependencies without an include path."); return false; @@ -69,16 +80,16 @@ bool first = true; UnscannedEntry root; root.FileName = src; - m_Unscanned.push(root); - m_Encountered.clear(); - m_Encountered.insert(src); + this->Unscanned.push(root); + this->Encountered.clear(); + this->Encountered.insert(src); std::set dependencies; std::set scanned; - while(!m_Unscanned.empty()) + while(!this->Unscanned.empty()) { // Get the next file to scan. - UnscannedEntry current = m_Unscanned.front(); - m_Unscanned.pop(); + UnscannedEntry current = this->Unscanned.front(); + this->Unscanned.pop(); // If not a full path, find the file in the include path. std::string fullName; @@ -101,8 +112,8 @@ } else { - for(std::vector::const_iterator i = m_IncludePath->begin(); - i != m_IncludePath->end(); ++i) + for(std::vector::const_iterator i = this->IncludePath->begin(); + i != this->IncludePath->end(); ++i) { // Construct the name of the file as if it were in the current // include directory. Avoid using a leading "./". @@ -129,7 +140,7 @@ // Complain if the file cannot be found and matches the complain // regex. if(fullName.empty() && - m_IncludeRegexComplain.find(current.FileName.c_str())) + this->IncludeRegexComplain.find(current.FileName.c_str())) { cmSystemTools::Error("Cannot find file \"", current.FileName.c_str(), "\"."); @@ -142,18 +153,41 @@ // Record scanned files. scanned.insert(fullName); - // Try to scan the file. Just leave it out if we cannot find - // it. - std::ifstream fin(fullName.c_str()); - if(fin) + // Check whether this file is already in the cache + std::map::iterator fileIt= + this->fileCache.find(fullName); + if (fileIt!=this->fileCache.end()) { - // Add this file as a dependency. + fileIt->second->Used=true; dependencies.insert(fullName); + for (std::vector::const_iterator incIt= + fileIt->second->UnscannedEntries.begin(); + incIt!=fileIt->second->UnscannedEntries.end(); ++incIt) + { + if (this->Encountered.find(incIt->FileName) == + this->Encountered.end()) + { + this->Encountered.insert(incIt->FileName); + this->Unscanned.push(*incIt); + } + } + } + else + { + + // Try to scan the file. Just leave it out if we cannot find + // it. + std::ifstream fin(fullName.c_str()); + if(fin) + { + // Add this file as a dependency. + dependencies.insert(fullName); - // Scan this file for new dependencies. Pass the directory - // containing the file to handle double-quote includes. - std::string dir = cmSystemTools::GetFilenamePath(fullName); - this->Scan(fin, dir.c_str()); + // Scan this file for new dependencies. Pass the directory + // containing the file to handle double-quote includes. + std::string dir = cmSystemTools::GetFilenamePath(fullName); + this->Scan(fin, dir.c_str(), fullName); + } } } @@ -161,105 +195,140 @@ } // Write the dependencies to the output stream. + internalDepends << obj << std::endl; for(std::set::iterator i=dependencies.begin(); i != dependencies.end(); ++i) { - os << obj << ": " - << cmSystemTools::ConvertToOutputPath(i->c_str()).c_str() - << std::endl; + makeDepends << obj << ": " + << cmSystemTools::ConvertToOutputPath(i->c_str()).c_str() + << std::endl; + internalDepends << " " << i->c_str() << std::endl; } - os << std::endl; + makeDepends << std::endl; return true; } //---------------------------------------------------------------------------- -bool cmDependsC::CheckDependencies(std::istream& is) +void cmDependsC::ReadCacheFile() { - // Parse dependencies from the stream. If any dependee is missing - // or newer than the depender then dependencies should be - // regenerated. - bool okay = true; + if(this->CacheFileName.size() == 0) + { + return; + } + std::ifstream fin(this->CacheFileName.c_str()); + if(!fin) + { + return; + } + std::string line; - std::string depender; - std::string dependee; - while(cmSystemTools::GetLineFromStream(is, line)) + cmIncludeLines* cacheEntry=0; + bool haveFileName=false; + + while(cmSystemTools::GetLineFromStream(fin, line)) { - // Parse the dependency line. - if(!this->ParseDependency(line.c_str(), depender, dependee)) + if (line.empty()) { + cacheEntry=0; + haveFileName=false; continue; } - - // Dependencies must be regenerated if the dependee does not exist - // or if the depender exists and is older than the dependee. - bool regenerate = false; - if(!cmSystemTools::FileExists(dependee.c_str())) + //the first line after an empty line is the name of the parsed file + if (haveFileName==false) { - // The dependee does not exist. - regenerate = true; - - // Print verbose output. - if(m_Verbose) + haveFileName=true; + int newer=0; + cmFileTimeComparison comp; + bool res=comp.FileTimeCompare(this->CacheFileName.c_str(), + line.c_str(), &newer); + + if ((res==true) && (newer==1)) //cache is newer than the parsed file { - cmOStringStream msg; - msg << "Dependee \"" << dependee - << "\" does not exist for depender \"" - << depender << "\"." << std::endl; - cmSystemTools::Stdout(msg.str().c_str()); + cacheEntry=new cmIncludeLines; + this->fileCache[line]=cacheEntry; } } - else if(cmSystemTools::FileExists(depender.c_str())) + else if (cacheEntry!=0) { - // The dependee and depender both exist. Compare file times. - int result = 0; - if((!m_FileComparison->FileTimeCompare(depender.c_str(), dependee.c_str(), - &result) || result < 0)) + UnscannedEntry entry; + entry.FileName = line; + if (cmSystemTools::GetLineFromStream(fin, line)) { - // The depender is older than the dependee. - regenerate = true; - - // Print verbose output. - if(m_Verbose) + if (line!="-") { - cmOStringStream msg; - msg << "Dependee \"" << dependee - << "\" is newer than depender \"" - << depender << "\"." << std::endl; - cmSystemTools::Stdout(msg.str().c_str()); + entry.QuotedLocation=line; } + cacheEntry->UnscannedEntries.push_back(entry); } } - if(regenerate) - { - // Dependencies must be regenerated. - okay = false; + } +} - // Remove the depender to be sure it is rebuilt. - cmSystemTools::RemoveFile(depender.c_str()); - } +//---------------------------------------------------------------------------- +void cmDependsC::WriteCacheFile() const +{ + if(this->CacheFileName.size() == 0) + { + return; + } + std::ofstream cacheOut(this->CacheFileName.c_str()); + if(!cacheOut) + { + return; } + + for (std::map::const_iterator fileIt= + this->fileCache.begin(); + fileIt!=this->fileCache.end(); ++fileIt) + { + if (fileIt->second->Used) + { + cacheOut<first.c_str()<::const_iterator + incIt=fileIt->second->UnscannedEntries.begin(); + incIt!=fileIt->second->UnscannedEntries.end(); ++incIt) + { + cacheOut<FileName.c_str()<QuotedLocation.empty()) + { + cacheOut<<"-"<QuotedLocation.c_str()<Used=true; + this->fileCache[fullName]=newCacheEntry; + // Read one line at a time. std::string line; while(cmSystemTools::GetLineFromStream(is, line)) { // Match include directives. - if(m_IncludeRegexLine.find(line.c_str())) + if(this->IncludeRegexLine.find(line.c_str())) { // Get the file being included. UnscannedEntry entry; - entry.FileName = m_IncludeRegexLine.match(1); - if(m_IncludeRegexLine.match(2) == "\"") + entry.FileName = this->IncludeRegexLine.match(1); + if(this->IncludeRegexLine.match(2) == "\"" && + !cmSystemTools::FileIsFullPath(entry.FileName.c_str())) { - // This was a double-quoted include. We must check for the - // file in the directory containing the file we are scanning. + // This was a double-quoted include with a relative path. We + // must check for the file in the directory containing the + // file we are scanning. entry.QuotedLocation = directory; entry.QuotedLocation += "/"; entry.QuotedLocation += entry.FileName; @@ -272,95 +341,53 @@ // is included by double-quotes and the other by angle brackets. // This kind of problem will be fixed when a more // preprocessor-like implementation of this scanner is created. - if(m_Encountered.find(entry.FileName) == m_Encountered.end() && - m_IncludeRegexScan.find(entry.FileName.c_str())) + if (this->IncludeRegexScan.find(entry.FileName.c_str())) { - m_Encountered.insert(entry.FileName); - m_Unscanned.push(entry); + newCacheEntry->UnscannedEntries.push_back(entry); + if(this->Encountered.find(entry.FileName) == this->Encountered.end()) + { + this->Encountered.insert(entry.FileName); + this->Unscanned.push(entry); + } } } } } //---------------------------------------------------------------------------- -bool cmDependsC::ParseDependency(const char* line, std::string& depender, - std::string& dependee) -{ - // Start with empty names. - depender = ""; - dependee = ""; - - // Get the left-hand-side of the dependency. - const char* c = this->ParseFileName(line, depender); - - // Skip the ':' separator. - for(;c && *c && isspace(*c);++c); - if(!c || !*c || *c != ':') - { - return false; - } - ++c; - - // Get the right-hand-side of the dependency. - return this->ParseFileName(c, dependee)?true:false; -} - -//---------------------------------------------------------------------------- -const char* cmDependsC::ParseFileName(const char* in, std::string& name) +bool cmDependsC::FileExistsOrIsGenerated(const std::string& fname, + std::set& scanned, + std::set& dependencies) { - // Skip leading whitespace. - const char* c = in; - for(;c && *c && isspace(*c);++c); - - // If this is an empty line or a comment line return failure. - if(!c || !*c || *c == '#') + // Check for a generated file. + if(this->FileIsGenerated(fname, scanned, dependencies)) { - return 0; + return true; } - - // Parse the possibly quoted file name. - bool quoted = false; - char* buf = new char[strlen(in)+1]; - char* pos = buf; - - // for every character while we haven't hit the end of the string AND we - // are in a quoted string OR the current character isn't a : or the second - // character AND it isn't a space - for(;*c && (quoted || - ((*c != ':' || pos == buf+1) && !isspace(*c))); ++c) + else if(cmSystemTools::FileIsFullPath(fname.c_str())) { - if(*c == '"') - { - quoted = !quoted; - } - // handle unquoted escaped spaces - else if(!quoted && *c == '\\' && isspace(*(c+1))) + // The generated file may have been listed with a relative path. + std::string dir = cmSystemTools::CollapseFullPath(this->Directory.c_str()); + std::string rname = + cmSystemTools::RelativePath(dir.c_str(), fname.c_str()); + if(this->FileIsGenerated(rname, scanned, dependencies)) { - *pos = *(++c); - pos++; - } - else - { - *pos = *c; - pos++; + return true; } } - *pos =0; - name += buf; - delete [] buf; - // Return the ending position. - return c; + + // Check for an existing file. + return cmSystemTools::FileExists(fname.c_str()); } //---------------------------------------------------------------------------- -bool cmDependsC::FileExistsOrIsGenerated(const std::string& fname, - std::set& scanned, - std::set& dependencies) +bool cmDependsC::FileIsGenerated(const std::string& fname, + std::set& scanned, + std::set& dependencies) { - // Check first for a generated file. - if(m_GeneratedFiles && - std::set::const_iterator(m_GeneratedFiles->find(fname)) != - m_GeneratedFiles->end()) + if(this->GeneratedFiles && + std::set::const_iterator(this->GeneratedFiles->find(fname)) != + this->GeneratedFiles->end()) { // If the file does not really exist yet pretend it has already // been scanned. When it exists later then dependencies will be @@ -374,6 +401,6 @@ } else { - return cmSystemTools::FileExists(fname.c_str()); + return false; } } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsC.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsC.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsC.h 2005-08-30 04:19:32.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsC.h 2006-03-16 22:33:23.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDependsC.h,v $ Language: C++ - Date: $Date: 2005/08/29 20:19:32 $ - Version: $Revision: 1.6.2.2 $ + Date: $Date: 2006/03/16 14:33:23 $ + Version: $Revision: 1.17 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -32,53 +32,71 @@ cmDependsC(); cmDependsC(std::vector const& includes, const char* scanRegex, const char* complainRegex, - std::set const& generatedFiles); + std::set const& generatedFiles, + const cmStdString& cachFileName); /** Virtual destructor to cleanup subclasses properly. */ virtual ~cmDependsC(); - + protected: + typedef std::vector t_CharBuffer; + // Implement writing/checking methods required by superclass. - virtual bool WriteDependencies(const char *src, - const char *file, std::ostream& os); - virtual bool CheckDependencies(std::istream& is); + virtual bool WriteDependencies(const char *src, + const char *file, + std::ostream& makeDepends, + std::ostream& internalDepends); // Method to scan a single file. - void Scan(std::istream& is, const char* directory); - - // Method to parse a single dependency line. - bool ParseDependency(const char* line, std::string& depender, - std::string& dependee); - const char* ParseFileName(const char* in, std::string& name); + void Scan(std::istream& is, const char* directory, + const cmStdString& fullName); // Method to test for the existence of a file. bool FileExistsOrIsGenerated(const std::string& fname, std::set& scanned, std::set& dependencies); + bool FileIsGenerated(const std::string& fname, + std::set& scanned, + std::set& dependencies); // The include file search path. - std::vector const* m_IncludePath; + std::vector const* IncludePath; // Regular expression to identify C preprocessor include directives. - cmsys::RegularExpression m_IncludeRegexLine; + cmsys::RegularExpression IncludeRegexLine; // Regular expressions to choose which include files to scan // recursively and which to complain about not finding. - cmsys::RegularExpression m_IncludeRegexScan; - cmsys::RegularExpression m_IncludeRegexComplain; - - // Set of generated files available. - std::set const* m_GeneratedFiles; + cmsys::RegularExpression IncludeRegexScan; + cmsys::RegularExpression IncludeRegexComplain; + // Set of generated files available. + std::set const* GeneratedFiles; +public: // Data structures for dependency graph walk. struct UnscannedEntry { cmStdString FileName; cmStdString QuotedLocation; }; - std::set m_Encountered; - std::queue m_Unscanned; + struct cmIncludeLines + { + cmIncludeLines(): Used(false) {} + std::vector UnscannedEntries; + bool Used; + }; +protected: + std::set Encountered; + std::queue Unscanned; + t_CharBuffer Buffer; + + std::map fileCache; + + cmStdString CacheFileName; + + void WriteCacheFile() const; + void ReadCacheFile(); private: cmDependsC(cmDependsC const&); // Purposely not implemented. void operator=(cmDependsC const&); // Purposely not implemented. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDepends.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDepends.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDepends.cxx 2005-10-17 20:49:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDepends.cxx 2006-03-16 00:01:59.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDepends.cxx,v $ Language: C++ - Date: $Date: 2005/10/17 12:49:39 $ - Version: $Revision: 1.7.2.2 $ + Date: $Date: 2006/03/15 16:01:59 $ + Version: $Revision: 1.12 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -19,45 +19,50 @@ #include "cmGeneratedFileStream.h" #include "cmSystemTools.h" #include "cmFileTimeComparison.h" - -#include +#include //---------------------------------------------------------------------------- -cmDepends::cmDepends():m_FileComparison(0) +cmDepends::cmDepends(): Verbose(false), FileComparison(0), + MaxPath(cmSystemTools::GetMaximumFilePathLength()), + Dependee(new char[MaxPath]), + Depender(new char[MaxPath]) { - m_Verbose = false; } //---------------------------------------------------------------------------- cmDepends::~cmDepends() { + delete [] this->Dependee; + delete [] this->Depender; } //---------------------------------------------------------------------------- -bool cmDepends::Write(const char *src, const char *obj, std::ostream &fout) +bool cmDepends::Write(const char *src, const char *obj, + std::ostream &makeDepends, std::ostream &internalDepends) { - return this->WriteDependencies(src, obj, fout); + return this->WriteDependencies(src, obj, makeDepends, internalDepends); } //---------------------------------------------------------------------------- -void cmDepends::Check(const char *file) +void cmDepends::Check(const char *makeFile, const char *internalFile) { // Dependency checks must be done in proper working directory. std::string oldcwd = "."; - if(m_CompileDirectory != ".") + if(this->CompileDirectory != ".") { // Get the CWD but do not call CollapseFullPath because // we only need it to cd back, and the form does not matter oldcwd = cmSystemTools::GetCurrentWorkingDirectory(false); - cmSystemTools::ChangeDirectory(m_CompileDirectory.c_str()); + cmSystemTools::ChangeDirectory(this->CompileDirectory.c_str()); } // Check whether dependencies must be regenerated. - std::ifstream fin(file); + std::ifstream fin(internalFile); if(!(fin && this->CheckDependencies(fin))) { // Clear all dependencies so they will be regenerated. - this->Clear(file); + this->Clear(makeFile); + this->Clear(internalFile); } // Restore working directory. @@ -71,7 +76,7 @@ void cmDepends::Clear(const char *file) { // Print verbose output. - if(m_Verbose) + if(this->Verbose) { cmOStringStream msg; msg << "Clearing dependencies in \"" << file << "\"." << std::endl; @@ -83,7 +88,7 @@ std::string markFile = file; markFile += ".mark"; cmSystemTools::RemoveFile(markFile.c_str()); - + // Write an empty dependency file. cmGeneratedFileStream depFileStream(file); depFileStream @@ -91,3 +96,90 @@ << "# This may be replaced when dependencies are built." << std::endl; } +//---------------------------------------------------------------------------- +bool cmDepends::CheckDependencies(std::istream& internalDepends) +{ + // Parse dependencies from the stream. If any dependee is missing + // or newer than the depender then dependencies should be + // regenerated. + bool okay = true; + while(internalDepends.getline(this->Dependee, this->MaxPath)) + { + if ( this->Dependee[0] == 0 || this->Dependee[0] == '#' || this->Dependee[0] == '\r' ) + { + continue; + } + size_t len = internalDepends.gcount()-1; + if ( this->Dependee[len-1] == '\r' ) + { + len --; + this->Dependee[len] = 0; + } + if ( this->Dependee[0] != ' ' ) + { + memcpy(this->Depender, this->Dependee, len+1); + continue; + } + /* + // Parse the dependency line. + if(!this->ParseDependency(line.c_str())) + { + continue; + } + */ + + // Dependencies must be regenerated if the dependee does not exist + // or if the depender exists and is older than the dependee. + bool regenerate = false; + const char* dependee = this->Dependee+1; + const char* depender = this->Depender; + if(!cmSystemTools::FileExists(dependee)) + { + // The dependee does not exist. + regenerate = true; + + // Print verbose output. + if(this->Verbose) + { + cmOStringStream msg; + msg << "Dependee \"" << dependee + << "\" does not exist for depender \"" + << depender << "\"." << std::endl; + cmSystemTools::Stdout(msg.str().c_str()); + } + } + else if(cmSystemTools::FileExists(depender)) + { + // The dependee and depender both exist. Compare file times. + int result = 0; + if((!this->FileComparison->FileTimeCompare(depender, dependee, + &result) || result < 0)) + { + // The depender is older than the dependee. + regenerate = true; + + // Print verbose output. + if(this->Verbose) + { + cmOStringStream msg; + msg << "Dependee \"" << dependee + << "\" is newer than depender \"" + << depender << "\"." << std::endl; + cmSystemTools::Stdout(msg.str().c_str()); + } + } + } + if(regenerate) + { + // Dependencies must be regenerated. + okay = false; + + // Remove the depender to be sure it is rebuilt. + cmSystemTools::RemoveFile(depender); + } + } + + return okay; +} + + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsFortran.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsFortran.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsFortran.cxx 2005-08-12 02:02:19.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsFortran.cxx 2006-03-16 00:02:00.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDependsFortran.cxx,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:19 $ - Version: $Revision: 1.15.2.1 $ + Date: $Date: 2006/03/15 16:02:00 $ + Version: $Revision: 1.18 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -77,13 +77,13 @@ //---------------------------------------------------------------------------- cmDependsFortran::cmDependsFortran(): - m_IncludePath(0) + IncludePath(0) { } //---------------------------------------------------------------------------- cmDependsFortran::cmDependsFortran(std::vector const& includes): - m_IncludePath(&includes) + IncludePath(&includes) { } @@ -93,8 +93,8 @@ } //---------------------------------------------------------------------------- -bool cmDependsFortran::WriteDependencies(const char *src, - const char *obj, std::ostream& os) +bool cmDependsFortran::WriteDependencies(const char *src, const char *obj, + std::ostream& makeDepends, std::ostream& internalDepends) { // Make sure this is a scanning instance. if(!src || src[0] == '\0') @@ -107,7 +107,7 @@ cmSystemTools::Error("Cannot scan dependencies without an object file."); return false; } - if(!m_IncludePath) + if(!this->IncludePath) { cmSystemTools::Error("Cannot scan dependencies without an include path."); return false; @@ -127,16 +127,19 @@ } // Write the include dependencies to the output stream. + internalDepends << obj << std::endl; for(std::set::const_iterator i = parser.Includes.begin(); i != parser.Includes.end(); ++i) { - os << obj << ": " + makeDepends << obj << ": " << cmSystemTools::ConvertToOutputPath(i->c_str()).c_str() << std::endl; + internalDepends << " " << i->c_str() << std::endl; } - os << std::endl; + makeDepends << std::endl; // Write module requirements to the output stream. + internalDepends << obj << ".requires" << std::endl; for(std::set::const_iterator i = parser.Requires.begin(); i != parser.Requires.end(); ++i) { @@ -144,23 +147,26 @@ if(parser.Provides.find(*i) == parser.Provides.end()) { // since we require some things add them to our list of requirements - os << obj << ".requires: " << i->c_str() << ".mod.proxy" + makeDepends << obj << ".requires: " << i->c_str() << ".mod.proxy" << std::endl; + internalDepends << " " << i->c_str() << ".mod.proxy" << std::endl; } } // Write provided modules to the output stream. + internalDepends << obj << ".mod.proxy" << std::endl; for(std::set::const_iterator i = parser.Provides.begin(); i != parser.Provides.end(); ++i) { - os << i->c_str() << ".mod.proxy: " << obj - << ".provides" << std::endl; + makeDepends << i->c_str() << ".mod.proxy: " << obj + << ".provides" << std::endl; + internalDepends << " " << i->c_str() << ".provides" << std::endl; } // If any modules are provided then they must be converted to stamp files. if(!parser.Provides.empty()) { - os << obj << ".provides.build:\n"; + makeDepends << obj << ".provides.build:\n"; for(std::set::const_iterator i = parser.Provides.begin(); i != parser.Provides.end(); ++i) { @@ -168,10 +174,10 @@ // cmake_copy_f90_mod will call back to this class, which will // try various cases for the real mod file name. std::string m = cmSystemTools::LowerCase(*i); - os << "\t$(CMAKE_COMMAND) -E cmake_copy_f90_mod " + makeDepends << "\t$(CMAKE_COMMAND) -E cmake_copy_f90_mod " << i->c_str() << " " << m.c_str() << ".mod.stamp\n"; } - os << "\t@touch " << obj << ".provides.build\n"; + makeDepends << "\t@touch " << obj << ".provides.build\n"; } /* @@ -232,13 +238,6 @@ } //---------------------------------------------------------------------------- -bool cmDependsFortran::CheckDependencies(std::istream&) -{ - // TODO: Parse and check dependencies. - return true; -} - -//---------------------------------------------------------------------------- bool cmDependsFortran::CopyModule(const std::vector& args) { // Implements @@ -312,8 +311,8 @@ } // Search the include path for the file. - for(std::vector::const_iterator i = m_IncludePath->begin(); - i != m_IncludePath->end(); ++i) + for(std::vector::const_iterator i = this->IncludePath->begin(); + i != this->IncludePath->end(); ++i) { fullName = *i; fullName += "/"; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsFortran.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsFortran.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsFortran.h 2005-08-12 02:02:19.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsFortran.h 2006-03-16 00:02:00.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDependsFortran.h,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:19 $ - Version: $Revision: 1.4.2.1 $ + Date: $Date: 2006/03/15 16:02:00 $ + Version: $Revision: 1.7 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -51,15 +51,15 @@ protected: // Implement writing/checking methods required by superclass. - virtual bool WriteDependencies(const char *src, - const char *file, std::ostream& os); - virtual bool CheckDependencies(std::istream& is); + virtual bool WriteDependencies( + const char *src, const char *file, + std::ostream& makeDepends, std::ostream& internalDepends); // The source file from which to start scanning. - std::string m_SourceFile; + std::string SourceFile; // The include file search path. - std::vector const* m_IncludePath; + std::vector const* IncludePath; private: cmDependsFortran(cmDependsFortran const&); // Purposely not implemented. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsFortranLexer.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsFortranLexer.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsFortranLexer.cxx 2005-11-29 04:15:30.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsFortranLexer.cxx 2006-03-16 00:02:01.000000000 +0800 @@ -43,7 +43,7 @@ typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; +typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; #endif /* ! C99 */ @@ -164,8 +164,9 @@ #define EOB_ACT_LAST_MATCH 2 #define YY_LESS_LINENO(n) - -/* Return all but the first "n" matched characters back to the input stream. */ + +/* Return all but the first "n" matched characters back to the input stream. + */ #define yyless(n) \ do \ { \ @@ -174,7 +175,8 @@ YY_LESS_LINENO(yyless_macro_arg);\ *yy_cp = yyg->yy_hold_char; \ YY_RESTORE_YY_MORE_OFFSET \ - yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + yyg->yy_c_buf_p \ + = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) @@ -231,7 +233,7 @@ int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -248,8 +250,8 @@ * possible backing-up. * * When we actually see the EOF, we change the status to "new" - * (via cmDependsFortran_yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. + * (via cmDependsFortran_yyrestart()), so that the user can continue + * scanning by just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 @@ -594,8 +596,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDependsFortranLexer.cxx,v $ Language: C++ - Date: $Date: 2005/11/28 20:15:30 $ - Version: $Revision: 1.2.2.1 $ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.5 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -774,7 +776,7 @@ #endif static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner); - + #ifndef yytext_ptr static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); #endif @@ -1396,10 +1398,10 @@ else { - size_t num_to_read = + size_t nuto_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - while ( num_to_read <= 0 ) + while ( nuto_read <= 0 ) { /* Not enough room in the buffer - grow it. */ /* just a shorter name for the current buffer */ @@ -1431,17 +1433,17 @@ yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + nuto_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; } - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; + if ( nuto_read > YY_READ_BUF_SIZE ) + nuto_read = YY_READ_BUF_SIZE; /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, num_to_read ); + yyg->yy_n_chars, nuto_read ); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; } @@ -1722,7 +1724,7 @@ YY_BUFFER_STATE cmDependsFortran_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - + b = (YY_BUFFER_STATE) cmDependsFortran_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in cmDependsFortran_yy_create_buffer()" ); @@ -1766,7 +1768,7 @@ #ifndef __cplusplus extern int isatty (int ); #endif /* __cplusplus */ - + /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a cmDependsFortran_yyrestart() or at EOF. @@ -1792,7 +1794,7 @@ } b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - + errno = oerrno; } @@ -1883,7 +1885,7 @@ */ static void cmDependsFortran_yyensure_buffer_stack (yyscan_t yyscanner) { - int num_to_alloc; + int nuto_alloc; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!yyg->yy_buffer_stack) { @@ -1892,14 +1894,15 @@ * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ - num_to_alloc = 1; + nuto_alloc = 1; yyg->yy_buffer_stack = (struct yy_buffer_state**)cmDependsFortran_yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) + (nuto_alloc * sizeof(struct yy_buffer_state*) , yyscanner); - memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + memset(yyg->yy_buffer_stack, 0, + nuto_alloc * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_max = nuto_alloc; yyg->yy_buffer_stack_top = 0; return; } @@ -1909,15 +1912,15 @@ /* Increase the buffer to prepare for a possible push. */ int grow_size = 8 /* arbitrary grow size */; - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + nuto_alloc = yyg->yy_buffer_stack_max + grow_size; yyg->yy_buffer_stack = (struct yy_buffer_state**)cmDependsFortran_yyrealloc (yyg->yy_buffer_stack, - num_to_alloc * sizeof(struct yy_buffer_state*) + nuto_alloc * sizeof(struct yy_buffer_state*) , yyscanner); /* zero only the new slots.*/ memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_max = nuto_alloc; } } @@ -1925,12 +1928,12 @@ * @param base the character buffer * @param size the size in bytes of the character buffer * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. + * @return the newly allocated buffer state object. */ YY_BUFFER_STATE cmDependsFortran_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - + if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) @@ -1966,7 +1969,7 @@ */ YY_BUFFER_STATE cmDependsFortran_yy_scan_string (yyconst char * yy_str , yyscan_t yyscanner) { - + return cmDependsFortran_yy_scan_bytes(yy_str,strlen(yy_str) ,yyscanner); } @@ -1983,7 +1986,7 @@ char *buf; yy_size_t n; int i; - + /* Get memory for full buffer, including space for trailing EOB's. */ n = len + 2; buf = (char *) cmDependsFortran_yyalloc(n ,yyscanner ); @@ -2051,10 +2054,10 @@ int cmDependsFortran_yyget_lineno (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - + if (! YY_CURRENT_BUFFER) return 0; - + return yylineno; } @@ -2064,10 +2067,10 @@ int cmDependsFortran_yyget_column (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - + if (! YY_CURRENT_BUFFER) return 0; - + return yycolumn; } @@ -2128,8 +2131,8 @@ /* lineno is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "cmDependsFortran_yyset_lineno called with no buffer" , yyscanner); - + yy_fatal_error( "cmDependsFortran_yyset_lineno called with no buffer" , yyscanner); + yylineno = line_number; } @@ -2143,8 +2146,8 @@ /* column is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "cmDependsFortran_yyset_column called with no buffer" , yyscanner); - + yy_fatal_error( "cmDependsFortran_yyset_column called with no buffer" , yyscanner); + yycolumn = column_no; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsFortranLexer.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsFortranLexer.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsFortranLexer.h 2005-02-01 23:42:34.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsFortranLexer.h 2006-03-11 02:06:26.000000000 +0800 @@ -43,7 +43,7 @@ typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; +typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; #endif /* ! C99 */ @@ -173,7 +173,7 @@ int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -185,16 +185,24 @@ #endif /* !YY_STRUCT_YY_BUFFER_STATE */ void cmDependsFortran_yyrestart (FILE *input_file ,yyscan_t yyscanner ); -void cmDependsFortran_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmDependsFortran_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); -void cmDependsFortran_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void cmDependsFortran_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void cmDependsFortran_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +void cmDependsFortran_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , + yyscan_t yyscanner ); +YY_BUFFER_STATE cmDependsFortran_yy_create_buffer (FILE *file,int size , + yyscan_t yyscanner ); +void cmDependsFortran_yy_delete_buffer (YY_BUFFER_STATE b , + yyscan_t yyscanner ); +void cmDependsFortran_yy_flush_buffer (YY_BUFFER_STATE b , + yyscan_t yyscanner ); +void cmDependsFortran_yypush_buffer_state (YY_BUFFER_STATE new_buffer , + yyscan_t yyscanner ); void cmDependsFortran_yypop_buffer_state (yyscan_t yyscanner ); -YY_BUFFER_STATE cmDependsFortran_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmDependsFortran_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmDependsFortran_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); +YY_BUFFER_STATE cmDependsFortran_yy_scan_buffer (char *base,yy_size_t size , + yyscan_t yyscanner ); +YY_BUFFER_STATE cmDependsFortran_yy_scan_string (yyconst char *yy_str , + yyscan_t yyscanner ); +YY_BUFFER_STATE cmDependsFortran_yy_scan_bytes (yyconst char *bytes,int len , + yyscan_t yyscanner ); void *cmDependsFortran_yyalloc (yy_size_t ,yyscan_t yyscanner ); void *cmDependsFortran_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); @@ -231,7 +239,8 @@ YY_EXTRA_TYPE cmDependsFortran_yyget_extra (yyscan_t yyscanner ); -void cmDependsFortran_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); +void cmDependsFortran_yyset_extra (YY_EXTRA_TYPE user_defined , + yyscan_t yyscanner ); FILE *cmDependsFortran_yyget_in (yyscan_t yyscanner ); @@ -294,7 +303,8 @@ #define YY_DECL int cmDependsFortran_yylex (yyscan_t yyscanner) #endif /* !YY_DECL */ -/* yy_get_previous_state - get the state just before the EOB char was reached */ +/* yy_get_previous_state - get the state just before the EOB char was reached + */ #undef YY_NEW_FILE #undef YY_FLUSH_BUFFER diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsFortranLexer.in.l /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsFortranLexer.in.l --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsFortranLexer.in.l 2005-11-29 04:15:30.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsFortranLexer.in.l 2005-10-17 21:58:53.000000000 +0800 @@ -4,8 +4,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDependsFortranLexer.in.l,v $ Language: C++ - Date: $Date: 2005/11/28 20:15:30 $ - Version: $Revision: 1.4.2.1 $ + Date: $Date: 2005/10/17 13:58:53 $ + Version: $Revision: 1.5 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsFortranParserTokens.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsFortranParserTokens.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsFortranParserTokens.h 2005-02-01 23:42:34.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsFortranParserTokens.h 2006-03-11 02:54:57.000000000 +0800 @@ -1,7 +1,7 @@ /* A Bison parser, made by GNU Bison 1.875d. */ -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +/* Skeleton parser for Yacc-like parsing with Bison, Copyright (C) 1984, + 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDepends.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDepends.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDepends.h 2005-10-17 20:49:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDepends.h 2006-03-16 00:02:00.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDepends.h,v $ Language: C++ - Date: $Date: 2005/10/17 12:49:39 $ - Version: $Revision: 1.5.2.2 $ + Date: $Date: 2006/03/15 16:02:00 $ + Version: $Revision: 1.8 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -36,45 +36,51 @@ cmDepends(); /** at what level will the compile be done from */ - void SetCompileDirectory(const char *dir) {m_CompileDirectory = dir;}; + void SetCompileDirectory(const char *dir) {this->CompileDirectory = dir;}; /** should this be verbose in its output */ - void SetVerbose(bool verb) { m_Verbose = verb; } + void SetVerbose(bool verb) { this->Verbose = verb; } /** Virtual destructor to cleanup subclasses properly. */ virtual ~cmDepends(); /** Write dependencies for the target file. */ - bool Write(const char *src, const char *obj, std::ostream &os); + bool Write(const char *src, const char *obj, + std::ostream &makeDepends, std::ostream &internalDepends); /** Check dependencies for the target file. */ - void Check(const char *file); + void Check(const char *makeFile, const char* internalFile); /** Clear dependencies for the target file so they will be regenerated. */ void Clear(const char *file); /** Set the file comparison object */ - void SetFileComparison(cmFileTimeComparison* fc) { m_FileComparison = fc; } + void SetFileComparison(cmFileTimeComparison* fc) { + this->FileComparison = fc; } protected: // Write dependencies for the target file to the given stream. // Return true for success and false for failure. - virtual bool WriteDependencies(const char *src, - const char* obj, std::ostream& os)=0; + virtual bool WriteDependencies(const char *src, const char* obj, + std::ostream& makeDepends, std::ostream& internalDepends)=0; // Check dependencies for the target file in the given stream. // Return false if dependencies must be regenerated and true // otherwise. - virtual bool CheckDependencies(std::istream& is) = 0; + virtual bool CheckDependencies(std::istream& internalDepends); // The directory in which the build rule for the target file is executed. - std::string m_Directory; - std::string m_CompileDirectory; + std::string Directory; + std::string CompileDirectory; // Flag for verbose output. - bool m_Verbose; - cmFileTimeComparison* m_FileComparison; + bool Verbose; + cmFileTimeComparison* FileComparison; + + size_t MaxPath; + char* Dependee; + char* Depender; private: cmDepends(cmDepends const&); // Purposely not implemented. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsJava.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsJava.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsJava.cxx 2005-08-12 02:02:19.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsJava.cxx 2005-10-13 01:52:29.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDependsJava.cxx,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:19 $ - Version: $Revision: 1.4.2.1 $ + Date: $Date: 2005/10/12 17:52:29 $ + Version: $Revision: 1.7 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -30,8 +30,8 @@ } //---------------------------------------------------------------------------- -bool cmDependsJava::WriteDependencies(const char *src, - const char *, std::ostream&) +bool cmDependsJava::WriteDependencies(const char *src, const char *, + std::ostream&, std::ostream&) { // Make sure this is a scanning instance. if(!src || src[0] == '\0') @@ -43,7 +43,6 @@ return true; } -//---------------------------------------------------------------------------- bool cmDependsJava::CheckDependencies(std::istream&) { return true; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsJava.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsJava.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsJava.h 2005-08-12 02:02:19.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsJava.h 2005-10-13 01:52:29.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDependsJava.h,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:19 $ - Version: $Revision: 1.3.2.1 $ + Date: $Date: 2005/10/12 17:52:29 $ + Version: $Revision: 1.5 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -34,9 +34,9 @@ protected: // Implement writing/checking methods required by superclass. - virtual bool WriteDependencies(const char *src, - const char *file, std::ostream& os); - virtual bool CheckDependencies(std::istream& is); + virtual bool WriteDependencies(const char *src, const char *file, + std::ostream& makeDepends, std::ostream& internalDepends); + virtual bool CheckDependencies(std::istream& internalDepends); private: cmDependsJava(cmDependsJava const&); // Purposely not implemented. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsJavaLexer.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsJavaLexer.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsJavaLexer.cxx 2005-05-04 03:19:34.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsJavaLexer.cxx 2006-03-16 00:02:01.000000000 +0800 @@ -641,8 +641,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDependsJavaLexer.cxx,v $ Language: C++ - Date: $Date: 2005/05/03 19:19:34 $ - Version: $Revision: 1.6 $ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.7 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -1672,10 +1672,10 @@ else { - size_t num_to_read = + size_t nuto_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - while ( num_to_read <= 0 ) + while ( nuto_read <= 0 ) { /* Not enough room in the buffer - grow it. */ /* just a shorter name for the current buffer */ @@ -1707,17 +1707,17 @@ yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + nuto_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; } - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; + if ( nuto_read > YY_READ_BUF_SIZE ) + nuto_read = YY_READ_BUF_SIZE; /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, num_to_read ); + yyg->yy_n_chars, nuto_read ); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; } @@ -2118,7 +2118,7 @@ */ static void cmDependsJava_yyensure_buffer_stack (yyscan_t yyscanner) { - int num_to_alloc; + int nuto_alloc; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!yyg->yy_buffer_stack) { @@ -2127,14 +2127,14 @@ * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ - num_to_alloc = 1; + nuto_alloc = 1; yyg->yy_buffer_stack = (struct yy_buffer_state**)cmDependsJava_yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) + (nuto_alloc * sizeof(struct yy_buffer_state*) , yyscanner); - memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + memset(yyg->yy_buffer_stack, 0, nuto_alloc * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_max = nuto_alloc; yyg->yy_buffer_stack_top = 0; return; } @@ -2144,15 +2144,15 @@ /* Increase the buffer to prepare for a possible push. */ int grow_size = 8 /* arbitrary grow size */; - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + nuto_alloc = yyg->yy_buffer_stack_max + grow_size; yyg->yy_buffer_stack = (struct yy_buffer_state**)cmDependsJava_yyrealloc (yyg->yy_buffer_stack, - num_to_alloc * sizeof(struct yy_buffer_state*) + nuto_alloc * sizeof(struct yy_buffer_state*) , yyscanner); /* zero only the new slots.*/ memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_max = nuto_alloc; } } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsJavaLexer.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsJavaLexer.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsJavaLexer.h 2005-02-01 23:44:34.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsJavaLexer.h 2006-03-11 02:54:57.000000000 +0800 @@ -185,16 +185,22 @@ #endif /* !YY_STRUCT_YY_BUFFER_STATE */ void cmDependsJava_yyrestart (FILE *input_file ,yyscan_t yyscanner ); -void cmDependsJava_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmDependsJava_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); +void cmDependsJava_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , + yyscan_t yyscanner ); +YY_BUFFER_STATE cmDependsJava_yy_create_buffer (FILE *file,int size , + yyscan_t yyscanner ); void cmDependsJava_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); void cmDependsJava_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void cmDependsJava_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +void cmDependsJava_yypush_buffer_state (YY_BUFFER_STATE new_buffer , + yyscan_t yyscanner ); void cmDependsJava_yypop_buffer_state (yyscan_t yyscanner ); -YY_BUFFER_STATE cmDependsJava_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmDependsJava_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmDependsJava_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); +YY_BUFFER_STATE cmDependsJava_yy_scan_buffer (char *base,yy_size_t size , + yyscan_t yyscanner ); +YY_BUFFER_STATE cmDependsJava_yy_scan_string (yyconst char *yy_str , + yyscan_t yyscanner ); +YY_BUFFER_STATE cmDependsJava_yy_scan_bytes (yyconst char *bytes,int len , + yyscan_t yyscanner ); void *cmDependsJava_yyalloc (yy_size_t ,yyscan_t yyscanner ); void *cmDependsJava_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); @@ -229,7 +235,8 @@ YY_EXTRA_TYPE cmDependsJava_yyget_extra (yyscan_t yyscanner ); -void cmDependsJava_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); +void cmDependsJava_yyset_extra (YY_EXTRA_TYPE user_defined , + yyscan_t yyscanner ); FILE *cmDependsJava_yyget_in (yyscan_t yyscanner ); @@ -292,7 +299,8 @@ #define YY_DECL int cmDependsJava_yylex (yyscan_t yyscanner) #endif /* !YY_DECL */ -/* yy_get_previous_state - get the state just before the EOB char was reached */ +/* yy_get_previous_state - get the state just before the + EOB char was reached */ #undef YY_NEW_FILE #undef YY_FLUSH_BUFFER diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsJavaParserHelper.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsJavaParserHelper.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsJavaParserHelper.h 2005-01-29 06:13:58.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsJavaParserHelper.h 2006-03-11 02:54:57.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDependsJavaParserHelper.h,v $ Language: C++ - Date: $Date: 2005/01/28 22:13:58 $ - Version: $Revision: 1.1 $ + Date: $Date: 2006/03/10 18:54:57 $ + Version: $Revision: 1.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -75,7 +75,8 @@ cmStdString Name; std::vector NestedClasses; CurrentClass() {} - void AddFileNamesForPrinting(std::vector *files, const char* prefix, const char* sep); + void AddFileNamesForPrinting(std::vector *files, + const char* prefix, const char* sep); }; cmStdString CurrentPackage; cmStdString::size_type InputBufferPos; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsJavaParserTokens.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsJavaParserTokens.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDependsJavaParserTokens.h 2005-01-29 06:43:57.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDependsJavaParserTokens.h 2006-03-11 02:54:57.000000000 +0800 @@ -1,7 +1,7 @@ /* A Bison parser, made by GNU Bison 1.875d. */ -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +/* Skeleton parser for Yacc-like parsing with Bison, Copyright (C) 1984, + 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDocumentation.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDocumentation.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDocumentation.cxx 2005-08-12 02:02:19.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDocumentation.cxx 2005-12-17 05:49:01.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDocumentation.cxx,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:19 $ - Version: $Revision: 1.25.2.1 $ + Date: $Date: 2005/12/16 21:49:01 $ + Version: $Revision: 1.29 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -18,6 +18,7 @@ #include "cmSystemTools.h" #include "cmVersion.h" +#include //---------------------------------------------------------------------------- static const cmDocumentationEntry cmDocumentationStandardOptions[] = @@ -51,6 +52,15 @@ }; //---------------------------------------------------------------------------- +static const cmDocumentationEntry cmDocumentationModulesHeader[] = +{ + {0, + "The following modules are provided with CMake. " + "They can be used with INCLUDE(ModuleName).", 0}, + {0,0,0} +}; + +//---------------------------------------------------------------------------- static const cmDocumentationEntry cmDocumentationGeneratorsHeader[] = { {0, @@ -126,6 +136,16 @@ } //---------------------------------------------------------------------------- +cmDocumentation::~cmDocumentation() +{ + for(std::vector< char* >::iterator i = this->ModuleStrings.begin(); + i != this->ModuleStrings.end(); ++i) + { + delete [] *i; + } +} + +//---------------------------------------------------------------------------- bool cmDocumentation::PrintCopyright(std::ostream& os) { for(const cmDocumentationEntry* op = cmDocumentationCopyright; @@ -181,7 +201,9 @@ { case cmDocumentation::Usage: return this->PrintDocumentationUsage(os); case cmDocumentation::Single: return this->PrintDocumentationSingle(os); + case cmDocumentation::SingleModule: return this->PrintDocumentationSingleModule(os); case cmDocumentation::List: return this->PrintDocumentationList(os); + case cmDocumentation::ModuleList: return this->PrintModuleList(os); case cmDocumentation::Full: return this->PrintDocumentationFull(os); case cmDocumentation::HTML: return this->PrintDocumentationHTML(os); case cmDocumentation::Man: return this->PrintDocumentationMan(os); @@ -192,6 +214,121 @@ } //---------------------------------------------------------------------------- +bool cmDocumentation::CreateModulesSection() +{ + this->ModulesSection.push_back(cmDocumentationModulesHeader[0]); +#ifdef CMAKE_ROOT_DIR + std::string cmakeModules = CMAKE_ROOT_DIR; + cmakeModules += "/Modules"; + cmsys::Directory dir; + dir.Load(cmakeModules.c_str()); + for(unsigned int i = 0; i < dir.GetNumberOfFiles(); ++i) + { + std::string fname = dir.GetFile(i); + if(fname.length() > 6) + { + if(fname.substr(fname.length()-6, 6) == ".cmake") + { + std::string moduleName = fname.substr(0, fname.length()-6); + std::string path = cmakeModules; + path += "/"; + path += fname; + this->CreateSingleModule(path.c_str(), moduleName.c_str()); + } + } + } +#endif + cmDocumentationEntry e = { 0, 0, 0 }; + this->ModulesSection.push_back(e); + return true; +} + +//---------------------------------------------------------------------------- +bool cmDocumentation::CreateSingleModule(const char* fname, const char* moduleName) +{ + std::ifstream fin(fname); + if(!fin) + { + std::cerr << "Internal error: can not open module." << fname << std::endl; + return false; + } + std::string line; + std::string text; + std::string brief; + brief = " "; + bool newParagraph = true; + while ( fin && cmSystemTools::GetLineFromStream(fin, line) ) + { + if(line.size() && line[0] == '#') + { + // blank line + if(line.size() <= 2) + { + text += "\n"; + newParagraph = true; + } + else if(line[2] == '-') + { + brief = line.c_str()+4; + } + else + { + // two spaces + if(line[1] == ' ' && line[2] == ' ') + { + if(!newParagraph) + { + text += "\n"; + newParagraph = true; + } + // Skip #, and leave space for preformatted + text += line.c_str()+1; + text += "\n"; + } + else if(line[1] == ' ') + { + if(!newParagraph) + { + text += " "; + } + newParagraph = false; + // skip # and space + text += line.c_str()+2; + } + else + { + if(!newParagraph) + { + text += " "; + } + newParagraph = false; + // skip # + text += line.c_str()+1; + } + } + } + else + { + if(text.length() < 2 && brief.length() == 1) + { + return false; + } + char* pname = strcpy(new char[strlen(moduleName)+1], moduleName); + char* ptext = strcpy(new char[text.length()+1], text.c_str()); + this->ModuleStrings.push_back(pname); + this->ModuleStrings.push_back(ptext); + char* pbrief = strcpy(new char[brief.length()+1], brief.c_str()); + this->ModuleStrings.push_back(pbrief); + cmDocumentationEntry e = { pname, pbrief, ptext }; + this->ModulesSection.push_back(e); + return true; + } + } + return true; +} + + +//---------------------------------------------------------------------------- bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os) { bool result = true; @@ -300,10 +437,23 @@ i = i+1; } } + else if(strcmp(argv[i], "--help-module") == 0) + { + type = cmDocumentation::SingleModule; + if((i+1 < argc) && !this->IsOption(argv[i+1])) + { + this->SingleModuleName = argv[i+1]; + i = i+1; + } + } else if(strcmp(argv[i], "--help-command-list") == 0) { type = cmDocumentation::List; } + else if(strcmp(argv[i], "--help-module-list") == 0) + { + type = cmDocumentation::ModuleList; + } else if(strcmp(argv[i], "--copyright") == 0) { type = cmDocumentation::Copyright; @@ -768,6 +918,10 @@ column = static_cast(r-l); newSentence = (*(r-1) == '.'); } + else + { + column = 0; + } } // Move to beginning of next word. Skip over whitespace. @@ -835,6 +989,33 @@ } //---------------------------------------------------------------------------- +bool cmDocumentation::PrintDocumentationSingleModule(std::ostream& os) +{ + if(this->SingleModuleName.length() == 0) + { + os << "Argument --help-module needs a module name.\n"; + return false; + } +#ifdef CMAKE_ROOT_DIR + std::string cmakeModules = CMAKE_ROOT_DIR; + cmakeModules += "/Modules/"; + cmakeModules += this->SingleModuleName; + cmakeModules += ".cmake"; + if(cmSystemTools::FileExists(cmakeModules.c_str()) + && this->CreateSingleModule(cmakeModules.c_str(), + this->SingleModuleName.c_str())) + { + this->PrintDocumentationCommand(os, &this->ModulesSection[0]); + return true; + } + // Argument was not a module. Complain. + os << "Argument \"" << this->SingleModuleName.c_str() + << "\" to --help-module is not a CMake module."; +#endif + return false; +} + +//---------------------------------------------------------------------------- bool cmDocumentation::PrintDocumentationList(std::ostream& os) { if(this->CommandsSection.empty()) @@ -854,6 +1035,26 @@ } //---------------------------------------------------------------------------- +bool cmDocumentation::PrintModuleList(std::ostream& os) +{ + this->CreateModulesSection(); + if(this->ModulesSection.empty()) + { + os << "Internal error: modules list is empty." << std::endl; + return false; + } + for(cmDocumentationEntry* entry = &this->ModulesSection[0]; + entry->brief; ++entry) + { + if(entry->name) + { + os << entry->name << std::endl; + } + } + return true; +} + +//---------------------------------------------------------------------------- bool cmDocumentation::PrintDocumentationUsage(std::ostream& os) { this->CreateUsageDocumentation(); @@ -951,6 +1152,11 @@ { this->AddSection("Listfile Commands", &this->CommandsSection[0]); } + this->CreateModulesSection(); + if(!this->ModulesSection.empty()) + { + this->AddSection("Standard CMake Modules", &this->ModulesSection[0]); + } this->AddSection("Copyright", cmDocumentationCopyright); this->AddSection("Mailing List", cmDocumentationMailingList); } @@ -983,6 +1189,12 @@ { this->AddSection("COMMANDS", &this->CommandsSection[0]); } + this->CreateModulesSection(); + if(!this->ModulesSection.empty()) + { + this->AddSection("MODULES", &this->ModulesSection[0]); + } + this->AddSection("COPYRIGHT", cmDocumentationCopyright); this->AddSection("MAILING LIST", cmDocumentationMailingList); if(!this->SeeAlsoSection.empty()) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDocumentation.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDocumentation.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDocumentation.h 2004-04-15 02:25:43.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDocumentation.h 2005-12-15 02:51:08.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDocumentation.h,v $ Language: C++ - Date: $Date: 2004/04/14 18:25:43 $ - Version: $Revision: 1.13 $ + Date: $Date: 2005/12/14 18:51:08 $ + Version: $Revision: 1.14 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -25,10 +25,12 @@ public: cmDocumentation(); + ~cmDocumentation(); // High-level interface for standard documents: /** Types of help provided. */ - enum Type { None, Usage, Single, List, Full, HTML, Man, Copyright, Version }; + enum Type { None, Usage, Single, SingleModule, List, ModuleList, + Full, HTML, Man, Copyright, Version }; /** * Check command line arguments for documentation options. Returns @@ -121,10 +123,14 @@ void PrintColumn(std::ostream& os, const char* text); void PrintHTMLEscapes(std::ostream& os, const char* text); + bool CreateSingleModule(const char* fname, const char* moduleName); + bool CreateModulesSection(); bool PrintCopyright(std::ostream& os); bool PrintVersion(std::ostream& os); bool PrintDocumentationList(std::ostream& os); + bool PrintModuleList(std::ostream& os); bool PrintDocumentationSingle(std::ostream& os); + bool PrintDocumentationSingleModule(std::ostream& os); bool PrintDocumentationUsage(std::ostream& os); bool PrintDocumentationFull(std::ostream& os); bool PrintDocumentationHTML(std::ostream& os); @@ -149,11 +155,14 @@ std::vector DescriptionSection; std::vector OptionsSection; std::vector CommandsSection; + std::vector ModulesSection; std::vector GeneratorsSection; std::vector SeeAlsoSection; std::string SeeAlsoString; std::string SingleCommand; + std::string SingleModuleName; + std::vector< char* > ModuleStrings; std::vector< const char* > Names; std::vector< const cmDocumentationEntry* > Sections; Form CurrentForm; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDynamicLoader.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDynamicLoader.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDynamicLoader.cxx 2005-08-12 02:02:19.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDynamicLoader.cxx 2006-03-17 06:09:08.000000000 +0800 @@ -3,40 +3,32 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDynamicLoader.cxx,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:19 $ - Version: $Revision: 1.24.2.1 $ + Date: $Date: 2006/03/16 22:09:08 $ + Version: $Revision: 1.29 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "cmDynamicLoader.h" -// This file is actually several different implementations. -// 1. HP machines which uses shl_load -// 2. Apple OSX which uses NSLinkModule -// 3. Windows which uses LoadLibrary -// 4. Most unix systems which use dlopen (default ) -// Each part of the ifdef contains a complete implementation for -// the static methods of cmDynamicLoader. - - -class cmDynamicLoaderCache +class cmDynamicLoaderCache { public: ~cmDynamicLoaderCache(); - void CacheFile(const char* path, const cmLibHandle&); - bool GetCacheFile(const char* path, cmLibHandle&); + void CacheFile(const char* path, + const cmsys::DynamicLoader::LibraryHandle&); + bool GetCacheFile(const char* path, cmsys::DynamicLoader::LibraryHandle&); bool FlushCache(const char* path); void FlushCache(); static cmDynamicLoaderCache* GetInstance(); private: - std::map m_CacheMap; + std::map CacheMap; static cmDynamicLoaderCache* Instance; }; @@ -46,20 +38,23 @@ { } -void cmDynamicLoaderCache::CacheFile(const char* path, const cmLibHandle& p) +void cmDynamicLoaderCache::CacheFile(const char* path, + const cmsys::DynamicLoader::LibraryHandle& p) { - cmLibHandle h; + cmsys::DynamicLoader::LibraryHandle h; if ( this->GetCacheFile(path, h) ) { this->FlushCache(path); } - this->m_CacheMap[path] = p; + this->CacheMap[path] = p; } -bool cmDynamicLoaderCache::GetCacheFile(const char* path, cmLibHandle& p) +bool cmDynamicLoaderCache::GetCacheFile(const char* path, + cmsys::DynamicLoader::LibraryHandle& p) { - std::map::iterator it = m_CacheMap.find(path); - if ( it != m_CacheMap.end() ) + std::map::iterator it + = this->CacheMap.find(path); + if ( it != this->CacheMap.end() ) { p = it->second; return true; @@ -69,12 +64,13 @@ bool cmDynamicLoaderCache::FlushCache(const char* path) { - std::map::iterator it = m_CacheMap.find(path); + std::map::iterator it + = this->CacheMap.find(path); bool ret = false; - if ( it != m_CacheMap.end() ) + if ( it != this->CacheMap.end() ) { - cmDynamicLoader::CloseLibrary(it->second); - m_CacheMap.erase(it); + cmsys::DynamicLoader::CloseLibrary(it->second); + this->CacheMap.erase(it); ret = true; } return ret; @@ -82,10 +78,12 @@ void cmDynamicLoaderCache::FlushCache() { - for ( std::map::iterator it = m_CacheMap.begin(); - it != m_CacheMap.end(); it++ ) + for ( std::map::iterator it + = this->CacheMap.begin(); + it != this->CacheMap.end(); it++ ) { - cmDynamicLoader::CloseLibrary(it->second); + cmsys::DynamicLoader::CloseLibrary(it->second); } delete cmDynamicLoaderCache::Instance; cmDynamicLoaderCache::Instance = 0; @@ -100,247 +98,20 @@ return cmDynamicLoaderCache::Instance; } -// --------------------------------------------------------------- -// 1. Implementation for HPUX machines -#ifdef __hpux -#define CMDYNAMICLOADER_DEFINED 1 -#include - -cmLibHandle cmDynamicLoader::OpenLibrary(const char* libname ) -{ - cmLibHandle lh; - if ( cmDynamicLoaderCache::GetInstance()->GetCacheFile(libname, lh) ) - { - return lh; - } - - lh = shl_load(libname, BIND_DEFERRED | DYNAMIC_PATH, 0L); - cmDynamicLoaderCache::GetInstance()->CacheFile(libname, lh); - return lh; -} - -int cmDynamicLoader::CloseLibrary(cmLibHandle lib) -{ - return !shl_unload(lib); -} - -cmDynamicLoaderFunction -cmDynamicLoader::GetSymbolAddress(cmLibHandle lib, const char* sym) -{ - void* addr; - int status; - - status = shl_findsym (&lib, sym, TYPE_PROCEDURE, &addr); - void* result = (status < 0) ? (void*)0 : addr; - - // Hack to cast pointer-to-data to pointer-to-function. - return *reinterpret_cast(&result); -} - - -const char* cmDynamicLoader::LastError() -{ - return 0; -} -#endif - - - -// --------------------------------------------------------------- -// 2. Implementation for Darwin (including OSX) Machines - -#ifdef __APPLE__ -#define CMDYNAMICLOADER_DEFINED -#include - -cmLibHandle cmDynamicLoader::OpenLibrary(const char* libname ) -{ - cmLibHandle lh; - if ( cmDynamicLoaderCache::GetInstance()->GetCacheFile(libname, lh) ) - { - return lh; - } - - NSObjectFileImageReturnCode rc; - NSObjectFileImage image = 0; - - rc = NSCreateObjectFileImageFromFile(libname, &image); - if(!image) - { - return 0; - } - lh = NSLinkModule(image, libname, TRUE); - if(lh) - { - cmDynamicLoaderCache::GetInstance()->CacheFile(libname, lh); - } - return lh; -} - -int cmDynamicLoader::CloseLibrary(cmLibHandle lib) -{ - // we have to use lib because the macro may not... - (void)lib; - - NSUnLinkModule((NSModule)lib, FALSE); - return 1; -} - -cmDynamicLoaderFunction -cmDynamicLoader::GetSymbolAddress(cmLibHandle /* lib */, const char* sym) -{ - void *result=0; - if(NSIsSymbolNameDefined(sym)) - { - NSSymbol symbol= NSLookupAndBindSymbol(sym); - if(symbol) - { - result = NSAddressOfSymbol(symbol); - } - } - // Hack to cast pointer-to-data to pointer-to-function. - return *reinterpret_cast(&result); -} - -const char* cmDynamicLoader::LastError() -{ - return 0; -} - -#endif - - - - -// --------------------------------------------------------------- -// 3. Implementation for Windows win32 code -#ifdef _WIN32 -#include -#define CMDYNAMICLOADER_DEFINED 1 - -cmLibHandle cmDynamicLoader::OpenLibrary(const char* libname ) +cmsys::DynamicLoader::LibraryHandle cmDynamicLoader::OpenLibrary( + const char* libname ) { - cmLibHandle lh; + cmsys::DynamicLoader::LibraryHandle lh; if ( cmDynamicLoaderCache::GetInstance()->GetCacheFile(libname, lh) ) { return lh; } -#ifdef UNICODE - wchar_t *libn = new wchar_t [mbstowcs(NULL, libname, 32000)]; - mbstowcs(libn, libname, 32000); - cmLibHandle ret = LoadLibrary(libn); - delete [] libn; - lh = ret; -#else - lh = LoadLibrary(libname); -#endif - + lh = cmsys::DynamicLoader::OpenLibrary(libname); cmDynamicLoaderCache::GetInstance()->CacheFile(libname, lh); return lh; } -int cmDynamicLoader::CloseLibrary(cmLibHandle lib) -{ - return (int)FreeLibrary(lib); -} - -cmDynamicLoaderFunction -cmDynamicLoader::GetSymbolAddress(cmLibHandle lib, const char* sym) -{ -#ifdef UNICODE - wchar_t *wsym = new wchar_t [mbstowcs(NULL, sym, 32000)]; - mbstowcs(wsym, sym, 32000); - void *ret = GetProcAddress(lib, wsym); - delete [] wsym; - void* result = ret; -#else - void* result = (void*)GetProcAddress(lib, sym); -#endif - // Hack to cast pointer-to-data to pointer-to-function. - return *reinterpret_cast(&result); -} - - -const char* cmDynamicLoader::LastError() -{ - LPVOID lpMsgBuf; - - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL - ); - - // Free the buffer. - - static char* str = 0; - delete [] str; - str = strcpy(new char[strlen((char*)lpMsgBuf)+1], (char*)lpMsgBuf); - LocalFree( lpMsgBuf ); - return str; -} - -#endif - -// --------------------------------------------------------------- -// 4. Implementation for default UNIX machines. -// if nothing has been defined then use this -#ifndef CMDYNAMICLOADER_DEFINED -#define CMDYNAMICLOADER_DEFINED -// Setup for most unix machines -#include - -cmLibHandle cmDynamicLoader::OpenLibrary(const char* libname ) -{ - cmLibHandle lh; - if ( cmDynamicLoaderCache::GetInstance()->GetCacheFile(libname, lh) ) - { - return lh; - } - - lh = dlopen(libname, RTLD_LAZY); - cmDynamicLoaderCache::GetInstance()->CacheFile(libname, lh); - return lh; -} - -int cmDynamicLoader::CloseLibrary(cmLibHandle lib) -{ - return !(int)dlclose(lib); -} - -cmDynamicLoaderFunction -cmDynamicLoader::GetSymbolAddress(cmLibHandle lib, const char* sym) -{ - void* result = dlsym(lib, sym); - - // Hack to cast pointer-to-data to pointer-to-function. - return *reinterpret_cast(&result); -} - -const char* cmDynamicLoader::LastError() -{ - return dlerror(); -} -#endif - void cmDynamicLoader::FlushCache() { cmDynamicLoaderCache::GetInstance()->FlushCache(); } - -// Stay consistent with the Modules/Platform directory as -// to what the correct prefix and lib extension -const char* cmDynamicLoader::LibPrefix() -{ - return CMAKE_SHARED_MODULE_PREFIX; -} - -const char* cmDynamicLoader::LibExtension() -{ - return CMAKE_SHARED_MODULE_SUFFIX; -} - diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDynamicLoader.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDynamicLoader.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmDynamicLoader.h 2005-03-23 03:27:08.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmDynamicLoader.h 2006-03-17 06:09:08.000000000 +0800 @@ -3,21 +3,21 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDynamicLoader.h,v $ Language: C++ - Date: $Date: 2005/03/22 19:27:08 $ - Version: $Revision: 1.6 $ + Date: $Date: 2006/03/16 22:09:08 $ + Version: $Revision: 1.9 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ // .NAME cmDynamicLoader - class interface to system dynamic libraries // .SECTION Description -// cmDynamicLoader provides a portable interface to loading dynamic -// libraries into a process. +// cmDynamicLoader provides a portable interface to loading dynamic +// libraries into a process. #ifndef __cmDynamicLoader_h @@ -25,63 +25,25 @@ #include "cmStandardIncludes.h" -// Ugly stuff for library handles -// They are different on several different OS's -#if defined(__hpux) -# include - typedef shl_t cmLibHandle; -#elif defined(_WIN32) - #include - typedef HMODULE cmLibHandle; -#elif defined(__APPLE__) - #include - typedef NSModule cmLibHandle; -#else - typedef void* cmLibHandle; -#endif - -// Return type from cmDynamicLoader::GetSymbolAddress. -typedef void (*cmDynamicLoaderFunction)(); +#include class cmDynamicLoader { public: // Description: // Load a dynamic library into the current process. - // The returned cmLibHandle can be used to access the symbols in the - // library. - static cmLibHandle OpenLibrary(const char*); - - // Description: - // Attempt to detach a dynamic library from the - // process. A value of true is returned if it is successful. - static int CloseLibrary(cmLibHandle); - - // Description: - // Find the address of the symbol in the given library - static cmDynamicLoaderFunction GetSymbolAddress(cmLibHandle, const char*); - - // Description: - // Return the library prefix for the given architecture - static const char* LibPrefix(); - - // Description: - // Return the library extension for the given architecture - static const char* LibExtension(); - - // Description: - // Return the last error produced from a calls made on this class. - static const char* LastError(); + // The returned cmsys::DynamicLoader::LibraryHandle can be used to access + // the symbols in the library. + static cmsys::DynamicLoader::LibraryHandle OpenLibrary(const char*); // Description: // Flush the cache of dynamic loader. static void FlushCache(); - + protected: cmDynamicLoader() {}; ~cmDynamicLoader() {}; - private: cmDynamicLoader(const cmDynamicLoader&); // Not implemented. void operator=(const cmDynamicLoader&); // Not implemented. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmElseCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmElseCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmElseCommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmElseCommand.h 2005-11-16 23:33:41.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmElseCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.11.2.1 $ + Date: $Date: 2005/11/16 15:33:41 $ + Version: $Revision: 1.12 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmEnableLanguageCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmEnableLanguageCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmEnableLanguageCommand.cxx 2004-09-23 02:42:05.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmEnableLanguageCommand.cxx 2006-03-16 00:02:01.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmEnableLanguageCommand.cxx,v $ Language: C++ - Date: $Date: 2004/09/22 18:42:05 $ - Version: $Revision: 1.1 $ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -24,7 +24,7 @@ this->SetError("ENABLE_LANGUAGE called with incorrect number of arguments"); return false; } - m_Makefile->EnableLanguage(args); + this->Makefile->EnableLanguage(args); return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmEnableLanguageCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmEnableLanguageCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmEnableLanguageCommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmEnableLanguageCommand.h 2005-11-16 23:33:49.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmEnableLanguageCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.2.2.1 $ + Date: $Date: 2005/11/16 15:33:49 $ + Version: $Revision: 1.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmEnableTestingCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmEnableTestingCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmEnableTestingCommand.cxx 2005-04-25 03:59:50.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmEnableTestingCommand.cxx 2006-03-16 00:02:01.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmEnableTestingCommand.cxx,v $ Language: C++ - Date: $Date: 2005/04/24 19:59:50 $ - Version: $Revision: 1.17 $ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.18 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -21,6 +21,6 @@ // been defined bool cmEnableTestingCommand::InitialPass(std::vector const&) { - m_Makefile->AddDefinition("CMAKE_TESTING_ENABLED","1"); + this->Makefile->AddDefinition("CMAKE_TESTING_ENABLED","1"); return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmEnableTestingCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmEnableTestingCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmEnableTestingCommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmEnableTestingCommand.h 2005-11-16 23:35:00.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmEnableTestingCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.11.2.1 $ + Date: $Date: 2005/11/16 15:35:00 $ + Version: $Revision: 1.12 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmEndForEachCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmEndForEachCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmEndForEachCommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmEndForEachCommand.h 2005-11-16 23:35:29.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmEndForEachCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.10.2.1 $ + Date: $Date: 2005/11/16 15:35:29 $ + Version: $Revision: 1.11 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmEndIfCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmEndIfCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmEndIfCommand.cxx 2003-05-24 22:07:58.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmEndIfCommand.cxx 2006-03-16 00:02:01.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmEndIfCommand.cxx,v $ Language: C++ - Date: $Date: 2003/05/24 14:07:58 $ - Version: $Revision: 1.12 $ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.13 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -19,7 +19,7 @@ bool cmEndIfCommand::InitialPass(std::vector const&) { const char* versionValue - = m_Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION"); + = this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION"); if (!versionValue || (atof(versionValue) <= 1.4)) { return true; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmEndIfCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmEndIfCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmEndIfCommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmEndIfCommand.h 2005-11-16 23:36:58.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmEndIfCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.10.2.1 $ + Date: $Date: 2005/11/16 15:36:58 $ + Version: $Revision: 1.11 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmEndWhileCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmEndWhileCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmEndWhileCommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmEndWhileCommand.h 2005-11-16 23:37:02.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmEndWhileCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.3.2.1 $ + Date: $Date: 2005/11/16 15:37:02 $ + Version: $Revision: 1.4 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExecProgramCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExecProgramCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExecProgramCommand.cxx 2004-06-24 20:57:54.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExecProgramCommand.cxx 2006-03-16 00:02:01.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmExecProgramCommand.cxx,v $ Language: C++ - Date: $Date: 2004/06/24 12:57:54 $ - Version: $Revision: 1.20 $ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.21 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -133,14 +133,14 @@ } std::string coutput = std::string(output, first, last-first+1); - m_Makefile->AddDefinition(output_variable.c_str(), coutput.c_str()); + this->Makefile->AddDefinition(output_variable.c_str(), coutput.c_str()); } if ( return_variable.size() > 0 ) { char buffer[100]; sprintf(buffer, "%d", retVal); - m_Makefile->AddDefinition(return_variable.c_str(), buffer); + this->Makefile->AddDefinition(return_variable.c_str(), buffer); } return true; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExecProgramCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExecProgramCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExecProgramCommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExecProgramCommand.h 2006-03-11 02:54:57.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmExecProgramCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.14.4.1 $ + Date: $Date: 2006/03/10 18:54:57 $ + Version: $Revision: 1.17 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -59,7 +59,9 @@ */ virtual const char* GetTerseDocumentation() { - return "Run and executable program during the processing of the CMakeList.txt file."; + return + "Run and executable program during the processing of the CMakeList.txt" + " file."; } /** @@ -80,7 +82,10 @@ "specifies a variable in which to store the output. " "To capture the return value of the execution, provide a RETURN_VALUE. " "If OUTPUT_VARIABLE is specified, then no output will go to the " - "stdout/stderr of the console running cmake."; + "stdout/stderr of the console running cmake.\n" + "The EXECUTE_PROCESS command is a newer more powerful version of " + "EXEC_PROGRAM, but the old command has been kept for compatibility." + ; } cmTypeMacro(cmExecProgramCommand, cmCommand); diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExecuteProcessCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExecuteProcessCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExecuteProcessCommand.cxx 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExecuteProcessCommand.cxx 2006-03-16 00:02:01.000000000 +0800 @@ -0,0 +1,351 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmExecuteProcessCommand.cxx,v $ + Language: C++ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.3 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "cmExecuteProcessCommand.h" +#include "cmSystemTools.h" + +#include + +void cmExecuteProcessCommandFixText(std::vector& output); + +// cmExecuteProcessCommand +bool cmExecuteProcessCommand::InitialPass(std::vector const& args) +{ + if(args.size() < 1 ) + { + this->SetError("called with incorrect number of arguments"); + return false; + } + std::vector< std::vector > cmds; + std::string arguments; + bool doing_command = false; + unsigned int command_index = 0; + bool output_quiet = false; + bool error_quiet = false; + std::string timeout_string; + std::string input_file; + std::string output_file; + std::string error_file; + std::string output_variable; + std::string error_variable; + std::string result_variable; + std::string working_directory; + for(size_t i=0; i < args.size(); ++i) + { + if(args[i] == "COMMAND") + { + doing_command = true; + command_index = cmds.size(); + cmds.push_back(std::vector()); + } + else if(args[i] == "OUTPUT_VARIABLE") + { + doing_command = false; + if(++i < args.size()) + { + output_variable = args[i]; + } + else + { + this->SetError(" called with no value for OUTPUT_VARIABLE."); + return false; + } + } + else if(args[i] == "ERROR_VARIABLE") + { + doing_command = false; + if(++i < args.size()) + { + error_variable = args[i]; + } + else + { + this->SetError(" called with no value for ERROR_VARIABLE."); + return false; + } + } + else if(args[i] == "RESULT_VARIABLE") + { + doing_command = false; + if(++i < args.size()) + { + result_variable = args[i]; + } + else + { + this->SetError(" called with no value for RESULT_VARIABLE."); + return false; + } + } + else if(args[i] == "WORKING_DIRECTORY") + { + doing_command = false; + if(++i < args.size()) + { + working_directory = args[i]; + } + else + { + this->SetError(" called with no value for WORKING_DIRECTORY."); + return false; + } + } + else if(args[i] == "INPUT_FILE") + { + doing_command = false; + if(++i < args.size()) + { + input_file = args[i]; + } + else + { + this->SetError(" called with no value for INPUT_FILE."); + return false; + } + } + else if(args[i] == "OUTPUT_FILE") + { + doing_command = false; + if(++i < args.size()) + { + output_file = args[i]; + } + else + { + this->SetError(" called with no value for OUTPUT_FILE."); + return false; + } + } + else if(args[i] == "ERROR_FILE") + { + doing_command = false; + if(++i < args.size()) + { + error_file = args[i]; + } + else + { + this->SetError(" called with no value for ERROR_FILE."); + return false; + } + } + else if(args[i] == "TIMEOUT") + { + doing_command = false; + if(++i < args.size()) + { + timeout_string = args[i]; + } + else + { + this->SetError(" called with no value for TIMEOUT."); + return false; + } + } + else if(args[i] == "OUTPUT_QUIET") + { + doing_command = false; + output_quiet = true; + } + else if(args[i] == "ERROR_QUIET") + { + doing_command = false; + error_quiet = true; + } + else if(doing_command) + { + cmds[command_index].push_back(args[i].c_str()); + } + } + + // Check for commands given. + if(cmds.empty()) + { + this->SetError(" called with no COMMAND argument."); + return false; + } + for(unsigned int i=0; i < cmds.size(); ++i) + { + if(cmds[i].empty()) + { + this->SetError(" given COMMAND argument with no value."); + return false; + } + else + { + // Add the null terminating pointer to the command argument list. + cmds[i].push_back(0); + } + } + + // Parse the timeout string. + double timeout = -1; + if(!timeout_string.empty()) + { + if(sscanf(timeout_string.c_str(), "%lg", &timeout) != 1) + { + this->SetError(" called with TIMEOUT value that could not be parsed."); + return false; + } + } + + // Create a process instance. + cmsysProcess* cp = cmsysProcess_New(); + + // Set the command sequence. + for(unsigned int i=0; i < cmds.size(); ++i) + { + cmsysProcess_AddCommand(cp, &*cmds[i].begin()); + } + + // Set the process working directory. + if(!working_directory.empty()) + { + cmsysProcess_SetWorkingDirectory(cp, working_directory.c_str()); + } + + // Always hide the process window. + cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1); + + // Check the output variables. + bool merge_output = (output_variable == error_variable); + if(error_variable.empty() && !error_quiet) + { + cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDERR, 1); + } + if(!input_file.empty()) + { + cmsysProcess_SetPipeFile(cp, cmsysProcess_Pipe_STDIN, input_file.c_str()); + } + if(!output_file.empty()) + { + cmsysProcess_SetPipeFile(cp, cmsysProcess_Pipe_STDOUT, output_file.c_str()); + } + if(!error_file.empty()) + { + cmsysProcess_SetPipeFile(cp, cmsysProcess_Pipe_STDERR, error_file.c_str()); + } + + // Set the timeout if any. + if(timeout >= 0) + { + cmsysProcess_SetTimeout(cp, timeout); + } + + // Start the process. + cmsysProcess_Execute(cp); + + // Read the process output. + std::vector tempOutput; + std::vector tempError; + int length; + char* data; + int p; + while((p = cmsysProcess_WaitForData(cp, &data, &length, 0), p)) + { + // Put the output in the right place. + if(p == cmsysProcess_Pipe_STDOUT && !output_quiet || + p == cmsysProcess_Pipe_STDERR && !error_quiet && merge_output) + { + if(output_variable.empty()) + { + cmSystemTools::Stdout(data, length); + } + else + { + tempOutput.insert(tempOutput.end(), data, data+length); + } + } + else if(p == cmsysProcess_Pipe_STDERR && !error_quiet) + { + if(!error_variable.empty()) + { + tempError.insert(tempError.end(), data, data+length); + } + } + } + + // All output has been read. Wait for the process to exit. + cmsysProcess_WaitForExit(cp, 0); + + // Fix the text in the output strings. + cmExecuteProcessCommandFixText(tempOutput); + cmExecuteProcessCommandFixText(tempError); + + // Store the output obtained. + if(!output_variable.empty()) + { + this->Makefile->AddDefinition(output_variable.c_str(), &*tempOutput.begin()); + } + if(!merge_output && !error_variable.empty()) + { + this->Makefile->AddDefinition(error_variable.c_str(), &*tempError.begin()); + } + + // Store the result of running the process. + if(!result_variable.empty()) + { + switch(cmsysProcess_GetState(cp)) + { + case cmsysProcess_State_Exited: + { + int v = cmsysProcess_GetExitValue(cp); + char buf[100]; + sprintf(buf, "%d", v); + this->Makefile->AddDefinition(result_variable.c_str(), buf); + } + break; + case cmsysProcess_State_Exception: + this->Makefile->AddDefinition(result_variable.c_str(), + cmsysProcess_GetExceptionString(cp)); + break; + case cmsysProcess_State_Error: + this->Makefile->AddDefinition(result_variable.c_str(), + cmsysProcess_GetErrorString(cp)); + break; + case cmsysProcess_State_Expired: + this->Makefile->AddDefinition(result_variable.c_str(), + "Process terminated due to timeout"); + break; + } + } + + // Delete the process instance. + cmsysProcess_Delete(cp); + + return true; +} + +//---------------------------------------------------------------------------- +void cmExecuteProcessCommandFixText(std::vector& output) +{ + // Remove \0 characters and the \r part of \r\n pairs. + unsigned int in_index = 0; + unsigned int out_index = 0; + while(in_index < output.size()) + { + char c = output[in_index++]; + if((c != '\r' || !(in_index < output.size() && output[in_index] == '\n')) + && c != '\0') + { + output[out_index++] = c; + } + } + output.resize(out_index); + + // Put a terminator on the text string. + output.push_back('\0'); +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExecuteProcessCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExecuteProcessCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExecuteProcessCommand.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExecuteProcessCommand.h 2006-02-11 00:43:35.000000000 +0800 @@ -0,0 +1,115 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmExecuteProcessCommand.h,v $ + Language: C++ + Date: $Date: 2006/02/10 16:43:35 $ + Version: $Revision: 1.2 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef cmExecuteProcessCommand_h +#define cmExecuteProcessCommand_h + +#include "cmCommand.h" + +/** \class cmExecuteProcessCommand + * \brief Command that adds a target to the build system. + * + * cmExecuteProcessCommand is a CMake language interface to the KWSys + * Process Execution implementation. + */ +class cmExecuteProcessCommand : public cmCommand +{ +public: + /** + * This is a virtual constructor for the command. + */ + virtual cmCommand* Clone() + { + return new cmExecuteProcessCommand; + } + + /** + * This is called when the command is first encountered in + * the CMakeLists.txt file. + */ + virtual bool InitialPass(std::vector const& args); + + /** + * The name of the command as specified in CMakeList.txt. + */ + virtual const char* GetName() + {return "EXECUTE_PROCESS";} + + /** + * This determines if the command is invoked when in script mode. + */ + virtual bool IsScriptable() { return true; } + + /** + * Succinct documentation. + */ + virtual const char* GetTerseDocumentation() + { + return "Execute one or more child processes."; + } + + /** + * More documentation. + */ + virtual const char* GetFullDocumentation() + { + return + " EXECUTE_PROCESS(COMMAND [args1...]]\n" + " [COMMAND [args2...] [...]]\n" + " [WORKING_DIRECTORY ]\n" + " [TIMEOUT ]\n" + " [RESULT_VARIABLE ]\n" + " [OUTPUT_VARIABLE ]\n" + " [ERROR_VARIABLE ]\n" + " [INPUT_FILE ]\n" + " [OUTPUT_FILE ]\n" + " [ERROR_FILE ]\n" + " [OUTPUT_QUIET]\n" + " [ERROR_QUIET])\n" + "Runs the given sequence of one or more commands with the standard " + "output of each process piped to the standard input of the next. " + "A single standard error pipe is used for all processes. " + "If WORKING_DIRECTORY is given the named directory will be set as " + "the current working directory of the child processes. " + "If TIMEOUT is given the child processes will be terminated if they " + "do not finish in the specified number of seconds " + "(fractions are allowed). " + "If RESULT_VARIABLE is given the variable will be set to contain " + "the result of running the processes. This will be an integer return " + "code from the last child or a string describing an error condition. " + "If OUTPUT_VARIABLE or ERROR_VARIABLE are given the variable named " + "will be set with the contents of the standard output and standard error " + "pipes respectively. If the same variable is named for both pipes " + "their output will be merged in the order produced. " + "If INPUT_FILE, OUTPUT_FILE, or ERROR_FILE is given the file named " + "will be attached to the standard input of the first process, " + "standard output of the last process, or standard error of all " + "processes respectively. " + "If OUTPUT_QUIET or ERROR_QUIET is given then the standard output " + "or standard error results will be quietly ignored. " + "If more than one OUTPUT_* or ERROR_* option is given for the same " + "pipe the precedence is not specified. " + "If no OUTPUT_* or ERROR_* options are given the output will be shared " + "with the corresponding pipes of the CMake process itself.\n" + "The EXECUTE_PROCESS command is a newer more powerful version of " + "EXEC_PROGRAM, but the old command has been kept for compatibility." + ; + } + + cmTypeMacro(cmExecuteProcessCommand, cmCommand); +}; + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExportLibraryDependencies.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExportLibraryDependencies.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExportLibraryDependencies.cxx 2005-06-22 21:06:45.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExportLibraryDependencies.cxx 2006-03-17 05:04:30.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmExportLibraryDependencies.cxx,v $ Language: C++ - Date: $Date: 2005/06/22 13:06:45 $ - Version: $Revision: 1.10 $ + Date: $Date: 2006/03/16 21:04:30 $ + Version: $Revision: 1.14 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -20,7 +20,7 @@ #include "cmGeneratedFileStream.h" #include "cmake.h" -#include // auto_ptr +#include // cmExecutableCommand bool cmExportLibraryDependenciesCommand::InitialPass(std::vector const& args) @@ -38,7 +38,7 @@ // store the arguments for the final pass // also expand any CMake variables - m_Args = args; + this->Args = args; return true; } @@ -46,32 +46,32 @@ void cmExportLibraryDependenciesCommand::FinalPass() { // Create a full path filename for output - std::string fname = m_Args[0]; + std::string fname = this->Args[0]; bool append = false; - if(m_Args.size() > 1) + if(this->Args.size() > 1) { - if(m_Args[1] == "APPEND") + if(this->Args[1] == "APPEND") { append = true; } } // Use copy-if-different if not appending. - std::ostream* foutPtr; - std::auto_ptr foutNew; + cmsys::auto_ptr foutPtr; if(append) { - foutPtr = new std::ofstream(fname.c_str(), std::ios::app); + cmsys::auto_ptr ap( + new std::ofstream(fname.c_str(), std::ios::app)); + foutPtr = ap; } else { - std::auto_ptr ap( + cmsys::auto_ptr ap( new cmGeneratedFileStream(fname.c_str(), true)); ap->SetCopyIfDifferent(true); - foutNew = ap; - foutPtr = foutNew.get(); + foutPtr = ap; } - std::ostream& fout = *foutPtr; + std::ostream& fout = *foutPtr.get(); if (!fout) { @@ -79,7 +79,7 @@ cmSystemTools::ReportLastSystemError(""); return; } - cmake* cm = m_Makefile->GetCMakeInstance(); + cmake* cm = this->Makefile->GetCMakeInstance(); cmGlobalGenerator* global = cm->GetGlobalGenerator(); std::vector locals; global->GetLocalGenerators(locals); @@ -99,7 +99,7 @@ { libDepName = l->first; libDepName += "_LIB_DEPENDS"; - const char* def = m_Makefile->GetDefinition(libDepName.c_str()); + const char* def = this->Makefile->GetDefinition(libDepName.c_str()); if(def) { fout << "SET(" << libDepName << " \"" << def << "\")\n"; @@ -110,7 +110,7 @@ { libDepName = *d; libDepName += "_LINK_TYPE"; - defType = m_Makefile->GetDefinition(libDepName.c_str()); + defType = this->Makefile->GetDefinition(libDepName.c_str()); libDepName = cmSystemTools::EscapeSpaces(libDepName.c_str()); if(defType) { diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExportLibraryDependencies.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExportLibraryDependencies.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExportLibraryDependencies.h 2003-08-11 06:30:53.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExportLibraryDependencies.h 2006-03-16 00:02:01.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmExportLibraryDependencies.h,v $ Language: C++ - Date: $Date: 2003/08/10 22:30:53 $ - Version: $Revision: 1.3 $ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.4 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -79,7 +79,7 @@ cmTypeMacro(cmExportLibraryDependenciesCommand, cmCommand); private: - std::vector m_Args; + std::vector Args; }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExprLexer.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExprLexer.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExprLexer.cxx 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExprLexer.cxx 2006-03-16 00:02:01.000000000 +0800 @@ -0,0 +1,1954 @@ +#line 2 "/home/andy/vtk/CMake-bin/Source/cmExprLexer.cxx" + +#line 4 "/home/andy/vtk/CMake-bin/Source/cmExprLexer.cxx" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 31 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +int cmExpr_yylex_init (yyscan_t* scanner); + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE cmExpr_yyrestart(yyin ,yyscanner ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef unsigned int yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via cmExpr_yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void cmExpr_yyrestart (FILE *input_file ,yyscan_t yyscanner ); +void cmExpr_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +YY_BUFFER_STATE cmExpr_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); +void cmExpr_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void cmExpr_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void cmExpr_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +void cmExpr_yypop_buffer_state (yyscan_t yyscanner ); + +static void cmExpr_yyensure_buffer_stack (yyscan_t yyscanner ); +static void cmExpr_yy_load_buffer_state (yyscan_t yyscanner ); +static void cmExpr_yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); + +#define YY_FLUSH_BUFFER cmExpr_yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner) + +YY_BUFFER_STATE cmExpr_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); +YY_BUFFER_STATE cmExpr_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); +YY_BUFFER_STATE cmExpr_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); + +void *cmExpr_yyalloc (yy_size_t ,yyscan_t yyscanner ); +void *cmExpr_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); +void cmExpr_yyfree (void * ,yyscan_t yyscanner ); + +#define yy_new_buffer cmExpr_yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + cmExpr_yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + cmExpr_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + cmExpr_yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + cmExpr_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define cmExpr_yywrap(n) 1 +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); +static int yy_get_next_buffer (yyscan_t yyscanner ); +static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 15 +#define YY_END_OF_BUFFER 16 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[23] = + { 0, + 0, 0, 16, 15, 6, 8, 13, 14, 4, 2, + 3, 5, 1, 15, 15, 9, 7, 10, 1, 11, + 12, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 2, 3, 1, 4, + 5, 6, 7, 1, 8, 1, 9, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 1, 1, 11, + 1, 12, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 13, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 14, 1, 15, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[16] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int16_t yy_base[23] = + { 0, + 0, 0, 20, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 9, 7, 5, 21, 21, 21, 6, 21, + 21, 21 + } ; + +static yyconst flex_int16_t yy_def[23] = + { 0, + 22, 1, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 0 + } ; + +static yyconst flex_int16_t yy_nxt[37] = + { 0, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 21, 20, 19, 22, + 3, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22 + } ; + +static yyconst flex_int16_t yy_chk[37] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 19, 15, 14, 13, 3, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" +#line 2 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmExprLexer.cxx,v $ + Language: C++ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.2 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +/* + +This file must be translated to C and modified to build everywhere. + +Run flex like this: + + flex --prefix=cmExpr_yy --header-file=cmExprLexer.h -ocmExprLexer.cxx cmExprLexer.in.l + +Modify cmExprLexer.cxx: + - remove TABs + - remove "yyscanner" argument from these methods: + yy_fatal_error, cmExpr_yyalloc, cmExpr_yyrealloc, cmExpr_yyfree + - remove all YY_BREAK lines occurring right after return statements + - change while ( 1 ) to for(;;) + +Modify cmExprLexer.h: + - remove TABs + - remove the yy_init_globals function + - remove the block that includes unistd.h + - remove #line directives (avoids bogus warning on old Sun) + +*/ + +#include "cmExprParserHelper.h" + +/* Disable some warnings. */ +#if defined(_MSC_VER) +# pragma warning ( disable : 4127 ) +# pragma warning ( disable : 4131 ) +# pragma warning ( disable : 4244 ) +# pragma warning ( disable : 4251 ) +# pragma warning ( disable : 4267 ) +# pragma warning ( disable : 4305 ) +# pragma warning ( disable : 4309 ) +# pragma warning ( disable : 4706 ) +# pragma warning ( disable : 4786 ) +#endif + +/* Disable features we do not need. */ +#define YY_NEVER_INTERACTIVE 1 +#undef ECHO /* SGI termios defines this differently. */ +#define ECHO + +/* Replace the lexer input function. */ +#undef YY_INPUT +#define YY_INPUT(buf, result, max_size) \ + { result = yyextra->LexInput(buf, max_size); } + +/* Include the set of tokens from the parser. */ +#include "cmExprParserTokens.h" + + +#if defined( _WIN32 ) && !defined( __CYGWIN__ ) +/* Handle Windows properly */ +# include +# if defined( _MSC_VER ) +# define isatty _isatty +# endif +# define YY_NO_UNISTD_H 1 +#endif + +/*--------------------------------------------------------------------------*/ +#line 518 "/home/andy/vtk/CMake-bin/Source/cmExprLexer.cxx" + +#define INITIAL 0 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + int yy_n_chars; + int yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + }; /* end struct yyguts_t */ + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int cmExpr_yylex_destroy (yyscan_t yyscanner ); + +int cmExpr_yyget_debug (yyscan_t yyscanner ); + +void cmExpr_yyset_debug (int debug_flag ,yyscan_t yyscanner ); + +YY_EXTRA_TYPE cmExpr_yyget_extra (yyscan_t yyscanner ); + +void cmExpr_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); + +FILE *cmExpr_yyget_in (yyscan_t yyscanner ); + +void cmExpr_yyset_in (FILE * in_str ,yyscan_t yyscanner ); + +FILE *cmExpr_yyget_out (yyscan_t yyscanner ); + +void cmExpr_yyset_out (FILE * out_str ,yyscan_t yyscanner ); + +int cmExpr_yyget_leng (yyscan_t yyscanner ); + +char *cmExpr_yyget_text (yyscan_t yyscanner ); + +int cmExpr_yyget_lineno (yyscan_t yyscanner ); + +void cmExpr_yyset_lineno (int line_number ,yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int cmExpr_yywrap (yyscan_t yyscanner ); +#else +extern int cmExpr_yywrap (yyscan_t yyscanner ); +#endif +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (yyscan_t yyscanner ); +#else +static int input (yyscan_t yyscanner ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int cmExpr_yylex (yyscan_t yyscanner); + +#define YY_DECL int cmExpr_yylex (yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + +#line 86 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" + + +#line 736 "/home/andy/vtk/CMake-bin/Source/cmExprLexer.cxx" + + if ( yyg->yy_init ) + { + yyg->yy_init = 0; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + cmExpr_yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + cmExpr_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + } + + cmExpr_yy_load_buffer_state(yyscanner ); + } + + for(;;) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 23 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 21 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 88 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" +{ yylvalp->Number = atoi(yytext); return exp_NUMBER; } +case 2: +YY_RULE_SETUP +#line 90 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" +{ return exp_PLUS; } +case 3: +YY_RULE_SETUP +#line 91 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" +{ return exp_MINUS; } +case 4: +YY_RULE_SETUP +#line 92 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" +{ return exp_TIMES; } +case 5: +YY_RULE_SETUP +#line 93 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" +{ return exp_DIVIDE; } +case 6: +YY_RULE_SETUP +#line 94 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" +{ return exp_MOD; } +case 7: +YY_RULE_SETUP +#line 95 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" +{ return exp_OR; } +case 8: +YY_RULE_SETUP +#line 96 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" +{ return exp_AND; } +case 9: +YY_RULE_SETUP +#line 97 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" +{ return exp_XOR; } +case 10: +YY_RULE_SETUP +#line 98 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" +{ return exp_NOT; } +case 11: +YY_RULE_SETUP +#line 99 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" +{ return exp_SHIFTLEFT; } +case 12: +YY_RULE_SETUP +#line 100 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" +{ return exp_SHIFTRIGHT; } +case 13: +YY_RULE_SETUP +#line 101 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" +{ return exp_OPENPARENT; } +case 14: +YY_RULE_SETUP +#line 102 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" +{ return exp_CLOSEPARENT; } +case 15: +YY_RULE_SETUP +#line 104 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" +ECHO; + YY_BREAK +#line 894 "/home/andy/vtk/CMake-bin/Source/cmExprLexer.cxx" +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * cmExpr_yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( cmExpr_yywrap(yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of cmExpr_yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = yyg->yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + size_t nuto_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( nuto_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + cmExpr_yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + nuto_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( nuto_read > YY_READ_BUF_SIZE ) + nuto_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, nuto_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + cmExpr_yyrestart(yyin ,yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + register yy_state_type yy_current_state; + register char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 23 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + register int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + register char *yy_cp = yyg->yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 23 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 22); + + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + cmExpr_yyrestart(yyin ,yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( cmExpr_yywrap(yyscanner ) ) + return EOF; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void cmExpr_yyrestart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + cmExpr_yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + cmExpr_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + } + + cmExpr_yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); + cmExpr_yy_load_buffer_state(yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void cmExpr_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * cmExpr_yypop_buffer_state(); + * cmExpr_yypush_buffer_state(new_buffer); + */ + cmExpr_yyensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + cmExpr_yy_load_buffer_state(yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (cmExpr_yywrap()) processing, but the only time this flag + * is looked at is after cmExpr_yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void cmExpr_yy_load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE cmExpr_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) cmExpr_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in cmExpr_yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) cmExpr_yyalloc(b->yy_buf_size + 2 ,yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in cmExpr_yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + cmExpr_yy_init_buffer(b,file ,yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with cmExpr_yy_create_buffer() + * @param yyscanner The scanner object. + */ + void cmExpr_yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + cmExpr_yyfree((void *) b->yy_ch_buf ,yyscanner ); + + cmExpr_yyfree((void *) b ,yyscanner ); +} + +#ifndef __cplusplus +extern int isatty (int ); +#endif /* __cplusplus */ + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a cmExpr_yyrestart() or at EOF. + */ + static void cmExpr_yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + cmExpr_yy_flush_buffer(b ,yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then cmExpr_yy_init_buffer was _probably_ + * called from cmExpr_yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void cmExpr_yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + cmExpr_yy_load_buffer_state(yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void cmExpr_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + cmExpr_yyensure_buffer_stack(yyscanner); + + /* This block is copied from cmExpr_yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from cmExpr_yy_switch_to_buffer. */ + cmExpr_yy_load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void cmExpr_yypop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + cmExpr_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + cmExpr_yy_load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void cmExpr_yyensure_buffer_stack (yyscan_t yyscanner) +{ + int nuto_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + nuto_alloc = 1; + yyg->yy_buffer_stack = (struct yy_buffer_state**)cmExpr_yyalloc + (nuto_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + + memset(yyg->yy_buffer_stack, 0, nuto_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = nuto_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + nuto_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)cmExpr_yyrealloc + (yyg->yy_buffer_stack, + nuto_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = nuto_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE cmExpr_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) cmExpr_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in cmExpr_yy_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + cmExpr_yy_switch_to_buffer(b ,yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to cmExpr_yylex() will + * scan from a @e copy of @a str. + * @param str a NUL-terminated string to scan + * @param yy_str a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * cmExpr_yy_scan_bytes() instead. + */ +YY_BUFFER_STATE cmExpr_yy_scan_string (yyconst char * yy_str , yyscan_t yyscanner) +{ + + return cmExpr_yy_scan_bytes(yy_str,strlen(yy_str) ,yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to cmExpr_yylex() will + * scan from a @e copy of @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE cmExpr_yy_scan_bytes (yyconst char * bytes, int len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) cmExpr_yyalloc(n ,yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in cmExpr_yy_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = cmExpr_yy_scan_buffer(buf,n ,yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in cmExpr_yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg , yyscan_t) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE cmExpr_yyget_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int cmExpr_yyget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int cmExpr_yyget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *cmExpr_yyget_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *cmExpr_yyget_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +int cmExpr_yyget_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *cmExpr_yyget_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void cmExpr_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param line_number + * @param yyscanner The scanner object. + */ +void cmExpr_yyset_lineno (int line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + yy_fatal_error( "cmExpr_yyset_lineno called with no buffer" , yyscanner); + + yylineno = line_number; +} + +/** Set the current column. + * @param line_number + * @param yyscanner The scanner object. + */ +void cmExpr_yyset_column (int column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + yy_fatal_error( "cmExpr_yyset_column called with no buffer" , yyscanner); + + yycolumn = column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * @param yyscanner The scanner object. + * @see cmExpr_yy_switch_to_buffer + */ +void cmExpr_yyset_in (FILE * in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = in_str ; +} + +void cmExpr_yyset_out (FILE * out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = out_str ; +} + +int cmExpr_yyget_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void cmExpr_yyset_debug (int bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + This function is called once per scanner lifetime. */ + + yyg->yy_buffer_stack = 0; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = (char *) 0; + yyg->yy_init = 1; + yyg->yy_start = 0; + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = (int *) 0; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = (FILE *) 0; + yyout = (FILE *) 0; +#endif + + /* For future reference: Set errno on error, since we are called by + * cmExpr_yylex_init() + */ + return 0; +} + +/* User-visible API */ + +/* cmExpr_yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ + +int cmExpr_yylex_init(yyscan_t* ptr_yy_globals) + +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) cmExpr_yyalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + memset(*ptr_yy_globals,0,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* cmExpr_yylex_destroy is for both reentrant and non-reentrant scanners. */ +int cmExpr_yylex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + cmExpr_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + cmExpr_yypop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + cmExpr_yyfree(yyg->yy_buffer_stack ,yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + cmExpr_yyfree(yyg->yy_start_stack ,yyscanner ); + yyg->yy_start_stack = NULL; + + /* Destroy the main struct (reentrant only). */ + cmExpr_yyfree ( yyscanner , yyscanner ); + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) +{ + register int i; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) +{ + register int n; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *cmExpr_yyalloc (yy_size_t size , yyscan_t) +{ + return (void *) malloc( size ); +} + +void *cmExpr_yyrealloc (void * ptr, yy_size_t size , yyscan_t) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void cmExpr_yyfree (void * ptr , yyscan_t) +{ + free( (char *) ptr ); /* see cmExpr_yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#undef YY_NEW_FILE +#undef YY_FLUSH_BUFFER +#undef yy_set_bol +#undef yy_new_buffer +#undef yy_set_interactive +#undef yytext_ptr +#undef YY_DO_BEFORE_ACTION + +#ifdef YY_DECL_IS_OURS +#undef YY_DECL_IS_OURS +#undef YY_DECL +#endif +#line 104 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" + + + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExprLexer.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExprLexer.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExprLexer.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExprLexer.h 2006-03-11 02:54:57.000000000 +0800 @@ -0,0 +1,322 @@ +#ifndef cmExpr_yyHEADER_H +#define cmExpr_yyHEADER_H 1 +#define cmExpr_yyIN_HEADER 1 + + + + + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 31 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +int cmExpr_yylex_init (yyscan_t* scanner); + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef unsigned int yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +void cmExpr_yyrestart (FILE *input_file ,yyscan_t yyscanner ); +void cmExpr_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , + yyscan_t yyscanner ); +YY_BUFFER_STATE cmExpr_yy_create_buffer (FILE *file,int size , + yyscan_t yyscanner ); +void cmExpr_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void cmExpr_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void cmExpr_yypush_buffer_state (YY_BUFFER_STATE new_buffer , + yyscan_t yyscanner ); +void cmExpr_yypop_buffer_state (yyscan_t yyscanner ); + +YY_BUFFER_STATE cmExpr_yy_scan_buffer (char *base,yy_size_t size , + yyscan_t yyscanner ); +YY_BUFFER_STATE cmExpr_yy_scan_string (yyconst char *yy_str , + yyscan_t yyscanner ); +YY_BUFFER_STATE cmExpr_yy_scan_bytes (yyconst char *bytes,int len , + yyscan_t yyscanner ); + +void *cmExpr_yyalloc (yy_size_t ,yyscan_t yyscanner ); +void *cmExpr_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); +void cmExpr_yyfree (void * ,yyscan_t yyscanner ); + +/* Begin user sect3 */ + +#define cmExpr_yywrap(n) 1 +#define YY_SKIP_YYWRAP + +#define yytext_ptr yytext_r + +#ifdef YY_HEADER_EXPORT_START_CONDITIONS +#define INITIAL 0 + +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int cmExpr_yylex_destroy (yyscan_t yyscanner ); + +int cmExpr_yyget_debug (yyscan_t yyscanner ); + +void cmExpr_yyset_debug (int debug_flag ,yyscan_t yyscanner ); + +YY_EXTRA_TYPE cmExpr_yyget_extra (yyscan_t yyscanner ); + +void cmExpr_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); + +FILE *cmExpr_yyget_in (yyscan_t yyscanner ); + +void cmExpr_yyset_in (FILE * in_str ,yyscan_t yyscanner ); + +FILE *cmExpr_yyget_out (yyscan_t yyscanner ); + +void cmExpr_yyset_out (FILE * out_str ,yyscan_t yyscanner ); + +int cmExpr_yyget_leng (yyscan_t yyscanner ); + +char *cmExpr_yyget_text (yyscan_t yyscanner ); + +int cmExpr_yyget_lineno (yyscan_t yyscanner ); + +void cmExpr_yyset_lineno (int line_number ,yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int cmExpr_yywrap (yyscan_t yyscanner ); +#else +extern int cmExpr_yywrap (yyscan_t yyscanner ); +#endif +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int cmExpr_yylex (yyscan_t yyscanner); + +#define YY_DECL int cmExpr_yylex (yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +#undef YY_NEW_FILE +#undef YY_FLUSH_BUFFER +#undef yy_set_bol +#undef yy_new_buffer +#undef yy_set_interactive +#undef yytext_ptr +#undef YY_DO_BEFORE_ACTION + +#ifdef YY_DECL_IS_OURS +#undef YY_DECL_IS_OURS +#undef YY_DECL +#endif + + + + +#undef cmExpr_yyIN_HEADER +#endif /* cmExpr_yyHEADER_H */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExprLexer.in.l /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExprLexer.in.l --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExprLexer.in.l 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExprLexer.in.l 2005-10-18 04:42:47.000000000 +0800 @@ -0,0 +1,104 @@ +%{ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmExprLexer.in.l,v $ + Language: C++ + Date: $Date: 2005/10/17 20:42:47 $ + Version: $Revision: 1.1 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +/* + +This file must be translated to C and modified to build everywhere. + +Run flex like this: + + flex --prefix=cmExpr_yy --header-file=cmExprLexer.h -ocmExprLexer.cxx cmExprLexer.in.l + +Modify cmExprLexer.cxx: + - remove TABs + - remove "yyscanner" argument from these methods: + yy_fatal_error, yyalloc, yyrealloc, yyfree + - remove all YY_BREAK lines occurring right after return statements + - change while ( 1 ) to for(;;) + +Modify cmExprLexer.h: + - remove TABs + - remove the yy_init_globals function + - remove the block that includes unistd.h + - remove #line directives (avoids bogus warning on old Sun) + +*/ + +#include "cmExprParserHelper.h" + +/* Disable some warnings. */ +#if defined(_MSC_VER) +# pragma warning ( disable : 4127 ) +# pragma warning ( disable : 4131 ) +# pragma warning ( disable : 4244 ) +# pragma warning ( disable : 4251 ) +# pragma warning ( disable : 4267 ) +# pragma warning ( disable : 4305 ) +# pragma warning ( disable : 4309 ) +# pragma warning ( disable : 4706 ) +# pragma warning ( disable : 4786 ) +#endif + +/* Disable features we do not need. */ +#define YY_NEVER_INTERACTIVE 1 +#undef ECHO /* SGI termios defines this differently. */ +#define ECHO + +/* Replace the lexer input function. */ +#undef YY_INPUT +#define YY_INPUT(buf, result, max_size) \ + { result = yyextra->LexInput(buf, max_size); } + +/* Include the set of tokens from the parser. */ +#include "cmExprParserTokens.h" + + +#if defined( _WIN32 ) && !defined( __CYGWIN__ ) +/* Handle Windows properly */ +# include +# if defined( _MSC_VER ) +# define isatty _isatty +# endif +# define YY_NO_UNISTD_H 1 +#endif + +/*--------------------------------------------------------------------------*/ +%} + +%option reentrant +%option noyywrap +%pointer + +%% + +[0-9][0-9]* { yylvalp->Number = atoi(yytext); return exp_NUMBER; } + +"+" { return exp_PLUS; } +"-" { return exp_MINUS; } +"*" { return exp_TIMES; } +"/" { return exp_DIVIDE; } +"%" { return exp_MOD; } +"\|" { return exp_OR; } +"&" { return exp_AND; } +"^" { return exp_XOR; } +"~" { return exp_NOT; } +"<<" { return exp_SHIFTLEFT; } +">>" { return exp_SHIFTRIGHT; } +"(" { return exp_OPENPARENT; } +")" { return exp_CLOSEPARENT; } + +%% diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExprParser.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExprParser.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExprParser.cxx 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExprParser.cxx 2005-10-18 04:53:11.000000000 +0800 @@ -0,0 +1,1428 @@ +/* A Bison parser, made by GNU Bison 1.875d. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Written by Richard Stallman by simplifying the original so called + ``semantic'' parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* If NAME_PREFIX is specified substitute the variables and functions + names. */ +#define yyparse cmExpr_yyparse +#define yylex cmExpr_yylex +#define yyerror cmExpr_yyerror +#define yylval cmExpr_yylval +#define yychar cmExpr_yychar +#define yydebug cmExpr_yydebug +#define yynerrs cmExpr_yynerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + exp_PLUS = 258, + exp_MINUS = 259, + exp_TIMES = 260, + exp_DIVIDE = 261, + exp_MOD = 262, + exp_SHIFTLEFT = 263, + exp_SHIFTRIGHT = 264, + exp_OPENPARENT = 265, + exp_CLOSEPARENT = 266, + exp_OR = 267, + exp_AND = 268, + exp_XOR = 269, + exp_NOT = 270, + exp_NUMBER = 271 + }; +#endif +#define exp_PLUS 258 +#define exp_MINUS 259 +#define exp_TIMES 260 +#define exp_DIVIDE 261 +#define exp_MOD 262 +#define exp_SHIFTLEFT 263 +#define exp_SHIFTRIGHT 264 +#define exp_OPENPARENT 265 +#define exp_CLOSEPARENT 266 +#define exp_OR 267 +#define exp_AND 268 +#define exp_XOR 269 +#define exp_NOT 270 +#define exp_NUMBER 271 + + + + +/* Copy the first part of user declarations. */ + + +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmExprParser.cxx,v $ + Language: C++ + Date: $Date: 2005/10/17 20:53:11 $ + Version: $Revision: 1.2 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +/* + +This file must be translated to C and modified to build everywhere. + +Run bison like this: + + bison --yacc --name-prefix=cmExpr_yy --defines=cmExprParserTokens.h -ocmExprParser.cxx cmExprParser.y + +Modify cmExprParser.cxx: + - remove TABs + - add __HP_aCC to the #if test for yyerrorlab warning suppression + +*/ + +/* Configure the parser to use a lexer object. */ +#define YYPARSE_PARAM yyscanner +#define YYLEX_PARAM yyscanner +#define YYERROR_VERBOSE 1 +#define cmExpr_yyerror(x) \ + cmExprError(yyscanner, x) +#define yyGetParser (cmExpr_yyget_extra(yyscanner)) + +/*-------------------------------------------------------------------------*/ +#include "cmExprParserHelper.h" /* Interface to parser object. */ +#include "cmExprLexer.h" /* Interface to lexer object. */ +#include "cmExprParserTokens.h" /* Need YYSTYPE for YY_DECL. */ + +#include + +/* Forward declare the lexer entry point. */ +YY_DECL; + +/* Internal utility functions. */ +static void cmExprError(yyscan_t yyscanner, const char* message); + +#define YYDEBUG 1 +//#define YYMAXDEPTH 100000 +//#define YYINITDEPTH 10000 + + +/* Disable some warnings in the generated code. */ +#ifdef __BORLANDC__ +# pragma warn -8004 /* Variable assigned a value that is not used. */ +#endif +#ifdef _MSC_VER +# pragma warning (disable: 4102) /* Unused goto label. */ +# pragma warning (disable: 4065) /* Switch statement contains default but no case. */ +#endif + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 214 of yacc.c. */ + + +#if ! defined (yyoverflow) || YYERROR_VERBOSE + +# ifndef YYFREE +# define YYFREE free +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# endif + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# define YYSTACK_ALLOC alloca +# endif +# else +# if defined (alloca) || defined (_ALLOCA_H) +# define YYSTACK_ALLOC alloca +# else +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# else +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# endif +#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ + + +#if (! defined (yyoverflow) \ + && (! defined (__cplusplus) \ + || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + short int yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined (__GNUC__) && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + register YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (0) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined (__STDC__) || defined (__cplusplus) + typedef signed char yysigned_char; +#else + typedef short int yysigned_char; +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 12 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 25 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 17 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 9 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 20 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 34 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 271 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const unsigned char yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const unsigned char yyprhs[] = +{ + 0, 0, 3, 5, 7, 11, 13, 17, 19, 23, + 25, 29, 33, 35, 39, 43, 45, 49, 53, 57, + 59 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yysigned_char yyrhs[] = +{ + 18, 0, -1, 19, -1, 20, -1, 19, 12, 20, + -1, 21, -1, 20, 14, 21, -1, 22, -1, 21, + 13, 22, -1, 23, -1, 22, 8, 23, -1, 22, + 9, 23, -1, 24, -1, 23, 3, 24, -1, 23, + 4, 24, -1, 25, -1, 24, 5, 25, -1, 24, + 6, 25, -1, 24, 7, 25, -1, 16, -1, 10, + 19, 11, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const unsigned char yyrline[] = +{ + 0, 94, 94, 100, 103, 107, 110, 114, 117, 121, + 124, 127, 132, 135, 138, 142, 145, 148, 151, 155, + 158 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE +/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "exp_PLUS", "exp_MINUS", "exp_TIMES", + "exp_DIVIDE", "exp_MOD", "exp_SHIFTLEFT", "exp_SHIFTRIGHT", + "exp_OPENPARENT", "exp_CLOSEPARENT", "exp_OR", "exp_AND", "exp_XOR", + "exp_NOT", "exp_NUMBER", "$accept", "Start", "exp", "bitwiseor", + "bitwisexor", "bitwiseand", "shift", "term", "factor", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const unsigned short int yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const unsigned char yyr1[] = +{ + 0, 17, 18, 19, 19, 20, 20, 21, 21, 22, + 22, 22, 23, 23, 23, 24, 24, 24, 24, 25, + 25 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const unsigned char yyr2[] = +{ + 0, 2, 1, 1, 3, 1, 3, 1, 3, 1, + 3, 3, 1, 3, 3, 1, 3, 3, 3, 1, + 3 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const unsigned char yydefact[] = +{ + 0, 0, 19, 0, 2, 3, 5, 7, 9, 12, + 15, 0, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 20, 4, 6, 8, 10, 11, 13, + 14, 16, 17, 18 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yysigned_char yydefgoto[] = +{ + -1, 3, 4, 5, 6, 7, 8, 9, 10 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -14 +static const yysigned_char yypact[] = +{ + -10, -10, -14, 18, 7, 6, 8, 2, 1, -4, + -14, 3, -14, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -14, 6, 8, 2, 1, 1, -4, + -4, -14, -14, -14 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yysigned_char yypgoto[] = +{ + -14, -14, 21, 10, 11, 9, 0, -6, -13 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const unsigned char yytable[] = +{ + 1, 20, 21, 22, 18, 19, 2, 31, 32, 33, + 16, 17, 29, 30, 23, 13, 27, 28, 12, 13, + 14, 15, 11, 24, 26, 25 +}; + +static const unsigned char yycheck[] = +{ + 10, 5, 6, 7, 3, 4, 16, 20, 21, 22, + 8, 9, 18, 19, 11, 12, 16, 17, 0, 12, + 14, 13, 1, 13, 15, 14 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const unsigned char yystos[] = +{ + 0, 10, 16, 18, 19, 20, 21, 22, 23, 24, + 25, 19, 0, 12, 14, 13, 8, 9, 3, 4, + 5, 6, 7, 11, 20, 21, 22, 23, 23, 24, + 24, 25, 25, 25 +}; + +#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) +# define YYSIZE_T __SIZE_TYPE__ +#endif +#if ! defined (YYSIZE_T) && defined (size_t) +# define YYSIZE_T size_t +#endif +#if ! defined (YYSIZE_T) +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int +#endif + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror ("syntax error: cannot back up");\ + YYERROR; \ + } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +/* YYLLOC_DEFAULT -- Compute the default location (before the actions + are run). */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + ((Current).first_line = (Rhs)[1].first_line, \ + (Current).first_column = (Rhs)[1].first_column, \ + (Current).last_line = (Rhs)[N].last_line, \ + (Current).last_column = (Rhs)[N].last_column) +#endif + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +# define YYDSYMPRINT(Args) \ +do { \ + if (yydebug) \ + yysymprint Args; \ +} while (0) + +# define YYDSYMPRINTF(Title, Token, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yysymprint (stderr, \ + Token, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_stack_print (short int *bottom, short int *top) +#else +static void +yy_stack_print (bottom, top) + short int *bottom; + short int *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (/* Nothing. */; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_reduce_print (int yyrule) +#else +static void +yy_reduce_print (yyrule) + int yyrule; +#endif +{ + int yyi; + unsigned int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", + yyrule - 1, yylno); + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) + YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YYDSYMPRINT(Args) +# define YYDSYMPRINTF(Title, Token, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 +# undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined (__GLIBC__) && defined (_STRING_H) +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +# if defined (__STDC__) || defined (__cplusplus) +yystrlen (const char *yystr) +# else +yystrlen (yystr) + const char *yystr; +# endif +{ + register const char *yys = yystr; + + while (*yys++ != '\0') + continue; + + return yys - yystr - 1; +} +# endif +# endif + +# ifndef yystpcpy +# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +# if defined (__STDC__) || defined (__cplusplus) +yystpcpy (char *yydest, const char *yysrc) +# else +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +# endif +{ + register char *yyd = yydest; + register const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +#endif /* !YYERROR_VERBOSE */ + + + +#if YYDEBUG +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) +#else +static void +yysymprint (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + if (yytype < YYNTOKENS) + { + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); +# ifdef YYPRINT + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + } + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + switch (yytype) + { + default: + break; + } + YYFPRINTF (yyoutput, ")"); +} + +#endif /* ! YYDEBUG */ +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yydestruct (int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yytype, yyvaluep) + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM); +# else +int yyparse (); +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM) +# else +int yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + /* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + register int yystate; + register int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + short int yyssa[YYINITDEPTH]; + short int *yyss = yyssa; + register short int *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + register YYSTYPE *yyvsp; + + + +#define YYPOPSTACK (yyvsp--, yyssp--) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* When reducing, the number of symbols on the RHS of the reduced + rule. */ + int yylen; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. + */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + short int *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow ("parser stack overflow", + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyoverflowlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyoverflowlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + short int *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyoverflowlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; + + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + yystate = yyn; + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: + + { + yyGetParser->SetResult(yyvsp[0].Number); +} + break; + + case 3: + + {yyval.Number = yyvsp[0].Number;} + break; + + case 4: + + {yyval.Number = yyvsp[-2].Number | yyvsp[0].Number;} + break; + + case 5: + + {yyval.Number = yyvsp[0].Number;} + break; + + case 6: + + {yyval.Number = yyvsp[-2].Number ^ yyvsp[0].Number;} + break; + + case 7: + + {yyval.Number = yyvsp[0].Number;} + break; + + case 8: + + {yyval.Number = yyvsp[-2].Number & yyvsp[0].Number;} + break; + + case 9: + + {yyval.Number = yyvsp[0].Number;} + break; + + case 10: + + {yyval.Number = yyvsp[-2].Number << yyvsp[0].Number;} + break; + + case 11: + + {yyval.Number = yyvsp[-2].Number >> yyvsp[0].Number;} + break; + + case 12: + + {yyval.Number = yyvsp[0].Number;} + break; + + case 13: + + {yyval.Number = yyvsp[-2].Number + yyvsp[0].Number;} + break; + + case 14: + + {yyval.Number = yyvsp[-2].Number - yyvsp[0].Number;} + break; + + case 15: + + {yyval.Number = yyvsp[0].Number;} + break; + + case 16: + + {yyval.Number = yyvsp[-2].Number * yyvsp[0].Number;} + break; + + case 17: + + {yyval.Number = yyvsp[-2].Number / yyvsp[0].Number;} + break; + + case 18: + + {yyval.Number = yyvsp[-2].Number % yyvsp[0].Number;} + break; + + case 19: + + {yyval.Number = yyvsp[0].Number;} + break; + + case 20: + + {yyval.Number = yyvsp[-1].Number;} + break; + + + } + +/* Line 1010 of yacc.c. */ + + + yyvsp -= yylen; + yyssp -= yylen; + + + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (YYPACT_NINF < yyn && yyn < YYLAST) + { + YYSIZE_T yysize = 0; + int yytype = YYTRANSLATE (yychar); + const char* yyprefix; + char *yymsg; + int yyx; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 0; + + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); + yycount += 1; + if (yycount == 5) + { + yysize = 0; + break; + } + } + yysize += (sizeof ("syntax error, unexpected ") + + yystrlen (yytname[yytype])); + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg != 0) + { + char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); + yyp = yystpcpy (yyp, yytname[yytype]); + + if (yycount < 5) + { + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yyp = yystpcpy (yyp, yyprefix); + yyp = yystpcpy (yyp, yytname[yyx]); + yyprefix = " or "; + } + } + yyerror (yymsg); + YYSTACK_FREE (yymsg); + } + else + yyerror ("syntax error; also virtual memory exhausted"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror ("syntax error"); + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* If at end of input, pop the error token, + then the rest of the stack, then return failure. */ + if (yychar == YYEOF) + for (;;) + { + YYPOPSTACK; + if (yyssp == yyss) + YYABORT; + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[*yyssp], yyvsp); + } + } + else + { + YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); + yydestruct (yytoken, &yylval); + yychar = YYEMPTY; + + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + +#if defined( __GNUC__ ) || defined(__HP_aCC) + /* Pacify GCC when the user code never invokes YYERROR and the label + yyerrorlab therefore never appears in user code. */ + if (0) + goto yyerrorlab; +#endif + + yyvsp -= yylen; + yyssp -= yylen; + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[yystate], yyvsp); + YYPOPSTACK; + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + YYDPRINTF ((stderr, "Shifting error token, ")); + + *++yyvsp = yylval; + + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*----------------------------------------------. +| yyoverflowlab -- parser overflow comes here. | +`----------------------------------------------*/ +yyoverflowlab: + yyerror ("parser stack overflow"); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif + return yyresult; +} + + + + +/* End of grammar */ + +/*--------------------------------------------------------------------------*/ +void cmExprError(yyscan_t yyscanner, const char* message) +{ + yyGetParser->Error(message); +} + + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExprParserHelper.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExprParserHelper.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExprParserHelper.cxx 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExprParserHelper.cxx 2006-03-16 00:02:01.000000000 +0800 @@ -0,0 +1,133 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmExprParserHelper.cxx,v $ + Language: C++ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.2 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "cmExprParserHelper.h" + +#include "cmSystemTools.h" +#include "cmExprLexer.h" + +#include "cmMakefile.h" + +int cmExpr_yyparse( yyscan_t yyscanner ); +// +cmExprParserHelper::cmExprParserHelper() +{ + this->FileLine = -1; + this->FileName = 0; +} + + +cmExprParserHelper::~cmExprParserHelper() +{ + this->CleanupParser(); +} + +void cmExprParserHelper::SetLineFile(long line, const char* file) +{ + this->FileLine = line; + this->FileName = file; +} + +int cmExprParserHelper::ParseString(const char* str, int verb) +{ + if ( !str) + { + return 0; + } + //printf("Do some parsing: %s\n", str); + + this->Verbose = verb; + this->InputBuffer = str; + this->InputBufferPos = 0; + this->CurrentLine = 0; + + this->Result = 0; + + yyscan_t yyscanner; + cmExpr_yylex_init(&yyscanner); + cmExpr_yyset_extra(this, yyscanner); + int res = cmExpr_yyparse(yyscanner); + cmExpr_yylex_destroy(yyscanner); + if ( res != 0 ) + { + //str << "CAL_Parser returned: " << res << std::endl; + //std::cerr << "When parsing: [" << str << "]" << std::endl; + return 0; + } + + this->CleanupParser(); + + if ( Verbose ) + { + std::cerr << "Expanding [" << str << "] produced: [" << this->Result << "]" << std::endl; + } + return 1; +} + +void cmExprParserHelper::CleanupParser() +{ +} + +int cmExprParserHelper::LexInput(char* buf, int maxlen) +{ + //std::cout << "JPLexInput "; + //std::cout.write(buf, maxlen); + //std::cout << std::endl; + if ( maxlen < 1 ) + { + return 0; + } + if ( this->InputBufferPos < this->InputBuffer.size() ) + { + buf[0] = this->InputBuffer[ this->InputBufferPos++ ]; + if ( buf[0] == '\n' ) + { + this->CurrentLine ++; + } + return(1); + } + else + { + buf[0] = '\n'; + return( 0 ); + } +} + +void cmExprParserHelper::Error(const char* str) +{ + unsigned long pos = static_cast(this->InputBufferPos); + //fprintf(stderr, "Argument Parser Error: %s (%lu / Line: %d)\n", str, pos, this->CurrentLine); + cmOStringStream ostr; + ostr << str << " (" << pos << ")"; + /* + int cc; + std::cerr << "String: ["; + for ( cc = 0; cc < 30 && *(this->InputBuffer.c_str() + this->InputBufferPos + cc); + cc ++ ) + { + std::cerr << *(this->InputBuffer.c_str() + this->InputBufferPos + cc); + } + std::cerr << "]" << std::endl; + */ + this->ErrorString = ostr.str(); +} + +void cmExprParserHelper::SetResult(int value) +{ + this->Result = value; +} + + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExprParserHelper.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExprParserHelper.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExprParserHelper.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExprParserHelper.h 2006-03-16 00:02:01.000000000 +0800 @@ -0,0 +1,79 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmExprParserHelper.h,v $ + Language: C++ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.2 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef cmExprParserHelper_h +#define cmExprParserHelper_h + +#include "cmStandardIncludes.h" + +#define YYSTYPE cmExprParserHelper::ParserType +#define YYSTYPE_IS_DECLARED +#define YY_EXTRA_TYPE cmExprParserHelper* +#define YY_DECL int cmExpr_yylex(YYSTYPE* yylvalp, yyscan_t yyscanner) + +/** \class cmExprParserHelper + * \brief Helper class for parsing java source files + * + * Finds dependencies for java file and list of outputs + */ + +class cmMakefile; + +class cmExprParserHelper +{ +public: + typedef struct { + int Number; + } ParserType; + + cmExprParserHelper(); + ~cmExprParserHelper(); + + int ParseString(const char* str, int verb); + + int LexInput(char* buf, int maxlen); + void Error(const char* str); + + void SetResult(int value); + + int GetResult() { return this->Result; } + + void SetLineFile(long line, const char* file); + + const char* GetError() { return this->ErrorString.c_str(); } + +private: + cmStdString::size_type InputBufferPos; + cmStdString InputBuffer; + std::vector OutputBuffer; + int CurrentLine; + int UnionsAvailable; + int Verbose; + + void Print(const char* place, const char* str); + + void CleanupParser(); + + int Result; + const char* FileName; + long FileLine; + std::string ErrorString; +}; + +#endif + + + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExprParserTokens.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExprParserTokens.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExprParserTokens.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExprParserTokens.h 2006-03-11 02:54:57.000000000 +0800 @@ -0,0 +1,76 @@ +/* A Bison parser, made by GNU Bison 1.875d. */ + +/* Skeleton parser for Yacc-like parsing with Bison, Copyright (C) 1984, + 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + exp_PLUS = 258, + exp_MINUS = 259, + exp_TIMES = 260, + exp_DIVIDE = 261, + exp_MOD = 262, + exp_SHIFTLEFT = 263, + exp_SHIFTRIGHT = 264, + exp_OPENPARENT = 265, + exp_CLOSEPARENT = 266, + exp_OR = 267, + exp_AND = 268, + exp_XOR = 269, + exp_NOT = 270, + exp_NUMBER = 271 + }; +#endif +#define exp_PLUS 258 +#define exp_MINUS 259 +#define exp_TIMES 260 +#define exp_DIVIDE 261 +#define exp_MOD 262 +#define exp_SHIFTLEFT 263 +#define exp_SHIFTRIGHT 264 +#define exp_OPENPARENT 265 +#define exp_CLOSEPARENT 266 +#define exp_OR 267 +#define exp_AND 268 +#define exp_XOR 269 +#define exp_NOT 270 +#define exp_NUMBER 271 + + + + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + + + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExprParser.y /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExprParser.y --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmExprParser.y 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmExprParser.y 2005-10-18 04:53:11.000000000 +0800 @@ -0,0 +1,171 @@ +%{ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmExprParser.y,v $ + Language: C++ + Date: $Date: 2005/10/17 20:53:11 $ + Version: $Revision: 1.2 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +/* + +This file must be translated to C and modified to build everywhere. + +Run bison like this: + + bison --yacc --name-prefix=cmExpr_yy --defines=cmExprParserTokens.h -ocmExprParser.cxx cmExprParser.y + +Modify cmExprParser.cxx: + - remove TABs + - add __HP_aCC to the #if test for yyerrorlab warning suppression + +*/ + +/* Configure the parser to use a lexer object. */ +#define YYPARSE_PARAM yyscanner +#define YYLEX_PARAM yyscanner +#define YYERROR_VERBOSE 1 +#define cmExpr_yyerror(x) \ + cmExprError(yyscanner, x) +#define yyGetParser (cmExpr_yyget_extra(yyscanner)) + +/*-------------------------------------------------------------------------*/ +#include "cmExprParserHelper.h" /* Interface to parser object. */ +#include "cmExprLexer.h" /* Interface to lexer object. */ +#include "cmExprParserTokens.h" /* Need YYSTYPE for YY_DECL. */ + +#include + +/* Forward declare the lexer entry point. */ +YY_DECL; + +/* Internal utility functions. */ +static void cmExprError(yyscan_t yyscanner, const char* message); + +#define YYDEBUG 1 +//#define YYMAXDEPTH 100000 +//#define YYINITDEPTH 10000 + + +/* Disable some warnings in the generated code. */ +#ifdef __BORLANDC__ +# pragma warn -8004 /* Variable assigned a value that is not used. */ +#endif +#ifdef _MSC_VER +# pragma warning (disable: 4102) /* Unused goto label. */ +# pragma warning (disable: 4065) /* Switch statement contains default but no case. */ +#endif +%} + +/* Generate a reentrant parser object. */ +%pure_parser + +/*-------------------------------------------------------------------------*/ +/* Tokens */ +%token exp_PLUS +%token exp_MINUS +%token exp_TIMES +%token exp_DIVIDE +%token exp_MOD +%token exp_SHIFTLEFT +%token exp_SHIFTRIGHT +%token exp_OPENPARENT +%token exp_CLOSEPARENT +%token exp_OR; +%token exp_AND; +%token exp_XOR; +%token exp_NOT; +%token exp_NUMBER; + +/*-------------------------------------------------------------------------*/ +/* grammar */ +%% + + +Start: +exp +{ + yyGetParser->SetResult($1); +} + +exp: +bitwiseor +{$$ = $1;} +| +exp exp_OR bitwiseor +{$$ = $1 | $3;} + +bitwiseor: +bitwisexor +{$$ = $1;} +| +bitwiseor exp_XOR bitwisexor +{$$ = $1 ^ $3;} + +bitwisexor: +bitwiseand +{$$ = $1;} +| +bitwisexor exp_AND bitwiseand +{$$ = $1 & $3;} + +bitwiseand: +shift +{$$ = $1;} +| +bitwiseand exp_SHIFTLEFT shift +{$$ = $1 << $3;} +| +bitwiseand exp_SHIFTRIGHT shift +{$$ = $1 >> $3;} + + +shift: +term +{$$ = $1;} +| +shift exp_PLUS term +{$$ = $1 + $3;} +| +shift exp_MINUS term +{$$ = $1 - $3;} + +term: +factor +{$$ = $1;} +| +term exp_TIMES factor +{$$ = $1 * $3;} +| +term exp_DIVIDE factor +{$$ = $1 / $3;} +| +term exp_MOD factor +{$$ = $1 % $3;} + +factor: +exp_NUMBER +{$$ = $1;} +| +exp_OPENPARENT exp exp_CLOSEPARENT +{$$ = $2;} +; + + +%% +/* End of grammar */ + +/*--------------------------------------------------------------------------*/ +void cmExprError(yyscan_t yyscanner, const char* message) +{ + yyGetParser->Error(message); +} + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFileCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFileCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFileCommand.cxx 2005-10-25 03:43:52.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFileCommand.cxx 2006-03-16 00:02:01.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFileCommand.cxx,v $ Language: C++ - Date: $Date: 2005/10/24 19:43:52 $ - Version: $Revision: 1.29.2.4 $ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.44 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -20,6 +20,7 @@ #include #include +#include // cmLibraryCommand bool cmFileCommand::InitialPass(std::vector const& args) @@ -54,6 +55,14 @@ { return this->HandleMakeDirectoryCommand(args); } + else if ( subCommand == "REMOVE" ) + { + return this->HandleRemove(args, false); + } + else if ( subCommand == "REMOVE_RECURSE" ) + { + return this->HandleRemove(args, true); + } else if ( subCommand == "INSTALL" ) { return this->HandleInstallCommand(args); @@ -62,6 +71,10 @@ { return this->HandleRelativePathCommand(args); } + else if ( subCommand == "SYSTEM_PATH" ) + { + return this->HandleSystemPathCommand(args); + } std::string e = "does not recognize sub-command "+subCommand; this->SetError(e.c_str()); @@ -80,7 +93,7 @@ std::string fileName = *i; if ( !cmsys::SystemTools::FileIsFullPath(i->c_str()) ) { - fileName = m_Makefile->GetCurrentDirectory(); + fileName = this->Makefile->GetCurrentDirectory(); fileName += "/" + *i; } @@ -130,7 +143,7 @@ file << message; file.close(); cmSystemTools::SetPermissions(fileName.c_str(), mode); - m_Makefile->AddWrittenFile(fileName.c_str()); + this->Makefile->AddWrittenFile(fileName.c_str()); return true; } @@ -146,7 +159,7 @@ std::string fileName = args[1]; if ( !cmsys::SystemTools::FileIsFullPath(args[1].c_str()) ) { - fileName = m_Makefile->GetCurrentDirectory(); + fileName = this->Makefile->GetCurrentDirectory(); fileName += "/" + args[1]; } @@ -172,7 +185,7 @@ output += "\n"; } } - m_Makefile->AddDefinition(variable.c_str(), output.c_str()); + this->Makefile->AddDefinition(variable.c_str(), output.c_str()); return true; } @@ -200,7 +213,7 @@ { if ( !cmsys::SystemTools::FileIsFullPath(i->c_str()) ) { - std::string expr = m_Makefile->GetCurrentDirectory(); + std::string expr = this->Makefile->GetCurrentDirectory(); // Handle script mode if ( expr.size() > 0 ) { @@ -228,7 +241,7 @@ first = false; } } - m_Makefile->AddDefinition(variable.c_str(), output.c_str()); + this->Makefile->AddDefinition(variable.c_str(), output.c_str()); return true; } @@ -252,7 +265,7 @@ const std::string* cdir = &(*i); if ( !cmsys::SystemTools::FileIsFullPath(i->c_str()) ) { - expr = m_Makefile->GetCurrentDirectory(); + expr = this->Makefile->GetCurrentDirectory(); expr += "/" + *i; cdir = &expr; } @@ -276,9 +289,10 @@ return false; } + std::string rename = ""; std::string destination = ""; std::string stype = "FILES"; - const char* build_type = m_Makefile->GetDefinition("BUILD_TYPE"); + const char* build_type = this->Makefile->GetDefinition("BUILD_TYPE"); if ( build_type && strcmp(build_type, ".") == 0 ) { build_type = 0; @@ -288,27 +302,8 @@ build_type += 2; } - const char* debug_postfix - = m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX"); - if(!debug_postfix) - { - debug_postfix = ""; - } const char* destdir = cmSystemTools::GetEnv("DESTDIR"); - std::string extra_dir = ""; - int debug = 0; - if ( build_type ) - { - extra_dir = build_type; - std::string btype = cmSystemTools::LowerCase(build_type); - if ( m_Makefile->GetDefinition("WIN32") - && strncmp(btype.c_str(), "debug", strlen("debug")) == 0 ) - { - debug = 1; - } - } - std::vector files; int itype = cmTarget::INSTALL_FILES; @@ -317,8 +312,38 @@ std::map properties; + // Build a table of permissions flags. +#if defined(_WIN32) && !defined(__CYGWIN__) + mode_t mode_owner_read = S_IREAD; + mode_t mode_owner_write = S_IWRITE; + mode_t mode_owner_execute = S_IEXEC; + mode_t mode_group_read = 0; + mode_t mode_group_write = 0; + mode_t mode_group_execute = 0; + mode_t mode_world_read = 0; + mode_t mode_world_write = 0; + mode_t mode_world_execute = 0; + mode_t mode_setuid = 0; + mode_t mode_setgid = 0; +#else + mode_t mode_owner_read = S_IRUSR; + mode_t mode_owner_write = S_IWUSR; + mode_t mode_owner_execute = S_IXUSR; + mode_t mode_group_read = S_IRGRP; + mode_t mode_group_write = S_IWGRP; + mode_t mode_group_execute = S_IXGRP; + mode_t mode_world_read = S_IROTH; + mode_t mode_world_write = S_IWOTH; + mode_t mode_world_execute = S_IXOTH; + mode_t mode_setuid = S_ISUID; + mode_t mode_setgid = S_ISGID; +#endif + bool in_files = false; bool in_properties = false; + bool in_permissions = false; + bool use_given_permissions = false; + mode_t permissions = 0; bool optional = false; for ( ; i != args.size(); ++i ) { @@ -329,6 +354,7 @@ destination = args[i]; in_files = false; in_properties = false; + in_permissions = false; } else if ( *cstr == "TYPE" && i < args.size()-1 ) { @@ -341,16 +367,34 @@ } in_properties = false; in_files = false; + in_permissions = false; + } + else if ( *cstr == "RENAME" && i < args.size()-1 ) + { + i++; + rename = args[i]; + in_properties = false; + in_files = false; + in_permissions = false; } else if ( *cstr == "PROPERTIES" ) { in_properties = true; in_files = false; + in_permissions = false; + } + else if ( *cstr == "PERMISSIONS" ) + { + use_given_permissions = true; + in_properties = false; + in_files = false; + in_permissions = true; } else if ( *cstr == "FILES" && !in_files) { in_files = true; in_properties = false; + in_permissions = false; } else if ( in_properties && i < args.size()-1 ) { @@ -361,6 +405,50 @@ { files.push_back(*cstr); } + else if(in_permissions && args[i] == "OWNER_READ") + { + permissions |= mode_owner_read; + } + else if(in_permissions && args[i] == "OWNER_WRITE") + { + permissions |= mode_owner_write; + } + else if(in_permissions && args[i] == "OWNER_EXECUTE") + { + permissions |= mode_owner_execute; + } + else if(in_permissions && args[i] == "GROUP_READ") + { + permissions |= mode_group_read; + } + else if(in_permissions && args[i] == "GROUP_WRITE") + { + permissions |= mode_group_write; + } + else if(in_permissions && args[i] == "GROUP_EXECUTE") + { + permissions |= mode_group_execute; + } + else if(in_permissions && args[i] == "WORLD_READ") + { + permissions |= mode_world_read; + } + else if(in_permissions && args[i] == "WORLD_WRITE") + { + permissions |= mode_world_write; + } + else if(in_permissions && args[i] == "WORLD_EXECUTE") + { + permissions |= mode_world_execute; + } + else if(in_permissions && args[i] == "SETUID") + { + permissions |= mode_setuid; + } + else if(in_permissions && args[i] == "SETGID") + { + permissions |= mode_setgid; + } else { this->SetError("called with inappropriate arguments"); @@ -392,7 +480,7 @@ if ( ch1 != '/' ) { int relative = 0; - if ( ( ch1 >= 'a' && ch1 <= 'z' || ch1 >= 'a' && ch1 <= 'z' ) && + if ( ( ch1 >= 'a' && ch1 <= 'z' || ch1 >= 'A' && ch1 <= 'Z' ) && ch2 == ':' ) { // Assume windows @@ -471,45 +559,93 @@ } if ( !cmSystemTools::FileIsDirectory(destination.c_str()) ) { - std::string errstring = "found file: " + destination + - " where expecting directory with the same name."; + std::string errstring = "INSTALL destination: " + destination + + " is not a directory."; this->SetError(errstring.c_str()); return false; } + // Check rename form. + if(!rename.empty()) + { + if(itype != cmTarget::INSTALL_FILES) + { + this->SetError("INSTALL option RENAME may be used only with FILES."); + return false; + } + if(files.size() > 1) + { + this->SetError("INSTALL option RENAME may be used only with one file."); + return false; + } + } + + // If permissions were not specified set default permissions for + // this target type. + bool use_source_permissions = false; + if(!use_given_permissions) + { + switch(itype) + { + case cmTarget::SHARED_LIBRARY: + case cmTarget::MODULE_LIBRARY: +#if defined(__linux__) + // Use read/write permissions. + use_given_permissions = true; + permissions = 0; + permissions |= mode_owner_read; + permissions |= mode_owner_write; + permissions |= mode_group_read; + permissions |= mode_world_read; + break; +#endif + case cmTarget::EXECUTABLE: + case cmTarget::INSTALL_PROGRAMS: + // Use read/write/executable permissions. + use_given_permissions = true; + permissions = 0; + permissions |= mode_owner_read; + permissions |= mode_owner_write; + permissions |= mode_owner_execute; + permissions |= mode_group_read; + permissions |= mode_group_execute; + permissions |= mode_world_read; + permissions |= mode_world_execute; + break; + default: + // Use the permissions of the file being copied. + use_source_permissions = true; + break; + } + } + + // Get the current manifest. const char* manifest_files = - m_Makefile->GetDefinition("CMAKE_INSTALL_MANIFEST_FILES"); + this->Makefile->GetDefinition("CMAKE_INSTALL_MANIFEST_FILES"); std::string smanifest_files; if ( manifest_files ) { smanifest_files = manifest_files; } + // Handle each file listed. for ( i = 0; i < files.size(); i ++ ) { - std::string destfilewe - = destination + "/" - + cmSystemTools::GetFilenameWithoutExtension(files[i]); - std::string ctarget = files[i].c_str(); - std::string fname = cmSystemTools::GetFilenameName(ctarget); - std::string ext = cmSystemTools::GetFilenameExtension(ctarget); - std::string fnamewe - = cmSystemTools::GetFilenameWithoutExtension(ctarget); - std::string destfile = destfilewe; - if ( ext.size() ) - { - destfile += ext; - } - switch( itype ) - { - case cmTarget::MODULE_LIBRARY: - case cmTarget::STATIC_LIBRARY: - case cmTarget::SHARED_LIBRARY: - if ( debug ) - { - fname = fnamewe + debug_postfix + ext; - destfile = destfilewe + debug_postfix + ext; - } + // Split the input file into its directory and name components. + std::string fromDir = cmSystemTools::GetFilenamePath(files[i]); + std::string fromName = cmSystemTools::GetFilenameName(files[i]); + + // Compute the full path to the destination file. + std::string toFile = destination; + toFile += "/"; + toFile += rename.empty()? fromName : rename; + + // Handle type-specific installation details. + switch(itype) + { + case cmTarget::MODULE_LIBRARY: + case cmTarget::STATIC_LIBRARY: + case cmTarget::SHARED_LIBRARY: { // Handle shared library versioning const char* lib_version = 0; @@ -532,18 +668,18 @@ } if ( lib_version && lib_soversion ) { - std::string libname = destfile; - std::string soname = destfile; - std::string soname_nopath = fname; + std::string libname = toFile; + std::string soname = toFile; + std::string soname_nopath = fromName; soname += "."; soname += lib_soversion; soname_nopath += "."; soname_nopath += lib_soversion; - fname += "."; - fname += lib_version; - destfile += "."; - destfile += lib_version; + fromName += "."; + fromName += lib_version; + toFile += "."; + toFile += lib_version; cmSystemTools::RemoveFile(soname.c_str()); cmSystemTools::RemoveFile(libname.c_str()); @@ -556,11 +692,11 @@ } smanifest_files += ";"; smanifest_files += libname.substr(destDirLength);; - if ( destfile != soname ) + if ( toFile != soname ) { - if ( !cmSystemTools::CreateSymlink(fname.c_str(), soname.c_str()) ) + if ( !cmSystemTools::CreateSymlink(fromName.c_str(), soname.c_str()) ) { - std::string errstring = "error when creating symlink from: " + soname + " to " + fname; + std::string errstring = "error when creating symlink from: " + soname + " to " + fromName; this->SetError(errstring.c_str()); return false; } @@ -568,135 +704,134 @@ smanifest_files += soname.substr(destDirLength); } } - - // Reconstruct the source file path taking into account the - // extra directory and possible new file name. - cmOStringStream str; - str << cmSystemTools::GetFilenamePath(ctarget) << "/"; - if ( extra_dir.size() > 0 ) - { - str << extra_dir << "/"; - } - str << fname; - ctarget = str.str(); - } - break; - case cmTarget::EXECUTABLE: - { - // Handle executable versioning - const char* exe_version = 0; - if ( properties.find("VERSION") != properties.end() ) - { - exe_version = properties["VERSION"]; } - if ( exe_version ) + break; + case cmTarget::EXECUTABLE: { - std::string exename = destfile; - std::string exename_nopath = fname; - exename_nopath += "-"; - exename_nopath += exe_version; + // Handle executable versioning + const char* exe_version = 0; + if ( properties.find("VERSION") != properties.end() ) + { + exe_version = properties["VERSION"]; + } + if ( exe_version ) + { + std::string exename = toFile; + std::string exename_nopath = fromName; + exename_nopath += "-"; + exename_nopath += exe_version; - fname += "-"; - fname += exe_version; - destfile += "-"; - destfile += exe_version; + fromName += "-"; + fromName += exe_version; + toFile += "-"; + toFile += exe_version; - cmSystemTools::RemoveFile(exename.c_str()); + cmSystemTools::RemoveFile(exename.c_str()); - if (!cmSystemTools::CreateSymlink(exename_nopath.c_str(), exename.c_str()) ) - { - std::string errstring = "error when creating symlink from: " + exename + " to " + exename_nopath; - this->SetError(errstring.c_str()); - return false; + if (!cmSystemTools::CreateSymlink(exename_nopath.c_str(), exename.c_str()) ) + { + std::string errstring = "error when creating symlink from: " + exename + " to " + exename_nopath; + this->SetError(errstring.c_str()); + return false; + } + smanifest_files += ";"; + smanifest_files += exename.substr(destDirLength); } - smanifest_files += ";"; - smanifest_files += exename.substr(destDirLength); - } - - // Reconstruct the source file path taking into account the - // extra directory and possible new file name. - cmOStringStream str; - str << cmSystemTools::GetFilenamePath(ctarget) << "/"; - if ( extra_dir.size() > 0 ) - { - str << extra_dir << "/"; } - str << fname; - ctarget = str.str(); - } - break; + break; } - if ( !cmSystemTools::SameFile(ctarget.c_str(), destfile.c_str()) ) - { - if ( cmSystemTools::FileExists(ctarget.c_str()) ) - { - cmSystemTools::RemoveFile(destfile.c_str()); - if ( !cmSystemTools::CopyFileAlways(ctarget.c_str(), - destination.c_str()) ) - { - std::string errstring = "cannot copy file: " + ctarget + - " to directory : " + destination + "."; - this->SetError(errstring.c_str()); + // Construct the full path to the source file. The file name may + // have been changed above. + std::string fromFile = fromDir; + fromFile += "/"; + fromFile += fromName; + + std::string message; + if(!cmSystemTools::SameFile(fromFile.c_str(), toFile.c_str())) + { + if(cmSystemTools::FileExists(fromFile.c_str())) + { + // We will install this file. Display the information. + message = "Installing "; + message += toFile.c_str(); + this->Makefile->DisplayStatus(message.c_str(), -1); + + // If no permissions were already given use the permissions of + // the file being copied. + if(!use_given_permissions && + (!use_source_permissions || + !cmSystemTools::GetPermissions(fromFile.c_str(), permissions))) + { + // Set default permissions. + permissions = 0; + permissions |= mode_owner_read; + permissions |= mode_owner_write; + permissions |= mode_group_read; + permissions |= mode_world_read; + } + + // Remove the original file and try copying the new file. + // TODO: This should be copy-if-different. Don't forget to + // edit the destination file permissions, or compare files + // first. This would need a new SystemTools::FilesDiffer that + // does not read all of the files at once. + cmSystemTools::RemoveFile(toFile.c_str()); + if(!cmSystemTools::CopyFileAlways(fromFile.c_str(), toFile.c_str())) + { + cmOStringStream e; + e << "INSTALL cannot copy file \"" << fromFile + << "\" to \"" << toFile + "\"."; + this->SetError(e.str().c_str()); return false; } - switch( itype ) - { - case cmTarget::STATIC_LIBRARY: + + // Perform post-installation processing on the file depending + // on its type. #if defined(__APPLE_CC__) + // Static libraries need ranlib on this platform. + if(itype == cmTarget::STATIC_LIBRARY) + { + std::string ranlib = "ranlib "; + ranlib += cmSystemTools::ConvertToOutputPath(toFile.c_str()); + if(!cmSystemTools::RunSingleCommand(ranlib.c_str())) { - std::string ranlib = "ranlib "; - ranlib += cmSystemTools::ConvertToOutputPath(destfile.c_str()); - if(!cmSystemTools::RunSingleCommand(ranlib.c_str())) - { - std::string err = "ranlib failed: "; - err += ranlib; - this->SetError(err.c_str()); - } + std::string err = "ranlib failed: "; + err += ranlib; + this->SetError(err.c_str()); + return false; } + } #endif - break; - - case cmTarget::MODULE_LIBRARY: - case cmTarget::SHARED_LIBRARY: - case cmTarget::EXECUTABLE: - case cmTarget::INSTALL_PROGRAMS: - - if ( !cmSystemTools::SetPermissions(destfile.c_str(), -#if defined( _MSC_VER ) || defined( __MINGW32__ ) - S_IREAD | S_IWRITE | S_IEXEC -#elif defined( __BORLANDC__ ) - S_IRUSR | S_IWUSR | S_IXUSR -#else - S_IRUSR | S_IWUSR | S_IXUSR | - S_IRGRP | S_IXGRP | - S_IROTH | S_IXOTH -#endif - ) ) - { - cmOStringStream err; - err << "Problem setting permissions on file: " - << destfile.c_str(); - perror(err.str().c_str()); - } + + // Set permissions of the destination file. + if(!cmSystemTools::SetPermissions(toFile.c_str(), permissions)) + { + cmOStringStream e; + e << "Problem setting permissions on file \"" + << toFile.c_str() << "\""; + this->SetError(e.str().c_str()); + return false; } + + // Add the file to the manifest. smanifest_files += ";"; - smanifest_files += destfile.substr(destDirLength); + smanifest_files += toFile.substr(destDirLength); } - else + else if(!optional) { - if ( !optional ) - { - std::string errstring = "cannot find file: " + - ctarget + " to install."; - this->SetError(errstring.c_str()); - return false; - } + // The input file does not exist and installation is not optional. + cmOStringStream e; + e << "INSTALL cannot find file \"" << fromFile << "\" to install."; + this->SetError(e.str().c_str()); + return false; } } } - m_Makefile->AddDefinition("CMAKE_INSTALL_MANIFEST_FILES", - smanifest_files.c_str()); + + // Save the updated install manifest. + this->Makefile->AddDefinition("CMAKE_INSTALL_MANIFEST_FILES", + smanifest_files.c_str()); return true; } @@ -729,9 +864,57 @@ } std::string res = cmSystemTools::RelativePath(directoryName.c_str(), fileName.c_str()); - m_Makefile->AddDefinition(outVar.c_str(), + this->Makefile->AddDefinition(outVar.c_str(), res.c_str()); return true; } +//---------------------------------------------------------------------------- +bool cmFileCommand::HandleRemove(std::vector const& args, + bool recurse) +{ + + std::string message; + std::vector::const_iterator i = args.begin(); + + i++; // Get rid of subcommand + for(;i != args.end(); ++i) + { + if(cmSystemTools::FileIsDirectory(i->c_str()) && recurse) + { + cmSystemTools::RemoveADirectory(i->c_str()); + } + else + { + cmSystemTools::RemoveFile(i->c_str()); + } + } + return true; +} + +bool cmFileCommand::HandleSystemPathCommand(std::vector + const& args) +{ + std::vector::const_iterator i = args.begin(); + if(args.size() != 3) + { + this->SetError("FILE(SYSTEM_PATH ENV result) must be called with " + "only three arguments."); + return false; + } + i++; // Get rid of subcommand + std::vector path; + cmSystemTools::GetPath(path, i->c_str()); + i++; + const char* var = i->c_str(); + std::string value; + for(std::vector::iterator j = path.begin(); + j != path.end(); ++j) + { + value += *j; + value += ";"; + } + this->Makefile->AddDefinition(var, value.c_str()); + return true; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFileCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFileCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFileCommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFileCommand.h 2006-03-11 05:53:04.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFileCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.9.2.2 $ + Date: $Date: 2006/03/10 21:53:04 $ + Version: $Revision: 1.14 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -69,8 +69,11 @@ " FILE(READ filename variable)\n" " FILE(GLOB variable [globbing expressions]...)\n" " FILE(GLOB_RECURSE variable [globbing expressions]...)\n" + " FILE(REMOVE [directory]...)\n" + " FILE(REMOVE_RECURSE [directory]...)\n" " FILE(MAKE_DIRECTORY [directory]...)\n" " FILE(RELATIVE_PATH variable directory file)\n" + " FILE(SYSTEM_PATH ENVIRONMENT_VARIABLE result)\n" "WRITE will write a message into a file called 'filename'. It " "overwrites the file if it already exists, and creates the file " "if it does not exist.\n" @@ -95,18 +98,23 @@ "Examples of recursive globbing include:\n" " /dir/*.py - match all python files in /dir and subdirectories\n" "MAKE_DIRECTORY will create a directory at the specified location\n" - "RELATIVE_PATH will determine relative path from directory to the given file"; + "RELATIVE_PATH will determine relative path from directory to the given" + " file." + " SYSTEM_PATH will look up the environment variable named and " + "convert its contents into a cmake list of unix style paths. "; } cmTypeMacro(cmFileCommand, cmCommand); protected: + bool HandleRemove(std::vector const& args, bool recurse); bool HandleWriteCommand(std::vector const& args, bool append); bool HandleReadCommand(std::vector const& args); bool HandleGlobCommand(std::vector const& args, bool recurse); bool HandleMakeDirectoryCommand(std::vector const& args); bool HandleInstallCommand(std::vector const& args); bool HandleRelativePathCommand(std::vector const& args); + bool HandleSystemPathCommand(std::vector const& args); }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFileTimeComparison.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFileTimeComparison.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFileTimeComparison.cxx 2005-10-31 23:01:20.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFileTimeComparison.cxx 2006-03-16 00:02:01.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFileTimeComparison.cxx,v $ Language: C++ - Date: $Date: 2005/10/31 15:01:20 $ - Version: $Revision: 1.3.2.2 $ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.5 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -106,19 +106,19 @@ //---------------------------------------------------------------------------- cmFileTimeComparison::cmFileTimeComparison() { - m_Internals = new cmFileTimeComparisonInternal; + this->Internals = new cmFileTimeComparisonInternal; } //---------------------------------------------------------------------------- cmFileTimeComparison::~cmFileTimeComparison() { - delete m_Internals; + delete this->Internals; } //---------------------------------------------------------------------------- bool cmFileTimeComparison::FileTimeCompare(const char* f1, const char* f2, int* result) { - return m_Internals->FileTimeCompare(f1, f2, result); + return this->Internals->FileTimeCompare(f1, f2, result); } //---------------------------------------------------------------------------- diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFileTimeComparison.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFileTimeComparison.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFileTimeComparison.h 2005-10-18 09:34:24.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFileTimeComparison.h 2006-03-16 00:02:01.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFileTimeComparison.h,v $ Language: C++ - Date: $Date: 2005/10/18 01:34:24 $ - Version: $Revision: 1.1.2.1 $ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -42,7 +42,7 @@ protected: - cmFileTimeComparisonInternal* m_Internals; + cmFileTimeComparisonInternal* Internals; }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFindBase.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFindBase.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFindBase.cxx 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFindBase.cxx 2006-03-17 06:49:16.000000000 +0800 @@ -0,0 +1,430 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmFindBase.cxx,v $ + Language: C++ + Date: $Date: 2006/03/16 22:49:16 $ + Version: $Revision: 1.9 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "cmFindBase.h" + +cmFindBase::cmFindBase() +{ + this->AlreadyInCache = false; + this->NoDefaultPath = false; + // default is to search frameworks first on apple +#if defined(__APPLE__) + this->SearchFrameworkFirst = true; +#else + this->SearchFrameworkFirst = false; +#endif + this->SearchFrameworkOnly = false; + this->SearchFrameworkLast = false; + this->GenericDocumentation = + " FIND_XXX( name1 path1 path2 ...)\n" + "This is the short-hand signature for the command that " + "is sufficient in many cases. It is the same " + "as FIND_XXX( name1 PATHS path2 path2 ...)\n" + " FIND_XXX(\n" + " \n" + " name | NAMES name1 [name2 ...]\n" + " PATHS path1 [path2 ... ENV var]\n" + " [PATH_SUFFIXES suffix1 [suffix2 ...]]\n" + " [DOC \"cache documentation string\"]\n" + " [NO_DEFAULT_PATH]\n" + " )\n" + "" + "This command is used to find a SEARCH_XXX_DESC. " + "A cache entry named by is created to store the result " + "of this command. If nothing is found, the result will be " + "-NOTFOUND. The name of the SEARCH_XXX that " + "is searched for is specified by the names listed " + "after the NAMES argument. Additional search locations " + "can be specified after the PATHS argument. If ENV var is " + "found in the PATHS section the environment variable var " + "will be read and converted from a system environment variable to " + "a cmake style list of paths. For example ENV PATH would be a way " + "to list the system path variable. The argument " + "after DOC will be used for the documentation string in " + "the cache. PATH_SUFFIXES can be used to give sub directories " + "that will be appended to the search paths.\n" + "If NO_DEFAULT_PATH is specified, then no additional paths are " + "added to the search. " + "If NO_DEFAULT_PATH is not specified, the search process is as follows:\n" + "1. Search cmake specific environment variables." + "" + " CMAKE_FRAMEWORK_PATH\n" + " CMAKE_XXX_PATH\n" + "2. Search cmake variables with the same names as " + "the cmake specific environment variables. These " + "are intended to be used on the command line with a " + "-DVAR=value. \n" + "" + " CMAKE_FRAMEWORK_PATH\n" + " CMAKE_XXX_PATH\n" + "3. Search the standard system environment variables. " + " PATH\n" + " XXX_SYSTEM\n" // replace with "", LIB, or INCLUDE + "4. Search cmake variables defined in the Platform files " + "for the current system. \n" + " CMAKE_SYSTEM_FRAMEWORK_PATH\n" + " CMAKE_SYSTEM_XXX_PATH\n" + "5. Search the paths specified after PATHS or in the short-hand version " + "of the command.\n" + "On Darwin or systems supporting OSX Frameworks, the cmake variable" + " CMAKE_FIND_FRAMEWORK can be set to empty or one of the following:\n" + " \"FIRST\" - Try to find frameworks before standard\n" + " libraries or headers. This is the default on Darwin.\n" + " \"LAST\" - Try to find frameworks after standard\n" + " libraries or headers.\n" + " \"ONLY\" - Only try to find frameworks.\n" + " \"NEVER\". - Never try to find frameworks.\n"; +} + +bool cmFindBase::ParseArguments(std::vector const& argsIn) +{ + if(argsIn.size() < 2 ) + { + this->SetError("called with incorrect number of arguments"); + return false; + } + // copy argsIn into args so it can be modified, + // in the process extract the DOC "documentation" + size_t size = argsIn.size(); + std::vector args; + bool foundDoc = false; + for(unsigned int j = 0; j < size; ++j) + { + if(foundDoc || argsIn[j] != "DOC" ) + { + if(argsIn[j] == "ENV") + { + if(j+1 < size) + { + j++; + cmSystemTools::GetPath(args, argsIn[j].c_str()); + } + } + else + { + args.push_back(argsIn[j]); + } + } + else + { + if(j+1 < size) + { + foundDoc = true; + this->VariableDocumentation = argsIn[j+1]; + j++; + if(j >= size) + { + break; + } + } + } + } + this->VariableName = args[0]; + if(this->CheckForVariableInCache()) + { + this->AlreadyInCache = true; + return true; + } + this->AlreadyInCache = false; + std::vector userPaths; + std::string doc; + bool doingNames = true; // assume it starts with a name + bool doingPaths = false; + bool doingPathSuf = false; + bool newStyle = false; + + for (unsigned int j = 1; j < args.size(); ++j) + { + if(args[j] == "NAMES") + { + doingNames = true; + newStyle = true; + doingPathSuf = false; + doingPaths = false; + } + else if (args[j] == "PATHS") + { + doingPaths = true; + newStyle = true; + doingNames = false; + doingPathSuf = false; + } + else if (args[j] == "PATH_SUFFIXES") + { + doingPathSuf = true; + newStyle = true; + doingNames = false; + doingPaths = false; + } + else if (args[j] == "NO_SYSTEM_PATH") + { + doingPaths = false; + doingPathSuf = false; + doingNames = false; + this->NoDefaultPath = true; + } + else if (args[j] == "NO_DEFAULT_PATH") + { + doingPaths = false; + doingPathSuf = false; + doingNames = false; + this->NoDefaultPath = true; + } + else + { + if(doingNames) + { + this->Names.push_back(args[j]); + } + else if(doingPaths) + { + userPaths.push_back(args[j]); + } + else if(doingPathSuf) + { + this->SearchPathSuffixes.push_back(args[j]); + } + } + } + if(this->VariableDocumentation.size() == 0) + { + this->VariableDocumentation = "Whare can "; + if(this->Names.size() == 0) + { + this->VariableDocumentation += "the (unknown) library be found"; + } + else if(this->Names.size() == 1) + { + this->VariableDocumentation += "the " + this->Names[0] + " library be found"; + } + else + { + this->VariableDocumentation += "one of the " + this->Names[0]; + for (unsigned int j = 1; j < this->Names.size() - 1; ++j) + { + this->VariableDocumentation += ", " + this->Names[j]; + } + this->VariableDocumentation += " or " + this->Names[this->Names.size() - 1] + " libraries be found"; + } + } + + // look for old style + // FIND_*(VAR name path1 path2 ...) + if(!newStyle) + { + this->Names.clear(); // clear out any values in Names + this->Names.push_back(args[1]); + for(unsigned int j = 2; j < args.size(); ++j) + { + userPaths.push_back(args[j]); + } + } + this->ExpandPaths(userPaths); + return true; +} + +void cmFindBase::ExpandPaths(std::vector userPaths) +{ + // if NO Default paths was not specified add the + // standard search paths. + if(!this->NoDefaultPath) + { + // Add CMAKE_*_PATH environment variables + this->AddEnvironmentVairables(); + // Add CMake varibles of the same name as the previous environment + // varibles CMAKE_*_PATH to be used most of the time with -D + // command line options + this->AddCMakeVairables(); + // add System environment PATH and (LIB or INCLUDE) + this->AddSystemEnvironmentVairables(); + // Add CMAKE_SYSTEM_*_PATH variables which are defined in platform files + this->AddCMakeSystemVariables(); + } + // add the paths specified in the FIND_* call + for(unsigned int i =0; i < userPaths.size(); ++i) + { + this->SearchPaths.push_back(userPaths[i]); + } + // clean things up + this->ExpandRegistryAndCleanPath(); +} + +void cmFindBase::AddEnvironmentVairables() +{ + if(this->SearchFrameworkFirst || this->SearchFrameworkOnly) + { + cmSystemTools::GetPath(this->SearchPaths, "CMAKE_FRAMEWORK_PATH"); + } + std::string var = "CMAKE_"; + var += this->CMakePathName; + var += "_PATH"; + cmSystemTools::GetPath(this->SearchPaths, var.c_str()); + if(this->SearchFrameworkLast) + { + cmSystemTools::GetPath(this->SearchPaths, "CMAKE_FRAMEWORK_PATH"); + } + +} + +void cmFindBase::AddCMakeVairables() +{ + if(this->SearchFrameworkFirst || this->SearchFrameworkOnly) + { + if(const char* path = + this->Makefile->GetDefinition("CMAKE_FRAMEWORK_PATH")) + { + cmSystemTools::ExpandListArgument(path, this->SearchPaths); + } + } + std::string var = "CMAKE_"; + var += this->CMakePathName; + var += "_PATH"; + if(const char* path = this->Makefile->GetDefinition(var.c_str())) + { + cmSystemTools::ExpandListArgument(path, this->SearchPaths); + } + if(this->SearchFrameworkLast) + { + if(const char* path = + this->Makefile->GetDefinition("CMAKE_FRAMEWORK_PATH")) + { + cmSystemTools::ExpandListArgument(path, this->SearchPaths); + } + } +} + +void cmFindBase::AddSystemEnvironmentVairables() +{ + // Add LIB or INCLUDE + if(this->EnvironmentPath.size()) + { + cmSystemTools::GetPath(this->SearchPaths, this->EnvironmentPath.c_str()); + } + // Add PATH + cmSystemTools::GetPath(this->SearchPaths); +} + +void cmFindBase::AddCMakeSystemVariables() +{ + if(this->SearchFrameworkFirst || this->SearchFrameworkOnly) + { + if(const char* path = this->Makefile->GetDefinition("CMAKE_SYSTEM_FRAMEWORK_PATH")) + { + cmSystemTools::ExpandListArgument(path, this->SearchPaths); + } + } + std::string var = "CMAKE_SYSTEM_"; + var += this->CMakePathName; + var += "_PATH"; + if(const char* path = this->Makefile->GetDefinition(var.c_str())) + { + cmSystemTools::ExpandListArgument(path, this->SearchPaths); + } + if(this->SearchFrameworkLast) + { + if(const char* path = this->Makefile->GetDefinition("CMAKE_SYSTEM_FRAMEWORK_PATH")) + { + cmSystemTools::ExpandListArgument(path, this->SearchPaths); + } + } +} + +void cmFindBase::ExpandRegistryAndCleanPath() +{ + std::vector finalPath; + std::vector::iterator i; + for(i = this->SearchPaths.begin(); + i != this->SearchPaths.end(); ++i) + { + cmSystemTools::ExpandRegistryValues(*i); + cmSystemTools::GlobDirs(i->c_str(), finalPath); + } + this->SearchPaths.clear(); + // convert all paths to unix slashes + for(i = finalPath.begin(); + i != finalPath.end(); ++i) + { + cmSystemTools::ConvertToUnixSlashes(*i); + // copy each finalPath combined with SearchPathSuffixes + // to the SearchPaths ivar + for(std::vector::iterator j = this->SearchPathSuffixes.begin(); + j != this->SearchPathSuffixes.end(); ++j) + { + std::string p = *i + std::string("/") + *j; + if(cmSystemTools::FileIsDirectory(p.c_str())) + { + this->SearchPaths.push_back(p); + } + } + } + // now put the path without the path suffixes in the SearchPaths + for(i = finalPath.begin(); + i != finalPath.end(); ++i) + { + if(cmSystemTools::FileIsDirectory(i->c_str())) + { + this->SearchPaths.push_back(*i); + } + } +} + +void cmFindBase::PrintFindStuff() +{ + std::cerr << "VariableName " << this->VariableName << "\n"; + std::cerr << "VariableDocumentation " << this->VariableDocumentation << "\n"; + std::cerr << "NoDefaultPath " << this->NoDefaultPath << "\n"; + std::cerr << "EnvironmentPath " << this->EnvironmentPath << "\n"; + std::cerr << "CMakePathName " << this->CMakePathName << "\n"; + std::cerr << "Names "; + for(unsigned int i =0; i < this->Names.size(); ++i) + { + std::cerr << this->Names[i] << " "; + } + std::cerr << "\n"; + std::cerr << "\n"; + std::cerr << "SearchPathSuffixes "; + for(unsigned int i =0; i < this->SearchPathSuffixes.size(); ++i) + { + std::cerr << this->SearchPathSuffixes[i] << "\n"; + } + std::cerr << "\n"; + std::cerr << "SearchPaths\n"; + for(unsigned int i =0; i < this->SearchPaths.size(); ++i) + { + std::cerr << "[" << this->SearchPaths[i] << "]\n"; + } +} + +bool cmFindBase::CheckForVariableInCache() +{ + const char* cacheValue + = this->Makefile->GetDefinition(this->VariableName.c_str()); + if(cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue)) + { + return true; + } + if(cacheValue) + { + cmCacheManager::CacheIterator it = + this->Makefile->GetCacheManager()->GetCacheIterator(this->VariableName.c_str()); + if(!it.IsAtEnd()) + { + const char* hs = it.GetProperty("HELPSTRING"); + this->VariableDocumentation = hs?hs:"(none)"; + } + } + return false; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFindBase.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFindBase.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFindBase.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFindBase.h 2006-03-17 06:49:16.000000000 +0800 @@ -0,0 +1,78 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmFindBase.h,v $ + Language: C++ + Date: $Date: 2006/03/16 22:49:16 $ + Version: $Revision: 1.4 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef cmFindBase_h +#define cmFindBase_h + +#include "cmCommand.h" + +/** \class cmFindBase + * \brief Define a command to search for an executable program. + * + * cmFindBase is a parent class for cmFindProgramCommand, cmFindPathCommand, + * and cmFindLibraryCommand, cmFindFile + */ +class cmFindBase : public cmCommand +{ +public: + cmFindBase(); + /** + * This is called when the command is first encountered in + * the CMakeLists.txt file. + */ + virtual bool ParseArguments(std::vector const& args); + cmTypeMacro(cmFindBase, cmCommand); + + virtual const char* GetFullDocumentation() + {return this->GenericDocumentation.c_str();} + +protected: + void PrintFindStuff(); + void ExpandPaths(std::vector userPaths); + void AddEnvironmentVairables(); + void AddCMakeVairables(); + void AddSystemEnvironmentVairables(); + void AddCMakeSystemVariables(); + void ExpandRegistryAndCleanPath(); + // see if the VariableName is already set in the cache, + // also copy the documentation from the cache to VariableDocumentation + // if it has documentation in the cache + bool CheckForVariableInCache(); + + cmStdString GenericDocumentation; + // use by command during find + cmStdString VariableDocumentation; + cmStdString VariableName; + std::vector Names; + std::vector SearchPaths; + std::vector SearchPathSuffixes; + + // CMAKE_*_PATH CMAKE_SYSTEM_*_PATH FRAMEWORK|LIBRARY|INCLUDE|PROGRAM + cmStdString CMakePathName; + cmStdString EnvironmentPath; // LIB,INCLUDE + + bool AlreadyInCache; + bool NoDefaultPath; + + bool SearchFrameworkFirst; + bool SearchFrameworkOnly; + bool SearchFrameworkLast; + +}; + + + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFindFileCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFindFileCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFindFileCommand.cxx 2003-08-11 06:30:53.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFindFileCommand.cxx 2006-03-03 02:30:22.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFindFileCommand.cxx,v $ Language: C++ - Date: $Date: 2003/08/10 22:30:53 $ - Version: $Revision: 1.21 $ + Date: $Date: 2006/03/02 18:30:22 $ + Version: $Revision: 1.28 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -15,82 +15,15 @@ =========================================================================*/ #include "cmFindFileCommand.h" -#include "cmCacheManager.h" -#include - +#include "cmSystemTools.h" -// cmFindFileCommand -bool cmFindFileCommand::InitialPass(std::vector const& argsIn) +cmFindFileCommand::cmFindFileCommand() { - if(argsIn.size() < 2) - { - this->SetError("called with incorrect number of arguments"); - return false; - } - std::string helpString = "Where can the "; - helpString += argsIn[1] + " file be found"; - size_t size = argsIn.size(); - std::vector args; - for(unsigned int j = 0; j < size; ++j) - { - if(argsIn[j] != "DOC") - { - args.push_back(argsIn[j]); - } - else - { - if(j+1 < size) - { - helpString = argsIn[j+1]; - } - break; - } - } - - std::vector::const_iterator i = args.begin(); - // Use the first argument as the name of something to be defined - const char* define = (*i).c_str(); - i++; // move iterator to next arg - // Now check and see if the value has been stored in the cache - // already, if so use that value and don't look for the program - const char* cacheValue - = m_Makefile->GetDefinition(define); - if(cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue)) - { - return true; - } - // if it is not in the cache, then search the system path - std::vector path; - - // add any user specified paths - for (unsigned int j = 2; j < args.size(); j++) - { - // Glob the entry in case of wildcards. - cmSystemTools::GlobDirs(args[j].c_str(), path); - } - - // add the standard path - cmSystemTools::GetPath(path); - for(unsigned int k=0; k < path.size(); k++) - { - std::string tryPath = path[k]; - tryPath += "/"; - tryPath += *i; - if(cmSystemTools::FileExists(tryPath.c_str())) - { - // Save the value in the cache - m_Makefile->AddCacheDefinition(define, - tryPath.c_str(), - helpString.c_str(), - cmCacheManager::FILEPATH); - return true; - } - } - std::string s = args[0] + "-NOTFOUND"; - m_Makefile->AddCacheDefinition(args[0].c_str(), - s.c_str(), - helpString.c_str(), - cmCacheManager::FILEPATH); - return true; + this->IncludeFileInPath = true; + cmSystemTools::ReplaceString(this->GenericDocumentation, + "FIND_PATH", "FIND_FILE"); + cmSystemTools::ReplaceString(this->GenericDocumentation, + "directory containing the named file", "full path to named file"); + cmSystemTools::ReplaceString(this->GenericDocumentation, + "file in a directory", "full path to a file"); } - diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFindFileCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFindFileCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFindFileCommand.h 2005-03-18 23:41:40.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFindFileCommand.h 2006-03-03 02:30:22.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFindFileCommand.h,v $ Language: C++ - Date: $Date: 2005/03/18 15:41:40 $ - Version: $Revision: 1.15 $ + Date: $Date: 2006/03/02 18:30:22 $ + Version: $Revision: 1.19 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -17,7 +17,7 @@ #ifndef cmFindFileCommand_h #define cmFindFileCommand_h -#include "cmCommand.h" +#include "cmFindPathCommand.h" /** \class cmFindFileCommand * \brief Define a command to search for an executable program. @@ -27,9 +27,10 @@ * in the current path (e.g., PATH environment variable) for * an executable that matches one of the supplied names. */ -class cmFindFileCommand : public cmCommand +class cmFindFileCommand : public cmFindPathCommand { public: + cmFindFileCommand(); /** * This is a virtual constructor for the command. */ @@ -37,21 +38,6 @@ { return new cmFindFileCommand; } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - virtual bool InitialPass(std::vector const& args); - - /** - * This determines if the command is invoked when in script mode. - */ - virtual bool IsScriptable() { return true; } - - /** - * The name of the command as specified in CMakeList.txt. - */ virtual const char* GetName() { return "FIND_FILE";} /** @@ -62,25 +48,7 @@ return "Find the full path to a file."; } - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() - { - return - " FIND_FILE( fileName path1 [path2 ...]\n" - " [DOC \"docstring\"])\n" - "Find the full path to a file named by fileName. Paths " - "are searched in the order specified. A cache entry named by " - " is created to store the result. If the file is not " - "found, the result will be -NOTFOUND. If DOC is specified " - "then the next argument is treated as a documentation string for " - "the cache entry . Note that since executables can have " - "different extensions on different platforms, FIND_PROGRAM " - "should be used instead of FIND_FILE when looking for them."; - } - - cmTypeMacro(cmFindFileCommand, cmCommand); + cmTypeMacro(cmFindFileCommand, cmFindPathCommand); }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFindLibraryCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFindLibraryCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFindLibraryCommand.cxx 2003-02-07 23:18:07.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFindLibraryCommand.cxx 2006-03-16 00:02:01.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFindLibraryCommand.cxx,v $ Language: C++ - Date: $Date: 2003/02/07 15:18:07 $ - Version: $Revision: 1.34 $ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.37 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -17,129 +17,182 @@ #include "cmFindLibraryCommand.h" #include "cmCacheManager.h" +cmFindLibraryCommand::cmFindLibraryCommand() +{ + cmSystemTools::ReplaceString(this->GenericDocumentation, + "FIND_XXX", "FIND_LIBRARY"); + cmSystemTools::ReplaceString(this->GenericDocumentation, + "CMAKE_XXX_PATH", "CMAKE_LIBRARY_PATH"); + cmSystemTools::ReplaceString(this->GenericDocumentation, + "XXX_SYSTEM", "LIB"); + cmSystemTools::ReplaceString(this->GenericDocumentation, + "CMAKE_SYSTEM_XXX_PATH", "CMAKE_SYSTEM_LIBRARY_PATH"); + cmSystemTools::ReplaceString(this->GenericDocumentation, + "SEARCH_XXX_DESC", "library"); + cmSystemTools::ReplaceString(this->GenericDocumentation, + "SEARCH_XXX", "library"); + this->GenericDocumentation += + "\n" + "If the library found is a framework, then VAR will be set to " + "the full path to the framework /A.framework. " + "When a full path to a framework is used as a library, " + "CMake will use a -framework A, and a -F to " + "link the framework to the target. "; +} + // cmFindLibraryCommand bool cmFindLibraryCommand::InitialPass(std::vector const& argsIn) { - if(argsIn.size() < 2) + this->VariableDocumentation = "Path to a library."; + this->CMakePathName = "LIBRARY"; + if(!this->ParseArguments(argsIn)) { - this->SetError("called with incorrect number of arguments"); return false; - } - std::string helpString; - size_t size = argsIn.size(); - std::vector args; - for(unsigned int j = 0; j < size; ++j) + } + if(this->AlreadyInCache) { - if(argsIn[j] != "DOC") - { - args.push_back(argsIn[j]); - } - else - { - if(j+1 < size) - { - helpString = argsIn[j+1]; - } - break; - } + return true; } - - std::vector path; - std::vector names; - bool foundName = false; - bool foundPath = false; - bool doingNames = true; - for (unsigned int j = 1; j < args.size(); ++j) + // add special 64 bit paths if this is a 64 bit compile. + this->AddLib64Paths(); + std::string library; + for(std::vector::iterator i = this->Names.begin(); + i != this->Names.end() ; ++i) { - if(args[j] == "NAMES") + library = this->FindLibrary(i->c_str()); + if(library != "") + { + this->Makefile->AddCacheDefinition(this->VariableName.c_str(), + library.c_str(), + this->VariableDocumentation.c_str(), + cmCacheManager::FILEPATH); + return true; + } + } + std::string notfound = this->VariableName + "-NOTFOUND"; + this->Makefile->AddCacheDefinition(this->VariableName.c_str(), + notfound.c_str(), + this->VariableDocumentation.c_str(), + cmCacheManager::FILEPATH); + return true; +} + + +void cmFindLibraryCommand::AddLib64Paths() +{ + if(!this->Makefile->GetLocalGenerator()->GetGlobalGenerator()->GetLanguageEnabled("C")) + { + return; + } + std::string voidsize = this->Makefile->GetRequiredDefinition("CMAKE_SIZEOF_VOID_P"); + int size = atoi(voidsize.c_str()); + std::vector path64; + if(size != 8) + { + return; + } + bool found64 = false; + for(std::vector::iterator i = this->SearchPaths.begin(); + i != this->SearchPaths.end(); ++i) + { + std::string s = *i; + std::string s2 = *i; + cmSystemTools::ReplaceString(s, "lib/", "lib64/"); + // try to replace lib with lib64 and see if it is there, + // then prepend it to the path + if((s != *i) && cmSystemTools::FileIsDirectory(s.c_str())) + { + path64.push_back(s); + found64 = true; + } + // now just add a 64 to the path name and if it is there, + // add it to the path + s2 += "64"; + if(cmSystemTools::FileIsDirectory(s2.c_str())) { - doingNames = true; - foundName = true; - } - else if (args[j] == "PATHS") + found64 = true; + path64.push_back(s2); + } + // now add the original unchanged path + if(cmSystemTools::FileIsDirectory(i->c_str())) { - doingNames = false; - foundPath = true; - } - else - { - if(doingNames) - { - names.push_back(args[j]); - } - else - { - cmSystemTools::ExpandRegistryValues(args[j]); - // Glob the entry in case of wildcards. - cmSystemTools::GlobDirs(args[j].c_str(), path); - } + path64.push_back(*i); } } - // old style name path1 path2 path3 - if(!foundPath && !foundName) + // now replace the SearchPaths with the 64 bit converted path + // if any 64 bit paths were discovered + if(found64) { - names.clear(); - path.clear(); - names.push_back(args[1]); - // add any user specified paths - for (unsigned int j = 2; j < args.size(); j++) - { - // expand variables - std::string exp = args[j]; - cmSystemTools::ExpandRegistryValues(exp); - - // Glob the entry in case of wildcards. - cmSystemTools::GlobDirs(exp.c_str(), path); - } + this->SearchPaths = path64; } - if(helpString.size() == 0) +} + +std::string cmFindLibraryCommand::FindLibrary(const char* name) +{ + bool supportFrameworks = false; + bool onlyFrameworks = false; + std::string ff = this->Makefile->GetSafeDefinition("CMAKE_FIND_FRAMEWORK"); + if(ff == "FIRST" || ff == "LAST") { - helpString = "Where can "; - if (names.size() == 0) - { - helpString += "the (unknown) library be found"; - } - else if (names.size() == 1) - { - helpString += "the " + names[0] + " library be found"; + supportFrameworks = true; + } + if(ff == "ONLY") + { + onlyFrameworks = true; + supportFrameworks = true; + } + + const char* prefixes_list = + this->Makefile->GetRequiredDefinition("CMAKE_FIND_LIBRARY_PREFIXES"); + const char* suffixes_list = + this->Makefile->GetRequiredDefinition("CMAKE_FIND_LIBRARY_SUFFIXES"); + std::vector prefixes; + std::vector suffixes; + cmSystemTools::ExpandListArgument(prefixes_list, prefixes, true); + cmSystemTools::ExpandListArgument(suffixes_list, suffixes, true); + std::string tryPath; + for(std::vector::const_iterator p = this->SearchPaths.begin(); + p != this->SearchPaths.end(); ++p) + { + if(supportFrameworks) + { + tryPath = *p; + tryPath += "/"; + tryPath += name; + tryPath += ".framework"; + if(cmSystemTools::FileExists(tryPath.c_str()) + && cmSystemTools::FileIsDirectory(tryPath.c_str())) + { + tryPath = cmSystemTools::CollapseFullPath(tryPath.c_str()); + cmSystemTools::ConvertToUnixSlashes(tryPath); + return tryPath; + } } - else + if(!onlyFrameworks) { - helpString += "one of the " + names[0]; - for (unsigned int j = 1; j < names.size() - 1; ++j) + // Try various library naming conventions. + for(std::vector::iterator prefix = prefixes.begin(); + prefix != prefixes.end(); ++prefix) { - helpString += ", " + names[j]; + for(std::vector::iterator suffix = suffixes.begin(); + suffix != suffixes.end(); ++suffix) + { + tryPath = *p; + tryPath += "/"; + tryPath += *prefix; + tryPath += name; + tryPath += *suffix; + if(cmSystemTools::FileExists(tryPath.c_str()) + && !cmSystemTools::FileIsDirectory(tryPath.c_str())) + { + tryPath = cmSystemTools::CollapseFullPath(tryPath.c_str()); + cmSystemTools::ConvertToUnixSlashes(tryPath); + return tryPath; + } + } } - helpString += " or " + names[names.size() - 1] + " libraries be found"; } } - - const char* cacheValue - = m_Makefile->GetDefinition(args[0].c_str()); - if(cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue)) - { - return true; - } - - std::string library; - for(std::vector::iterator i = names.begin(); - i != names.end() ; ++i) - { - library = m_Makefile->FindLibrary(i->c_str(), path); - if(library != "") - { - m_Makefile->AddCacheDefinition(args[0].c_str(), - library.c_str(), - helpString.c_str(), - cmCacheManager::FILEPATH); - return true; - } - } - std::string s = args[0] + "-NOTFOUND"; - m_Makefile->AddCacheDefinition(args[0].c_str(), - s.c_str(), - helpString.c_str(), - cmCacheManager::FILEPATH); - return true; + // Couldn't find the library. + return ""; } - diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFindLibraryCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFindLibraryCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFindLibraryCommand.h 2005-03-18 23:41:40.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFindLibraryCommand.h 2006-03-03 02:30:22.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFindLibraryCommand.h,v $ Language: C++ - Date: $Date: 2005/03/18 15:41:40 $ - Version: $Revision: 1.19 $ + Date: $Date: 2006/03/02 18:30:22 $ + Version: $Revision: 1.21 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -17,7 +17,7 @@ #ifndef cmFindLibraryCommand_h #define cmFindLibraryCommand_h -#include "cmCommand.h" +#include "cmFindBase.h" /** \class cmFindLibraryCommand @@ -27,9 +27,10 @@ * that specifies a library. The command searches for a given * file in a list of directories. */ -class cmFindLibraryCommand : public cmCommand +class cmFindLibraryCommand : public cmFindBase { public: + cmFindLibraryCommand(); /** * This is a virtual constructor for the command. */ @@ -61,31 +62,11 @@ { return "Find a library."; } + cmTypeMacro(cmFindLibraryCommand, cmFindBase); - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() - { - return - " FIND_LIBRARY( NAMES name1 [name2 ...]\n" - " [PATHS path1 path2 ...]\n" - " [DOC \"docstring\"])\n" - "Find a library named by one of the names given after the NAMES " - "argument. Paths specified after the PATHS argument are searched " - "in the order specified. A cache entry named by is created " - "to store the result. If the library is not found, the result " - "will be -NOTFOUND. If DOC is specified then the next " - "argument is treated as a documentation string for the cache " - "entry .\n" - " FIND_LIBRARY(VAR libraryName [path1 path2 ...])\n" - "Find a library with the given name by searching in the specified " - "paths. This is a short-hand signature for the command that is " - "sufficient in many cases. The environment variable CMAKE_LIBRARY_PATH " - "is searched as well as the PATH variable.\n"; - } - - cmTypeMacro(cmFindLibraryCommand, cmCommand); +protected: + void AddLib64Paths();\ + std::string FindLibrary(const char* name); }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFindPackageCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFindPackageCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFindPackageCommand.cxx 2005-03-18 23:41:40.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFindPackageCommand.cxx 2006-03-16 00:02:01.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFindPackageCommand.cxx,v $ Language: C++ - Date: $Date: 2005/03/18 15:41:40 $ - Version: $Revision: 1.15 $ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.17 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -75,6 +75,11 @@ else if(args[i] == "REQUIRED") { required = true; + while (++i < args.size() && args[i] != "QUIET") + { + std::string req_var = Name + "_FIND_REQUIRED_" + args[i]; + this->Makefile->AddDefinition(req_var.c_str(), "1"); + } } else { @@ -113,7 +118,7 @@ if(!(upperDir == this->Variable)) { const char* versionValue = - m_Makefile->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY"); + this->Makefile->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY"); if(atof(versionValue) < 1.7) { needCompatibility = true; @@ -121,16 +126,16 @@ } // Try to find the config file. - const char* def = m_Makefile->GetDefinition(this->Variable.c_str()); + const char* def = this->Makefile->GetDefinition(this->Variable.c_str()); if(needCompatibility && cmSystemTools::IsOff(def)) { // Use the setting of the old name of the variable to provide the // value of the new. - const char* oldDef = m_Makefile->GetDefinition(upperDir.c_str()); + const char* oldDef = this->Makefile->GetDefinition(upperDir.c_str()); if(!cmSystemTools::IsOff(oldDef)) { - m_Makefile->AddDefinition(this->Variable.c_str(), oldDef); - def = m_Makefile->GetDefinition(this->Variable.c_str()); + this->Makefile->AddDefinition(this->Variable.c_str(), oldDef); + def = this->Makefile->GetDefinition(this->Variable.c_str()); } } if(cmSystemTools::IsOff(def)) @@ -144,7 +149,7 @@ // If the config file was found, load it. bool result = true; bool found = false; - def = m_Makefile->GetDefinition(this->Variable.c_str()); + def = this->Makefile->GetDefinition(this->Variable.c_str()); if(!cmSystemTools::IsOff(def)) { std::string f = def; @@ -191,16 +196,16 @@ // Set a variable marking whether the package was found. std::string foundVar = this->Name; foundVar += "_FOUND"; - m_Makefile->AddDefinition(foundVar.c_str(), found? "1":"0"); + this->Makefile->AddDefinition(foundVar.c_str(), found? "1":"0"); if(needCompatibility) { // Listfiles will be looking for the capitalized version of the // name. Provide it. - m_Makefile->AddDefinition(upperDir.c_str(), - m_Makefile->GetDefinition(this->Variable.c_str())); - m_Makefile->AddDefinition(upperFound.c_str(), - m_Makefile->GetDefinition(foundVar.c_str())); + this->Makefile->AddDefinition(upperDir.c_str(), + this->Makefile->GetDefinition(this->Variable.c_str())); + this->Makefile->AddDefinition(upperFound.c_str(), + this->Makefile->GetDefinition(foundVar.c_str())); } #ifdef CMAKE_BUILD_WITH_CMAKE @@ -210,11 +215,11 @@ { // Listfiles may use the capitalized version of the name. // Remove any previously added watch. - m_Makefile->GetVariableWatch()->RemoveWatch( + this->Makefile->GetVariableWatch()->RemoveWatch( upperDir.c_str(), cmFindPackageNeedBackwardsCompatibility ); - m_Makefile->GetVariableWatch()->RemoveWatch( + this->Makefile->GetVariableWatch()->RemoveWatch( upperFound.c_str(), cmFindPackageNeedBackwardsCompatibility ); @@ -223,11 +228,11 @@ { // Listfiles should not be using the capitalized version of the // name. Add a watch to warn the user. - m_Makefile->GetVariableWatch()->AddWatch( + this->Makefile->GetVariableWatch()->AddWatch( upperDir.c_str(), cmFindPackageNeedBackwardsCompatibility ); - m_Makefile->GetVariableWatch()->AddWatch( + this->Makefile->GetVariableWatch()->AddWatch( upperFound.c_str(), cmFindPackageNeedBackwardsCompatibility ); @@ -244,7 +249,7 @@ std::string module = "Find"; module += this->Name; module += ".cmake"; - std::string mfile = m_Makefile->GetModulesFile(module.c_str()); + std::string mfile = this->Makefile->GetModulesFile(module.c_str()); if ( mfile.size() ) { if(quiet) @@ -253,7 +258,7 @@ // quietly. std::string quietly = this->Name; quietly += "_FIND_QUIETLY"; - m_Makefile->AddDefinition(quietly.c_str(), "1"); + this->Makefile->AddDefinition(quietly.c_str(), "1"); } if(required) @@ -262,7 +267,7 @@ // a fatal error if the package is not found. std::string req = this->Name; req += "_FIND_REQUIRED"; - m_Makefile->AddDefinition(req.c_str(), "1"); + this->Makefile->AddDefinition(req.c_str(), "1"); } // Load the module we found. @@ -325,7 +330,7 @@ std::string init = this->SearchForConfig(); // Store the entry in the cache so it can be set by the user. - m_Makefile->AddCacheDefinition(this->Variable.c_str(), + this->Makefile->AddCacheDefinition(this->Variable.c_str(), init.c_str(), help.c_str(), cmCacheManager::PATH); @@ -388,7 +393,7 @@ //---------------------------------------------------------------------------- bool cmFindPackageCommand::ReadListFile(const char* f) { - if(m_Makefile->ReadListFile(m_Makefile->GetCurrentListFile(),f)) + if(this->Makefile->ReadListFile(this->Makefile->GetCurrentListFile(),f)) { return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFindPackageCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFindPackageCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFindPackageCommand.h 2005-03-18 23:41:40.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFindPackageCommand.h 2006-01-28 02:07:23.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFindPackageCommand.h,v $ Language: C++ - Date: $Date: 2005/03/18 15:41:40 $ - Version: $Revision: 1.8 $ + Date: $Date: 2006/01/27 18:07:23 $ + Version: $Revision: 1.10 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -42,6 +42,11 @@ virtual bool InitialPass(std::vector const& args); /** + * This determines if the command is invoked when in script mode. + */ + virtual bool IsScriptable() { return true; } + + /** * The name of the command as specified in CMakeList.txt. */ virtual const char* GetName() { return "FIND_PACKAGE";} @@ -60,7 +65,8 @@ virtual const char* GetFullDocumentation() { return - " FIND_PACKAGE( [major.minor] [QUIET] [REQUIRED])\n" + " FIND_PACKAGE( [major.minor] [QUIET]\n" + " [REQUIRED [componets...]])\n" "Finds and loads settings from an external project. _FOUND will " "be set to indicate whether the package was found. Settings that " "can be used when _FOUND is true are package-specific. The " @@ -78,7 +84,9 @@ "argument is specified. If _DIR has been set to a directory " "not containing a \"Config.cmake\" file, an error is always " "generated. If REQUIRED is specified and the package is not found, " - "a FATAL_ERROR is generated and the configure step stops executing."; + "a FATAL_ERROR is generated and the configure step stops executing." + " A package-specific list of components may be listed after the " + "REQUIRED option."; } cmTypeMacro(cmFindPackageCommand, cmCommand); diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFindPathCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFindPathCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFindPathCommand.cxx 2004-04-23 01:24:20.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFindPathCommand.cxx 2006-03-16 00:02:01.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFindPathCommand.cxx,v $ Language: C++ - Date: $Date: 2004/04/22 17:24:20 $ - Version: $Revision: 1.23 $ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.30 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -17,92 +17,172 @@ #include "cmFindPathCommand.h" #include "cmCacheManager.h" + +cmFindPathCommand::cmFindPathCommand() +{ + this->IncludeFileInPath = false; + cmSystemTools::ReplaceString(this->GenericDocumentation, + "FIND_XXX", "FIND_PATH"); + cmSystemTools::ReplaceString(this->GenericDocumentation, + "CMAKE_XXX_PATH", "CMAKE_INCLUDE_PATH"); + cmSystemTools::ReplaceString(this->GenericDocumentation, + "XXX_SYSTEM", "INCLUDE"); + cmSystemTools::ReplaceString(this->GenericDocumentation, + "CMAKE_SYSTEM_XXX_PATH", "CMAKE_SYSTEM_INCLUDE_PATH"); + cmSystemTools::ReplaceString(this->GenericDocumentation, + "SEARCH_XXX_DESC", "directory containing the named file"); + cmSystemTools::ReplaceString(this->GenericDocumentation, + "SEARCH_XXX", "file in a directory"); + this->ExtraDocAdded = false; +} + +const char* cmFindPathCommand::GetFullDocumentation() +{ + if(!this->ExtraDocAdded && !this->IncludeFileInPath) + { + this->GenericDocumentation += + "\n" + "When searching for frameworks, if the file is specified as " + "A/b.h, then the framework search will look for A.framework/Headers/b.h. " + "If that is found the path will be set to the path to the framework. " + "CMake will convert this to the correct -F option to include the file. "; + this->ExtraDocAdded = true; + } + return this->GenericDocumentation.c_str(); +} + // cmFindPathCommand bool cmFindPathCommand::InitialPass(std::vector const& argsIn) { - if(argsIn.size() < 2) + this->VariableDocumentation = "Path to a file."; + this->CMakePathName = "INCLUDE"; + if(!this->ParseArguments(argsIn)) { - this->SetError("called with incorrect number of arguments"); return false; } - - // Now check and see if the value has been stored in the cache - // already, if so use that value and don't look for the program - std::string helpString = "What is the path where the file "; - helpString += argsIn[1] + " can be found"; - std::vector args; - size_t size = argsIn.size(); - for(unsigned int j = 0; j < size; ++j) + if(this->AlreadyInCache) { - if(argsIn[j] != "DOC") - { - args.push_back(argsIn[j]); - } - else + return true; + } + std::string ff = this->Makefile->GetSafeDefinition("CMAKE_FIND_FRAMEWORK"); + bool supportFrameworks = true; + if( ff.size() == 0 || ff == "NEVER" ) + { + supportFrameworks = false; + } + std::string framework; + // Use the search path to find the file. + unsigned int k; + std::string result; + for(k=0; k < this->SearchPaths.size(); k++) + { + for(unsigned int j =0; j < this->Names.size(); ++j) { - if(j+1 < size) + // if frameworks are supported try to find the header in a framework + std::string tryPath; + if(supportFrameworks) + { + tryPath = this->FindHeaderInFramework(this->Names[j], + this->SearchPaths[k]); + if(tryPath.size()) + { + result = tryPath; + } + } + if(result.size() == 0) + { + tryPath = this->SearchPaths[k]; + tryPath += "/"; + tryPath += this->Names[j]; + if(cmSystemTools::FileExists(tryPath.c_str())) + { + if(this->IncludeFileInPath) + { + result = tryPath; + } + else + { + result = this->SearchPaths[k]; + } + } + } + if(result.size() != 0) { - helpString = argsIn[j+1]; + this->Makefile->AddCacheDefinition(this->VariableName.c_str(), + result.c_str(), + this->VariableDocumentation.c_str(), + (this->IncludeFileInPath) ? + cmCacheManager::FILEPATH :cmCacheManager::PATH); + return true; } - break; } } + this->Makefile->AddCacheDefinition(this->VariableName.c_str(), + (this->VariableName + "-NOTFOUND").c_str(), + this->VariableDocumentation.c_str(), + (this->IncludeFileInPath) ? + cmCacheManager::FILEPATH :cmCacheManager::PATH); + return true; +} - const char* cacheValue - = m_Makefile->GetDefinition(args[0].c_str()); - if(cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue)) - { - return true; - } - if(cacheValue) +std::string cmFindPathCommand::FindHeaderInFramework(std::string& file, + std::string& dir) +{ + cmStdString fileName = file; + cmStdString frameWorkName; + cmStdString::size_type pos = fileName.find("/"); + // if there is a / in the name try to find the header as a framework + // For example bar/foo.h would look for: + // bar.framework/Headers/foo.h + if(pos != fileName.npos) { - cmCacheManager::CacheIterator it = - m_Makefile->GetCacheManager()->GetCacheIterator(args[0].c_str()); - if(!it.IsAtEnd()) + // remove the name from the slash; + fileName = fileName.substr(pos+1); + frameWorkName = file; + frameWorkName = frameWorkName.substr(0, frameWorkName.size()-fileName.size()-1); + // if the framework has a path in it then just use the filename + if(frameWorkName.find("/") != frameWorkName.npos) { - const char* hs = it.GetProperty("HELPSTRING"); - helpString = hs?hs:"(none)"; + fileName = file; + frameWorkName = ""; + } + if(frameWorkName.size()) + { + std::string fpath = dir; + fpath += "/"; + fpath += frameWorkName; + fpath += ".framework"; + std::string intPath = fpath; + intPath += "/Headers/"; + intPath += fileName; + if(cmSystemTools::FileExists(intPath.c_str())) + { + if(this->IncludeFileInPath) + { + return intPath; + } + return fpath; + } } } - std::vector path; - // add any user specified paths - for (unsigned int j = 2; j < args.size(); j++) - { - // expand variables - std::string exp = args[j]; - cmSystemTools::ExpandRegistryValues(exp); - - // Glob the entry in case of wildcards. - cmSystemTools::GlobDirs(exp.c_str(), path); - } - cmSystemTools::GetPath(path, "CMAKE_INCLUDE_PATH"); - // add the standard path - cmSystemTools::GetPath(path); - unsigned int k; - for(k=0; k < path.size(); k++) + // if it is not found yet or not a framework header, then do a glob search + // for all files in dir/*/Headers/ + cmStdString glob = dir; + glob += "/*/Headers/"; + glob += file; + cmGlob globIt; + globIt.FindFiles(glob); + std::vector files = globIt.GetFiles(); + if(files.size()) { - std::string tryPath = path[k]; - tryPath += "/"; - tryPath += args[1]; - if(cmSystemTools::FileExists(tryPath.c_str())) + cmStdString fheader = cmSystemTools::CollapseFullPath(files[0].c_str()); + if(this->IncludeFileInPath) { - path[k] = cmSystemTools::CollapseFullPath(path[k].c_str()); - if(path[k].size() && path[k][path[k].size()-1] == '/') - { - path[k] = path[k].substr(0, path[k].size()-1); - } - m_Makefile->AddCacheDefinition(args[0].c_str(), - path[k].c_str(), - helpString.c_str(), - cmCacheManager::PATH); - return true; + return fheader; } + fheader = cmSystemTools::GetFilenamePath(fheader); + return fheader; } - - m_Makefile->AddCacheDefinition(args[0].c_str(), - (args[0] + "-NOTFOUND").c_str(), - helpString.c_str(), - cmCacheManager::PATH); - return true; + return ""; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFindPathCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFindPathCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFindPathCommand.h 2005-03-18 23:41:40.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFindPathCommand.h 2006-03-03 02:30:22.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFindPathCommand.h,v $ Language: C++ - Date: $Date: 2005/03/18 15:41:40 $ - Version: $Revision: 1.13 $ + Date: $Date: 2006/03/02 18:30:22 $ + Version: $Revision: 1.16 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -17,7 +17,7 @@ #ifndef cmFindPathCommand_h #define cmFindPathCommand_h -#include "cmCommand.h" +#include "cmFindBase.h" /** \class cmFindPathCommand @@ -27,9 +27,10 @@ * that specifies a library. The command searches for a given * file in a list of directories. */ -class cmFindPathCommand : public cmCommand +class cmFindPathCommand : public cmFindBase { public: + cmFindPathCommand(); /** * This is a virtual constructor for the command. */ @@ -61,25 +62,13 @@ { return "Find the directory containing a file."; } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() - { - return - " FIND_PATH( fileName path1 [path2 ...]\n" - " [DOC \"docstring\"])\n" - "Find the directory containing a file named by fileName. Paths " - "are searched in the order specified. A cache entry named by " - " is created to store the result. If the file is not " - "found, the result will be -NOTFOUND. If DOC is specified " - "then the next argument is treated as a documentation string for " - "the cache entry . The environment variable CMAKE_INCLUDE_PATH " - "is searched as well as the PATH variable.\n"; - } - - cmTypeMacro(cmFindPathCommand, cmCommand); + + std::string FindHeaderInFramework( std::string& file, + std::string& dir); + virtual const char* GetFullDocumentation(); + cmTypeMacro(cmFindPathCommand, cmFindBase); + bool IncludeFileInPath; + bool ExtraDocAdded; }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFindProgramCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFindProgramCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFindProgramCommand.cxx 2003-08-11 06:30:53.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFindProgramCommand.cxx 2006-03-16 00:02:01.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFindProgramCommand.cxx,v $ Language: C++ - Date: $Date: 2003/08/10 22:30:53 $ - Version: $Revision: 1.30 $ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.33 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -18,130 +18,51 @@ #include "cmCacheManager.h" #include +cmFindProgramCommand::cmFindProgramCommand() +{ + cmSystemTools::ReplaceString(this->GenericDocumentation, + "FIND_XXX", "FIND_PROGRAM"); + cmSystemTools::ReplaceString(this->GenericDocumentation, + "CMAKE_XXX_PATH", "CMAKE_PROGRAM_PATH"); + cmSystemTools::ReplaceString(this->GenericDocumentation, + "XXX_SYSTEM", ""); + cmSystemTools::ReplaceString(this->GenericDocumentation, + "CMAKE_SYSTEM_XXX_PATH", "CMAKE_SYSTEM_PROGRAM_PATH"); + cmSystemTools::ReplaceString(this->GenericDocumentation, + "SEARCH_XXX_DESC", "program"); + cmSystemTools::ReplaceString(this->GenericDocumentation, + "SEARCH_XXX", "program"); +} // cmFindProgramCommand bool cmFindProgramCommand::InitialPass(std::vector const& argsIn) { - if(argsIn.size() < 2 ) + this->VariableDocumentation = "Path to a program."; + this->CMakePathName = "PROGRAM"; + // call cmFindBase::ParseArguments + if(!this->ParseArguments(argsIn)) { - this->SetError("called with incorrect number of arguments"); return false; } - std::string doc = "Path to a program."; - size_t size = argsIn.size(); - std::vector args; - for(unsigned int j = 0; j < size; ++j) - { - if(argsIn[j] != "DOC") - { - args.push_back(argsIn[j]); - } - else - { - if(j+1 < size) - { - doc = argsIn[j+1]; - } - break; - } - } - - std::vector::iterator i = args.begin(); - // Use the first argument as the name of something to be defined - const char* define = (*i).c_str(); - i++; // move iterator to next arg - // Now check and see if the value has been stored in the cache - // already, if so use that value and don't look for the program - const char* cacheValue - = m_Makefile->GetDefinition(define); - if(cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue)) + if(this->AlreadyInCache) { return true; } - if(cacheValue) - { - cmCacheManager::CacheIterator it = - m_Makefile->GetCacheManager()->GetCacheIterator(args[0].c_str()); - if(!it.IsAtEnd()) - { - const char* hs = it.GetProperty("HELPSTRING"); - doc = hs?hs:"(none)"; - } - } - std::vector path; - std::vector names; - bool foundName = false; - bool foundPath = false; - bool doingNames = true; - bool no_system_path = false; - for (unsigned int j = 1; j < args.size(); ++j) - { - if(args[j] == "NAMES") - { - doingNames = true; - foundName = true; - } - else if (args[j] == "PATHS") - { - doingNames = false; - foundPath = true; - } - else if (args[j] == "NO_SYSTEM_PATH") - { - no_system_path = true; - } - else - { - if(doingNames) - { - names.push_back(args[j]); - } - else - { - cmSystemTools::ExpandRegistryValues(args[j]); - // Glob the entry in case of wildcards. - cmSystemTools::GlobDirs(args[j].c_str(), path); - } - } - } - // if it is not in the cache, then search the system path - // add any user specified paths - if(!foundPath && !foundName) - { - path.clear(); - names.clear(); - names.push_back(args[1]); - for (unsigned int j = 2; j < args.size(); j++) - { - // expand variables - std::string exp = args[j]; - cmSystemTools::ExpandRegistryValues(exp); - - // Glob the entry in case of wildcards. - cmSystemTools::GlobDirs(exp.c_str(), path); - } - } - for(std::vector::iterator it = names.begin(); - it != names.end() ; ++it) - { - // Try to find the program. - std::string result = cmSystemTools::FindProgram(it->c_str(), - path, - no_system_path); - if(result != "") - { - // Save the value in the cache - m_Makefile->AddCacheDefinition(define, - result.c_str(), - doc.c_str(), - cmCacheManager::FILEPATH); - - return true; - } + std::string result = cmSystemTools::FindProgram(this->Names, + this->SearchPaths, true); + if(result != "") + { + // Save the value in the cache + this->Makefile->AddCacheDefinition(this->VariableName.c_str(), + result.c_str(), + this->VariableDocumentation.c_str(), + cmCacheManager::FILEPATH); + + return true; } - m_Makefile->AddCacheDefinition(args[0].c_str(), - (args[0] + "-NOTFOUND").c_str(), - doc.c_str(), + this->Makefile->AddCacheDefinition(this->VariableName.c_str(), + (this->VariableName + "-NOTFOUND").c_str(), + this->VariableDocumentation.c_str(), cmCacheManager::FILEPATH); return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFindProgramCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFindProgramCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFindProgramCommand.h 2005-03-18 23:41:40.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFindProgramCommand.h 2006-03-03 02:30:22.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFindProgramCommand.h,v $ Language: C++ - Date: $Date: 2005/03/18 15:41:40 $ - Version: $Revision: 1.17 $ + Date: $Date: 2006/03/02 18:30:22 $ + Version: $Revision: 1.18 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -17,7 +17,7 @@ #ifndef cmFindProgramCommand_h #define cmFindProgramCommand_h -#include "cmCommand.h" +#include "cmFindBase.h" /** \class cmFindProgramCommand * \brief Define a command to search for an executable program. @@ -27,9 +27,10 @@ * in the current path (e.g., PATH environment variable) for * an executable that matches one of the supplied names. */ -class cmFindProgramCommand : public cmCommand +class cmFindProgramCommand : public cmFindBase { public: + cmFindProgramCommand(); /** * This is a virtual constructor for the command. */ @@ -62,32 +63,7 @@ return "Find an executable program."; } - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() - { - return - " FIND_PROGRAM( NAMES name1 [name2 ...]\n" - " [PATHS path1 path2 ...]\n" - " [NO_SYSTEM_PATH]\n" - " [DOC \"docstring\"])\n" - "Find an executable named by one of the names given after the NAMES " - "argument. Paths specified after the PATHS argument are searched " - "in the order specified. If the NO_SYSTEM_PATH argument is not " - "specified, the search continues with the system search path " - "specified by the PATH environment variable. A cache entry named " - "by is created to store the result. If the program is not " - "found, the result will be -NOTFOUND. If DOC is specified " - "then the next argument is treated as a documentation string for " - "the cache entry .\n" - " FIND_PROGRAM(VAR executableName [path1 path2 ...])\n" - "Find a program with the given name by searching in the specified " - "paths. This is a short-hand signature for the command that is " - "sufficient in many cases."; - } - - cmTypeMacro(cmFindProgramCommand, cmCommand); + cmTypeMacro(cmFindProgramCommand, cmFindBase); }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFLTKWrapUICommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFLTKWrapUICommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFLTKWrapUICommand.cxx 2005-08-12 02:02:19.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFLTKWrapUICommand.cxx 2006-03-16 00:02:01.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFLTKWrapUICommand.cxx,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:19 $ - Version: $Revision: 1.23.2.1 $ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.28 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -28,27 +28,27 @@ } // what is the current source dir - std::string cdir = m_Makefile->GetCurrentDirectory(); + std::string cdir = this->Makefile->GetCurrentDirectory(); const char* fluid_exe = - m_Makefile->GetRequiredDefinition("FLTK_FLUID_EXECUTABLE"); + this->Makefile->GetRequiredDefinition("FLTK_FLUID_EXECUTABLE"); // get parameter for the command - m_Target = args[0]; // Target that will use the generated files + this->Target = args[0]; // Target that will use the generated files std::vector newArgs; - m_Makefile->ExpandSourceListArguments(args,newArgs, 1); + this->Makefile->ExpandSourceListArguments(args,newArgs, 1); // get the list of GUI files from which .cxx and .h will be generated - std::string outputDirectory = m_Makefile->GetCurrentOutputDirectory(); + std::string outputDirectory = this->Makefile->GetCurrentOutputDirectory(); // Some of the generated files are *.h so the directory "GUI" // where they are created have to be added to the include path - m_Makefile->AddIncludeDirectory( outputDirectory.c_str() ); + this->Makefile->AddIncludeDirectory( outputDirectory.c_str() ); for(std::vector::iterator i = (newArgs.begin() + 1); i != newArgs.end(); i++) { - cmSourceFile *curr = m_Makefile->GetSource(i->c_str()); + cmSourceFile *curr = this->Makefile->GetSource(i->c_str()); // if we should use the source GUI // to generate .cxx and .h files if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE")) @@ -63,7 +63,6 @@ // add starting depends std::vector depends; depends.push_back(origname); - depends.push_back("fluid"); std::string cxxres = outputDirectory.c_str(); cxxres += "/" + srcName; cxxres += ".cxx"; @@ -82,22 +81,25 @@ // Add command for generating the .h and .cxx files const char* no_main_dependency = 0; const char* no_comment = 0; - m_Makefile->AddCustomCommandToOutput(cxxres.c_str(), + const char* no_working_dir = 0; + this->Makefile->AddCustomCommandToOutput(cxxres.c_str(), depends, no_main_dependency, - commandLines, no_comment); - m_Makefile->AddCustomCommandToOutput(hname.c_str(), + commandLines, no_comment, + no_working_dir); + this->Makefile->AddCustomCommandToOutput(hname.c_str(), depends, no_main_dependency, - commandLines, no_comment); + commandLines, no_comment, + no_working_dir); - cmSourceFile *sf = m_Makefile->GetSource(cxxres.c_str()); + cmSourceFile *sf = this->Makefile->GetSource(cxxres.c_str()); sf->GetDepends().push_back(hname); sf->GetDepends().push_back(origname); - m_GeneratedSourcesClasses.push_back(sf); + this->GeneratedSourcesClasses.push_back(sf); } } // create the variable with the list of sources in it - size_t lastHeadersClass = m_GeneratedSourcesClasses.size(); + size_t lastHeadersClass = this->GeneratedSourcesClasses.size(); std::string sourceListValue; for(size_t classNum = 0; classNum < lastHeadersClass; classNum++) { @@ -105,11 +107,11 @@ { sourceListValue += ";"; } - sourceListValue += m_GeneratedSourcesClasses[classNum]->GetFullPath(); + sourceListValue += this->GeneratedSourcesClasses[classNum]->GetFullPath(); } - std::string varName = m_Target; + std::string varName = this->Target; varName += "_FLTK_UI_SRCS"; - m_Makefile->AddDefinition(varName.c_str(), sourceListValue.c_str()); + this->Makefile->AddDefinition(varName.c_str(), sourceListValue.c_str()); return true; } @@ -120,12 +122,12 @@ // didn't support that, so check and see if they added the files in and if // they didn;t then print a warning and add then anyhow std::vector srcs = - m_Makefile->GetTargets()[m_Target].GetSourceLists(); + this->Makefile->GetTargets()[this->Target].GetSourceLists(); bool found = false; for (unsigned int i = 0; i < srcs.size(); ++i) { if (srcs[i] == - m_GeneratedSourcesClasses[0]->GetFullPath()) + this->GeneratedSourcesClasses[0]->GetFullPath()) { found = true; break; @@ -135,16 +137,16 @@ { std::string msg = "In CMake 2.2 the FLTK_WRAP_UI command sets a variable to the list of source files that should be added to your executable or library. It appears that you have not added these source files to your target. You should change your CMakeLists.txt file to directly add the generated files to the target. For example FTLK_WRAP_UI(foo src1 src2 src3) will create a variable named foo_FLTK_UI_SRCS that contains the list of sources to add to your target when you call ADD_LIBRARY or ADD_EXECUTABLE. For now CMake 2.2 will add the sources to your target for you as was done in CMake 2.0 and earlier. In the future this may become an error. "; msg += "The problem was found while processing the source directory: "; - msg += m_Makefile->GetStartDirectory(); + msg += this->Makefile->GetStartDirectory(); cmSystemTools::Message(msg.c_str(),"Warning"); // first we add the rules for all the .fl to .h and .cxx files - size_t lastHeadersClass = m_GeneratedSourcesClasses.size(); + size_t lastHeadersClass = this->GeneratedSourcesClasses.size(); // Generate code for all the .fl files for(size_t classNum = 0; classNum < lastHeadersClass; classNum++) { - m_Makefile->GetTargets()[m_Target].GetSourceFiles().push_back( - m_GeneratedSourcesClasses[classNum]); + this->Makefile->GetTargets()[this->Target].GetSourceFiles().push_back( + this->GeneratedSourcesClasses[classNum]); } } } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFLTKWrapUICommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFLTKWrapUICommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmFLTKWrapUICommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmFLTKWrapUICommand.h 2006-03-16 00:02:01.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFLTKWrapUICommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.11.2.1 $ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.14 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -22,7 +22,8 @@ /** \class cmFLTKWrapUICommand * \brief Create .h and .cxx files rules for FLTK user interfaces files * - * cmFLTKWrapUICommand is used to create wrappers for FLTK classes into normal C++ + * cmFLTKWrapUICommand is used to create wrappers for FLTK classes into + * normal C++ */ class cmFLTKWrapUICommand : public cmCommand { @@ -82,13 +83,13 @@ /** * List of produced files. */ - std::vector m_GeneratedSourcesClasses; + std::vector GeneratedSourcesClasses; /** * List of Fluid files that provide the source * generating .cxx and .h files */ - std::string m_Target; + std::string Target; }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmForEachCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmForEachCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmForEachCommand.cxx 2005-06-23 23:03:57.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmForEachCommand.cxx 2006-03-16 00:02:01.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmForEachCommand.cxx,v $ Language: C++ - Date: $Date: 2005/06/23 15:03:57 $ - Version: $Revision: 1.19 $ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.20 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -21,49 +21,49 @@ { // Prevent recusion and don't let this blobker block its own // commands. - if (m_Executing) + if (this->Executing) { return false; } // at end of for each execute recorded commands - if (cmSystemTools::LowerCase(lff.m_Name) == "endforeach") + if (cmSystemTools::LowerCase(lff.Name) == "endforeach") { std::vector expandedArguments; - mf.ExpandArguments(lff.m_Arguments, expandedArguments); - if(!expandedArguments.empty() && (expandedArguments[0] == m_Args[0])) + mf.ExpandArguments(lff.Arguments, expandedArguments); + if(!expandedArguments.empty() && (expandedArguments[0] == this->Args[0])) { // store the old value std::string oldDef; - if (mf.GetDefinition(m_Args[0].c_str())) + if (mf.GetDefinition(this->Args[0].c_str())) { - oldDef = mf.GetDefinition(m_Args[0].c_str()); + oldDef = mf.GetDefinition(this->Args[0].c_str()); } - m_Executing = true; - std::vector::const_iterator j = m_Args.begin(); + this->Executing = true; + std::vector::const_iterator j = this->Args.begin(); ++j; std::string tmps; cmListFileArgument arg; - for( ; j != m_Args.end(); ++j) + for( ; j != this->Args.end(); ++j) { // set the variable to the loop value - mf.AddDefinition(m_Args[0].c_str(),j->c_str()); + mf.AddDefinition(this->Args[0].c_str(),j->c_str()); // Invoke all the functions that were collected in the block. - for(unsigned int c = 0; c < m_Functions.size(); ++c) + for(unsigned int c = 0; c < this->Functions.size(); ++c) { - mf.ExecuteCommand(m_Functions[c]); + mf.ExecuteCommand(this->Functions[c]); } } // restore the variable to its prior value - mf.AddDefinition(m_Args[0].c_str(),oldDef.c_str()); + mf.AddDefinition(this->Args[0].c_str(),oldDef.c_str()); mf.RemoveFunctionBlocker(lff); return true; } } // record the command - m_Functions.push_back(lff); + this->Functions.push_back(lff); // always return true return true; @@ -72,11 +72,11 @@ bool cmForEachFunctionBlocker:: ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) { - if(cmSystemTools::LowerCase(lff.m_Name) == "endforeach") + if(cmSystemTools::LowerCase(lff.Name) == "endforeach") { std::vector expandedArguments; - mf.ExpandArguments(lff.m_Arguments, expandedArguments); - if(!expandedArguments.empty() && (expandedArguments[0] == m_Args[0])) + mf.ExpandArguments(lff.Arguments, expandedArguments); + if(!expandedArguments.empty() && (expandedArguments[0] == this->Args[0])) { return true; } @@ -163,18 +163,18 @@ break; } } - f->m_Args = range; + f->Args = range; } else { - f->m_Args = args; + f->Args = args; } } else { - f->m_Args = args; + f->Args = args; } - m_Makefile->AddFunctionBlocker(f); + this->Makefile->AddFunctionBlocker(f); return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmForEachCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmForEachCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmForEachCommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmForEachCommand.h 2006-03-16 00:02:01.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmForEachCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.13.2.1 $ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.15 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -29,16 +29,16 @@ class cmForEachFunctionBlocker : public cmFunctionBlocker { public: - cmForEachFunctionBlocker() {m_Executing = false;} + cmForEachFunctionBlocker() {this->Executing = false;} virtual ~cmForEachFunctionBlocker() {} virtual bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf); virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf); virtual void ScopeEnded(cmMakefile &mf); - std::vector m_Args; - std::vector m_Functions; - bool m_Executing; + std::vector Args; + std::vector Functions; + bool Executing; }; /** \class cmForEachCommand diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGeneratedFileStream.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGeneratedFileStream.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGeneratedFileStream.cxx 2005-05-10 23:11:28.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGeneratedFileStream.cxx 2006-03-16 00:02:01.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGeneratedFileStream.cxx,v $ Language: C++ - Date: $Date: 2005/05/10 15:11:28 $ - Version: $Revision: 1.9 $ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.15 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -39,12 +39,12 @@ //---------------------------------------------------------------------------- cmGeneratedFileStream::cmGeneratedFileStream(const char* name, bool quiet): cmGeneratedFileStreamBase(name), - Stream(m_TempName.c_str()) + Stream(TempName.c_str()) { // Check if the file opened. if(!*this && !quiet) { - cmSystemTools::Error("Cannot open file for write: ", m_TempName.c_str()); + cmSystemTools::Error("Cannot open file for write: ", this->TempName.c_str()); cmSystemTools::ReportLastSystemError(""); } } @@ -57,23 +57,30 @@ // stream will be destroyed which will close the temporary file. // Finally the base destructor will be called to replace the // destination file. - m_Okay = (*this)?true:false; + this->Okay = (*this)?true:false; } //---------------------------------------------------------------------------- cmGeneratedFileStream& -cmGeneratedFileStream::Open(const char* name, bool quiet) +cmGeneratedFileStream::Open(const char* name, bool quiet, bool binaryFlag) { // Store the file name and construct the temporary file name. this->cmGeneratedFileStreamBase::Open(name); // Open the temporary output file. - this->Stream::open(m_TempName.c_str()); + if ( binaryFlag ) + { + this->Stream::open(this->TempName.c_str(), std::ios::out | std::ios::binary); + } + else + { + this->Stream::open(this->TempName.c_str(), std::ios::out); + } // Check if the file opened. if(!*this && !quiet) { - cmSystemTools::Error("Cannot open file for write: ", m_TempName.c_str()); + cmSystemTools::Error("Cannot open file for write: ", this->TempName.c_str()); cmSystemTools::ReportLastSystemError(""); } return *this; @@ -84,7 +91,7 @@ cmGeneratedFileStream::Close() { // Save whether the temporary output file is valid before closing. - m_Okay = (*this)?true:false; + this->Okay = (*this)?true:false; // Close the temporary output file. this->Stream::close(); @@ -98,32 +105,40 @@ //---------------------------------------------------------------------------- void cmGeneratedFileStream::SetCopyIfDifferent(bool copy_if_different) { - m_CopyIfDifferent = copy_if_different; + this->CopyIfDifferent = copy_if_different; } //---------------------------------------------------------------------------- void cmGeneratedFileStream::SetCompression(bool compression) { - m_Compress = compression; + this->Compress = compression; +} + +//---------------------------------------------------------------------------- +void cmGeneratedFileStream::SetCompressionExtraExtension(bool ext) +{ + this->CompressExtraExtension = ext; } //---------------------------------------------------------------------------- cmGeneratedFileStreamBase::cmGeneratedFileStreamBase(): - m_Name(), - m_TempName(), - m_CopyIfDifferent(false), - m_Okay(false), - m_Compress(false) + Name(), + TempName(), + CopyIfDifferent(false), + Okay(false), + Compress(false), + CompressExtraExtension(true) { } //---------------------------------------------------------------------------- cmGeneratedFileStreamBase::cmGeneratedFileStreamBase(const char* name): - m_Name(), - m_TempName(), - m_CopyIfDifferent(false), - m_Okay(false), - m_Compress(false) + Name(), + TempName(), + CopyIfDifferent(false), + Okay(false), + Compress(false), + CompressExtraExtension(true) { this->Open(name); } @@ -138,41 +153,41 @@ void cmGeneratedFileStreamBase::Open(const char* name) { // Save the original name of the file. - m_Name = name; + this->Name = name; // Create the name of the temporary file. - m_TempName = name; - m_TempName += ".tmp"; + this->TempName = name; + this->TempName += ".tmp"; // Make sure the temporary file that will be used is not present. - cmSystemTools::RemoveFile(m_TempName.c_str()); + cmSystemTools::RemoveFile(this->TempName.c_str()); - std::string dir = cmSystemTools::GetFilenamePath(m_TempName); + std::string dir = cmSystemTools::GetFilenamePath(this->TempName); cmSystemTools::MakeDirectory(dir.c_str()); } //---------------------------------------------------------------------------- void cmGeneratedFileStreamBase::Close() { - std::string resname = m_Name; - if ( m_Compress ) + std::string resname = this->Name; + if ( this->Compress && this->CompressExtraExtension ) { resname += ".gz"; } // Only consider replacing the destination file if no error // occurred. - if(!m_Name.empty() && - m_Okay && - (!m_CopyIfDifferent || - cmSystemTools::FilesDiffer(m_TempName.c_str(), resname.c_str()))) + if(!this->Name.empty() && + this->Okay && + (!this->CopyIfDifferent || + cmSystemTools::FilesDiffer(this->TempName.c_str(), resname.c_str()))) { // The destination is to be replaced. Rename the temporary to the // destination atomically. - if ( m_Compress ) + if ( this->Compress ) { - std::string gzname = m_TempName + ".temp.gz"; - if ( this->CompressFile(m_TempName.c_str(), gzname.c_str()) ) + std::string gzname = this->TempName + ".temp.gz"; + if ( this->CompressFile(this->TempName.c_str(), gzname.c_str()) ) { this->RenameFile(gzname.c_str(), resname.c_str()); } @@ -180,14 +195,14 @@ } else { - this->RenameFile(m_TempName.c_str(), resname.c_str()); + this->RenameFile(this->TempName.c_str(), resname.c_str()); } } // Else, the destination was not replaced. // // Always delete the temporary file. We never want it to stay around. - cmSystemTools::RemoveFile(m_TempName.c_str()); + cmSystemTools::RemoveFile(this->TempName.c_str()); } //---------------------------------------------------------------------------- @@ -284,8 +299,8 @@ { if ( !fname ) { - m_Name = ""; + this->Name = ""; return; } - m_Name = fname; + this->Name = fname; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGeneratedFileStream.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGeneratedFileStream.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGeneratedFileStream.h 2005-05-10 23:11:28.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGeneratedFileStream.h 2006-03-16 00:02:01.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGeneratedFileStream.h,v $ Language: C++ - Date: $Date: 2005/05/10 15:11:28 $ - Version: $Revision: 1.17 $ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.21 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -41,7 +41,7 @@ // Internal methods to handle the temporary file. Open is always // called before the real stream is opened. Close is always called - // after the real stream is closed and m_Okay is set to whether the + // after the real stream is closed and Okay is set to whether the // real stream was still valid for writing when it was closed. void Open(const char* name); void Close(); @@ -53,19 +53,22 @@ int CompressFile(const char* oldname, const char* newname); // The name of the final destination file for the output. - std::string m_Name; + std::string Name; // The name of the temporary file. - std::string m_TempName; + std::string TempName; // Whether to do a copy-if-different. - bool m_CopyIfDifferent; + bool CopyIfDifferent; // Whether the real file stream was valid when it was closed. - bool m_Okay; + bool Okay; // Whether the destionation file is compressed - bool m_Compress; + bool Compress; + + // Whether the destionation file is compressed + bool CompressExtraExtension; }; /** \class cmGeneratedFileStream @@ -111,7 +114,8 @@ * temporary file. If the file cannot be opened an error message is * produced unless the second argument is set to true. */ - cmGeneratedFileStream& Open(const char* name, bool quiet=false); + cmGeneratedFileStream& Open(const char* name, bool quiet=false, + bool binaryFlag=false); /** * Close the output file. This should be used only with an open @@ -132,6 +136,11 @@ void SetCompression(bool compression); /** + * Set whether compression has extra extension + */ + void SetCompressionExtraExtension(bool ext); + + /** * Set name of the file that will hold the actual output. This method allows * the output file to be changed during the use of cmGeneratedFileStream. */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGetCMakePropertyCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGetCMakePropertyCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGetCMakePropertyCommand.cxx 2004-02-23 02:14:59.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGetCMakePropertyCommand.cxx 2006-03-16 00:02:01.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGetCMakePropertyCommand.cxx,v $ Language: C++ - Date: $Date: 2004/02/22 18:14:59 $ - Version: $Revision: 1.5 $ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.6 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -39,7 +39,7 @@ { cacheonly = 1; } - std::vector vars = m_Makefile->GetDefinitions(cacheonly); + std::vector vars = this->Makefile->GetDefinitions(cacheonly); for ( cc = 0; cc < vars.size(); cc ++ ) { if ( cc > 0 ) @@ -52,9 +52,9 @@ else if ( args[1] == "COMMANDS" ) { cmake::RegisteredCommandsMap::iterator cmds - = m_Makefile->GetCMakeInstance()->GetCommands()->begin(); + = this->Makefile->GetCMakeInstance()->GetCommands()->begin(); for (cc=0 ; - cmds != m_Makefile->GetCMakeInstance()->GetCommands()->end(); + cmds != this->Makefile->GetCMakeInstance()->GetCommands()->end(); ++ cmds ) { if ( cc > 0 ) @@ -67,7 +67,7 @@ } else if ( args[1] == "MACROS" ) { - m_Makefile->GetListOfMacros(output); + this->Makefile->GetListOfMacros(output); } else { @@ -75,7 +75,7 @@ this->SetError(emsg.c_str()); return false; } - m_Makefile->AddDefinition(variable.c_str(), output.c_str()); + this->Makefile->AddDefinition(variable.c_str(), output.c_str()); return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGetCMakePropertyCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGetCMakePropertyCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGetCMakePropertyCommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGetCMakePropertyCommand.h 2005-12-08 00:39:08.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGetCMakePropertyCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.4.8.1 $ + Date: $Date: 2005/12/07 16:39:08 $ + Version: $Revision: 1.6 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -34,6 +34,11 @@ virtual bool InitialPass(std::vector const& args); /** + * This determines if the command is invoked when in script mode. + */ + virtual bool IsScriptable() { return true; } + + /** * The name of the command as specified in CMakeList.txt. */ virtual const char* GetName() { return "GET_CMAKE_PROPERTY";} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGetDirectoryPropertyCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGetDirectoryPropertyCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGetDirectoryPropertyCommand.cxx 2005-09-16 04:38:36.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGetDirectoryPropertyCommand.cxx 2006-03-16 00:02:01.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGetDirectoryPropertyCommand.cxx,v $ Language: C++ - Date: $Date: 2005/09/15 20:38:36 $ - Version: $Revision: 1.4.2.1 $ + Date: $Date: 2006/03/15 16:02:01 $ + Version: $Revision: 1.6 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -33,9 +33,9 @@ std::string variable = *i; ++i; std::string output = ""; - + // get the directory argument if there is one - cmMakefile *dir = m_Makefile; + cmMakefile *dir = this->Makefile; if (*i == "DIRECTORY") { ++i; @@ -49,13 +49,13 @@ // make sure the start dir is a full path if (!cmSystemTools::FileIsFullPath(sd.c_str())) { - sd = m_Makefile->GetStartDirectory(); + sd = this->Makefile->GetStartDirectory(); sd += "/"; sd += *i; } // lookup the makefile from the directory name cmLocalGenerator *lg = - m_Makefile->GetLocalGenerator()->GetGlobalGenerator()-> + this->Makefile->GetLocalGenerator()->GetGlobalGenerator()-> FindLocalGenerator(sd.c_str()); if (!lg) { @@ -151,13 +151,13 @@ const char *prop = dir->GetProperty(i->c_str()); if (prop) { - m_Makefile->AddDefinition(variable.c_str(), prop); + this->Makefile->AddDefinition(variable.c_str(), prop); return true; } - m_Makefile->AddDefinition(variable.c_str(), ""); + this->Makefile->AddDefinition(variable.c_str(), ""); return true; } - m_Makefile->AddDefinition(variable.c_str(), output.c_str()); + this->Makefile->AddDefinition(variable.c_str(), output.c_str()); return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGetDirectoryPropertyCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGetDirectoryPropertyCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGetDirectoryPropertyCommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGetDirectoryPropertyCommand.h 2005-12-08 00:39:08.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGetDirectoryPropertyCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.2.2.2 $ + Date: $Date: 2005/12/07 16:39:08 $ + Version: $Revision: 1.5 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -34,6 +34,11 @@ virtual bool InitialPass(std::vector const& args); /** + * This determines if the command is invoked when in script mode. + */ + virtual bool IsScriptable() { return true; } + + /** * The name of the command as specified in CMakeList.txt. */ virtual const char* GetName() { return "GET_DIRECTORY_PROPERTY";} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGetFilenameComponentCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGetFilenameComponentCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGetFilenameComponentCommand.cxx 2003-02-08 03:04:16.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGetFilenameComponentCommand.cxx 2006-03-16 00:02:02.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGetFilenameComponentCommand.cxx,v $ Language: C++ - Date: $Date: 2003/02/07 19:04:16 $ - Version: $Revision: 1.13 $ + Date: $Date: 2006/03/15 16:02:02 $ + Version: $Revision: 1.15 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -30,7 +30,7 @@ // already, if so use that value if(args.size() == 4 && args[3] == "CACHE") { - const char* cacheValue = m_Makefile->GetDefinition(args[0].c_str()); + const char* cacheValue = this->Makefile->GetDefinition(args[0].c_str()); if(cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue)) { return true; @@ -75,6 +75,20 @@ } else if (args[2] == "ABSOLUTE") { + // If the path given is relative evaluate it relative to the + // current source directory. + if(!cmSystemTools::FileIsFullPath(filename.c_str())) + { + std::string fname = this->Makefile->GetCurrentDirectory(); + if(!fname.empty()) + { + fname += "/"; + fname += filename; + filename = fname; + } + } + + // Collapse the path to its simplest form. result = cmSystemTools::CollapseFullPath(filename.c_str()); } else @@ -88,13 +102,13 @@ { if(programArgs.size() && storeArgs.size()) { - m_Makefile->AddCacheDefinition(storeArgs.c_str(), + this->Makefile->AddCacheDefinition(storeArgs.c_str(), programArgs.c_str(), "", args[2] == "PATH" ? cmCacheManager::FILEPATH : cmCacheManager::STRING); } - m_Makefile->AddCacheDefinition(args[0].c_str(), + this->Makefile->AddCacheDefinition(args[0].c_str(), result.c_str(), "", args[2] == "PATH" ? cmCacheManager::FILEPATH @@ -104,9 +118,9 @@ { if(programArgs.size() && storeArgs.size()) { - m_Makefile->AddDefinition(storeArgs.c_str(), programArgs.c_str()); + this->Makefile->AddDefinition(storeArgs.c_str(), programArgs.c_str()); } - m_Makefile->AddDefinition(args[0].c_str(), result.c_str()); + this->Makefile->AddDefinition(args[0].c_str(), result.c_str()); } return true; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGetSourceFilePropertyCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGetSourceFilePropertyCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGetSourceFilePropertyCommand.cxx 2004-02-23 02:14:59.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGetSourceFilePropertyCommand.cxx 2006-03-16 00:02:02.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGetSourceFilePropertyCommand.cxx,v $ Language: C++ - Date: $Date: 2004/02/22 18:14:59 $ - Version: $Revision: 1.7 $ + Date: $Date: 2006/03/15 16:02:02 $ + Version: $Revision: 1.8 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -29,19 +29,19 @@ } const char* var = args[0].c_str(); const char* file = args[1].c_str(); - cmSourceFile* sf = m_Makefile->GetSource(file); + cmSourceFile* sf = this->Makefile->GetSource(file); if(sf) { const char *prop = sf->GetProperty(args[2].c_str()); if (prop) { - m_Makefile->AddDefinition(var, prop); + this->Makefile->AddDefinition(var, prop); return true; } } - m_Makefile->AddDefinition(var, "NOTFOUND"); + this->Makefile->AddDefinition(var, "NOTFOUND"); return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGetSourceFilePropertyCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGetSourceFilePropertyCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGetSourceFilePropertyCommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGetSourceFilePropertyCommand.h 2005-11-17 01:08:39.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGetSourceFilePropertyCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.7.8.2 $ + Date: $Date: 2005/11/16 17:08:39 $ + Version: $Revision: 1.9 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -53,7 +53,7 @@ { return " GET_SOURCE_FILE_PROPERTY(VAR file property)\n" - "Get a property from a source file. The value of the property is " + "Get a property from a source file. The value of the property is " "stored in the variable VAR. If the property is not found, VAR " "will be set to \"NOTFOUND\". Use SET_SOURCE_FILES_PROPERTIES to set " "property values. Source file properties usually control how the " diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGetTargetPropertyCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGetTargetPropertyCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGetTargetPropertyCommand.cxx 2005-06-21 02:00:48.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGetTargetPropertyCommand.cxx 2006-03-16 00:02:02.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGetTargetPropertyCommand.cxx,v $ Language: C++ - Date: $Date: 2005/06/20 18:00:48 $ - Version: $Revision: 1.6 $ + Date: $Date: 2006/03/15 16:02:02 $ + Version: $Revision: 1.7 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -28,7 +28,7 @@ const char* var = args[0].c_str(); const char* targetName = args[1].c_str(); - cmTarget *tgt = m_Makefile->GetLocalGenerator()->GetGlobalGenerator() + cmTarget *tgt = this->Makefile->GetLocalGenerator()->GetGlobalGenerator() ->FindTarget(0,targetName); if (tgt) { @@ -36,11 +36,11 @@ const char *prop = target.GetProperty(args[2].c_str()); if (prop) { - m_Makefile->AddDefinition(var, prop); + this->Makefile->AddDefinition(var, prop); return true; } } - m_Makefile->AddDefinition(var, "NOTFOUND"); + this->Makefile->AddDefinition(var, "NOTFOUND"); return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGetTargetPropertyCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGetTargetPropertyCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGetTargetPropertyCommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGetTargetPropertyCommand.h 2005-11-17 01:11:14.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGetTargetPropertyCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.6.2.2 $ + Date: $Date: 2005/11/16 17:11:14 $ + Version: $Revision: 1.9 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -53,7 +53,7 @@ { return " GET_TARGET_PROPERTY(VAR target property)\n" - "Get a property from a target. The value of the property is " + "Get a property from a target. The value of the property is " "stored in the variable VAR. If the property is not found, VAR " "will be set to \"NOTFOUND\". Use SET_TARGET_PROPERTIES to set " "property values. Properties are usually used to control how " diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGetTestPropertyCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGetTestPropertyCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGetTestPropertyCommand.cxx 2005-10-07 03:28:33.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGetTestPropertyCommand.cxx 2006-03-16 00:02:02.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGetTestPropertyCommand.cxx,v $ Language: C++ - Date: $Date: 2005/10/06 19:28:33 $ - Version: $Revision: 1.1.2.2 $ + Date: $Date: 2006/03/15 16:02:02 $ + Version: $Revision: 1.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -31,17 +31,17 @@ std::string testName = args[0]; std::string var = args[2]; - cmTest *test = m_Makefile->GetTest(testName.c_str()); + cmTest *test = this->Makefile->GetTest(testName.c_str()); if (test) { const char *prop = test->GetProperty(args[1].c_str()); if (prop) { - m_Makefile->AddDefinition(var.c_str(), prop); + this->Makefile->AddDefinition(var.c_str(), prop); return true; } } - m_Makefile->AddDefinition(var.c_str(), "NOTFOUND"); + this->Makefile->AddDefinition(var.c_str(), "NOTFOUND"); return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGetTestPropertyCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGetTestPropertyCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGetTestPropertyCommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGetTestPropertyCommand.h 2005-11-17 03:02:30.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGetTestPropertyCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.1.2.2 $ + Date: $Date: 2005/11/16 19:02:30 $ + Version: $Revision: 1.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalBorlandMakefileGenerator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalBorlandMakefileGenerator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalBorlandMakefileGenerator.cxx 2005-05-12 22:49:56.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalBorlandMakefileGenerator.cxx 2006-03-16 00:02:02.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalBorlandMakefileGenerator.cxx,v $ Language: C++ - Date: $Date: 2005/05/12 14:49:56 $ - Version: $Revision: 1.16 $ + Date: $Date: 2006/03/15 16:02:02 $ + Version: $Revision: 1.19 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -21,15 +21,16 @@ cmGlobalBorlandMakefileGenerator::cmGlobalBorlandMakefileGenerator() { - m_FindMakeProgramFile = "CMakeBorlandFindMake.cmake"; - m_ForceUnixPaths = false; + this->EmptyRuleHackDepends = "NUL"; + this->FindMakeProgramFile = "CMakeBorlandFindMake.cmake"; + this->ForceUnixPaths = false; } void cmGlobalBorlandMakefileGenerator::EnableLanguage(std::vectorconst& l, cmMakefile *mf) { - std::string outdir = m_CMakeInstance->GetStartOutputDirectory(); + std::string outdir = this->CMakeInstance->GetStartOutputDirectory(); mf->AddDefinition("BORLAND", "1"); mf->AddDefinition("CMAKE_GENERATOR_CC", "bcc32"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "bcc32"); @@ -43,9 +44,11 @@ lg->SetEchoNeedsQuote(false); lg->SetIncludeDirective("!include"); lg->SetWindowsShell(true); + lg->SetDefineWindowsNULL(true); lg->SetMakefileVariableSize(32); lg->SetPassMakeflags(true); lg->SetGlobalGenerator(this); + lg->SetUnixCD(false); return lg; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalBorlandMakefileGenerator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalBorlandMakefileGenerator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalBorlandMakefileGenerator.h 2004-08-27 20:41:07.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalBorlandMakefileGenerator.h 2006-03-11 02:54:57.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalBorlandMakefileGenerator.h,v $ Language: C++ - Date: $Date: 2004/08/27 12:41:07 $ - Version: $Revision: 1.5 $ + Date: $Date: 2006/03/10 18:54:57 $ + Version: $Revision: 1.6 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -28,7 +28,8 @@ { public: cmGlobalBorlandMakefileGenerator(); - static cmGlobalGenerator* New() { return new cmGlobalBorlandMakefileGenerator; } + static cmGlobalGenerator* New() + { return new cmGlobalBorlandMakefileGenerator; } ///! Get the name for the generator. virtual const char* GetName() const { @@ -45,7 +46,8 @@ * Try to determine system infomation such as shared library * extension, pthreads, byte order etc. */ - virtual void EnableLanguage(std::vectorconst& languages, cmMakefile *); + virtual void EnableLanguage(std::vectorconst& languages, + cmMakefile *); }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalGenerator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalGenerator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalGenerator.cxx 2005-09-16 04:38:36.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalGenerator.cxx 2006-03-17 07:24:26.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalGenerator.cxx,v $ Language: C++ - Date: $Date: 2005/09/15 20:38:36 $ - Version: $Revision: 1.94.2.3 $ + Date: $Date: 2006/03/16 23:24:26 $ + Version: $Revision: 1.125 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -32,33 +32,33 @@ cmGlobalGenerator::cmGlobalGenerator() { // by default use the native paths - m_ForceUnixPaths = false; + this->ForceUnixPaths = false; } cmGlobalGenerator::~cmGlobalGenerator() { // Delete any existing cmLocalGenerators unsigned int i; - for (i = 0; i < m_LocalGenerators.size(); ++i) + for (i = 0; i < this->LocalGenerators.size(); ++i) { - delete m_LocalGenerators[i]; + delete this->LocalGenerators[i]; } - m_LocalGenerators.clear(); + this->LocalGenerators.clear(); } // Find the make program for the generator, required for try compiles void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf) { - if(m_FindMakeProgramFile.size() == 0) + if(this->FindMakeProgramFile.size() == 0) { cmSystemTools::Error( "Generator implementation error, " - "all generators must specify m_FindMakeProgramFile"); + "all generators must specify this->FindMakeProgramFile"); } if(!mf->GetDefinition("CMAKE_MAKE_PROGRAM") || cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) { - std::string setMakeProgram = mf->GetModulesFile(m_FindMakeProgramFile.c_str()); + std::string setMakeProgram = mf->GetModulesFile(this->FindMakeProgramFile.c_str()); if(setMakeProgram.size()) { mf->ReadListFile(0, setMakeProgram.c_str()); @@ -146,9 +146,9 @@ // If the configuration files path has been set, // then we are in a try compile and need to copy the enable language // files from the parent cmake bin dir, into the try compile bin dir - if(m_ConfiguredFilesPath.size()) + if(this->ConfiguredFilesPath.size()) { - std::string src = m_ConfiguredFilesPath; + std::string src = this->ConfiguredFilesPath; src += "/CMakeSystem.cmake"; std::string dst = rootBin; dst += "/CMakeSystem.cmake"; @@ -162,7 +162,7 @@ continue; } const char* lang = l->c_str(); - std::string src2 = m_ConfiguredFilesPath; + std::string src2 = this->ConfiguredFilesPath; src2 += "/CMake"; src2 += lang; src2 += "Compiler.cmake"; @@ -171,7 +171,7 @@ dst2 += lang; dst2 += "Compiler.cmake"; cmSystemTools::CopyFileIfDifferent(src2.c_str(), dst2.c_str()); - src2 = m_ConfiguredFilesPath; + src2 = this->ConfiguredFilesPath; src2 += "/CMake"; src2 += lang; src2 += "Platform.cmake"; @@ -181,7 +181,7 @@ dst2 += "Platform.cmake"; cmSystemTools::CopyFileIfDifferent(src2.c_str(), dst2.c_str()); } - rootBin = m_ConfiguredFilesPath; + rootBin = this->ConfiguredFilesPath; } // find and make sure CMAKE_MAKE_PROGRAM is defined @@ -216,8 +216,8 @@ std::string systemFile = mf->GetModulesFile("CMakeDetermineSystem.cmake"); mf->ReadListFile(0, systemFile.c_str()); // load the CMakeSystem.cmake from the binary directory - // this file is configured by the CMakeDetermineSystem.cmake file - fpath = rootBin; + // this file is configured by the CMakeDetermineSystem.cmake file + fpath = rootBin; fpath += "/CMakeSystem.cmake"; mf->ReadListFile(0,fpath.c_str()); } @@ -239,36 +239,36 @@ std::string loadedLang = "CMAKE_"; loadedLang += lang; loadedLang += "_COMPILER_LOADED"; - // If the existing build tree was already configured with this - // version of CMake then try to load the configured file first - // to avoid duplicate compiler tests. - unsigned int cacheMajor = mf->GetCacheMajorVersion(); - unsigned int cacheMinor = mf->GetCacheMinorVersion(); - unsigned int selfMajor = cmMakefile::GetMajorVersion(); - unsigned int selfMinor = cmMakefile::GetMinorVersion(); - if((m_CMakeInstance->GetIsInTryCompile() || + // If the existing build tree was already configured with this + // version of CMake then try to load the configured file first + // to avoid duplicate compiler tests. + unsigned int cacheMajor = mf->GetCacheMajorVersion(); + unsigned int cacheMinor = mf->GetCacheMinorVersion(); + unsigned int selfMajor = cmMakefile::GetMajorVersion(); + unsigned int selfMinor = cmMakefile::GetMinorVersion(); + if((this->CMakeInstance->GetIsInTryCompile() || (selfMajor == cacheMajor && selfMinor == cacheMinor)) && !mf->GetDefinition(loadedLang.c_str())) + { + fpath = rootBin; + fpath += "/CMake"; + fpath += lang; + fpath += "Compiler.cmake"; + if(cmSystemTools::FileExists(fpath.c_str())) + { + if(!mf->ReadListFile(0,fpath.c_str())) { - fpath = rootBin; - fpath += "/CMake"; - fpath += lang; - fpath += "Compiler.cmake"; - if(cmSystemTools::FileExists(fpath.c_str())) - { - if(!mf->ReadListFile(0,fpath.c_str())) - { - cmSystemTools::Error("Could not find cmake module file:", fpath.c_str()); - } + cmSystemTools::Error("Could not find cmake module file:", fpath.c_str()); + } // if this file was found then the language was already determined to be working needTestLanguage[lang] = false; this->SetLanguageEnabled(lang, mf); // this can only be called after loading CMake(LANG)Compiler.cmake - } } + } if(!this->GetLanguageEnabled(lang) ) { - if (m_CMakeInstance->GetIsInTryCompile()) + if (this->CMakeInstance->GetIsInTryCompile()) { cmSystemTools::Error("This should not have happen. " "If you see this message, you are probably using a " @@ -286,7 +286,7 @@ { cmSystemTools::Error("Could not find cmake module file:", determineFile.c_str()); - } + } needTestLanguage[lang] = true; determineLanguageCalled = true; // Some generators like visual studio should not use the env variables @@ -325,7 +325,7 @@ // the language must be enabled for try compile to work, but // we do not know if it is a working compiler yet so set the test language flag needTestLanguage[lang] = true; - } + } } // end loop over languages // **** Load the system specific information if not yet loaded @@ -368,7 +368,7 @@ // If the language is untested then test it now with a try compile. if(needTestLanguage[lang]) { - if (!m_CMakeInstance->GetIsInTryCompile()) + if (!this->CMakeInstance->GetIsInTryCompile()) { std::string testLang = "CMakeTest"; testLang += lang; @@ -395,26 +395,26 @@ else { // load backwards compatibility stuff for C and CXX - // for old versions of CMake ListFiles C and CXX had some - // backwards compatibility files they have to load + // for old versions of CMake ListFiles C and CXX had some + // backwards compatibility files they have to load // These files have a bunch of try compiles in them so // should only be done - const char* versionValue - = mf->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY"); - if (atof(versionValue) <= 1.4) - { - if(strcmp(lang, "C") == 0) - { - ifpath = mf->GetModulesFile("CMakeBackwardCompatibilityC.cmake"); - mf->ReadListFile(0,ifpath.c_str()); - } - if(strcmp(lang, "CXX") == 0) + const char* versionValue + = mf->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY"); + if (atof(versionValue) <= 1.4) { - ifpath = mf->GetModulesFile("CMakeBackwardCompatibilityCXX.cmake"); - mf->ReadListFile(0,ifpath.c_str()); + if(strcmp(lang, "C") == 0) + { + ifpath = mf->GetModulesFile("CMakeBackwardCompatibilityC.cmake"); + mf->ReadListFile(0,ifpath.c_str()); + } + if(strcmp(lang, "CXX") == 0) + { + ifpath = mf->GetModulesFile("CMakeBackwardCompatibilityCXX.cmake"); + mf->ReadListFile(0,ifpath.c_str()); + } } - } - } + } } // end if in try compile } // end need test language } // end for each language @@ -430,13 +430,6 @@ { mf->ReadListFile(0,projectCompatibility.c_str()); } - // next load the file pointed to by CMAKE_USER_MAKE_RULES_OVERRIDE - std::string userMakeRules = - mf->GetSafeDefinition("CMAKE_USER_MAKE_RULES_OVERRIDE"); - if(userMakeRules.size()) - { - mf->ReadListFile(0,userMakeRules.c_str()); - } } const char* cmGlobalGenerator::GetLanguageOutputExtensionForLanguage(const char* lang) @@ -445,9 +438,9 @@ { return ""; } - if(m_LanguageToOutputExtension.count(lang) > 0) + if(this->LanguageToOutputExtension.count(lang) > 0) { - return m_LanguageToOutputExtension[lang].c_str(); + return this->LanguageToOutputExtension[lang].c_str(); } return ""; } @@ -464,7 +457,7 @@ // if no language is found then check to see if it is already an // ouput extension for some language. In that case it should be ignored // and in this map, so it will not be compiled but will just be used. - if(m_OutputExtensions.count(ext)) + if(this->OutputExtensions.count(ext)) { return ext; } @@ -482,16 +475,16 @@ { ++ext; } - if(m_ExtensionToLanguage.count(ext) > 0) + if(this->ExtensionToLanguage.count(ext) > 0) { - return m_ExtensionToLanguage[ext].c_str(); + return this->ExtensionToLanguage[ext].c_str(); } return 0; } void cmGlobalGenerator::SetLanguageEnabled(const char* l, cmMakefile* mf) { - if(m_LanguageEnabled.count(l) > 0) + if(this->LanguageEnabled.count(l) > 0) { return; } @@ -500,11 +493,11 @@ const char* outputExtension = mf->GetDefinition(outputExtensionVar.c_str()); if(outputExtension) { - m_LanguageToOutputExtension[l] = outputExtension; - m_OutputExtensions[outputExtension] = outputExtension; + this->LanguageToOutputExtension[l] = outputExtension; + this->OutputExtensions[outputExtension] = outputExtension; if(outputExtension[0] == '.') { - m_OutputExtensions[outputExtension+1] = outputExtension+1; + this->OutputExtensions[outputExtension+1] = outputExtension+1; } } @@ -515,7 +508,7 @@ { linkerPref = "None"; } - m_LanguageToLinkerPreference[l] = linkerPref; + this->LanguageToLinkerPreference[l] = linkerPref; std::string extensionsVar = std::string("CMAKE_") + std::string(l) + std::string("_SOURCE_FILE_EXTENSIONS"); @@ -528,15 +521,15 @@ for(std::vector::iterator i = extensionList.begin(); i != extensionList.end(); ++i) { - m_ExtensionToLanguage[*i] = l; + this->ExtensionToLanguage[*i] = l; } cmSystemTools::ExpandListArgument(ignoreExts, extensionList); for(std::vector::iterator i = extensionList.begin(); i != extensionList.end(); ++i) { - m_IgnoreExtensions[*i] = true; + this->IgnoreExtensions[*i] = true; } - m_LanguageEnabled[l] = true; + this->LanguageEnabled[l] = true; } bool cmGlobalGenerator::IgnoreFile(const char* l) @@ -545,41 +538,41 @@ { return false; } - return (m_IgnoreExtensions.count(l) > 0); + return (this->IgnoreExtensions.count(l) > 0); } bool cmGlobalGenerator::GetLanguageEnabled(const char* l) { - return (m_LanguageEnabled.count(l) > 0); + return (this->LanguageEnabled.count(l) > 0); } void cmGlobalGenerator::ClearEnabledLanguages() { - m_LanguageEnabled.clear(); + this->LanguageEnabled.clear(); } void cmGlobalGenerator::Configure() { // Delete any existing cmLocalGenerators unsigned int i; - for (i = 0; i < m_LocalGenerators.size(); ++i) + for (i = 0; i < this->LocalGenerators.size(); ++i) { - delete m_LocalGenerators[i]; + delete this->LocalGenerators[i]; } - m_LocalGenerators.clear(); + this->LocalGenerators.clear(); // Setup relative path generation. this->ConfigureRelativePaths(); // start with this directory cmLocalGenerator *lg = this->CreateLocalGenerator(); - m_LocalGenerators.push_back(lg); + this->LocalGenerators.push_back(lg); // set the Start directories lg->GetMakefile()->SetStartDirectory - (m_CMakeInstance->GetStartDirectory()); + (this->CMakeInstance->GetStartDirectory()); lg->GetMakefile()->SetStartOutputDirectory - (m_CMakeInstance->GetStartOutputDirectory()); + (this->CMakeInstance->GetStartOutputDirectory()); lg->GetMakefile()->MakeStartDirectoriesCurrent(); // now do it @@ -588,7 +581,7 @@ // update the cache entry for the number of local generators, this is used // for progress char num[100]; - sprintf(num,"%d",static_cast(m_LocalGenerators.size())); + sprintf(num,"%d",static_cast(this->LocalGenerators.size())); this->GetCMakeInstance()->AddCacheEntry ("CMAKE_NUMBER_OF_LOCAL_GENERATORS", num, "number of local generators", cmCacheManager::INTERNAL); @@ -596,17 +589,17 @@ std::set notFoundMap; // after it is all done do a ConfigureFinalPass cmCacheManager* manager = 0; - for (i = 0; i < m_LocalGenerators.size(); ++i) + for (i = 0; i < this->LocalGenerators.size(); ++i) { - manager = m_LocalGenerators[i]->GetMakefile()->GetCacheManager(); - m_LocalGenerators[i]->ConfigureFinalPass(); + manager = this->LocalGenerators[i]->GetMakefile()->GetCacheManager(); + this->LocalGenerators[i]->ConfigureFinalPass(); cmTargets & targets = - m_LocalGenerators[i]->GetMakefile()->GetTargets(); + this->LocalGenerators[i]->GetMakefile()->GetTargets(); for (cmTargets::iterator l = targets.begin(); l != targets.end(); l++) { - cmTarget::LinkLibraries libs = l->second.GetLinkLibraries(); - for(cmTarget::LinkLibraries::iterator lib = libs.begin(); + cmTarget::LinkLibraryVectorType libs = l->second.GetLinkLibraries(); + for(cmTarget::LinkLibraryVectorType::iterator lib = libs.begin(); lib != libs.end(); ++lib) { if(lib->first.size() > 9 && @@ -617,7 +610,7 @@ } } std::vector& incs = - m_LocalGenerators[i]->GetMakefile()->GetIncludeDirectories(); + this->LocalGenerators[i]->GetMakefile()->GetIncludeDirectories(); for( std::vector::iterator lib = incs.begin(); lib != incs.end(); ++lib) @@ -629,9 +622,9 @@ notFoundMap.insert(varName); } } - m_CMakeInstance->UpdateProgress("Configuring", - 0.9f+0.1f*(i+1.0f)/m_LocalGenerators.size()); - m_LocalGenerators[i]->GetMakefile()->CheckInfiniteLoops(); + this->CMakeInstance->UpdateProgress("Configuring", + 0.9f+0.1f*(i+1.0f)/this->LocalGenerators.size()); + this->LocalGenerators[i]->GetMakefile()->CheckInfiniteLoops(); } } @@ -658,12 +651,12 @@ "Please set the following variables:\n", notFoundVars.c_str()); } - // at this point m_LocalGenerators has been filled, + // at this point this->LocalGenerators has been filled, // so create the map from project name to vector of local generators this->FillProjectMap(); - if ( !m_CMakeInstance->GetScriptMode() ) + if ( !this->CMakeInstance->GetScriptMode() ) { - m_CMakeInstance->UpdateProgress("Configuring done", -1); + this->CMakeInstance->UpdateProgress("Configuring done", -1); } } @@ -671,15 +664,39 @@ { // For each existing cmLocalGenerator unsigned int i; - for (i = 0; i < m_LocalGenerators.size(); ++i) + + // Consolidate global targets + cmTargets globalTargets; + this->CreateDefaultGlobalTargets(&globalTargets); + for (i = 0; i < this->LocalGenerators.size(); ++i) + { + cmTargets* targets = &(this->LocalGenerators[i]->GetMakefile()->GetTargets()); + cmTargets::iterator tarIt; + for ( tarIt = targets->begin(); tarIt != targets->end(); ++ tarIt ) + { + if ( tarIt->second.GetType() == cmTarget::GLOBAL_TARGET ) + { + globalTargets[tarIt->first] = tarIt->second; + } + } + } + + // Generate project files + for (i = 0; i < this->LocalGenerators.size(); ++i) { - m_LocalGenerators[i]->Generate(); - m_LocalGenerators[i]->GenerateInstallRules(); - m_LocalGenerators[i]->GenerateTestFiles(); - m_CMakeInstance->UpdateProgress("Generating", - (i+1.0f)/m_LocalGenerators.size()); + cmTargets* targets = &(this->LocalGenerators[i]->GetMakefile()->GetTargets()); + cmTargets::iterator tit; + for ( tit = globalTargets.begin(); tit != globalTargets.end(); ++ tit ) + { + (*targets)[tit->first] = tit->second; + } + this->LocalGenerators[i]->Generate(); + this->LocalGenerators[i]->GenerateInstallRules(); + this->LocalGenerators[i]->GenerateTestFiles(); + this->CMakeInstance->UpdateProgress("Generating", + (i+1.0f)/this->LocalGenerators.size()); } - m_CMakeInstance->UpdateProgress("Generating done", -1); + this->CMakeInstance->UpdateProgress("Generating done", -1); } int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir, @@ -688,7 +705,7 @@ std::string *output, cmMakefile *mf) { std::string makeCommand = - m_CMakeInstance->GetCacheManager()->GetCacheValue("CMAKE_MAKE_PROGRAM"); + this->CMakeInstance->GetCacheManager()->GetCacheValue("CMAKE_MAKE_PROGRAM"); if(makeCommand.size() == 0) { cmSystemTools::Error( @@ -719,8 +736,8 @@ } std::string cmGlobalGenerator::GenerateBuildCommand(const char* makeProgram, - const char *projectName, const char *targetName, const char* config, - bool ignoreErrors) + const char *projectName, const char* additionalOptions, const char *targetName, + const char* config, bool ignoreErrors) { // Project name and config are not used yet. (void)projectName; @@ -738,6 +755,11 @@ { makeCommand += " -i"; } + if ( additionalOptions ) + { + makeCommand += " "; + makeCommand += additionalOptions; + } if ( targetName ) { makeCommand += " "; @@ -770,7 +792,8 @@ // should we do a clean first? if (clean) { - std::string cleanCommand = this->GenerateBuildCommand(makeCommandCSTR, projectName, "clean", config, false); + std::string cleanCommand = this->GenerateBuildCommand(makeCommandCSTR, projectName, + 0, "clean", config, false); if (!cmSystemTools::RunSingleCommand(cleanCommand.c_str(), output, &retVal, 0, false, timeout)) { @@ -788,7 +811,8 @@ } // now build - std::string makeCommand = this->GenerateBuildCommand(makeCommandCSTR, projectName, target, config, false); + std::string makeCommand = this->GenerateBuildCommand(makeCommandCSTR, projectName, + 0, target, config, false); if (!cmSystemTools::RunSingleCommand(makeCommand.c_str(), output, &retVal, 0, false, timeout)) @@ -823,12 +847,12 @@ void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg) { - m_LocalGenerators.push_back(lg); + this->LocalGenerators.push_back(lg); // update progress // estimate how many lg there will be const char *numGenC = - m_CMakeInstance->GetCacheManager()->GetCacheValue + this->CMakeInstance->GetCacheManager()->GetCacheValue ("CMAKE_NUMBER_OF_LOCAL_GENERATORS"); if (!numGenC) @@ -837,12 +861,12 @@ } int numGen = atoi(numGenC); - float prog = 0.9f*m_LocalGenerators.size()/numGen; + float prog = 0.9f*this->LocalGenerators.size()/numGen; if (prog > 0.9f) { prog = 0.9f; } - m_CMakeInstance->UpdateProgress("Configuring", prog); + this->CMakeInstance->UpdateProgress("Configuring", prog); } cmLocalGenerator *cmGlobalGenerator::CreateLocalGenerator() @@ -863,12 +887,12 @@ "make program", cmCacheManager::FILEPATH); // copy the enabled languages - this->m_LanguageEnabled = gen->m_LanguageEnabled; - this->m_ExtensionToLanguage = gen->m_ExtensionToLanguage; - this->m_IgnoreExtensions = gen->m_IgnoreExtensions; - this->m_LanguageToOutputExtension = gen->m_LanguageToOutputExtension; - this->m_LanguageToLinkerPreference = gen->m_LanguageToLinkerPreference; - this->m_OutputExtensions = gen->m_OutputExtensions; + this->LanguageEnabled = gen->LanguageEnabled; + this->ExtensionToLanguage = gen->ExtensionToLanguage; + this->IgnoreExtensions = gen->IgnoreExtensions; + this->LanguageToOutputExtension = gen->LanguageToOutputExtension; + this->LanguageToLinkerPreference = gen->LanguageToLinkerPreference; + this->OutputExtensions = gen->OutputExtensions; } //---------------------------------------------------------------------------- @@ -897,8 +921,8 @@ void cmGlobalGenerator::GetEnabledLanguages(std::vector& lang) { - for(std::map::iterator i = m_LanguageEnabled.begin(); - i != m_LanguageEnabled.end(); ++i) + for(std::map::iterator i = this->LanguageEnabled.begin(); + i != this->LanguageEnabled.end(); ++i) { lang.push_back(i->first); } @@ -906,9 +930,9 @@ const char* cmGlobalGenerator::GetLinkerPreference(const char* lang) { - if(m_LanguageToLinkerPreference.count(lang)) + if(this->LanguageToLinkerPreference.count(lang)) { - return m_LanguageToLinkerPreference[lang].c_str(); + return this->LanguageToLinkerPreference[lang].c_str(); } return "None"; } @@ -916,19 +940,19 @@ void cmGlobalGenerator::FillProjectMap() { - m_ProjectMap.clear(); // make sure we start with a clean map + this->ProjectMap.clear(); // make sure we start with a clean map unsigned int i; - for(i = 0; i < m_LocalGenerators.size(); ++i) + for(i = 0; i < this->LocalGenerators.size(); ++i) { // for each local generator add all projects - cmLocalGenerator *lg = m_LocalGenerators[i]; + cmLocalGenerator *lg = this->LocalGenerators[i]; std::string name; do { if (name != lg->GetMakefile()->GetProjectName()) { name = lg->GetMakefile()->GetProjectName(); - m_ProjectMap[name].push_back(m_LocalGenerators[i]); + this->ProjectMap[name].push_back(this->LocalGenerators[i]); } lg = lg->GetParent(); } @@ -940,7 +964,7 @@ ///! Find a local generator by its startdirectory cmLocalGenerator* cmGlobalGenerator::FindLocalGenerator(const char* start_dir) { - std::vector* gens = &m_LocalGenerators; + std::vector* gens = &this->LocalGenerators; for(unsigned int i = 0; i < gens->size(); ++i) { std::string sd = (*gens)[i]->GetMakefile()->GetStartDirectory(); @@ -956,10 +980,10 @@ cmTarget* cmGlobalGenerator::FindTarget(const char* project, const char* name) { - std::vector* gens = &m_LocalGenerators; + std::vector* gens = &this->LocalGenerators; if(project) { - gens = &m_ProjectMap[project]; + gens = &this->ProjectMap[project]; } for(unsigned int i = 0; i < gens->size(); ++i) { @@ -978,17 +1002,17 @@ // The current working directory on Windows cannot be a network // path. Therefore relative paths cannot work when the build tree // is a network path. - std::string source = m_CMakeInstance->GetHomeDirectory(); - std::string binary = m_CMakeInstance->GetHomeOutputDirectory(); + std::string source = this->CMakeInstance->GetHomeDirectory(); + std::string binary = this->CMakeInstance->GetHomeOutputDirectory(); if(binary.size() < 2 || binary.substr(0, 2) != "//") { - m_RelativePathTopSource = source; - m_RelativePathTopBinary = binary; + this->RelativePathTopSource = source; + this->RelativePathTopBinary = binary; } else { - m_RelativePathTopSource = ""; - m_RelativePathTopBinary = ""; + this->RelativePathTopSource = ""; + this->RelativePathTopBinary = ""; } } @@ -1011,14 +1035,14 @@ // Skip conversion if the path is not in the source or binary tree. std::string original = in_remote; - if((original.size() < m_RelativePathTopSource.size() || + if((original.size() < this->RelativePathTopSource.size() || !cmSystemTools::ComparePath( - original.substr(0, m_RelativePathTopSource.size()).c_str(), - m_RelativePathTopSource.c_str())) && - (original.size() < m_RelativePathTopBinary.size() || + original.substr(0, this->RelativePathTopSource.size()).c_str(), + this->RelativePathTopSource.c_str())) && + (original.size() < this->RelativePathTopBinary.size() || !cmSystemTools::ComparePath( - original.substr(0, m_RelativePathTopBinary.size()).c_str(), - m_RelativePathTopBinary.c_str()))) + original.substr(0, this->RelativePathTopBinary.size()).c_str(), + this->RelativePathTopBinary.c_str()))) { return in_remote; } @@ -1105,7 +1129,7 @@ void cmGlobalGenerator::SetupTests() { std::string ctest = - m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND"); + this->LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND"); ctest = removeQuotes(ctest); ctest = cmSystemTools::GetFilenamePath(ctest.c_str()); ctest += "/"; @@ -1114,7 +1138,7 @@ if(!cmSystemTools::FileExists(ctest.c_str())) { ctest = - m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND"); + this->LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND"); ctest = cmSystemTools::GetFilenamePath(ctest.c_str()); ctest += "/Debug/"; ctest += "ctest"; @@ -1123,7 +1147,7 @@ if(!cmSystemTools::FileExists(ctest.c_str())) { ctest = - m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND"); + this->LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND"); ctest = cmSystemTools::GetFilenamePath(ctest.c_str()); ctest += "/Release/"; ctest += "ctest"; @@ -1134,9 +1158,9 @@ { // Create a full path filename for output Testfile std::string fname; - fname = m_CMakeInstance->GetStartOutputDirectory(); + fname = this->CMakeInstance->GetStartOutputDirectory(); fname += "/"; - if ( m_LocalGenerators[0]->GetMakefile()->IsSet("CTEST_NEW_FORMAT") ) + if ( this->LocalGenerators[0]->GetMakefile()->IsSet("CTEST_NEW_FORMAT") ) { fname += "CTestTestfile.txt"; } @@ -1148,18 +1172,19 @@ // Add run_test only if any tests are foun long total_tests = 0; unsigned int i; - for (i = 0; i < m_LocalGenerators.size(); ++i) + for (i = 0; i < this->LocalGenerators.size(); ++i) { - total_tests += m_LocalGenerators[i]->GetMakefile()->GetTests()->size(); + total_tests += this->LocalGenerators[i]->GetMakefile()->GetTests()->size(); } // If the file doesn't exist, then ENABLE_TESTING hasn't been run if (total_tests > 0) { const char* no_output = 0; + const char* no_working_dir = 0; std::vector no_depends; std::map >::iterator it; - for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it) + for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) { std::vector& gen = it->second; // add the RUN_TESTS to the first local generator of each project @@ -1169,10 +1194,196 @@ if(const char* outDir = mf->GetDefinition("CMAKE_CFG_INTDIR")) { mf->AddUtilityCommand("RUN_TESTS", false, no_output, no_depends, - ctest.c_str(), "-C", outDir); + no_working_dir, + ctest.c_str(), "-C", outDir); } } } } } } + +void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) +{ + cmMakefile* mf = this->LocalGenerators[0]->GetMakefile(); + const char* cmakeCfgIntDir = this->GetCMakeCFGInitDirectory(); + const char* cmakeCommand = mf->GetRequiredDefinition("CMAKE_COMMAND"); + + // CPack + cmCustomCommandLines cpackCommandLines; + std::vector depends; + cmCustomCommandLine singleLine; + cpackCommandLines.erase(cpackCommandLines.begin(), cpackCommandLines.end()); + singleLine.erase(singleLine.begin(), singleLine.end()); + depends.erase(depends.begin(), depends.end()); + singleLine.push_back(this->GetCMakeInstance()->GetCPackCommand()); + if ( cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.' ) + { + singleLine.push_back("-C"); + singleLine.push_back(mf->GetDefinition("CMAKE_CFG_INTDIR")); + } + singleLine.push_back("--config"); + std::string configFile = mf->GetStartOutputDirectory();; + configFile += "/CPackConfig.cmake"; + singleLine.push_back(configFile); + cpackCommandLines.push_back(singleLine); + if ( this->GetPreinstallTargetName() ) + { + depends.push_back("preinstall"); + } + (*targets)[this->GetPackageTargetName()] + = this->CreateGlobalTarget(this->GetPackageTargetName(), + "Run CPack packaging tool...", &cpackCommandLines, depends); + + // Test + if(mf->IsOn("CMAKE_TESTING_ENABLED")) + { + cpackCommandLines.erase(cpackCommandLines.begin(), cpackCommandLines.end()); + singleLine.erase(singleLine.begin(), singleLine.end()); + depends.erase(depends.begin(), depends.end()); + singleLine.push_back(this->GetCMakeInstance()->GetCTestCommand()); + singleLine.push_back("--force-new-ctest-process"); + cpackCommandLines.push_back(singleLine); + (*targets)[this->GetTestTargetName()] + = this->CreateGlobalTarget(this->GetTestTargetName(), + "Running tests...", &cpackCommandLines, depends); + } + + //Edit Cache + const char* editCacheTargetName = this->GetEditCacheTargetName(); + if ( editCacheTargetName ) + { + cpackCommandLines.erase(cpackCommandLines.begin(), cpackCommandLines.end()); + singleLine.erase(singleLine.begin(), singleLine.end()); + depends.erase(depends.begin(), depends.end()); + + // Use CMAKE_EDIT_COMMAND for the edit_cache rule if it is defined. + // Otherwise default to the interactive command-line interface. + if(mf->GetDefinition("CMAKE_EDIT_COMMAND")) + { + singleLine.push_back(mf->GetDefinition("CMAKE_EDIT_COMMAND")); + singleLine.push_back("-H$(CMAKE_SOURCE_DIR)"); + singleLine.push_back("-B$(CMAKE_BINARY_DIR)"); + cpackCommandLines.push_back(singleLine); + (*targets)[editCacheTargetName] = + this->CreateGlobalTarget( + editCacheTargetName, "Running CMake cache editor...", + &cpackCommandLines, depends); + } + else + { + singleLine.push_back(cmakeCommand); + singleLine.push_back("-H$(CMAKE_SOURCE_DIR)"); + singleLine.push_back("-B$(CMAKE_BINARY_DIR)"); + singleLine.push_back("-i"); + cpackCommandLines.push_back(singleLine); + (*targets)[editCacheTargetName] = + this->CreateGlobalTarget( + editCacheTargetName, "Running interactive CMake command-line interface...", + &cpackCommandLines, depends); + } + } + + //Rebuild Cache + const char* rebuildCacheTargetName = this->GetRebuildCacheTargetName(); + if ( rebuildCacheTargetName ) + { + cpackCommandLines.erase(cpackCommandLines.begin(), cpackCommandLines.end()); + singleLine.erase(singleLine.begin(), singleLine.end()); + depends.erase(depends.begin(), depends.end()); + singleLine.push_back(cmakeCommand); + singleLine.push_back("-H$(CMAKE_SOURCE_DIR)"); + singleLine.push_back("-B$(CMAKE_BINARY_DIR)"); + cpackCommandLines.push_back(singleLine); + (*targets)[rebuildCacheTargetName] = + this->CreateGlobalTarget( + rebuildCacheTargetName, "Running CMake to regenerate build system...", + &cpackCommandLines, depends); + } + + //Install + std::string cmd; + cpackCommandLines.erase(cpackCommandLines.begin(), cpackCommandLines.end()); + singleLine.erase(singleLine.begin(), singleLine.end()); + depends.erase(depends.begin(), depends.end()); + if ( this->GetPreinstallTargetName() ) + { + depends.push_back(this->GetPreinstallTargetName()); + } + else + { + const char* noall = + mf->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY"); + if(!noall || cmSystemTools::IsOff(noall)) + { + depends.push_back(this->GetAllTargetName()); + } + } + if(mf->GetDefinition("CMake_BINARY_DIR")) + { + // We are building CMake itself. We cannot use the original + // executable to install over itself. + cmd = mf->GetDefinition("EXECUTABLE_OUTPUT_PATH"); + if(cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.') + { + cmd += "/"; + cmd += cmakeCfgIntDir; + } + cmd += "/cmake"; + } + else + { + cmd = cmakeCommand; + } + singleLine.push_back(cmd.c_str()); + if ( cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.' ) + { + std::string cfgArg = "-DBUILD_TYPE="; + cfgArg += mf->GetDefinition("CMAKE_CFG_INTDIR"); + singleLine.push_back(cfgArg); + } + singleLine.push_back("-P"); + singleLine.push_back("cmake_install.cmake"); + cpackCommandLines.push_back(singleLine); + (*targets)[this->GetInstallTargetName()] = + this->CreateGlobalTarget( + this->GetInstallTargetName(), "Install the project...", + &cpackCommandLines, depends); +} + +cmTarget cmGlobalGenerator::CreateGlobalTarget( + const char* name, const char* message, + const cmCustomCommandLines* commandLines, + std::vector depends, + bool depends_on_all /* = false */) +{ + // Package + cmTarget target; + target.SetType(cmTarget::GLOBAL_TARGET, name); + target.SetInAll(false); + + std::vector fileDepends; + // Store the custom command in the target. + cmCustomCommand cc(0, fileDepends, *commandLines, 0, 0); + target.GetPostBuildCommands().push_back(cc); + target.SetProperty("EchoString", message); + if ( depends_on_all ) + { + target.AddUtility("all"); + } + std::vector::iterator dit; + for ( dit = depends.begin(); dit != depends.end(); ++ dit ) + { + target.AddUtility(dit->c_str()); + } + return target; +} + +//---------------------------------------------------------------------------- +void cmGlobalGenerator::AppendDirectoryForConfig(const char*, const char*, + const char*, std::string&) +{ + // Subclasses that support multiple configurations should implement + // this method to append the subdirectory for the given build + // configuration. +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalGenerator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalGenerator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalGenerator.h 2005-09-16 04:38:36.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalGenerator.h 2006-03-16 23:53:14.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalGenerator.h,v $ Language: C++ - Date: $Date: 2005/09/15 20:38:36 $ - Version: $Revision: 1.37.2.1 $ + Date: $Date: 2006/03/16 15:53:14 $ + Version: $Revision: 1.50 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -20,6 +20,8 @@ #include "cmStandardIncludes.h" +#include "cmTarget.h" // For cmTargets + class cmake; class cmMakefile; class cmLocalGenerator; @@ -71,7 +73,8 @@ * Try to determine system infomation such as shared library * extension, pthreads, byte order etc. */ - virtual void EnableLanguage(std::vectorconst& languages, cmMakefile *); + virtual void EnableLanguage(std::vectorconst& languages, + cmMakefile *); /** * Try to determine system infomation, get it from another generator @@ -98,25 +101,30 @@ std::string *output, const char *makeProgram, const char *config, bool clean); - virtual std::string GenerateBuildCommand(const char* makeProgram, - const char *projectName, const char *targetName, - const char* config, bool ignoreErrors); + virtual std::string GenerateBuildCommand + (const char* makeProgram, + const char *projectName, const char* additionalOptions, + const char *targetName, + const char* config, bool ignoreErrors); + ///! Set the CMake instance - void SetCMakeInstance(cmake *cm) { - this->m_CMakeInstance = cm; }; + void SetCMakeInstance(cmake *cm) { this->CMakeInstance = cm; }; ///! Get the CMake instance - cmake *GetCMakeInstance() { - return this->m_CMakeInstance; }; + cmake *GetCMakeInstance() { return this->CMakeInstance; }; + + void SetConfiguredFilesPath(const char* s){this->ConfiguredFilesPath = s;} + cmLocalGenerator* GetLocalGenerator(int p) { + return this->LocalGenerators[p];} + void GetLocalGenerators(std::vector&g) { + g = this->LocalGenerators;} - void SetConfiguredFilesPath(const char* s){m_ConfiguredFilesPath = s;} - void GetLocalGenerators(std::vector&g) { g = m_LocalGenerators;} void AddLocalGenerator(cmLocalGenerator *lg); static int s_TryCompileTimeout; - bool GetForceUnixPaths() {return m_ForceUnixPaths;} + bool GetForceUnixPaths() {return this->ForceUnixPaths;} ///! return the language for the given extension const char* GetLanguageFromExtension(const char* ext); ///! is an extension to be ignored @@ -128,6 +136,9 @@ ///! What is the output extension for a given source file extension. const char* GetLanguageOutputExtensionFromExtension(const char* lang); + ///! What is the configurations directory variable called? + virtual const char* GetCMakeCFGInitDirectory() { return "."; } + /** * Convert the given remote path to a relative path with respect to * the given local path. The local path must be given in component @@ -149,39 +160,61 @@ ///! Find a local generator by its startdirectory cmLocalGenerator* FindLocalGenerator(const char* start_dir); + /** Append the subdirectory for the given configuration. If anything is + appended the given prefix and suffix will be appended around it, which + is useful for leading or trailing slashes. */ + virtual void AppendDirectoryForConfig(const char* prefix, + const char* config, + const char* suffix, + std::string& dir); + protected: - // Fill the m_ProjectMap, this must be called after m_LocalGenerators has been populated. + // Fill the ProjectMap, this must be called after LocalGenerators + // has been populated. void FillProjectMap(); bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen); void ConfigureRelativePaths(); void SetupTests(); - - bool m_ForceUnixPaths; - cmStdString m_FindMakeProgramFile; - cmStdString m_ConfiguredFilesPath; - cmake *m_CMakeInstance; - std::vector m_LocalGenerators; + + void CreateDefaultGlobalTargets(cmTargets* targets); + cmTarget CreateGlobalTarget(const char* name, const char* message, + const cmCustomCommandLines* commandLines, + std::vector depends, bool depends_on_all = false); + + virtual const char* GetAllTargetName() { return "ALL_BUILD"; } + virtual const char* GetInstallTargetName() { return "INSTALL"; } + virtual const char* GetPreinstallTargetName() { return 0; } + virtual const char* GetTestTargetName() { return "RUN_TESTS"; } + virtual const char* GetPackageTargetName() { return "PACKAGE"; } + virtual const char* GetEditCacheTargetName() { return 0; } + virtual const char* GetRebuildCacheTargetName() { return 0; } + + bool ForceUnixPaths; + cmStdString FindMakeProgramFile; + cmStdString ConfiguredFilesPath; + cmake *CMakeInstance; + std::vector LocalGenerators; // map from project name to vector of local generators in that project - std::map > m_ProjectMap; + std::map > ProjectMap; private: // If you add a new map here, make sure it is copied // in EnableLanguagesFromGenerator - std::map m_IgnoreExtensions; - std::map m_LanguageEnabled; - std::map m_OutputExtensions; - std::map m_LanguageToOutputExtension; - std::map m_ExtensionToLanguage; - std::map m_LanguageToLinkerPreference; + std::map IgnoreExtensions; + std::map LanguageEnabled; + std::map OutputExtensions; + std::map LanguageToOutputExtension; + std::map ExtensionToLanguage; + std::map LanguageToLinkerPreference; // The paths to the tops of the source and binary trees used for // relative path computation. A path must be either in the source // tree or the build tree to be converted to a relative path. The // ConfigureRelativePaths method may set these to be empty when // using relative paths is unsafe. - std::string m_RelativePathTopSource; - std::string m_RelativePathTopBinary; + std::string RelativePathTopSource; + std::string RelativePathTopBinary; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalKdevelopGenerator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalKdevelopGenerator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalKdevelopGenerator.cxx 2005-06-22 21:06:45.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalKdevelopGenerator.cxx 2006-03-16 00:02:03.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalKdevelopGenerator.cxx,v $ Language: C++ - Date: $Date: 2005/06/22 13:06:45 $ - Version: $Revision: 1.7 $ + Date: $Date: 2006/03/15 16:02:03 $ + Version: $Revision: 1.9 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2004 Alexander Neundorf, neundorf@kde.org. All rights reserved. @@ -26,8 +26,8 @@ cmGlobalKdevelopGenerator::cmGlobalKdevelopGenerator() { // This type of makefile always requires unix style paths - m_ForceUnixPaths = true; - m_FindMakeProgramFile = "CMakeUnixFindMake.cmake"; + this->ForceUnixPaths = true; + this->FindMakeProgramFile = "CMakeUnixFindMake.cmake"; } ///! Create a local generator appropriate to this Global Generator @@ -59,17 +59,18 @@ // for each sub project in the project create // a kdevelop project std::map >::iterator it; - for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it) + for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) { cmMakefile* mf = it->second[0]->GetMakefile(); std::string outputDir=mf->GetStartOutputDirectory(); std::string projectDir=mf->GetHomeDirectory(); std::string projectName=mf->GetProjectName(); std::string cmakeFilePattern("CMakeLists.txt;*.cmake;"); + std::string fileToOpen; // create the project.kdevelop.filelist file if(!this->CreateFilelistFile(it->second[0], it->second, outputDir, projectDir, - projectName, cmakeFilePattern)) + projectName, cmakeFilePattern, fileToOpen)) { cmSystemTools::Error("Can not create filelist file"); return; @@ -83,13 +84,13 @@ { if (ti->second.GetType()==cmTarget::EXECUTABLE) { - executable=ti->first; + executable = ti->second.GetProperty("LOCATION"); break; } } // now create a project file this->CreateProjectFile(outputDir, projectDir, projectName, - executable, cmakeFilePattern); + executable, cmakeFilePattern, fileToOpen); } } @@ -99,7 +100,8 @@ const std::string& outputDir, const std::string& projectDirIn, const std::string& projectname, - std::string& cmakeFilePattern) + std::string& cmakeFilePattern, + std::string& fileToOpen) { std::string projectDir = projectDirIn + "/"; std::string filename = outputDir+ "/" + projectname +".kdevelop.filelist"; @@ -188,11 +190,21 @@ return false; } + fileToOpen=""; for (std::set::const_iterator it=files.begin(); it!=files.end(); it++) { // get the full path to the file tmp=cmSystemTools::CollapseFullPath(it->c_str(), projectDir.c_str()); + // just select the first source file + if (fileToOpen.empty()) + { + std::string ext = cmSystemTools::GetFilenameExtension(tmp); + if ((ext==".c") || (ext==".cc") || (ext==".cpp") || (ext==".C") || (ext==".h")) + { + fileToOpen=tmp; + } + } // make it relative to the project dir cmSystemTools::ReplaceString(tmp, projectDir.c_str(), ""); // only put relative paths @@ -212,20 +224,24 @@ const std::string& projectDir, const std::string& projectname, const std::string& executable, - const std::string& cmakeFilePattern) + const std::string& cmakeFilePattern, + const std::string& fileToOpen) { std::string filename=outputDir+"/"; filename+=projectname+".kdevelop"; + std::string sessionFilename=outputDir+"/"; + sessionFilename+=projectname+".kdevses"; if (cmSystemTools::FileExists(filename.c_str())) { this->MergeProjectFiles(outputDir, projectDir, filename, - executable, cmakeFilePattern); + executable, cmakeFilePattern, fileToOpen, sessionFilename); } else { + this->CreateNewProjectFile(outputDir, projectDir, filename, - executable, cmakeFilePattern); + executable, cmakeFilePattern, fileToOpen, sessionFilename); } } @@ -235,12 +251,14 @@ const std::string& projectDir, const std::string& filename, const std::string& executable, - const std::string& cmakeFilePattern) + const std::string& cmakeFilePattern, + const std::string& fileToOpen, + const std::string& sessionFilename) { std::ifstream oldProjectFile(filename.c_str()); if (!oldProjectFile) { - this->CreateNewProjectFile(outputDir, projectDir, filename, executable, cmakeFilePattern); + this->CreateNewProjectFile(outputDir, projectDir, filename, executable, cmakeFilePattern, fileToOpen, sessionFilename); return; } @@ -305,7 +323,9 @@ const std::string& projectDir, const std::string& filename, const std::string& executable, - const std::string& cmakeFilePattern) + const std::string& cmakeFilePattern, + const std::string& fileToOpen, + const std::string& sessionFilename) { cmGeneratedFileStream fout(filename.c_str()); if(!fout) @@ -331,7 +351,7 @@ fout<<" \n"; fout<<" "<\n"; fout<<" \n"; - fout<<" "<\n"; + fout<<" "<\n"; fout<<" custom\n"; fout<<" /\n"; fout<<" \n"; @@ -409,5 +429,23 @@ fout<<" \n"; fout<<"\n"; + if (sessionFilename.empty()) + return; + + // and a session file, so that kdevelop opens a file if it opens the project the first time + cmGeneratedFileStream devses(sessionFilename.c_str()); + if(!devses) + { + return; + } + devses<<"\n"; + devses<<"\n"; + devses<<"\n"; + devses<<" \n"; + devses<<" \n"; + devses<<" \n"; + devses<<" \n"; + devses<<" \n"; + devses<<"\n"; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalKdevelopGenerator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalKdevelopGenerator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalKdevelopGenerator.h 2005-06-09 23:39:12.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalKdevelopGenerator.h 2006-02-19 00:03:36.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalKdevelopGenerator.h,v $ Language: C++ - Date: $Date: 2005/06/09 15:39:12 $ - Version: $Revision: 1.3 $ + Date: $Date: 2006/02/18 16:03:36 $ + Version: $Revision: 1.4 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2004 Alexander Neundorf, neundorf@kde.org. All rights reserved. @@ -63,7 +63,8 @@ const std::string& outputDir, const std::string& projectDirIn, const std::string& projectname, - std::string& cmakeFilePattern); + std::string& cmakeFilePattern, + std::string& fileToOpen); /** Create the foo.kdevelop file. This one calls MergeProjectFiles() if it already exists, otherwise createNewProjectFile() The project @@ -75,7 +76,8 @@ const std::string& projectDir, const std::string& projectname, const std::string& executable, - const std::string& cmakeFilePattern); + const std::string& cmakeFilePattern, + const std::string& fileToOpen); /*** Reads the old foo.kdevelop line by line and only replaces the "important" lines @@ -84,13 +86,17 @@ const std::string& projectDir, const std::string& filename, const std::string& executable, - const std::string& cmakeFilePattern); - ///! Creates a new foo.kdevelop file + const std::string& cmakeFilePattern, + const std::string& fileToOpen, + const std::string& sessionFilename); + ///! Creates a new foo.kdevelop and a new foo.kdevses file void CreateNewProjectFile(const std::string& outputDir, const std::string& projectDir, const std::string& filename, const std::string& executable, - const std::string& cmakeFilePattern); + const std::string& cmakeFilePattern, + const std::string& fileToOpen, + const std::string& sessionFilename); }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalMinGWMakefileGenerator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalMinGWMakefileGenerator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalMinGWMakefileGenerator.cxx 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalMinGWMakefileGenerator.cxx 2006-03-16 00:02:03.000000000 +0800 @@ -0,0 +1,73 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmGlobalMinGWMakefileGenerator.cxx,v $ + Language: C++ + Date: $Date: 2006/03/15 16:02:03 $ + Version: $Revision: 1.3 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "cmGlobalMinGWMakefileGenerator.h" +#include "cmLocalUnixMakefileGenerator3.h" +#include "cmMakefile.h" + +cmGlobalMinGWMakefileGenerator::cmGlobalMinGWMakefileGenerator() +{ + this->FindMakeProgramFile = "CMakeMinGWFindMake.cmake"; + this->ForceUnixPaths = true; + +} + +void cmGlobalMinGWMakefileGenerator::EnableLanguage(std::vectorconst& l, + cmMakefile *mf) +{ + this->FindMakeProgram(mf); + std::string makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); + std::vector locations; + locations.push_back(cmSystemTools::GetProgramPath(makeProgram.c_str())); + locations.push_back("/mingw/bin"); + locations.push_back("c:/mingw/bin"); + std::string tgcc = cmSystemTools::FindProgram("gcc", locations); + std::string gcc = "gcc.exe"; + if(tgcc.size()) + { + gcc = tgcc; + } + std::string tgxx = cmSystemTools::FindProgram("g++", locations); + std::string gxx = "g++.exe"; + if(tgxx.size()) + { + gxx = tgxx; + } + mf->AddDefinition("CMAKE_GENERATOR_CC", gcc.c_str()); + mf->AddDefinition("CMAKE_GENERATOR_CXX", gxx.c_str()); + this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf); +} + +///! Create a local generator appropriate to this Global Generator +cmLocalGenerator *cmGlobalMinGWMakefileGenerator::CreateLocalGenerator() +{ + cmLocalUnixMakefileGenerator3* lg = new cmLocalUnixMakefileGenerator3; + lg->SetWindowsShell(true); + lg->SetGlobalGenerator(this); + lg->SetIgnoreLibPrefix(true); + lg->SetPassMakeflags(false); + lg->SetUnixCD(true); + return lg; +} + +//---------------------------------------------------------------------------- +void cmGlobalMinGWMakefileGenerator::GetDocumentation(cmDocumentationEntry& entry) const +{ + entry.name = this->GetName(); + entry.brief = "Generates a make file for use with mingw32-make."; + entry.full = "The makefiles generated use cmd.exe as the shell. " + "They do not require msys or a unix shell."; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalMinGWMakefileGenerator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalMinGWMakefileGenerator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalMinGWMakefileGenerator.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalMinGWMakefileGenerator.h 2006-03-11 02:54:57.000000000 +0800 @@ -0,0 +1,51 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmGlobalMinGWMakefileGenerator.h,v $ + Language: C++ + Date: $Date: 2006/03/10 18:54:57 $ + Version: $Revision: 1.2 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef cmGlobalMinGWMakefileGenerator_h +#define cmGlobalMinGWMakefileGenerator_h + +#include "cmGlobalUNIXMakefileGenerator3.h" + +/** \class cmGlobalMinGWMakefileGenerator + * \brief Write a NMake makefiles. + * + * cmGlobalMinGWMakefileGenerator manages nmake build process for a tree + */ +class cmGlobalMinGWMakefileGenerator : public cmGlobalUnixMakefileGenerator3 +{ +public: + cmGlobalMinGWMakefileGenerator(); + static cmGlobalGenerator* New() { return new cmGlobalMinGWMakefileGenerator; } + ///! Get the name for the generator. + virtual const char* GetName() const { + return cmGlobalMinGWMakefileGenerator::GetActualName();} + static const char* GetActualName() {return "MinGW Makefiles";} + + /** Get the documentation entry for this generator. */ + virtual void GetDocumentation(cmDocumentationEntry& entry) const; + + ///! Create a local generator appropriate to this Global Generator + virtual cmLocalGenerator *CreateLocalGenerator(); + + /** + * Try to determine system infomation such as shared library + * extension, pthreads, byte order etc. + */ + virtual void EnableLanguage(std::vectorconst& languages, + cmMakefile *); +}; + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalMSYSMakefileGenerator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalMSYSMakefileGenerator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalMSYSMakefileGenerator.cxx 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalMSYSMakefileGenerator.cxx 2006-03-16 00:02:03.000000000 +0800 @@ -0,0 +1,101 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmGlobalMSYSMakefileGenerator.cxx,v $ + Language: C++ + Date: $Date: 2006/03/15 16:02:03 $ + Version: $Revision: 1.6 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "cmGlobalMSYSMakefileGenerator.h" +#include "cmLocalUnixMakefileGenerator3.h" +#include "cmMakefile.h" +#include "cmake.h" + +cmGlobalMSYSMakefileGenerator::cmGlobalMSYSMakefileGenerator() +{ + this->FindMakeProgramFile = "CMakeMSYSFindMake.cmake"; + this->ForceUnixPaths = true; +} + +std::string +cmGlobalMSYSMakefileGenerator::FindMinGW(std::string const& makeloc) +{ + std::string fstab = makeloc; + fstab += "/../etc/fstab"; + std::ifstream fin(fstab.c_str()); + std::string path; + std::string mount; + std::string mingwBin; + while(fin) + { + fin >> path; + fin >> mount; + if(mount == "/mingw") + { + mingwBin = path; + mingwBin += "/bin"; + } + } + return mingwBin; +} + +void cmGlobalMSYSMakefileGenerator::EnableLanguage(std::vectorconst& l, + cmMakefile *mf) +{ + this->FindMakeProgram(mf); + std::string makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); + std::vector locations; + std::string makeloc = cmSystemTools::GetProgramPath(makeProgram.c_str()); + locations.push_back(this->FindMinGW(makeloc)); + locations.push_back(makeloc); + locations.push_back("/mingw/bin"); + locations.push_back("c:/mingw/bin"); + std::string tgcc = cmSystemTools::FindProgram("gcc", locations); + std::string gcc = "gcc.exe"; + if(tgcc.size()) + { + gcc = tgcc; + } + std::string tgxx = cmSystemTools::FindProgram("g++", locations); + std::string gxx = "g++.exe"; + if(tgxx.size()) + { + gxx = tgxx; + } + mf->AddDefinition("CMAKE_GENERATOR_CC", gcc.c_str()); + mf->AddDefinition("CMAKE_GENERATOR_CXX", gxx.c_str()); + this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf); + if(!mf->IsSet("CMAKE_AR") && !this->CMakeInstance->GetIsInTryCompile()) + { + cmSystemTools::Error("CMAKE_AR was not found, please set to archive program. ", + mf->GetDefinition("CMAKE_AR")); + } +} + +///! Create a local generator appropriate to this Global Generator +cmLocalGenerator *cmGlobalMSYSMakefileGenerator::CreateLocalGenerator() +{ + cmLocalUnixMakefileGenerator3* lg = new cmLocalUnixMakefileGenerator3; + lg->SetWindowsShell(false); + lg->SetGlobalGenerator(this); + lg->SetIgnoreLibPrefix(true); + lg->SetPassMakeflags(false); + lg->SetUnixCD(true); + return lg; +} + +//---------------------------------------------------------------------------- +void cmGlobalMSYSMakefileGenerator::GetDocumentation(cmDocumentationEntry& entry) const +{ + entry.name = this->GetName(); + entry.brief = "Generates MSYS makefiles."; + entry.full = "The makefiles use /bin/sh as the shell. They require msys to be installed on the machine."; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalMSYSMakefileGenerator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalMSYSMakefileGenerator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalMSYSMakefileGenerator.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalMSYSMakefileGenerator.h 2006-03-11 02:54:57.000000000 +0800 @@ -0,0 +1,54 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmGlobalMSYSMakefileGenerator.h,v $ + Language: C++ + Date: $Date: 2006/03/10 18:54:57 $ + Version: $Revision: 1.3 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef cmGlobalMSYSMakefileGenerator_h +#define cmGlobalMSYSMakefileGenerator_h + +#include "cmGlobalUNIXMakefileGenerator3.h" + +/** \class cmGlobalMSYSMakefileGenerator + * \brief Write a NMake makefiles. + * + * cmGlobalMSYSMakefileGenerator manages nmake build process for a tree + */ +class cmGlobalMSYSMakefileGenerator : public cmGlobalUnixMakefileGenerator3 +{ +public: + cmGlobalMSYSMakefileGenerator(); + static cmGlobalGenerator* New() { return new cmGlobalMSYSMakefileGenerator; } + ///! Get the name for the generator. + virtual const char* GetName() const { + return cmGlobalMSYSMakefileGenerator::GetActualName();} + static const char* GetActualName() {return "MSYS Makefiles";} + + /** Get the documentation entry for this generator. */ + virtual void GetDocumentation(cmDocumentationEntry& entry) const; + + ///! Create a local generator appropriate to this Global Generator + virtual cmLocalGenerator *CreateLocalGenerator(); + + /** + * Try to determine system infomation such as shared library + * extension, pthreads, byte order etc. + */ + virtual void EnableLanguage(std::vectorconst& languages, + cmMakefile *); + +private: + std::string FindMinGW(std::string const& makeloc); +}; + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalNMakeMakefileGenerator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalNMakeMakefileGenerator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalNMakeMakefileGenerator.cxx 2005-05-12 22:49:56.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalNMakeMakefileGenerator.cxx 2006-03-16 00:02:03.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalNMakeMakefileGenerator.cxx,v $ Language: C++ - Date: $Date: 2005/05/12 14:49:56 $ - Version: $Revision: 1.16 $ + Date: $Date: 2006/03/15 16:02:03 $ + Version: $Revision: 1.18 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -20,8 +20,8 @@ cmGlobalNMakeMakefileGenerator::cmGlobalNMakeMakefileGenerator() { - m_FindMakeProgramFile = "CMakeNMakeFindMake.cmake"; - m_ForceUnixPaths = false; + this->FindMakeProgramFile = "CMakeNMakeFindMake.cmake"; + this->ForceUnixPaths = false; } void cmGlobalNMakeMakefileGenerator::EnableLanguage(std::vectorconst& l, @@ -38,11 +38,13 @@ { cmLocalUnixMakefileGenerator3* lg = new cmLocalUnixMakefileGenerator3; lg->SetEchoNeedsQuote(false); + lg->SetDefineWindowsNULL(true); lg->SetWindowsShell(true); lg->SetMakeSilentFlag("/nologo"); lg->SetGlobalGenerator(this); lg->SetIgnoreLibPrefix(true); lg->SetPassMakeflags(true); + lg->SetUnixCD(false); return lg; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalNMakeMakefileGenerator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalNMakeMakefileGenerator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalNMakeMakefileGenerator.h 2005-05-12 22:49:56.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalNMakeMakefileGenerator.h 2006-03-11 02:54:57.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalNMakeMakefileGenerator.h,v $ Language: C++ - Date: $Date: 2005/05/12 14:49:56 $ - Version: $Revision: 1.9 $ + Date: $Date: 2006/03/10 18:54:57 $ + Version: $Revision: 1.10 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -44,7 +44,8 @@ * Try to determine system infomation such as shared library * extension, pthreads, byte order etc. */ - virtual void EnableLanguage(std::vectorconst& languages, cmMakefile *); + virtual void EnableLanguage(std::vectorconst& languages, + cmMakefile *); }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalUnixMakefileGenerator3.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalUnixMakefileGenerator3.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalUnixMakefileGenerator3.cxx 2005-10-25 03:43:52.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalUnixMakefileGenerator3.cxx 2006-03-16 00:02:03.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator3 Module: $RCSfile: cmGlobalUnixMakefileGenerator3.cxx,v $ Language: C++ - Date: $Date: 2005/10/24 19:43:52 $ - Version: $Revision: 1.33.2.4 $ + Date: $Date: 2006/03/15 16:02:03 $ + Version: $Revision: 1.53 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -24,14 +24,13 @@ cmGlobalUnixMakefileGenerator3::cmGlobalUnixMakefileGenerator3() { // This type of makefile always requires unix style paths - m_ForceUnixPaths = true; - m_FindMakeProgramFile = "CMakeUnixFindMake.cmake"; + this->ForceUnixPaths = true; + this->FindMakeProgramFile = "CMakeUnixFindMake.cmake"; } void cmGlobalUnixMakefileGenerator3 ::EnableLanguage(std::vectorconst& languages, cmMakefile *mf) { - mf->AddDefinition("CMAKE_CFG_INTDIR","."); this->cmGlobalGenerator::EnableLanguage(languages, mf); std::string path; for(std::vector::const_iterator l = languages.begin(); @@ -51,27 +50,31 @@ cmSystemTools::Error(langComp.c_str(), " not set, after EnableLanguage"); continue; } - const char* cc = mf->GetRequiredDefinition(langComp.c_str()); - path = cmSystemTools::FindProgram(cc); - if(path.size() == 0) + const char* name = mf->GetRequiredDefinition(langComp.c_str()); + if(!cmSystemTools::FileIsFullPath(name)) + { + path = cmSystemTools::FindProgram(name); + } + else + { + path = name; + } + if(path.size() == 0 || !cmSystemTools::FileExists(path.c_str())) { std::string message = "your "; message += lang; - message += " compiler: "; - if(cc) - { - message += cc; - } - else - { - message += "(NULL)"; - } - message += " was not found in your path. " - "For CMake to correctly use try compile commands, the compiler must " - "be in your path. Please add the compiler to your PATH environment," - " and re-run CMake."; - cmSystemTools::Error(message.c_str()); - } + message += " compiler: \""; + message += name; + message += "\" was not found. Please set "; + message += langComp; + message += " to a valid compiler path or name."; + cmSystemTools::Error(message.c_str()); + path = name; + } + std::string doc = lang; + doc += " compiler."; + mf->AddCacheDefinition(langComp.c_str(), path.c_str(), + doc.c_str(), cmCacheManager::FILEPATH); } } @@ -121,11 +124,11 @@ // get a local generator for some useful methods cmLocalUnixMakefileGenerator3 *lg = - static_cast(m_LocalGenerators[0]); + static_cast(this->LocalGenerators[0]); // Write the do not edit header. lg->WriteDisclaimer(makefileStream); - + // Write the main entry point target. This must be the VERY first // target so that make with no arguments will run it. // Just depend on the all target to drive the build. @@ -139,20 +142,37 @@ "given to make.", "default_target", depends, - no_commands); + no_commands, true); + + depends.clear(); + + // The all and preinstall rules might never have any dependencies + // added to them. + if(this->EmptyRuleHackDepends != "") + { + depends.push_back(this->EmptyRuleHackDepends); + } // Write and empty all: lg->WriteMakeRule(makefileStream, "The main recursive all target", "all", - no_commands, no_commands); + depends, no_commands, true); + + // Write an empty preinstall: + lg->WriteMakeRule(makefileStream, + "The main recursive preinstall target", "preinstall", + depends, no_commands, true); lg->WriteMakeVariables(makefileStream); + + // Write out the "special" stuff + lg->WriteSpecialTargetsTop(makefileStream); // write the target convenience rules unsigned int i; - for (i = 0; i < m_LocalGenerators.size(); ++i) + for (i = 0; i < this->LocalGenerators.size(); ++i) { - lg = static_cast(m_LocalGenerators[i]); + lg = static_cast(this->LocalGenerators[i]); // are any parents excluded bool exclude = false; cmLocalGenerator *lg3 = lg; @@ -168,7 +188,7 @@ this->WriteConvenienceRules2(makefileStream,lg,exclude); } - lg = static_cast(m_LocalGenerators[0]); + lg = static_cast(this->LocalGenerators[0]); lg->WriteSpecialTargetsBottom(makefileStream); } @@ -194,7 +214,7 @@ // get a local generator for some useful methods cmLocalUnixMakefileGenerator3 *lg = - static_cast(m_LocalGenerators[0]); + static_cast(this->LocalGenerators[0]); // Write the do not edit header. lg->WriteDisclaimer(cmakefileStream); @@ -206,9 +226,9 @@ // for each cmMakefile get its list of dependencies std::vector lfiles; - for (unsigned int i = 0; i < m_LocalGenerators.size(); ++i) + for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) { - lg = static_cast(m_LocalGenerators[i]); + lg = static_cast(this->LocalGenerators[i]); // Get the list of files contributing to this generation step. lfiles.insert(lfiles.end(),lg->GetMakefile()->GetListFiles().begin(), @@ -221,7 +241,7 @@ lfiles.erase(new_end, lfiles.end()); // reset lg to the first makefile - lg = static_cast(m_LocalGenerators[0]); + lg = static_cast(this->LocalGenerators[0]); // Build the path to the cache file. std::string cache = this->GetCMakeInstance()->GetHomeOutputDirectory(); @@ -259,9 +279,9 @@ // add in all the directory information files std::string tmpStr; - for (unsigned int i = 0; i < m_LocalGenerators.size(); ++i) + for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) { - lg = static_cast(m_LocalGenerators[i]); + lg = static_cast(this->LocalGenerators[i]); tmpStr = lg->GetMakefile()->GetStartOutputDirectory(); tmpStr += "/CMakeFiles/CMakeDirectoryInformation.cmake"; cmakefileStream << " \"" << @@ -269,7 +289,7 @@ } cmakefileStream << " )\n\n"; - this->WriteMainCMakefileLanguageRules(cmakefileStream, m_LocalGenerators); + this->WriteMainCMakefileLanguageRules(cmakefileStream, this->LocalGenerators); } void cmGlobalUnixMakefileGenerator3 @@ -305,267 +325,107 @@ cmakefileStream << " )\n"; } - //---------------------------------------------------------------------------- void cmGlobalUnixMakefileGenerator3 -::WriteDirectoryRules(std::ostream& ruleFileStream, - cmLocalUnixMakefileGenerator3 *lg) -{ - std::vector depends; - std::vector commands; - std::string localName; - std::string makeTargetName; +::WriteDirectoryRule2(std::ostream& ruleFileStream, + cmLocalUnixMakefileGenerator3* lg, + const char* pass, bool check_all, + bool check_relink) +{ + // Get the relative path to the subdirectory from the top. + std::string makeTarget = lg->GetMakefile()->GetStartOutputDirectory(); + makeTarget += "/"; + makeTarget += pass; + makeTarget = lg->Convert(makeTarget.c_str(), + cmLocalGenerator::HOME_OUTPUT, + cmLocalGenerator::MAKEFILE); - depends.push_back("cmake_check_build_system"); - if (lg->GetParent()) + // The directory-level rule should depend on the target-level rules + // for all targets in the directory. + std::vector depends; + for(cmTargets::iterator l = lg->GetMakefile()->GetTargets().begin(); + l != lg->GetMakefile()->GetTargets().end(); ++l) { - std::string dir = lg->GetMakefile()->GetStartOutputDirectory(); - dir = lg->Convert(dir.c_str(),cmLocalGenerator::HOME_OUTPUT,cmLocalGenerator::MAKEFILE); - - lg->WriteDivider(ruleFileStream); - ruleFileStream - << "# Directory level rules for directory " - << dir << "\n\n"; - - localName = dir; - localName += "/directorystart"; - makeTargetName = dir; - makeTargetName += "/directory"; - - std::vector all_tgts; - - // for all of out targets - for (cmTargets::iterator l = lg->GetMakefile()->GetTargets().begin(); - l != lg->GetMakefile()->GetTargets().end(); l++) - { - if((l->second.GetType() == cmTarget::EXECUTABLE) || - (l->second.GetType() == cmTarget::STATIC_LIBRARY) || - (l->second.GetType() == cmTarget::SHARED_LIBRARY) || - (l->second.GetType() == cmTarget::MODULE_LIBRARY) || - (l->second.GetType() == cmTarget::UTILITY)) + if((l->second.GetType() == cmTarget::EXECUTABLE) || + (l->second.GetType() == cmTarget::STATIC_LIBRARY) || + (l->second.GetType() == cmTarget::SHARED_LIBRARY) || + (l->second.GetType() == cmTarget::MODULE_LIBRARY) || + (l->second.GetType() == cmTarget::UTILITY)) + { + // Add this to the list of depends rules in this directory. + if((!check_all || l->second.IsInAll()) && + (!check_relink || l->second.NeedRelinkBeforeInstall())) { - // Add this to the list of depends rules in this directory. - if(l->second.IsInAll()) - { - std::string tname = lg->GetRelativeTargetDirectory(l->second); - tname += "/all"; - all_tgts.push_back(tname); - } - } - } - - // write the directory rule add in the subdirs - std::vector subdirs = lg->GetChildren(); - - // for each subdir add the directory depend - std::vector::iterator sdi = subdirs.begin(); - for (; sdi != subdirs.end(); ++sdi) - { - cmLocalUnixMakefileGenerator3 * lg2 = - static_cast(*sdi); - dir = lg2->GetMakefile()->GetStartOutputDirectory(); - dir += "/directory"; - dir = lg2->Convert(dir.c_str(),cmLocalGenerator::HOME_OUTPUT, - cmLocalGenerator::MAKEFILE); - all_tgts.push_back(dir); - } - - // write the directory rule - commands.clear(); - commands.push_back - (lg->GetRecursiveMakeCall("CMakeFiles/Makefile2", - makeTargetName.c_str())); - - // Write the rule. - lg->WriteMakeRule(ruleFileStream, "Convenience name for directory.", - localName.c_str(), depends, commands); - - // Write the rule. - commands.clear(); - lg->WriteMakeRule(ruleFileStream, "Convenience name for directory.", - makeTargetName.c_str(), all_tgts, commands); - } - - // now do the clean targets - if (lg->GetParent()) - { - std::string dir = lg->GetMakefile()->GetStartOutputDirectory(); - dir = lg->Convert(dir.c_str(),cmLocalGenerator::HOME_OUTPUT,cmLocalGenerator::MAKEFILE); - makeTargetName = dir; - makeTargetName += "/clean"; - - std::vector all_tgts; - - // for all of out targets - for (cmTargets::iterator l = lg->GetMakefile()->GetTargets().begin(); - l != lg->GetMakefile()->GetTargets().end(); l++) - { - if((l->second.GetType() == cmTarget::EXECUTABLE) || - (l->second.GetType() == cmTarget::STATIC_LIBRARY) || - (l->second.GetType() == cmTarget::SHARED_LIBRARY) || - (l->second.GetType() == cmTarget::MODULE_LIBRARY) || - (l->second.GetType() == cmTarget::UTILITY)) - { - // Add this to the list of depends rules in this directory. std::string tname = lg->GetRelativeTargetDirectory(l->second); - tname += "/clean"; - all_tgts.push_back(tname); + tname += "/"; + tname += pass; + depends.push_back(tname); } } - - // write the directory rule add in the subdirs - std::vector subdirs = lg->GetChildren(); - - // for each subdir add the directory depend - std::vector::iterator sdi = subdirs.begin(); - for (; sdi != subdirs.end(); ++sdi) - { - cmLocalUnixMakefileGenerator3 * lg2 = - static_cast(*sdi); - dir = lg2->GetMakefile()->GetStartOutputDirectory(); - dir += "/clean"; - dir = lg2->Convert(dir.c_str(),cmLocalGenerator::HOME_OUTPUT, - cmLocalGenerator::MAKEFILE); - all_tgts.push_back(dir); - } - - // write the directory clean rule - commands.clear(); - lg->WriteMakeRule(ruleFileStream, "Convenience name for directory clean.", - makeTargetName.c_str(), all_tgts, commands); } + + // The directory-level rule should depend on the directory-level + // rules of the subdirectories. + for(std::vector::iterator sdi = lg->GetChildren().begin(); + sdi != lg->GetChildren().end(); ++sdi) + { + cmLocalUnixMakefileGenerator3* slg = + static_cast(*sdi); + std::string subdir = slg->GetMakefile()->GetStartOutputDirectory(); + subdir += "/"; + subdir += pass; + subdir = slg->Convert(subdir.c_str(), + cmLocalGenerator::HOME_OUTPUT, + cmLocalGenerator::MAKEFILE); + depends.push_back(subdir); + } + + // Work-around for makes that drop rules that have no dependencies + // or commands. + if(depends.empty() && this->EmptyRuleHackDepends != "") + { + depends.push_back(this->EmptyRuleHackDepends); + } + + // Write the rule. + std::string doc = "Convenience name for \""; + doc += pass; + doc += "\" pass in the directory."; + std::vector no_commands; + lg->WriteMakeRule(ruleFileStream, doc.c_str(), + makeTarget.c_str(), depends, no_commands, true); } //---------------------------------------------------------------------------- void cmGlobalUnixMakefileGenerator3 -::WriteDirectoryRules2(std::ostream& ruleFileStream, - cmLocalUnixMakefileGenerator3 *lg) +::WriteDirectoryRules2(std::ostream& ruleFileStream, + cmLocalUnixMakefileGenerator3* lg) { - std::vector depends; - std::vector commands; - std::string localName; - std::string makeTargetName; - - depends.push_back("cmake_check_build_system"); - if (lg->GetParent()) + // Only subdirectories need these rules. + if(!lg->GetParent()) { - std::string dir = lg->GetMakefile()->GetStartOutputDirectory(); - dir = lg->Convert(dir.c_str(),cmLocalGenerator::HOME_OUTPUT,cmLocalGenerator::MAKEFILE); - - lg->WriteDivider(ruleFileStream); - ruleFileStream - << "# Directory level rules for directory " - << dir << "\n\n"; - - localName = dir; - localName += "/directorystart"; - makeTargetName = dir; - makeTargetName += "/directory"; - - std::vector all_tgts; - - // for all of out targets - for (cmTargets::iterator l = lg->GetMakefile()->GetTargets().begin(); - l != lg->GetMakefile()->GetTargets().end(); l++) - { - if((l->second.GetType() == cmTarget::EXECUTABLE) || - (l->second.GetType() == cmTarget::STATIC_LIBRARY) || - (l->second.GetType() == cmTarget::SHARED_LIBRARY) || - (l->second.GetType() == cmTarget::MODULE_LIBRARY) || - (l->second.GetType() == cmTarget::UTILITY)) - { - // Add this to the list of depends rules in this directory. - if(l->second.IsInAll()) - { - std::string tname = lg->GetRelativeTargetDirectory(l->second); - tname += "/all"; - all_tgts.push_back(tname); - } - } - } - - // write the directory rule add in the subdirs - std::vector subdirs = lg->GetChildren(); - - // for each subdir add the directory depend - std::vector::iterator sdi = subdirs.begin(); - for (; sdi != subdirs.end(); ++sdi) - { - cmLocalUnixMakefileGenerator3 * lg2 = - static_cast(*sdi); - dir = lg2->GetMakefile()->GetStartOutputDirectory(); - dir += "/directory"; - dir = lg2->Convert(dir.c_str(),cmLocalGenerator::HOME_OUTPUT, - cmLocalGenerator::MAKEFILE); - all_tgts.push_back(dir); - } - - // write the directory rule - commands.clear(); - commands.push_back - (lg->GetRecursiveMakeCall("CMakeFiles/Makefile2", - makeTargetName.c_str())); - - // Write the rule. - lg->WriteMakeRule(ruleFileStream, "Convenience name for directory.", - localName.c_str(), depends, commands); - - // Write the rule. - commands.clear(); - lg->WriteMakeRule(ruleFileStream, "Convenience name for directory.", - makeTargetName.c_str(), all_tgts, commands); - } - - // now do the clean targets - if (lg->GetParent()) - { - std::string dir = lg->GetMakefile()->GetStartOutputDirectory(); - dir = lg->Convert(dir.c_str(),cmLocalGenerator::HOME_OUTPUT,cmLocalGenerator::MAKEFILE); - makeTargetName = dir; - makeTargetName += "/clean"; - - std::vector all_tgts; - - // for all of out targets - for (cmTargets::iterator l = lg->GetMakefile()->GetTargets().begin(); - l != lg->GetMakefile()->GetTargets().end(); l++) - { - if((l->second.GetType() == cmTarget::EXECUTABLE) || - (l->second.GetType() == cmTarget::STATIC_LIBRARY) || - (l->second.GetType() == cmTarget::SHARED_LIBRARY) || - (l->second.GetType() == cmTarget::MODULE_LIBRARY) || - (l->second.GetType() == cmTarget::UTILITY)) - { - // Add this to the list of depends rules in this directory. - std::string tname = lg->GetRelativeTargetDirectory(l->second); - tname += "/clean"; - all_tgts.push_back(tname); - } - } - - // write the directory rule add in the subdirs - std::vector subdirs = lg->GetChildren(); - - // for each subdir add the directory depend - std::vector::iterator sdi = subdirs.begin(); - for (; sdi != subdirs.end(); ++sdi) - { - cmLocalUnixMakefileGenerator3 * lg2 = - static_cast(*sdi); - dir = lg2->GetMakefile()->GetStartOutputDirectory(); - dir += "/clean"; - dir = lg2->Convert(dir.c_str(),cmLocalGenerator::HOME_OUTPUT, - cmLocalGenerator::MAKEFILE); - all_tgts.push_back(dir); - } - - // write the directory clean rule - commands.clear(); - lg->WriteMakeRule(ruleFileStream, "Convenience name for directory clean.", - makeTargetName.c_str(), all_tgts, commands); + return; } + + // Begin the directory-level rules section. + std::string dir = lg->GetMakefile()->GetStartOutputDirectory(); + dir = lg->Convert(dir.c_str(), cmLocalGenerator::HOME_OUTPUT, + cmLocalGenerator::MAKEFILE); + lg->WriteDivider(ruleFileStream); + ruleFileStream + << "# Directory level rules for directory " + << dir << "\n\n"; + + // Write directory-level rules for "all". + this->WriteDirectoryRule2(ruleFileStream, lg, "all", true, false); + + // Write directory-level rules for "clean". + this->WriteDirectoryRule2(ruleFileStream, lg, "clean", false, false); + + // Write directory-level rules for "preinstall". + this->WriteDirectoryRule2(ruleFileStream, lg, "preinstall", false, true); } //---------------------------------------------------------------------------- @@ -578,49 +438,49 @@ std::vector commands; depends.push_back("cmake_check_build_system"); - + // write the target convenience rules unsigned int i; cmLocalUnixMakefileGenerator3 *lg; - for (i = 0; i < m_LocalGenerators.size(); ++i) - { - lg = static_cast(m_LocalGenerators[i]); - - // for each target Generate the rule files for each target. - cmTargets& targets = lg->GetMakefile()->GetTargets(); - for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) + for (i = 0; i < this->LocalGenerators.size(); ++i) { - if((t->second.GetType() == cmTarget::EXECUTABLE) || - (t->second.GetType() == cmTarget::STATIC_LIBRARY) || - (t->second.GetType() == cmTarget::SHARED_LIBRARY) || - (t->second.GetType() == cmTarget::MODULE_LIBRARY) || - (t->second.GetType() == cmTarget::UTILITY)) - { - // Don't emit the same rule twice (e.g. two targets with the same - // simple name) - if(t->second.GetName() && - strlen(t->second.GetName()) && - emitted.insert(t->second.GetName()).second) - { - // Add a rule to build the target by name. - lg->WriteDivider(ruleFileStream); - ruleFileStream - << "# Target rules for targets named " - << t->second.GetName() << "\n\n"; - - // Write the rule. - commands.clear(); - commands.push_back(lg->GetRecursiveMakeCall("CMakeFiles/Makefile2", - t->second.GetName())); - depends.clear(); - depends.push_back("cmake_check_build_system"); - lg->WriteMakeRule(ruleFileStream, - "Build rule for target.", - t->second.GetName(), depends, commands); + lg = static_cast(this->LocalGenerators[i]); + // for each target Generate the rule files for each target. + cmTargets& targets = lg->GetMakefile()->GetTargets(); + for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) + { + if((t->second.GetType() == cmTarget::EXECUTABLE) || + (t->second.GetType() == cmTarget::STATIC_LIBRARY) || + (t->second.GetType() == cmTarget::SHARED_LIBRARY) || + (t->second.GetType() == cmTarget::MODULE_LIBRARY) || + (t->second.GetType() == cmTarget::UTILITY)) + { + // Don't emit the same rule twice (e.g. two targets with the same + // simple name) + if(t->second.GetName() && + strlen(t->second.GetName()) && + emitted.insert(t->second.GetName()).second) + { + // Add a rule to build the target by name. + lg->WriteDivider(ruleFileStream); + ruleFileStream + << "# Target rules for targets named " + << t->second.GetName() << "\n\n"; + + // Write the rule. + commands.clear(); + commands.push_back(lg->GetRecursiveMakeCall + ("CMakeFiles/Makefile2",t->second.GetName())); + depends.clear(); + depends.push_back("cmake_check_build_system"); + lg->WriteMakeRule(ruleFileStream, + "Build rule for target.", + t->second.GetName(), depends, commands, + true); + } } } } - } } @@ -670,29 +530,29 @@ { makeTargetName = localName; makeTargetName += "/depend"; - commands.push_back(lg->GetRecursiveMakeCall(makefileName.c_str(), - makeTargetName.c_str())); + commands.push_back(lg->GetRecursiveMakeCall + (makefileName.c_str(),makeTargetName.c_str())); // add requires if we need it for this generator if (needRequiresStep) { makeTargetName = localName; makeTargetName += "/requires"; - commands.push_back(lg->GetRecursiveMakeCall(makefileName.c_str(), - makeTargetName.c_str())); + commands.push_back(lg->GetRecursiveMakeCall + (makefileName.c_str(),makeTargetName.c_str())); } } makeTargetName = localName; makeTargetName += "/build"; - commands.push_back(lg->GetRecursiveMakeCall(makefileName.c_str(), - makeTargetName.c_str())); + commands.push_back(lg->GetRecursiveMakeCall + (makefileName.c_str(),makeTargetName.c_str())); // Write the rule. localName += "/all"; depends.clear(); this->AppendGlobalTargetDepends(depends,t->second); lg->WriteMakeRule(ruleFileStream, "All Build rule for target.", - localName.c_str(), depends, commands); + localName.c_str(), depends, commands, true); // add the all/all dependency if (!exclude && t->second.IsInAll()) @@ -700,28 +560,47 @@ depends.clear(); depends.push_back(localName); commands.clear(); - lg->WriteMakeRule(ruleFileStream, "All Build rule for target.", - "all", depends, commands); + lg->WriteMakeRule(ruleFileStream, "Include target in all.", + "all", depends, commands, true); } // Write the rule. commands.clear(); - commands.push_back(lg->GetRecursiveMakeCall("CMakeFiles/Makefile2", - localName.c_str())); + commands.push_back(lg->GetRecursiveMakeCall + ("CMakeFiles/Makefile2",localName.c_str())); depends.clear(); depends.push_back("cmake_check_build_system"); localName = lg->GetRelativeTargetDirectory(t->second); localName += "/rule"; lg->WriteMakeRule(ruleFileStream, "Build rule for subdir invocation for target.", - localName.c_str(), depends, commands); + localName.c_str(), depends, commands, true); // Add a target with the canonical name (no prefix, suffix or path). commands.clear(); depends.clear(); depends.push_back(localName); lg->WriteMakeRule(ruleFileStream, "Convenience name for target.", - t->second.GetName(), depends, commands); + t->second.GetName(), depends, commands, true); + + // Add rules to prepare the target for installation. + if(t->second.NeedRelinkBeforeInstall()) + { + localName = lg->GetRelativeTargetDirectory(t->second); + localName += "/preinstall"; + depends.clear(); + commands.clear(); + commands.push_back(lg->GetRecursiveMakeCall + (makefileName.c_str(), localName.c_str())); + this->AppendGlobalTargetDepends(depends,t->second); + lg->WriteMakeRule(ruleFileStream, "Pre-install relink rule for target.", + localName.c_str(), depends, commands, true); + depends.clear(); + depends.push_back(localName); + commands.clear(); + lg->WriteMakeRule(ruleFileStream, "Prepare target for install.", + "preinstall", depends, commands, true); + } // add the clean rule localName = lg->GetRelativeTargetDirectory(t->second); @@ -729,14 +608,14 @@ makeTargetName += "/clean"; depends.clear(); commands.clear(); - commands.push_back(lg->GetRecursiveMakeCall(makefileName.c_str(), - makeTargetName.c_str())); + commands.push_back(lg->GetRecursiveMakeCall + (makefileName.c_str(), makeTargetName.c_str())); lg->WriteMakeRule(ruleFileStream, "clean rule for target.", - makeTargetName.c_str(), depends, commands); + makeTargetName.c_str(), depends, commands, true); commands.clear(); depends.push_back(makeTargetName); lg->WriteMakeRule(ruleFileStream, "clean rule for target.", - "clean", depends, commands); + "clean", depends, commands, true); } } } @@ -757,8 +636,8 @@ // Loop over all library dependencies but not for static libs if (target.GetType() != cmTarget::STATIC_LIBRARY) { - const cmTarget::LinkLibraries& tlibs = target.GetLinkLibraries(); - for(cmTarget::LinkLibraries::const_iterator lib = tlibs.begin(); + const cmTarget::LinkLibraryVectorType& tlibs = target.GetLinkLibraries(); + for(cmTarget::LinkLibraryVectorType::const_iterator lib = tlibs.begin(); lib != tlibs.end(); ++lib) { // Don't emit the same library twice for this target. @@ -803,42 +682,43 @@ // search each local generator until a match is found if (!result) { - unsigned int i; - for (i = 0; i < m_LocalGenerators.size(); ++i) - { - // search all targets - result = m_LocalGenerators[i]->GetMakefile()->FindTarget(name); + unsigned int i; + for (i = 0; i < this->LocalGenerators.size(); ++i) + { + // search all targets + result = this->LocalGenerators[i]->GetMakefile()->FindTarget(name); if (result) { lg3 = static_cast - (m_LocalGenerators[i]); + (this->LocalGenerators[i]); break; } } } - // if a match was found then ... - if (result) - { - std::string tgtName = lg3->GetRelativeTargetDirectory(*result); - tgtName += "/all"; - depends.push_back(tgtName); - if(result->GetType() == cmTarget::STATIC_LIBRARY) - { - const cmTarget::LinkLibraries& tlibs = result->GetLinkLibraries(); - for(cmTarget::LinkLibraries::const_iterator lib = tlibs.begin(); - lib != tlibs.end(); ++lib) + // if a match was found then ... + if (result) + { + std::string tgtName = lg3->GetRelativeTargetDirectory(*result); + tgtName += "/all"; + depends.push_back(tgtName); + if(result->GetType() == cmTarget::STATIC_LIBRARY) + { + const cmTarget::LinkLibraryVectorType& tlibs + = result->GetLinkLibraries(); + for(cmTarget::LinkLibraryVectorType::const_iterator lib = tlibs.begin(); + lib != tlibs.end(); ++lib) + { + // Don't emit the same library twice for this target. + if(emitted.insert(lib->first).second) { - // Don't emit the same library twice for this target. - if(emitted.insert(lib->first).second) - { - // Add this dependency. - this->AppendAnyGlobalDepend(depends, lib->first.c_str(), + // Add this dependency. + this->AppendAnyGlobalDepend(depends, lib->first.c_str(), emitted, *result); - } } } - return; + } + return; } } @@ -864,36 +744,45 @@ // for each local generator unsigned int i; cmLocalUnixMakefileGenerator3 *lg2; - for (i = 0; i < m_LocalGenerators.size(); ++i) + for (i = 0; i < this->LocalGenerators.size(); ++i) { - lg2 = static_cast(m_LocalGenerators[i]); + lg2 = static_cast(this->LocalGenerators[i]); // for the passed in makefile or if this is the top Makefile wripte out // the targets if (lg2 == lg || !lg->GetParent()) { - // for each target Generate the rule files for each target. - cmTargets& targets = lg->GetMakefile()->GetTargets(); - for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) - { - if((t->second.GetType() == cmTarget::EXECUTABLE) || - (t->second.GetType() == cmTarget::STATIC_LIBRARY) || - (t->second.GetType() == cmTarget::SHARED_LIBRARY) || - (t->second.GetType() == cmTarget::MODULE_LIBRARY) || - (t->second.GetType() == cmTarget::UTILITY)) - { - if(emittedTargets.insert(t->second.GetName()).second) + // for each target Generate the rule files for each target. + cmTargets& targets = lg->GetMakefile()->GetTargets(); + for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) + { + if((t->second.GetType() == cmTarget::EXECUTABLE) || + (t->second.GetType() == cmTarget::STATIC_LIBRARY) || + (t->second.GetType() == cmTarget::SHARED_LIBRARY) || + (t->second.GetType() == cmTarget::MODULE_LIBRARY) || + (t->second.GetType() == cmTarget::UTILITY)) { - path = "... "; - path += t->second.GetName(); - lg->AppendEcho(commands,path.c_str()); + if(emittedTargets.insert(t->second.GetName()).second) + { + path = "... "; + path += t->second.GetName(); + lg->AppendEcho(commands,path.c_str()); } } } + std::map > const& objs = + lg->GetLocalObjectFiles(); + for(std::map >::const_iterator o = + objs.begin(); o != objs.end(); ++o) + { + path = "... "; + path += o->first; + lg->AppendEcho(commands, path.c_str()); + } } } lg->WriteMakeRule(ruleFileStream, "Help Target", "help:", - no_depends, commands); + no_depends, commands, true); ruleFileStream << "\n\n"; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalUnixMakefileGenerator3.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalUnixMakefileGenerator3.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalUnixMakefileGenerator3.h 2005-10-25 03:43:52.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalUnixMakefileGenerator3.h 2006-03-16 00:02:03.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator3 Module: $RCSfile: cmGlobalUnixMakefileGenerator3.h,v $ Language: C++ - Date: $Date: 2005/10/24 19:43:52 $ - Version: $Revision: 1.13.2.3 $ + Date: $Date: 2006/03/15 16:02:03 $ + Version: $Revision: 1.24 $ Copyright (c) 2005 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -75,7 +75,8 @@ * Try to determine system infomation such as shared library * extension, pthreads, byte order etc. */ - virtual void EnableLanguage(std::vectorconst& languages, cmMakefile *); + virtual void EnableLanguage(std::vectorconst& languages, + cmMakefile *); /** * Generate the all required files for building this project/tree. This @@ -104,10 +105,12 @@ cmLocalUnixMakefileGenerator3 *, bool exclude); - void WriteDirectoryRules(std::ostream& ruleFileStream, - cmLocalUnixMakefileGenerator3 *lg); - void WriteDirectoryRules2(std::ostream& ruleFileStream, - cmLocalUnixMakefileGenerator3 *lg); + void WriteDirectoryRule2(std::ostream& ruleFileStream, + cmLocalUnixMakefileGenerator3* lg, + const char* pass, bool check_all, + bool check_relink); + void WriteDirectoryRules2(std::ostream& ruleFileStream, + cmLocalUnixMakefileGenerator3* lg); void AppendGlobalTargetDepends(std::vector& depends, cmTarget& target); @@ -119,6 +122,21 @@ // does this generator need a requires step for any of its targets bool NeedRequiresStep(cmLocalUnixMakefileGenerator3 *lg, const char *); + // Setup target names + virtual const char* GetAllTargetName() { return "all"; } + virtual const char* GetInstallTargetName() { return "install"; } + virtual const char* GetPreinstallTargetName() { return "preinstall"; } + virtual const char* GetTestTargetName() { return "test"; } + virtual const char* GetPackageTargetName() { return "package"; } + virtual const char* GetEditCacheTargetName() { return "edit_cache"; } + virtual const char* GetRebuildCacheTargetName() { return "rebuild_cache"; } + + // Some make programs (Borland) do not keep a rule if there are no + // dependencies or commands. This is a problem for creating rules + // that might not do anything but might have other dependencies + // added later. If non-empty this variable holds a fake dependency + // that can be added. + std::string EmptyRuleHackDepends; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalVisualStudio6Generator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalVisualStudio6Generator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalVisualStudio6Generator.cxx 2005-06-22 21:06:45.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalVisualStudio6Generator.cxx 2006-03-16 00:02:03.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalVisualStudio6Generator.cxx,v $ Language: C++ - Date: $Date: 2005/06/22 13:06:45 $ - Version: $Revision: 1.49 $ + Date: $Date: 2006/03/15 16:02:03 $ + Version: $Revision: 1.58 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -21,13 +21,12 @@ cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator() { - m_FindMakeProgramFile = "CMakeVS6FindMake.cmake"; + this->FindMakeProgramFile = "CMakeVS6FindMake.cmake"; } void cmGlobalVisualStudio6Generator::EnableLanguage(std::vectorconst& lang, cmMakefile *mf) { - mf->AddDefinition("CMAKE_CFG_INTDIR","$(IntDir)"); mf->AddDefinition("CMAKE_GENERATOR_CC", "cl"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl"); mf->AddDefinition("CMAKE_GENERATOR_RC", "rc"); @@ -68,7 +67,8 @@ } std::string cmGlobalVisualStudio6Generator::GenerateBuildCommand(const char* makeProgram, - const char *projectName, const char *targetName, const char* config, bool ignoreErrors) + const char *projectName, const char* additionalOptions, const char *targetName, + const char* config, bool ignoreErrors) { // Ingoring errors is not implemented in visual studio 6 (void) ignoreErrors; @@ -134,6 +134,11 @@ { makeCommand += "\" /BUILD"; } + if ( additionalOptions ) + { + makeCommand += " "; + makeCommand += additionalOptions; + } return makeCommand; } @@ -152,33 +157,17 @@ // of one configuration only. const char* no_output = 0; std::vector no_depends; + const char* no_working_dir = 0; std::map >::iterator it; - for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it) + for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) { std::vector& gen = it->second; // add the ALL_BUILD to the first local generator of each project if(gen.size()) { gen[0]->GetMakefile()-> - AddUtilityCommand("ALL_BUILD", false, no_output, no_depends, + AddUtilityCommand("ALL_BUILD", false, no_output, no_depends, no_working_dir, "echo", "Build all projects"); - std::string cmake_command = - m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND"); - gen[0]->GetMakefile()-> - AddUtilityCommand("INSTALL", false, no_output, no_depends, - cmake_command.c_str(), - "-DBUILD_TYPE=$(IntDir)", "-P", "cmake_install.cmake"); - - // Make the INSTALL target depend on ALL_BUILD unless the - // project says to not do so. - const char* noall = - gen[0]->GetMakefile() - ->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY"); - if(!noall || cmSystemTools::IsOff(noall)) - { - cmTarget* install = gen[0]->GetMakefile()->FindTarget("INSTALL"); - install->AddUtility("ALL_BUILD"); - } } } @@ -208,6 +197,9 @@ bool doneAllBuild = false; bool doneRunTests = false; bool doneInstall = false; + bool doneEditCache = false; + bool doneRebuildCache = false; + bool donePackage = false; for(i = 0; i < generators.size(); ++i) { @@ -253,7 +245,8 @@ { if (al->second.IsInAll()) { - if (al->second.GetType() == cmTarget::UTILITY) + if (al->second.GetType() == cmTarget::UTILITY || + al->second.GetType() == cmTarget::GLOBAL_TARGET) { l->second.AddUtility(al->first.c_str()); } @@ -315,6 +308,39 @@ doneRunTests = true; } } + if(l->first == "EDIT_CACHE") + { + if(doneEditCache) + { + skip = true; + } + else + { + doneEditCache = true; + } + } + if(l->first == "REBUILD_CACHE") + { + if(doneRebuildCache) + { + skip = true; + } + else + { + doneRebuildCache = true; + } + } + if(l->first == "PACKAGE") + { + if(donePackage) + { + skip = true; + } + else + { + donePackage = true; + } + } if(!skip) { this->WriteProject(fout, si->c_str(), dir.c_str(),l->second); @@ -355,7 +381,7 @@ void cmGlobalVisualStudio6Generator::OutputDSWFile() { std::map >::iterator it; - for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it) + for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) { this->OutputDSWFile(it->second[0], it->second); } @@ -380,7 +406,7 @@ // insert Begin Project Dependency Project_Dep_Name project stuff here if (target.GetType() != cmTarget::STATIC_LIBRARY) { - cmTarget::LinkLibraries::const_iterator j, jend; + cmTarget::LinkLibraryVectorType::const_iterator j, jend; j = target.GetLinkLibraries().begin(); jend = target.GetLinkLibraries().end(); for(;j!= jend; ++j) @@ -388,11 +414,8 @@ if(j->first != dspname) { // is the library part of this DSW ? If so add dependency - std::string libPath = j->first + "_CMAKE_PATH"; - const char* cacheValue - = m_CMakeInstance->GetCacheDefinition(libPath.c_str()); - if(cacheValue && *cacheValue) - { + if(this->FindTarget(0, j->first.c_str())) + { fout << "Begin Project Dependency\n"; fout << "Project_Dep_Name " << j->first.c_str() << "\n"; fout << "End Project Dependency\n"; @@ -483,3 +506,19 @@ entry.brief = "Generates Visual Studio 6 project files."; entry.full = ""; } + +//---------------------------------------------------------------------------- +void +cmGlobalVisualStudio6Generator +::AppendDirectoryForConfig(const char* prefix, + const char* config, + const char* suffix, + std::string& dir) +{ + if(config) + { + dir += prefix; + dir += config; + dir += suffix; + } +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalVisualStudio6Generator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalVisualStudio6Generator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalVisualStudio6Generator.h 2005-06-22 21:06:45.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalVisualStudio6Generator.h 2006-03-11 02:54:57.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalVisualStudio6Generator.h,v $ Language: C++ - Date: $Date: 2005/06/22 13:06:45 $ - Version: $Revision: 1.20 $ + Date: $Date: 2006/03/10 18:54:57 $ + Version: $Revision: 1.25 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -55,8 +55,11 @@ * loaded commands, not as part of the usual build process. */ virtual std::string GenerateBuildCommand(const char* makeProgram, - const char *projectName, const char *targetName, const char* config, - bool ignoreErrors); + const char *projectName, + const char* additionalOptions, + const char *targetName, + const char* config, + bool ignoreErrors); /** * Generate the all required files for building this project/tree. This @@ -74,6 +77,15 @@ virtual void WriteDSWFile(std::ostream& fout, cmLocalGenerator* root, std::vector& generators); + + /** Append the subdirectory for the given configuration. */ + virtual void AppendDirectoryForConfig(const char* prefix, + const char* config, + const char* suffix, + std::string& dir); + + ///! What is the configurations directory variable called? + virtual const char* GetCMakeCFGInitDirectory() { return "$(IntDir)"; } private: void GenerateConfigurations(cmMakefile* mf); void WriteDSWFile(std::ostream& fout); diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalVisualStudio71Generator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalVisualStudio71Generator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalVisualStudio71Generator.cxx 2005-06-22 21:06:45.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalVisualStudio71Generator.cxx 2006-03-16 00:02:03.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalVisualStudio71Generator.cxx,v $ Language: C++ - Date: $Date: 2005/06/22 13:06:45 $ - Version: $Revision: 1.22 $ + Date: $Date: 2006/03/15 16:02:03 $ + Version: $Revision: 1.30 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -24,7 +24,8 @@ cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator() { - m_FindMakeProgramFile = "CMakeVS71FindMake.cmake"; + this->FindMakeProgramFile = "CMakeVS71FindMake.cmake"; + this->ProjectConfigurationSectionName = "ProjectConfiguration"; } @@ -52,8 +53,12 @@ std::string rootdir = root->GetMakefile()->GetStartOutputDirectory(); rootdir += "/"; bool doneAllBuild = false; + bool doneCheckBuild = false; bool doneRunTests = false; bool doneInstall = false; + bool doneEditCache = false; + bool doneRebuildCache = false; + bool donePackage = false; // For each cmMakefile, create a VCProj for it, and // add it to this SLN file @@ -102,7 +107,8 @@ { if (al->second.IsInAll()) { - if (al->second.GetType() == cmTarget::UTILITY) + if (al->second.GetType() == cmTarget::UTILITY || + al->second.GetType() == cmTarget::GLOBAL_TARGET) { l->second.AddUtility(al->first.c_str()); } @@ -141,6 +147,17 @@ doneAllBuild = true; } } + if(l->first == CMAKE_CHECK_BUILD_SYSTEM_TARGET) + { + if(doneCheckBuild) + { + skip = true; + } + else + { + doneCheckBuild = true; + } + } if(l->first == "INSTALL") { if(doneInstall) @@ -163,6 +180,39 @@ doneRunTests = true; } } + if(l->first == "EDIT_CACHE") + { + if(doneEditCache) + { + skip = true; + } + else + { + doneEditCache = true; + } + } + if(l->first == "REBUILD_CACHE") + { + if(doneRebuildCache) + { + skip = true; + } + else + { + doneRebuildCache = true; + } + } + if(l->first == "PACKAGE") + { + if(donePackage) + { + skip = true; + } + else + { + donePackage = true; + } + } if(!skip) { this->WriteProject(fout, si->c_str(), dir.c_str(),l->second); @@ -172,16 +222,10 @@ } } } - fout << "Global\n" - << "\tGlobalSection(SolutionConfiguration) = preSolution\n"; - - for(std::vector::iterator i = m_Configurations.begin(); - i != m_Configurations.end(); ++i) - { - fout << "\t\t" << *i << " = " << *i << "\n"; - } - fout << "\tEndGlobalSection\n"; - fout << "\tGlobalSection(ProjectConfiguration) = postSolution\n"; + fout << "Global\n"; + this->WriteSolutionConfigurations(fout); + fout << "\tGlobalSection(" << this->ProjectConfigurationSectionName + << ") = postSolution\n"; // loop over again and compute the depends for(i = 0; i < generators.size(); ++i) { @@ -221,6 +265,19 @@ } +void +cmGlobalVisualStudio71Generator +::WriteSolutionConfigurations(std::ostream& fout) +{ + fout << "\tGlobalSection(SolutionConfiguration) = preSolution\n"; + for(std::vector::iterator i = this->Configurations.begin(); + i != this->Configurations.end(); ++i) + { + fout << "\t\t" << *i << " = " << *i << "\n"; + } + fout << "\tEndGlobalSection\n"; +} + // Write a dsp file into the SLN file, // Note, that dependencies from executables to // the libraries it uses are also done here @@ -256,7 +313,7 @@ // insert Begin Project Dependency Project_Dep_Name project stuff here if (target.GetType() != cmTarget::STATIC_LIBRARY) { - cmTarget::LinkLibraries::const_iterator j, jend; + cmTarget::LinkLibraryVectorType::const_iterator j, jend; j = target.GetLinkLibraries().begin(); jend = target.GetLinkLibraries().end(); for(;j!= jend; ++j) @@ -264,10 +321,7 @@ if(j->first != dspname) { // is the library part of this SLN ? If so add dependency - std::string libPath = j->first + "_CMAKE_PATH"; - const char* cacheValue - = m_CMakeInstance->GetCacheDefinition(libPath.c_str()); - if(cacheValue && *cacheValue) + if(this->FindTarget(this->CurrentProject.c_str(), j->first.c_str())) { fout << "\t\t{" << this->GetGUID(j->first.c_str()) << "} = {" << this->GetGUID(j->first.c_str()) << "}\n"; @@ -360,8 +414,8 @@ bool in_all_build) { std::string guid = this->GetGUID(name); - for(std::vector::iterator i = m_Configurations.begin(); - i != m_Configurations.end(); ++i) + for(std::vector::iterator i = this->Configurations.begin(); + i != this->Configurations.end(); ++i) { fout << "\t\t{" << guid << "}." << *i << ".ActiveCfg = " << *i << "|Win32\n"; if (in_all_build) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalVisualStudio71Generator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalVisualStudio71Generator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalVisualStudio71Generator.h 2005-06-22 21:06:45.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalVisualStudio71Generator.h 2006-03-16 00:02:03.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalVisualStudio71Generator.h,v $ Language: C++ - Date: $Date: 2005/06/22 13:06:45 $ - Version: $Revision: 1.9 $ + Date: $Date: 2006/03/15 16:02:03 $ + Version: $Revision: 1.12 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -29,7 +29,8 @@ { public: cmGlobalVisualStudio71Generator(); - static cmGlobalGenerator* New() { return new cmGlobalVisualStudio71Generator; } + static cmGlobalGenerator* New() + { return new cmGlobalVisualStudio71Generator; } ///! Get the name for the generator. virtual const char* GetName() const { @@ -46,14 +47,19 @@ virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root, std::vector& generators); + virtual void WriteSolutionConfigurations(std::ostream& fout); virtual void WriteProject(std::ostream& fout, const char* name, const char* path, cmTarget &t); virtual void WriteProjectDepends(std::ostream& fout, const char* name, const char* path, cmTarget &t); - virtual void WriteProjectConfigurations(std::ostream& fout, const char* name, bool in_all); - virtual void WriteExternalProject(std::ostream& fout, const char* name, const char* path, + virtual void WriteProjectConfigurations(std::ostream& fout, const char* name, + bool in_all); + virtual void WriteExternalProject(std::ostream& fout, const char* name, + const char* path, const std::vector& depends); virtual void WriteSLNFooter(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout); + + std::string ProjectConfigurationSectionName; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalVisualStudio7Generator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalVisualStudio7Generator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalVisualStudio7Generator.cxx 2005-08-12 02:02:19.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalVisualStudio7Generator.cxx 2006-03-16 00:02:03.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalVisualStudio7Generator.cxx,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:19 $ - Version: $Revision: 1.55.2.1 $ + Date: $Date: 2006/03/15 16:02:03 $ + Version: $Revision: 1.70 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -24,14 +24,13 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator() { - m_FindMakeProgramFile = "CMakeVS7FindMake.cmake"; + this->FindMakeProgramFile = "CMakeVS7FindMake.cmake"; } void cmGlobalVisualStudio7Generator::EnableLanguage(std::vectorconst & lang, cmMakefile *mf) { - mf->AddDefinition("CMAKE_CFG_INTDIR","$(OutDir)"); mf->AddDefinition("CMAKE_GENERATOR_CC", "cl"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl"); mf->AddDefinition("CMAKE_GENERATOR_RC", "rc"); @@ -44,7 +43,8 @@ } std::string cmGlobalVisualStudio7Generator::GenerateBuildCommand(const char* makeProgram, - const char *projectName, const char *targetName, const char* config, bool ignoreErrors) + const char *projectName, const char* additionalOptions, const char *targetName, + const char* config, bool ignoreErrors) { // Ingoring errors is not implemented in visual studio 6 (void) ignoreErrors; @@ -100,6 +100,11 @@ { makeCommand += "ALL_BUILD"; } + if ( additionalOptions ) + { + makeCommand += " "; + makeCommand += additionalOptions; + } return makeCommand; } @@ -115,7 +120,7 @@ { // process the configurations const char* ct - = m_CMakeInstance->GetCacheDefinition("CMAKE_CONFIGURATION_TYPES"); + = this->CMakeInstance->GetCacheDefinition("CMAKE_CONFIGURATION_TYPES"); if ( ct ) { std::string configTypes = ct; @@ -140,10 +145,10 @@ config == "MinSizeRel" || config == "RelWithDebInfo") { // only add unique configurations - if(std::find(m_Configurations.begin(), - m_Configurations.end(), config) == m_Configurations.end()) + if(std::find(this->Configurations.begin(), + this->Configurations.end(), config) == this->Configurations.end()) { - m_Configurations.push_back(config); + this->Configurations.push_back(config); } } else @@ -156,18 +161,18 @@ start = endpos+1; } } - if(m_Configurations.size() == 0) + if(this->Configurations.size() == 0) { - m_Configurations.push_back("Debug"); - m_Configurations.push_back("Release"); + this->Configurations.push_back("Debug"); + this->Configurations.push_back("Release"); } // Reset the entry to have a semi-colon separated list. - std::string configs = m_Configurations[0]; - for(unsigned int i=1; i < m_Configurations.size(); ++i) + std::string configs = this->Configurations[0]; + for(unsigned int i=1; i < this->Configurations.size(); ++i) { configs += ";"; - configs += m_Configurations[i]; + configs += this->Configurations[i]; } mf->AddCacheDefinition( @@ -184,9 +189,10 @@ // add a special target that depends on ALL projects for easy build // of one configuration only. const char* no_output = 0; + const char* no_working_dir = 0; std::vector no_depends; std::map >::iterator it; - for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it) + for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) { std::vector& gen = it->second; // add the ALL_BUILD to the first local generator of each project @@ -194,24 +200,11 @@ { gen[0]->GetMakefile()-> AddUtilityCommand("ALL_BUILD", false, no_output, no_depends, + no_working_dir, "echo", "Build all projects"); std::string cmake_command = - m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND"); - gen[0]->GetMakefile()-> - AddUtilityCommand("INSTALL", false, no_output, no_depends, - cmake_command.c_str(), - "-DBUILD_TYPE=$(OutDir)", "-P", "cmake_install.cmake"); - - // Make the INSTALL target depend on ALL_BUILD unless the - // project says to not do so. - const char* noall = - gen[0]->GetMakefile() - ->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY"); - if(!noall || cmSystemTools::IsOff(noall)) - { - cmTarget* install = gen[0]->GetMakefile()->FindTarget("INSTALL"); - install->AddUtility("ALL_BUILD"); - } + this->LocalGenerators[0]->GetMakefile()-> + GetRequiredDefinition("CMAKE_COMMAND"); } } @@ -232,6 +225,7 @@ { return; } + this->CurrentProject = root->GetMakefile()->GetProjectName(); std::string fname = root->GetMakefile()->GetStartOutputDirectory(); fname += "/"; fname += root->GetMakefile()->GetProjectName(); @@ -249,7 +243,7 @@ void cmGlobalVisualStudio7Generator::OutputSLNFile() { std::map >::iterator it; - for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it) + for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) { this->OutputSLNFile(it->second[0], it->second); } @@ -270,6 +264,9 @@ bool doneAllBuild = false; bool doneRunTests = false; bool doneInstall = false; + bool doneEditCache = false; + bool doneRebuildCache = false; + bool donePackage = false; // For each cmMakefile, create a VCProj for it, and // add it to this SLN file @@ -318,7 +315,8 @@ { if (al->second.IsInAll()) { - if (al->second.GetType() == cmTarget::UTILITY) + if (al->second.GetType() == cmTarget::UTILITY || + al->second.GetType() == cmTarget::GLOBAL_TARGET) { l->second.AddUtility(al->first.c_str()); } @@ -379,6 +377,39 @@ doneRunTests = true; } } + if(l->first == "EDIT_CACHE") + { + if(doneEditCache) + { + skip = true; + } + else + { + doneEditCache = true; + } + } + if(l->first == "REBUILD_CACHE") + { + if(doneRebuildCache) + { + skip = true; + } + else + { + doneRebuildCache = true; + } + } + if(l->first == "PACKAGE") + { + if(donePackage) + { + skip = true; + } + else + { + donePackage = true; + } + } if(!skip) { this->WriteProject(fout, si->c_str(), dir.c_str(),l->second); @@ -392,8 +423,8 @@ << "\tGlobalSection(SolutionConfiguration) = preSolution\n"; int c = 0; - for(std::vector::iterator i = m_Configurations.begin(); - i != m_Configurations.end(); ++i) + for(std::vector::iterator i = this->Configurations.begin(); + i != this->Configurations.end(); ++i) { fout << "\t\tConfigName." << c << " = " << *i << "\n"; c++; @@ -521,7 +552,7 @@ // insert Begin Project Dependency Project_Dep_Name project stuff here if (target.GetType() != cmTarget::STATIC_LIBRARY) { - cmTarget::LinkLibraries::const_iterator j, jend; + cmTarget::LinkLibraryVectorType::const_iterator j, jend; j = target.GetLinkLibraries().begin(); jend = target.GetLinkLibraries().end(); for(;j!= jend; ++j) @@ -529,10 +560,7 @@ if(j->first != dspname) { // is the library part of this SLN ? If so add dependency - std::string libPath = j->first + "_CMAKE_PATH"; - const char* cacheValue - = m_CMakeInstance->GetCacheDefinition(libPath.c_str()); - if(cacheValue && *cacheValue) + if(this->FindTarget(this->CurrentProject.c_str(), j->first.c_str())) { std::string guid = this->GetGUID(j->first.c_str()); if(guid.size() == 0) @@ -543,9 +571,8 @@ m += j->first.c_str(); cmSystemTools::Error(m.c_str()); } - - fout << "\t\t{" << this->GetGUID(dspname) << "}." << depcount << " = {" - << guid << "}\n"; + fout << "\t\t{" << this->GetGUID(dspname) << "}." + << depcount << " = {" << guid << "}\n"; depcount++; } } @@ -598,8 +625,8 @@ bool in_all_build) { std::string guid = this->GetGUID(name); - for(std::vector::iterator i = m_Configurations.begin(); - i != m_Configurations.end(); ++i) + for(std::vector::iterator i = this->Configurations.begin(); + i != this->Configurations.end(); ++i) { fout << "\t\t{" << guid << "}." << *i << ".ActiveCfg = " << *i << "|Win32\n"; if (in_all_build) @@ -651,7 +678,7 @@ { std::string guidStoreName = name; guidStoreName += "_GUID_CMAKE"; - const char* storedGUID = m_CMakeInstance->GetCacheDefinition(guidStoreName.c_str()); + const char* storedGUID = this->CMakeInstance->GetCacheDefinition(guidStoreName.c_str()); if(storedGUID) { return std::string(storedGUID); @@ -666,7 +693,7 @@ { std::string guidStoreName = name; guidStoreName += "_GUID_CMAKE"; - if(m_CMakeInstance->GetCacheDefinition(guidStoreName.c_str())) + if(this->CMakeInstance->GetCacheDefinition(guidStoreName.c_str())) { return; } @@ -678,13 +705,13 @@ ret = reinterpret_cast(uidstr); RpcStringFree(&uidstr); ret = cmSystemTools::UpperCase(ret); - m_CMakeInstance->AddCacheEntry(guidStoreName.c_str(), ret.c_str(), "Stored GUID", + this->CMakeInstance->AddCacheEntry(guidStoreName.c_str(), ret.c_str(), "Stored GUID", cmCacheManager::INTERNAL); } std::vector *cmGlobalVisualStudio7Generator::GetConfigurations() { - return &m_Configurations; + return &this->Configurations; }; //---------------------------------------------------------------------------- @@ -702,4 +729,23 @@ this->CreateGUID("ALL_BUILD"); this->CreateGUID("INSTALL"); this->CreateGUID("RUN_TESTS"); + this->CreateGUID("EDIT_CACHE"); + this->CreateGUID("REBUILD_CACHE"); + this->CreateGUID("PACKAGE"); +} + +//---------------------------------------------------------------------------- +void +cmGlobalVisualStudio7Generator +::AppendDirectoryForConfig(const char* prefix, + const char* config, + const char* suffix, + std::string& dir) +{ + if(config) + { + dir += prefix; + dir += config; + dir += suffix; + } } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalVisualStudio7Generator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalVisualStudio7Generator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalVisualStudio7Generator.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalVisualStudio7Generator.h 2006-03-16 00:02:03.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalVisualStudio7Generator.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.24.2.1 $ + Date: $Date: 2006/03/15 16:02:03 $ + Version: $Revision: 1.34 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -47,15 +47,19 @@ * Try to determine system infomation such as shared library * extension, pthreads, byte order etc. */ - virtual void EnableLanguage(std::vectorconst& languages, cmMakefile *); + virtual void EnableLanguage(std::vectorconst& languages, + cmMakefile *); /** * Try running cmake and building a file. This is used for dynalically * loaded commands, not as part of the usual build process. */ virtual std::string GenerateBuildCommand(const char* makeProgram, - const char *projectName, const char *targetName, const char* config, - bool ignoreErrors); + const char *projectName, + const char* additionalOptions, + const char *targetName, + const char* config, + bool ignoreErrors); /** * Generate the all required files for building this project/tree. This @@ -81,6 +85,15 @@ ///! do configure step virtual void Configure(); + /** Append the subdirectory for the given configuration. */ + virtual void AppendDirectoryForConfig(const char* prefix, + const char* config, + const char* suffix, + std::string& dir); + + ///! What is the configurations directory variable called? + virtual const char* GetCMakeCFGInitDirectory() { return "$(OutDir)"; } + protected: virtual void OutputSLNFile(cmLocalGenerator* root, std::vector& generators); @@ -90,7 +103,8 @@ const char* name, const char* path, cmTarget &t); virtual void WriteProjectDepends(std::ostream& fout, const char* name, const char* path, cmTarget &t); - virtual void WriteProjectConfigurations(std::ostream& fout, const char* name, bool in_all); + virtual void WriteProjectConfigurations(std::ostream& fout, const char* name, + bool in_all); virtual void WriteSLNFooter(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout); @@ -100,8 +114,15 @@ const char* name, const char* path, const std::vector& dependencies); - std::vector m_Configurations; - std::map m_GUIDMap; + + std::vector Configurations; + std::map GUIDMap; + + // Set during OutputSLNFile with the name of the current project. + // There is one SLN file per project. + std::string CurrentProject; }; +#define CMAKE_CHECK_BUILD_SYSTEM_TARGET "ZERO_CHECK" + #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalVisualStudio8Generator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalVisualStudio8Generator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalVisualStudio8Generator.cxx 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalVisualStudio8Generator.cxx 2006-03-16 00:02:03.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalVisualStudio8Generator.cxx,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.1.6.1 $ + Date: $Date: 2006/03/15 16:02:03 $ + Version: $Revision: 1.8 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -24,7 +24,8 @@ cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator() { - m_FindMakeProgramFile = "CMakeVS8FindMake.cmake"; + this->FindMakeProgramFile = "CMakeVS8FindMake.cmake"; + this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms"; } @@ -53,3 +54,177 @@ entry.brief = "Generates Visual Studio .NET 2005 project files."; entry.full = ""; } + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio8Generator::Configure() +{ + this->cmGlobalVisualStudio7Generator::Configure(); + this->CreateGUID(CMAKE_CHECK_BUILD_SYSTEM_TARGET); +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio8Generator::Generate() +{ + // Add a special target on which all other targets depend that + // checks the build system and optionally re-runs CMake. + const char* no_output = 0; + const char* no_working_directory = 0; + std::vector no_depends; + std::map >::iterator it; + for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) + { + std::vector& generators = it->second; + if(!generators.empty()) + { + // Add the build-system check target to the first local + // generator of this project. + cmLocalVisualStudio7Generator* lg = + static_cast(generators[0]); + cmMakefile* mf = lg->GetMakefile(); + std::string cmake_command = mf->GetRequiredDefinition("CMAKE_COMMAND"); + mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, true, + no_output, no_depends, + no_working_directory, + "echo", "Checking build system"); + cmTarget* tgt = mf->FindTarget(CMAKE_CHECK_BUILD_SYSTEM_TARGET); + if(!tgt) + { + cmSystemTools::Error("Error adding target " CMAKE_CHECK_BUILD_SYSTEM_TARGET); + continue; + } + + // Add a custom rule to re-run CMake if any input files changed. + const char* suppRegenRule = + mf->GetDefinition("CMAKE_SUPPRESS_REGENERATION"); + if(!cmSystemTools::IsOn(suppRegenRule)) + { + // Collect the input files used to generate all targets in this + // project. + std::vector listFiles; + for(unsigned int j = 0; j < generators.size(); ++j) + { + cmMakefile* lmf = generators[j]->GetMakefile(); + listFiles.insert(listFiles.end(), lmf->GetListFiles().begin(), + lmf->GetListFiles().end()); + } + // Sort the list of input files and remove duplicates. + std::sort(listFiles.begin(), listFiles.end(), std::less()); + std::vector::iterator new_end = + std::unique(listFiles.begin(), listFiles.end()); + listFiles.erase(new_end, listFiles.end()); + + // Create a rule to re-run CMake. + const char* dsprule = mf->GetRequiredDefinition("CMAKE_COMMAND"); + cmCustomCommandLine commandLine; + commandLine.push_back(dsprule); + std::string argH = "-H"; + argH += lg->Convert(mf->GetHomeDirectory(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::SHELL, true); + commandLine.push_back(argH); + std::string argB = "-B"; + argB += lg->Convert(mf->GetHomeOutputDirectory(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::SHELL, true); + commandLine.push_back(argB); + cmCustomCommandLines commandLines; + commandLines.push_back(commandLine); + + // Add the rule. Note that we cannot use the CMakeLists.txt + // file as the main dependency because it would get + // overwritten by the AddVCProjBuildRule of the ALL_BUILD + // target. + const char* no_comment = 0; + const char* no_main_dependency = 0; + const char* no_working_directory = 0; + mf->AddCustomCommandToOutput( + CMAKE_CHECK_BUILD_SYSTEM_TARGET ".vcproj.cmake", listFiles, + no_main_dependency, commandLines, no_comment, no_working_directory, true); + if(cmSourceFile* file = mf->GetSource(CMAKE_CHECK_BUILD_SYSTEM_TARGET ".vcproj.cmake.rule")) + { + tgt->GetSourceFiles().push_back(file); + } + else + { + cmSystemTools::Error("Error adding rule for " CMAKE_CHECK_BUILD_SYSTEM_TARGET ".vcproj.cmake"); + } + } + } + } + + // Now perform the main generation. + this->cmGlobalVisualStudio7Generator::Generate(); +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio8Generator::WriteSLNFile( + std::ostream& fout, cmLocalGenerator* root, + std::vector& generators) +{ + // Make all targets depend on their respective project's build + // system check target. + unsigned int i; + for(i = 0; i < generators.size(); ++i) + { + if(this->IsExcluded(root, generators[i])) + { + continue; + } + cmMakefile* mf = generators[i]->GetMakefile(); + std::vector dspnames = + static_cast(generators[i]) + ->GetCreatedProjectNames(); + cmTargets& tgts = mf->GetTargets(); + for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l) + { + if(l->first == CMAKE_CHECK_BUILD_SYSTEM_TARGET) + { + for(unsigned int j = 0; j < generators.size(); ++j) + { + // Every target in all generators should depend on this target. + cmMakefile* lmf = generators[j]->GetMakefile(); + cmTargets &atgts = lmf->GetTargets(); + for(cmTargets::iterator al = atgts.begin(); al != atgts.end(); ++al) + { + al->second.AddUtility(l->first.c_str()); + } + } + } + } + } + + // Now write the solution file. + this->cmGlobalVisualStudio71Generator::WriteSLNFile(fout, root, generators); +} + +//---------------------------------------------------------------------------- +void +cmGlobalVisualStudio8Generator +::WriteSolutionConfigurations(std::ostream& fout) +{ + fout << "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n"; + for(std::vector::iterator i = this->Configurations.begin(); + i != this->Configurations.end(); ++i) + { + fout << "\t\t" << *i << "|Win32 = " << *i << "|Win32\n"; + } + fout << "\tEndGlobalSection\n"; +} + +//---------------------------------------------------------------------------- +void +cmGlobalVisualStudio8Generator +::WriteProjectConfigurations(std::ostream& fout, + const char* name, bool in_all_build) +{ + std::string guid = this->GetGUID(name); + for(std::vector::iterator i = this->Configurations.begin(); + i != this->Configurations.end(); ++i) + { + fout << "\t\t{" << guid << "}." << *i << "|Win32.ActiveCfg = " << *i << "|Win32\n"; + if (in_all_build) + { + fout << "\t\t{" << guid << "}." << *i << "|Win32.Build.0 = " << *i << "|Win32\n"; + } + } +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalVisualStudio8Generator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalVisualStudio8Generator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalVisualStudio8Generator.h 2004-07-06 00:16:33.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalVisualStudio8Generator.h 2006-02-15 04:35:34.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalVisualStudio8Generator.h,v $ Language: C++ - Date: $Date: 2004/07/05 16:16:33 $ - Version: $Revision: 1.1 $ + Date: $Date: 2006/02/14 20:35:34 $ + Version: $Revision: 1.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -42,7 +42,18 @@ ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); + /** + * Override Configure and Generate to add the build-system check + * target. + */ + virtual void Configure(); + virtual void Generate(); protected: + virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root, + std::vector& generators); virtual void WriteSLNHeader(std::ostream& fout); + virtual void WriteSolutionConfigurations(std::ostream& fout); + virtual void WriteProjectConfigurations(std::ostream& fout, + const char* name, bool in_all); }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalWatcomWMakeGenerator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalWatcomWMakeGenerator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalWatcomWMakeGenerator.cxx 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalWatcomWMakeGenerator.cxx 2006-03-16 00:02:03.000000000 +0800 @@ -0,0 +1,66 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmGlobalWatcomWMakeGenerator.cxx,v $ + Language: C++ + Date: $Date: 2006/03/15 16:02:03 $ + Version: $Revision: 1.3 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "cmGlobalWatcomWMakeGenerator.h" +#include "cmLocalUnixMakefileGenerator3.h" +#include "cmMakefile.h" + +cmGlobalWatcomWMakeGenerator::cmGlobalWatcomWMakeGenerator() +{ + this->FindMakeProgramFile = "CMakeFindWMake.cmake"; + this->ForceUnixPaths = false; +} + +void cmGlobalWatcomWMakeGenerator::EnableLanguage(std::vectorconst& l, + cmMakefile *mf) +{ + // pick a default + mf->AddDefinition("WATCOM", "1"); + mf->AddDefinition("CMAKE_QUOTE_INCLUDE_PATHS", "1"); + mf->AddDefinition("CMAKE_MANGLE_OBJECT_FILE_NAMES", "1"); + mf->AddDefinition("CMAKE_WINDOWS_OBJECT_PATH", "1"); + mf->AddDefinition("CMAKE_MAKE_LINE_CONTINUE", "&"); + mf->AddDefinition("CMAKE_MAKE_SYMBOLIC_RULE", ".SYMBOLIC"); + mf->AddDefinition("CMAKE_NO_QUOTED_OBJECTS", "1"); + mf->AddDefinition("CMAKE_GENERATOR_CC", "wcl386"); + mf->AddDefinition("CMAKE_GENERATOR_CXX", "wcl386"); + this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf); +} + +///! Create a local generator appropriate to this Global Generator +cmLocalGenerator *cmGlobalWatcomWMakeGenerator::CreateLocalGenerator() +{ + cmLocalUnixMakefileGenerator3* lg = new cmLocalUnixMakefileGenerator3; + lg->SetSilentNoColon(true); + lg->SetEchoNeedsQuote(false); + lg->SetDefineWindowsNULL(true); + lg->SetWindowsShell(true); + lg->SetMakeSilentFlag("-s -h"); + lg->SetGlobalGenerator(this); + lg->SetIgnoreLibPrefix(true); + lg->SetPassMakeflags(false); + lg->SetUnixCD(false); + lg->SetIncludeDirective("!include"); + return lg; +} + +//---------------------------------------------------------------------------- +void cmGlobalWatcomWMakeGenerator::GetDocumentation(cmDocumentationEntry& entry) const +{ + entry.name = this->GetName(); + entry.brief = "Generates Watcom WMake makefiles."; + entry.full = ""; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalWatcomWMakeGenerator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalWatcomWMakeGenerator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalWatcomWMakeGenerator.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalWatcomWMakeGenerator.h 2006-03-11 02:54:57.000000000 +0800 @@ -0,0 +1,51 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmGlobalWatcomWMakeGenerator.h,v $ + Language: C++ + Date: $Date: 2006/03/10 18:54:57 $ + Version: $Revision: 1.2 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef cmGlobalWatcomWMakeGenerator_h +#define cmGlobalWatcomWMakeGenerator_h + +#include "cmGlobalUNIXMakefileGenerator3.h" + +/** \class cmGlobalWatcomWMakeGenerator + * \brief Write a NMake makefiles. + * + * cmGlobalWatcomWMakeGenerator manages nmake build process for a tree + */ +class cmGlobalWatcomWMakeGenerator : public cmGlobalUnixMakefileGenerator3 +{ +public: + cmGlobalWatcomWMakeGenerator(); + static cmGlobalGenerator* New() { return new cmGlobalWatcomWMakeGenerator; } + ///! Get the name for the generator. + virtual const char* GetName() const { + return cmGlobalWatcomWMakeGenerator::GetActualName();} + static const char* GetActualName() {return "Watcom WMake";} + + /** Get the documentation entry for this generator. */ + virtual void GetDocumentation(cmDocumentationEntry& entry) const; + + ///! Create a local generator appropriate to this Global Generator + virtual cmLocalGenerator *CreateLocalGenerator(); + + /** + * Try to determine system infomation such as shared library + * extension, pthreads, byte order etc. + */ + virtual void EnableLanguage(std::vectorconst& languages, + cmMakefile *); +}; + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalXCode21Generator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalXCode21Generator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalXCode21Generator.cxx 2005-09-07 00:55:12.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalXCode21Generator.cxx 2006-03-16 01:02:33.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalXCode21Generator.cxx,v $ Language: C++ - Date: $Date: 2005/09/06 16:55:12 $ - Version: $Revision: 1.2.2.2 $ + Date: $Date: 2006/03/15 17:02:33 $ + Version: $Revision: 1.5 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -19,7 +19,7 @@ cmGlobalXCode21Generator::cmGlobalXCode21Generator() { - this->m_XcodeVersion = 21; + this->XcodeVersion = 21; } //---------------------------------------------------------------------------- @@ -38,8 +38,8 @@ fout << "};\n"; cmXCode21Object::Indent(1, fout); fout << "objectVersion = 42;\n"; - cmXCode21Object::PrintList(m_XCodeObjects, fout); + cmXCode21Object::PrintList(this->XCodeObjects, fout); cmXCode21Object::Indent(1, fout); - fout << "rootObject = " << m_RootObject->GetId() << " /* Project object */;\n"; + fout << "rootObject = " << this->RootObject->GetId() << " /* Project object */;\n"; fout << "}\n"; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalXCode21Generator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalXCode21Generator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalXCode21Generator.h 2005-09-07 00:55:12.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalXCode21Generator.h 2006-02-25 06:35:35.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalXCode21Generator.h,v $ Language: C++ - Date: $Date: 2005/09/06 16:55:12 $ - Version: $Revision: 1.1.2.2 $ + Date: $Date: 2006/02/24 22:35:35 $ + Version: $Revision: 1.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -32,6 +32,9 @@ virtual void WriteXCodePBXProj(std::ostream& fout, cmLocalGenerator* root, std::vector& generators); + + ///! What is the configurations directory variable called? + virtual const char* GetCMakeCFGInitDirectory() { return "$(CONFIGURATION)"; } }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalXCodeGenerator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalXCodeGenerator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalXCodeGenerator.cxx 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalXCodeGenerator.cxx 2006-03-16 01:02:34.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalXCodeGenerator.cxx,v $ Language: C++ -Date: $Date: 2005/11/23 17:33:38 $ -Version: $Revision: 1.60.2.5 $ +Date: $Date: 2006/03/15 17:02:34 $ +Version: $Revision: 1.103 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -35,29 +35,29 @@ public: void StartElement(const char* , const char** ) { - m_Data = ""; + this->Data = ""; } void EndElement(const char* name) { if(strcmp(name, "key") == 0) { - m_Key = m_Data; + this->Key = this->Data; } else if(strcmp(name, "string") == 0) { - if(m_Key == "CFBundleShortVersionString") + if(this->Key == "CFBundleShortVersionString") { - m_Version = (int)(10.0 * atof(m_Data.c_str())); + this->Version = (int)(10.0 * atof(this->Data.c_str())); } } } void CharacterDataHandler(const char* data, int length) { - m_Data.append(data, length); + this->Data.append(data, length); } - int m_Version; - std::string m_Key; - std::string m_Data; + int Version; + std::string Key; + std::string Data; }; #endif @@ -68,13 +68,13 @@ //---------------------------------------------------------------------------- cmGlobalXCodeGenerator::cmGlobalXCodeGenerator() { - m_FindMakeProgramFile = "CMakeFindXCode.cmake"; - m_RootObject = 0; - m_MainGroupChildren = 0; - m_SourcesGroupChildren = 0; - m_CurrentMakefile = 0; - m_CurrentLocalGenerator = 0; - m_XcodeVersion = 15; + this->FindMakeProgramFile = "CMakeFindXCode.cmake"; + this->RootObject = 0; + this->MainGroupChildren = 0; + this->SourcesGroupChildren = 0; + this->CurrentMakefile = 0; + this->CurrentLocalGenerator = 0; + this->XcodeVersion = 15; } //---------------------------------------------------------------------------- @@ -83,18 +83,18 @@ #if defined(CMAKE_BUILD_WITH_CMAKE) cmXcodeVersionParser parser; parser.ParseFile("/Developer/Applications/Xcode.app/Contents/version.plist"); - if(parser.m_Version == 15) + if(parser.Version == 15) { return new cmGlobalXCodeGenerator; } - else if (parser.m_Version == 20) + else if (parser.Version == 20) { cmSystemTools::Message("Xcode 2.0 not really supported by cmake, " "using Xcode 15 generator\n"); return new cmGlobalXCodeGenerator; } cmGlobalXCodeGenerator* ret = new cmGlobalXCode21Generator; - ret->SetVersion(parser.m_Version); + ret->SetVersion(parser.Version); return ret; #else std::cerr @@ -109,20 +109,18 @@ cmMakefile * mf) { mf->AddDefinition("XCODE","1"); - if(m_XcodeVersion == 15) + if(this->XcodeVersion == 15) { - mf->AddDefinition("CMAKE_CFG_INTDIR","."); } else { - mf->AddDefinition("CMAKE_CFG_INTDIR","$(CONFIGURATION)"); mf->AddCacheDefinition( - "CMAKE_CONFIGURATION_TYPES", - "Debug;Release;MinSizeRel;RelWithDebInfo", - "Semicolon separated list of supported configuration types, " - "only supports Debug, Release, MinSizeRel, and RelWithDebInfo, " - "anything else will be ignored.", - cmCacheManager::STRING); + "CMAKE_CONFIGURATION_TYPES", + "Debug;Release;MinSizeRel;RelWithDebInfo", + "Semicolon separated list of supported configuration types, " + "only supports Debug, Release, MinSizeRel, and RelWithDebInfo, " + "anything else will be ignored.", + cmCacheManager::STRING); } mf->AddDefinition("CMAKE_GENERATOR_CC", "gcc"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "g++"); @@ -132,11 +130,10 @@ //---------------------------------------------------------------------------- std::string cmGlobalXCodeGenerator::GenerateBuildCommand(const char* makeProgram, - const char *projectName, const char *targetName, const char* config, - bool ignoreErrors) + const char *projectName, const char* additionalOptions, const char *targetName, + const char* config, bool ignoreErrors) { // Config is not used yet - (void) config; (void) ignoreErrors; // now build the test @@ -154,7 +151,7 @@ makeCommand += " -project "; makeCommand += projectName; makeCommand += ".xcode"; - if(m_XcodeVersion > 20) + if(this->XcodeVersion > 20) { makeCommand += "proj"; } @@ -171,7 +168,7 @@ } else { - makeCommand += " build"; + makeCommand += " build"; } makeCommand += " -target "; if (targetName && strlen(targetName)) @@ -182,13 +179,19 @@ { makeCommand += "ALL_BUILD"; } - if(m_XcodeVersion == 15) + if(this->XcodeVersion == 15) { makeCommand += " -buildstyle Development "; } else { - makeCommand += " -configuration Debug"; + makeCommand += " -configuration "; + makeCommand += config?config:"Debug"; + } + if ( additionalOptions ) + { + makeCommand += " "; + makeCommand += additionalOptions; } makeCommand += " OBJROOT=."; return makeCommand; @@ -198,39 +201,39 @@ void cmGlobalXCodeGenerator::ConfigureOutputPaths() { // Format the library and executable output paths. - m_LibraryOutputPath = - m_CurrentMakefile->GetSafeDefinition("LIBRARY_OUTPUT_PATH"); - if(m_LibraryOutputPath.size() == 0) + this->LibraryOutputPath = + this->CurrentMakefile->GetSafeDefinition("LIBRARY_OUTPUT_PATH"); + if(this->LibraryOutputPath.size() == 0) { - m_LibraryOutputPath = m_CurrentMakefile->GetCurrentOutputDirectory(); + this->LibraryOutputPath = this->CurrentMakefile->GetCurrentOutputDirectory(); } // make sure there is a trailing slash - if(m_LibraryOutputPath.size() && - m_LibraryOutputPath[m_LibraryOutputPath.size()-1] != '/') + if(this->LibraryOutputPath.size() && + this->LibraryOutputPath[this->LibraryOutputPath.size()-1] != '/') { - m_LibraryOutputPath += "/"; - if(!cmSystemTools::MakeDirectory(m_LibraryOutputPath.c_str())) + this->LibraryOutputPath += "/"; + if(!cmSystemTools::MakeDirectory(this->LibraryOutputPath.c_str())) { cmSystemTools::Error("Error creating directory ", - m_LibraryOutputPath.c_str()); + this->LibraryOutputPath.c_str()); } } - m_CurrentMakefile->AddLinkDirectory(m_LibraryOutputPath.c_str()); - m_ExecutableOutputPath = - m_CurrentMakefile->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH"); - if(m_ExecutableOutputPath.size() == 0) + this->CurrentMakefile->AddLinkDirectory(this->LibraryOutputPath.c_str()); + this->ExecutableOutputPath = + this->CurrentMakefile->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH"); + if(this->ExecutableOutputPath.size() == 0) { - m_ExecutableOutputPath = m_CurrentMakefile->GetCurrentOutputDirectory(); + this->ExecutableOutputPath = this->CurrentMakefile->GetCurrentOutputDirectory(); } // make sure there is a trailing slash - if(m_ExecutableOutputPath.size() && - m_ExecutableOutputPath[m_ExecutableOutputPath.size()-1] != '/') + if(this->ExecutableOutputPath.size() && + this->ExecutableOutputPath[this->ExecutableOutputPath.size()-1] != '/') { - m_ExecutableOutputPath += "/"; - if(!cmSystemTools::MakeDirectory(m_ExecutableOutputPath.c_str())) + this->ExecutableOutputPath += "/"; + if(!cmSystemTools::MakeDirectory(this->ExecutableOutputPath.c_str())) { cmSystemTools::Error("Error creating directory ", - m_ExecutableOutputPath.c_str()); + this->ExecutableOutputPath.c_str()); } } } @@ -249,16 +252,16 @@ { this->cmGlobalGenerator::Generate(); std::map >::iterator it; - for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it) + for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) { cmLocalGenerator* root = it->second[0]; - m_CurrentProject = root->GetMakefile()->GetProjectName(); + this->CurrentProject = root->GetMakefile()->GetProjectName(); this->SetCurrentLocalGenerator(root); - m_OutputDir = m_CurrentMakefile->GetHomeOutputDirectory(); - m_OutputDir = cmSystemTools::CollapseFullPath(m_OutputDir.c_str()); - cmSystemTools::SplitPath(m_OutputDir.c_str(), - m_ProjectOutputDirectoryComponents); - m_CurrentLocalGenerator = root; + this->OutputDir = this->CurrentMakefile->GetHomeOutputDirectory(); + this->OutputDir = cmSystemTools::CollapseFullPath(this->OutputDir.c_str()); + cmSystemTools::SplitPath(this->OutputDir.c_str(), + this->ProjectOutputDirectoryComponents); + this->CurrentLocalGenerator = root; // add ALL_BUILD, INSTALL, etc this->AddExtraTargets(root, it->second); // now create the project @@ -274,61 +277,34 @@ cmMakefile* mf = root->GetMakefile(); // Add ALL_BUILD const char* no_output = 0; + const char* no_working_directory = 0; std::vector no_depends; mf->AddUtilityCommand("ALL_BUILD", false, no_output, no_depends, + no_working_directory, "echo", "Build all projects"); cmTarget* allbuild = mf->FindTarget("ALL_BUILD"); - // ADD install - std::string cmake_command = mf->GetRequiredDefinition("CMAKE_COMMAND"); - if(m_XcodeVersion == 15) - { - mf->AddUtilityCommand("install", false, no_output, no_depends, - cmake_command.c_str(), - "-P", "cmake_install.cmake"); - } - else - { - mf->AddUtilityCommand("install", false, no_output, no_depends, - cmake_command.c_str(), - "-DBUILD_TYPE=$(CONFIGURATION)", - "-P", "cmake_install.cmake"); - } - const char* noall = - mf->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY"); - if(!noall || cmSystemTools::IsOff(noall)) - { - cmTarget* install = mf->FindTarget("install"); - install->AddUtility("ALL_BUILD"); - } - - // Add RUN_TESTS target if testing has been enabled - std::string fname; - fname = mf->GetStartOutputDirectory(); - fname += "/"; - fname += "DartTestfile.txt"; - if (cmSystemTools::FileExists(fname.c_str())) - { - std::string ctest_command = - mf->GetRequiredDefinition("CMAKE_CTEST_COMMAND"); - mf->AddUtilityCommand("RUN_TESTS", false, no_output, no_depends, - ctest_command.c_str()); - } // Add XCODE depend helper std::string dir = mf->GetCurrentOutputDirectory(); - m_CurrentXCodeHackMakefile = dir; - m_CurrentXCodeHackMakefile += "/CMakeScripts"; - cmSystemTools::MakeDirectory(m_CurrentXCodeHackMakefile.c_str()); - m_CurrentXCodeHackMakefile += "/XCODE_DEPEND_HELPER.make"; + this->CurrentXCodeHackMakefile = dir; + this->CurrentXCodeHackMakefile += "/CMakeScripts"; + cmSystemTools::MakeDirectory(this->CurrentXCodeHackMakefile.c_str()); + this->CurrentXCodeHackMakefile += "/XCODE_DEPEND_HELPER.make"; cmCustomCommandLine makecommand; makecommand.push_back("make"); makecommand.push_back("-C"); makecommand.push_back(dir.c_str()); makecommand.push_back("-f"); - makecommand.push_back(m_CurrentXCodeHackMakefile.c_str()); + makecommand.push_back(this->CurrentXCodeHackMakefile.c_str()); + if(this->XcodeVersion > 20) + { + makecommand.push_back("all.$(CONFIGURATION)"); + } cmCustomCommandLines commandLines; commandLines.push_back(makecommand); - mf->AddUtilityCommand("XCODE_DEPEND_HELPER", false, no_output, no_depends, + mf->AddUtilityCommand("XCODE_DEPEND_HELPER", false, no_output, + no_working_directory, + no_depends, commandLines); // Add Re-Run CMake rules @@ -376,11 +352,12 @@ std::unique(lfiles.begin(), lfiles.end()); lfiles.erase(new_end, lfiles.end()); std::string dir = mf->GetHomeOutputDirectory(); - m_CurrentReRunCMakeMakefile = dir; - m_CurrentReRunCMakeMakefile += "/CMakeScripts"; - cmSystemTools::MakeDirectory(m_CurrentReRunCMakeMakefile.c_str()); - m_CurrentReRunCMakeMakefile += "/ReRunCMake.make"; - cmGeneratedFileStream makefileStream(m_CurrentReRunCMakeMakefile.c_str()); + this->CurrentReRunCMakeMakefile = dir; + this->CurrentReRunCMakeMakefile += "/CMakeScripts"; + cmSystemTools::MakeDirectory(this->CurrentReRunCMakeMakefile.c_str()); + this->CurrentReRunCMakeMakefile += "/ReRunCMake.make"; + cmGeneratedFileStream makefileStream(this->CurrentReRunCMakeMakefile.c_str()); + makefileStream.SetCopyIfDifferent(true); makefileStream << "# Generated by CMake, DO NOT EDIT\n"; makefileStream << "CMakeFiles/cmake.check_cache: "; for(std::vector::const_iterator i = lfiles.begin(); @@ -399,15 +376,15 @@ //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::ClearXCodeObjects() { - m_TargetDoneSet.clear(); - for(unsigned int i = 0; i < m_XCodeObjects.size(); ++i) + this->TargetDoneSet.clear(); + for(unsigned int i = 0; i < this->XCodeObjects.size(); ++i) { - delete m_XCodeObjects[i]; + delete this->XCodeObjects[i]; } - m_XCodeObjects.clear(); - m_GroupMap.clear(); - m_GroupNameMap.clear(); - m_TargetGroup.clear(); + this->XCodeObjects.clear(); + this->GroupMap.clear(); + this->GroupNameMap.clear(); + this->TargetGroup.clear(); } //---------------------------------------------------------------------------- @@ -415,7 +392,7 @@ cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::PBXType ptype) { cmXCodeObject* obj; - if(m_XcodeVersion == 15) + if(this->XcodeVersion == 15) { obj = new cmXCodeObject(ptype, cmXCodeObject::OBJECT); } @@ -423,7 +400,7 @@ { obj = new cmXCode21Object(ptype, cmXCodeObject::OBJECT); } - m_XCodeObjects.push_back(obj); + this->XCodeObjects.push_back(obj); return obj; } @@ -432,7 +409,7 @@ cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::Type type) { cmXCodeObject* obj = new cmXCodeObject(cmXCodeObject::None, type); - m_XCodeObjects.push_back(obj); + this->XCodeObjects.push_back(obj); return obj; } @@ -456,15 +433,19 @@ //---------------------------------------------------------------------------- cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, - cmSourceFile* sf) + cmSourceFile* sf, + cmTarget& cmtarget) { std::string flags; // Add flags from source file properties. + if(cmtarget.GetProperty("COMPILE_FLAGS")) + { + lg->AppendFlags(flags, cmtarget.GetProperty("COMPILE_FLAGS")); + } lg->AppendFlags(flags, sf->GetProperty("COMPILE_FLAGS")); - cmXCodeObject* fileRef = this->CreateObject(cmXCodeObject::PBXFileReference); - cmXCodeObject* group = m_GroupMap[sf]; + cmXCodeObject* group = this->GroupMap[sf]; cmXCodeObject* children = group->GetObject("children"); children->AddObject(fileRef); cmXCodeObject* buildFile = this->CreateObject(cmXCodeObject::PBXBuildFile); @@ -499,6 +480,10 @@ { sourcecode += ".cpp.objc"; } + else if(ext == "plist") + { + sourcecode += ".text.plist"; + } else if(!lang) { sourcecode += ext; @@ -525,9 +510,9 @@ fileRef->AddAttribute("name", this->CreateString(file.c_str())); fileRef->AddAttribute("path", this->CreateString(path.c_str())); - if(m_XcodeVersion == 15) + if(this->XcodeVersion == 15) { - fileRef->AddAttribute("refType", this->CreateString("4")); + fileRef->AddAttribute("refType", this->CreateString("4")); } if(path.size() > 1 && path[0] == '.' && path[1] == '.') { @@ -546,11 +531,11 @@ if(tname == "ALL_BUILD" || tname == "XCODE_DEPEND_HELPER" || tname == "install" || tname == "RUN_TESTS" ) { - if(m_TargetDoneSet.find(tname) != m_TargetDoneSet.end()) + if(this->TargetDoneSet.find(tname) != this->TargetDoneSet.end()) { return true; } - m_TargetDoneSet.insert(tname); + this->TargetDoneSet.insert(tname); return false; } return false; @@ -559,12 +544,35 @@ void cmGlobalXCodeGenerator::SetCurrentLocalGenerator(cmLocalGenerator* gen) { - m_CurrentLocalGenerator = gen; - m_CurrentMakefile = gen->GetMakefile(); + this->CurrentLocalGenerator = gen; + this->CurrentMakefile = gen->GetMakefile(); std::string outdir = - cmSystemTools::CollapseFullPath(m_CurrentMakefile-> + cmSystemTools::CollapseFullPath(this->CurrentMakefile-> GetCurrentOutputDirectory()); - cmSystemTools::SplitPath(outdir.c_str(), m_CurrentOutputDirectoryComponents); + cmSystemTools::SplitPath(outdir.c_str(), this->CurrentOutputDirectoryComponents); + + // Select the current set of configuration types. + this->CurrentConfigurationTypes.clear(); + if(this->XcodeVersion > 20) + { + if(const char* types = + this->CurrentMakefile->GetDefinition("CMAKE_CONFIGURATION_TYPES")) + { + cmSystemTools::ExpandListArgument(types, this->CurrentConfigurationTypes); + } + } + if(this->CurrentConfigurationTypes.empty()) + { + if(const char* buildType = + this->CurrentMakefile->GetDefinition("CMAKE_BUILD_TYPE")) + { + this->CurrentConfigurationTypes.push_back(buildType); + } + else + { + this->CurrentConfigurationTypes.push_back(""); + } + } } @@ -575,7 +583,7 @@ targets) { this->SetCurrentLocalGenerator(gen); - cmTargets &tgts = gen->GetMakefile()->GetTargets(); + cmTargets &tgts = this->CurrentMakefile->GetTargets(); for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { cmTarget& cmtarget = l->second; @@ -585,10 +593,12 @@ continue; } if(cmtarget.GetType() == cmTarget::UTILITY || + cmtarget.GetType() == cmTarget::GLOBAL_TARGET || cmtarget.GetType() == cmTarget::INSTALL_FILES || cmtarget.GetType() == cmTarget::INSTALL_PROGRAMS) { - if(cmtarget.GetType() == cmTarget::UTILITY) + if(cmtarget.GetType() == cmTarget::UTILITY || + cmtarget.GetType() == cmTarget::GLOBAL_TARGET) { targets.push_back(this->CreateUtilityTarget(cmtarget)); } @@ -612,7 +622,8 @@ for(std::vector::iterator i = classes.begin(); i != classes.end(); ++i) { - cmXCodeObject* xsf = this->CreateXCodeSourceFile(gen, *i); + cmXCodeObject* xsf = + this->CreateXCodeSourceFile(this->CurrentLocalGenerator, *i, cmtarget); cmXCodeObject* fr = xsf->GetObject("fileRef"); cmXCodeObject* filetype = fr->GetObject()->GetObject("lastKnownFileType"); @@ -684,7 +695,7 @@ cmXCodeObject* buildPhase = this->CreateObject(cmXCodeObject::PBXShellScriptBuildPhase); buildPhase->AddAttribute("buildActionMask", - this->CreateString("2147483647")); + this->CreateString("2147483647")); cmXCodeObject* buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); buildPhase->AddAttribute("files", buildFiles); buildPhase->AddAttribute("name", @@ -714,7 +725,6 @@ = cmtarget.GetPreLinkCommands(); std::vector const & postbuild = cmtarget.GetPostBuildCommands(); - cmtarget.TraceVSDependencies(cmtarget.GetName(), m_CurrentMakefile); std::vector &classes = cmtarget.GetSourceFiles(); // add all the sources std::vector commands; @@ -813,20 +823,20 @@ { if(strcmp(name, "cmakeReRunPhase") == 0) { - std::string cdir = m_CurrentMakefile->GetHomeOutputDirectory(); + std::string cdir = this->CurrentMakefile->GetHomeOutputDirectory(); cdir = this->ConvertToRelativeForMake(cdir.c_str()); std::string makecmd = "make -C "; makecmd += cdir; makecmd += " -f "; makecmd += - this->ConvertToRelativeForMake(m_CurrentReRunCMakeMakefile.c_str()); + this->ConvertToRelativeForMake(this->CurrentReRunCMakeMakefile.c_str()); cmSystemTools::ReplaceString(makecmd, "\\ ", "\\\\ "); buildphase->AddAttribute("shellScript", this->CreateString(makecmd.c_str())); return; } - std::string dir = m_CurrentMakefile->GetCurrentOutputDirectory(); + std::string dir = this->CurrentMakefile->GetCurrentOutputDirectory(); dir += "/CMakeScripts"; cmSystemTools::MakeDirectory(dir.c_str()); std::string makefile = dir; @@ -840,6 +850,7 @@ { return; } + makefileStream.SetCopyIfDifferent(true); makefileStream << "# Generated by CMake, DO NOT EDIT\n"; makefileStream << "# Custom rules for " << target.GetName() << "\n"; @@ -889,7 +900,7 @@ for(std::vector::const_iterator d = cc.GetDepends().begin(); d != cc.GetDepends().end(); ++d) { - if(!this->FindTarget(m_CurrentProject.c_str(), + if(!this->FindTarget(this->CurrentProject.c_str(), d->c_str())) { // if the depend is not a target but @@ -918,9 +929,17 @@ { // Build the command line in a single string. const cmCustomCommandLine& commandLine = *cl; - std::string cmd = commandLine[0]; - cmSystemTools::ReplaceString(cmd, "/./", "/"); - cmd = this->ConvertToRelativeForMake(cmd.c_str()); + std::string cmd2 = commandLine[0]; + cmSystemTools::ReplaceString(cmd2, "/./", "/"); + cmd2 = this->ConvertToRelativeForMake(cmd2.c_str()); + std::string cmd; + if(cc.GetWorkingDirectory()) + { + cmd += "cd "; + cmd += this->ConvertToRelativeForMake(cc.GetWorkingDirectory()); + cmd += " && "; + } + cmd += cmd2; for(unsigned int j=1; j < commandLine.size(); ++j) { cmd += " "; @@ -930,7 +949,7 @@ } } } - std::string cdir = m_CurrentMakefile->GetCurrentOutputDirectory(); + std::string cdir = this->CurrentMakefile->GetCurrentOutputDirectory(); cdir = this->ConvertToRelativeForXCode(cdir.c_str()); std::string makecmd = "make -C "; makecmd += cdir; @@ -947,7 +966,7 @@ std::string& fileType, std::string& productType, std::string& productName, - const char* buildtype) + const char* configName) { this->ConfigureOutputPaths(); std::string flags; @@ -959,7 +978,7 @@ defFlags += "-D"; if(const char* custom_export_name = target.GetProperty("DEFINE_SYMBOL")) { - defFlags += custom_export_name; + defFlags += custom_export_name; } else { @@ -972,78 +991,107 @@ std::string cflags; if(lang) { - if(buildtype) - { - m_CurrentMakefile->AddDefinition("CMAKE_BUILD_TYPE", buildtype); - } // for c++ projects get the c flags as well if(strcmp(lang, "CXX") == 0) { - m_CurrentLocalGenerator->AddLanguageFlags(cflags, "C"); - m_CurrentLocalGenerator->AddSharedFlags(cflags, lang, shared); + this->CurrentLocalGenerator->AddLanguageFlags(cflags, "C", configName); + this->CurrentLocalGenerator->AddSharedFlags(cflags, lang, shared); } + // Add language-specific flags. - m_CurrentLocalGenerator->AddLanguageFlags(flags, lang); + this->CurrentLocalGenerator->AddLanguageFlags(flags, lang, configName); // Add shared-library flags if needed. - m_CurrentLocalGenerator->AddSharedFlags(flags, lang, shared); - m_CurrentMakefile->AddDefinition("CMAKE_BUILD_TYPE", ""); + this->CurrentLocalGenerator->AddSharedFlags(flags, lang, shared); } // Add define flags - m_CurrentLocalGenerator->AppendFlags(defFlags, - m_CurrentMakefile->GetDefineFlags()); + this->CurrentLocalGenerator->AppendFlags(defFlags, + this->CurrentMakefile->GetDefineFlags()); cmSystemTools::ReplaceString(defFlags, "\"", "\\\""); cmSystemTools::ReplaceString(flags, "\"", "\\\""); cmSystemTools::ReplaceString(cflags, "\"", "\\\""); - if(m_XcodeVersion > 15) + if(this->XcodeVersion > 15) + { + buildSettings-> + AddAttribute("GCC_PREPROCESSOR_DEFINITIONS", + this->CreateString("CMAKE_INTDIR=\\\\\\\"$(CONFIGURATION)\\\\\\\"")); + + } + std::string extraLinkOptions; + if(target.GetType() == cmTarget::EXECUTABLE) + { + extraLinkOptions = + this->CurrentMakefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS"); + } + if(target.GetType() == cmTarget::SHARED_LIBRARY) { - defFlags += " -DCMAKE_INTDIR=\\\\\\\"$(CONFIGURATION)\\\\\\\" "; + extraLinkOptions = + this->CurrentMakefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS"); + } + if(target.GetType() == cmTarget::MODULE_LIBRARY) + { + extraLinkOptions = + this->CurrentMakefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS"); } - productName = target.GetName(); + const char* targetLinkFlags = target.GetProperty("LINK_FLAGS"); + if(targetLinkFlags) + { + extraLinkOptions += " "; + extraLinkOptions += targetLinkFlags; + } + + // The product name is the full name of the target for this configuration. + productName = target.GetFullName(configName); + + // Get the product name components. + std::string pnprefix; + std::string pnbase; + std::string pnsuffix; + target.GetFullName(pnprefix, pnbase, pnsuffix, configName); + + // Store the product name for all target types. + buildSettings->AddAttribute("PRODUCT_NAME", + this->CreateString(pnbase.c_str())); + + // Set attributes to specify the proper name for the target. + if(target.GetType() == cmTarget::STATIC_LIBRARY || + target.GetType() == cmTarget::SHARED_LIBRARY || + target.GetType() == cmTarget::MODULE_LIBRARY || + target.GetType() == cmTarget::EXECUTABLE) + { + std::string pndir = target.GetDirectory(); + buildSettings->AddAttribute("SYMROOT", + this->CreateString(pndir.c_str())); + buildSettings->AddAttribute("EXECUTABLE_PREFIX", + this->CreateString(pnprefix.c_str())); + buildSettings->AddAttribute("EXECUTABLE_SUFFIX", + this->CreateString(pnsuffix.c_str())); + } + + // Handle settings for each target type. switch(target.GetType()) { case cmTarget::STATIC_LIBRARY: - { - if(m_LibraryOutputPath.size()) - { - buildSettings->AddAttribute("SYMROOT", - this->CreateString - (m_LibraryOutputPath.c_str())); - } - productName += ".a"; - std::string t = "lib"; - t += productName; - productName = t; - productType = "com.apple.product-type.library.static"; - fileType = "archive.ar"; - buildSettings->AddAttribute("LIBRARY_STYLE", - this->CreateString("STATIC")); - break; - } + { + fileType = "archive.ar"; + productType = "com.apple.product-type.library.static"; + + buildSettings->AddAttribute("LIBRARY_STYLE", + this->CreateString("STATIC")); + break; + } case cmTarget::MODULE_LIBRARY: + { + buildSettings->AddAttribute("LIBRARY_STYLE", + this->CreateString("BUNDLE")); + if(this->XcodeVersion >= 22) { - if(m_LibraryOutputPath.size()) - { - buildSettings->AddAttribute("SYMROOT", - this->CreateString - (m_LibraryOutputPath.c_str())); - } - - buildSettings->AddAttribute("EXECUTABLE_PREFIX", - this->CreateString("lib")); - buildSettings->AddAttribute("EXECUTABLE_EXTENSION", - this->CreateString("so")); - buildSettings->AddAttribute("LIBRARY_STYLE", - this->CreateString("BUNDLE")); - productName += ".so"; - std::string t = "lib"; - t += productName; - productName = t; - if(m_XcodeVersion >= 22) - { + fileType = "compiled.mach-o.executable"; + productType = "com.apple.product-type.tool"; + buildSettings->AddAttribute("MACH_O_TYPE", this->CreateString("mh_bundle")); buildSettings->AddAttribute("GCC_DYNAMIC_NO_PIC", @@ -1055,108 +1103,144 @@ std::string outflag = "-o \\\"$(CONFIGURATION_BUILD_DIR)/"; outflag += productName; outflag += "\\\""; - buildSettings->AddAttribute("OTHER_LDFLAGS", - this->CreateString(outflag.c_str())); - productType = "com.apple.product-type.tool"; - fileType = "compiled.mach-o.executable"; + extraLinkOptions += " "; + extraLinkOptions += outflag; + + // Add the flags to create an executable. + std::string createFlags = + this->LookupFlags("CMAKE_", lang, "_LINK_FLAGS", ""); + if(!createFlags.empty()) + { + extraLinkOptions += " "; + extraLinkOptions += createFlags; + } } else { - buildSettings->AddAttribute("OTHER_LDFLAGS", - this->CreateString("-bundle")); - productType = "com.apple.product-type.library.dynamic"; fileType = "compiled.mach-o.dylib"; + productType = "com.apple.product-type.library.dynamic"; + + // Add the flags to create a module. + std::string createFlags = + this->LookupFlags("CMAKE_SHARED_MODULE_CREATE_", lang, "_FLAGS", + "-bundle"); + if(!createFlags.empty()) + { + extraLinkOptions += " "; + extraLinkOptions += createFlags; + } } - break; - } + break; + } case cmTarget::SHARED_LIBRARY: + { + fileType = "compiled.mach-o.dylib"; + productType = "com.apple.product-type.library.dynamic"; + + buildSettings->AddAttribute("LIBRARY_STYLE", + this->CreateString("DYNAMIC")); + buildSettings->AddAttribute("DYLIB_COMPATIBILITY_VERSION", + this->CreateString("1")); + buildSettings->AddAttribute("DYLIB_CURRENT_VERSION", + this->CreateString("1")); + + // Add the flags to create a shared library. + std::string createFlags = + this->LookupFlags("CMAKE_SHARED_LIBRARY_CREATE_", lang, "_FLAGS", + "-dynamiclib"); + if(!createFlags.empty()) { - if(m_LibraryOutputPath.size()) - { - buildSettings->AddAttribute("SYMROOT", - this->CreateString - (m_LibraryOutputPath.c_str())); - } - buildSettings->AddAttribute("LIBRARY_STYLE", - this->CreateString("DYNAMIC")); - productName += ".dylib"; - std::string t = "lib"; - t += productName; - productName = t; - buildSettings->AddAttribute("DYLIB_COMPATIBILITY_VERSION", - this->CreateString("1")); - buildSettings->AddAttribute("DYLIB_CURRENT_VERSION", - this->CreateString("1")); - buildSettings->AddAttribute("OTHER_LDFLAGS", - this->CreateString("-dynamiclib")); - productType = "com.apple.product-type.library.dynamic"; - fileType = "compiled.mach-o.dylib"; - break; + extraLinkOptions += " "; + extraLinkOptions += createFlags; } + break; + } case cmTarget::EXECUTABLE: + { + fileType = "compiled.mach-o.executable"; + + // Add the flags to create an executable. + std::string createFlags = + this->LookupFlags("CMAKE_", lang, "_LINK_FLAGS", ""); + if(!createFlags.empty()) + { + extraLinkOptions += " "; + extraLinkOptions += createFlags; + } + + // Handle bundles and normal executables separately. + if(target.GetPropertyAsBool("MACOSX_BUNDLE")) + { + productType = "com.apple.product-type.application"; + std::string f1 = + this->CurrentMakefile->GetModulesFile("MacOSXBundleInfo.plist.in"); + if ( f1.size() == 0 ) + { + cmSystemTools::Error("could not find Mac OSX bundle template file."); + } + std::string f2 = this->CurrentMakefile->GetCurrentOutputDirectory(); + f2 += "/Info.plist"; + this->CurrentMakefile->ConfigureFile(f1.c_str(), f2.c_str(), + false, false, false); + std::string path = + this->ConvertToRelativeForXCode(f2.c_str()); + buildSettings->AddAttribute("INFOPLIST_FILE", + this->CreateString(path.c_str())); + + } + else { - const char* outname = target.GetProperty("OUTPUT_NAME"); - std::string name; - if(outname) - { - productName = outname; - name = outname; - } - else - { - name = target.GetName(); - } - std::string symRoot; - if(m_ExecutableOutputPath.size()) - { - std::string path = m_ExecutableOutputPath; - if(target.GetPropertyAsBool("MACOSX_BUNDLE")) - { - path += name; - path += ".app/Contents/MacOS/"; - } - symRoot = path; - } - fileType = "compiled.mach-o.executable"; - if(target.GetPropertyAsBool("MACOSX_BUNDLE")) - { - if(symRoot.size() == 0) - { - symRoot = name; - symRoot += ".app/Contents/MacOS/"; - } - productType = "com.apple.product-type.tool"; - } - else - { - productType = "com.apple.product-type.tool"; - } - if(symRoot.size()) - { - buildSettings->AddAttribute("SYMROOT", - this->CreateString - (symRoot.c_str())); - } + productType = "com.apple.product-type.tool"; } - break; - case cmTarget::UTILITY: - - break; - case cmTarget::INSTALL_FILES: - break; - case cmTarget::INSTALL_PROGRAMS: + } + break; + default: break; } std::string dirs; - std::vector& includes = - m_CurrentMakefile->GetIncludeDirectories(); + std::vector includes; + this->CurrentLocalGenerator->GetIncludeDirectories(includes); std::vector::iterator i = includes.begin(); + std::string fdirs; + std::set emitted; for(;i != includes.end(); ++i) { - std::string incpath = - this->XCodeEscapePath(i->c_str()); - dirs += incpath + " "; + if(cmSystemTools::IsPathToFramework(i->c_str())) + { + std::string frameworkDir = *i; + frameworkDir += "/../"; + frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str()); + if(emitted.insert(frameworkDir).second) + { + fdirs += this->XCodeEscapePath(frameworkDir.c_str()); + fdirs += " "; + } + } + else + { + std::string incpath = + this->XCodeEscapePath(i->c_str()); + dirs += incpath + " "; + } + } + std::vector& frameworks = target.GetFrameworks(); + if(frameworks.size()) + { + for(std::vector::iterator fmIt = frameworks.begin(); + fmIt != frameworks.end(); ++fmIt) + { + if(emitted.insert(*fmIt).second) + { + fdirs += this->XCodeEscapePath(fmIt->c_str()); + fdirs += " "; + } + } + } + if(fdirs.size()) + { + buildSettings->AddAttribute("FRAMEWORK_SEARCH_PATHS", + this->CreateString(fdirs.c_str())); } if(dirs.size()) { @@ -1195,8 +1279,6 @@ this->CreateString(debugStr)); buildSettings->AddAttribute("GCC_OPTIMIZATION_LEVEL", this->CreateString(optLevel)); - buildSettings->AddAttribute("INSTALL_PATH", - this->CreateString("")); buildSettings->AddAttribute("OPTIMIZATION_CFLAGS", this->CreateString(oflagc.c_str())); if(lang && strcmp(lang, "CXX") == 0) @@ -1218,11 +1300,45 @@ buildSettings->AddAttribute("OTHER_CFLAGS", this->CreateString(flags.c_str())); } - if(!buildSettings->GetObject("OTHER_LDFLAGS")) + + // Create the INSTALL_PATH attribute. + std::string install_name_dir; + if(target.GetType() == cmTarget::SHARED_LIBRARY) { - buildSettings->AddAttribute("OTHER_LDFLAGS", - this->CreateString("")); + // Select whether to generate an install_name directory for the + // install tree or the build tree. + if(target.GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + install_name_dir = + target.GetInstallNameDirForInstallTree(configName); + } + else + { + install_name_dir = + target.GetInstallNameDirForBuildTree(configName); + } + + if(install_name_dir.empty()) + { + // Xcode will not pass the -install_name option at all if INSTALL_PATH + // is not given or is empty. We must explicitly put the flag in the + // link flags to create an install_name with just the library soname. + extraLinkOptions += " -install_name "; + extraLinkOptions += productName; + } + else + { + // Convert to a path for the native build tool. + cmSystemTools::ConvertToUnixSlashes(install_name_dir); + install_name_dir = + this->XCodeEscapePath(install_name_dir.c_str()); + } } + buildSettings->AddAttribute("INSTALL_PATH", + this->CreateString(install_name_dir.c_str())); + + buildSettings->AddAttribute("OTHER_LDFLAGS", + this->CreateString(extraLinkOptions.c_str())); buildSettings->AddAttribute("OTHER_REZFLAGS", this->CreateString("")); buildSettings->AddAttribute("SECTORDER_FLAGS", @@ -1233,20 +1349,6 @@ this->CreateString( "-Wmost -Wno-four-char-constants" " -Wno-unknown-pragmas")); - std::string pname; - if(target.GetType() == cmTarget::SHARED_LIBRARY) - { - pname = "lib"; - } - pname += target.GetName(); - if(target.GetType() == cmTarget::EXECUTABLE - && target.GetProperty("OUTPUT_NAME") ) - { - pname = target.GetProperty("OUTPUT_NAME"); - } - - buildSettings->AddAttribute("PRODUCT_NAME", - this->CreateString(pname.c_str())); } //---------------------------------------------------------------------------- @@ -1256,7 +1358,7 @@ cmXCodeObject* shellBuildPhase = this->CreateObject(cmXCodeObject::PBXShellScriptBuildPhase); shellBuildPhase->AddAttribute("buildActionMask", - this->CreateString("2147483647")); + this->CreateString("2147483647")); cmXCodeObject* buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); shellBuildPhase->AddAttribute("files", buildFiles); cmXCodeObject* inputPaths = this->CreateObject(cmXCodeObject::OBJECT_LIST); @@ -1264,12 +1366,12 @@ cmXCodeObject* outputPaths = this->CreateObject(cmXCodeObject::OBJECT_LIST); shellBuildPhase->AddAttribute("outputPaths", outputPaths); shellBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", - this->CreateString("0")); + this->CreateString("0")); shellBuildPhase->AddAttribute("shellPath", - this->CreateString("/bin/sh")); + this->CreateString("/bin/sh")); shellBuildPhase->AddAttribute("shellScript", - this->CreateString( - "# shell script goes here\nexit 0")); + this->CreateString( + "# shell script goes here\nexit 0")); cmXCodeObject* target = this->CreateObject(cmXCodeObject::PBXAggregateTarget); target->SetComment(cmtarget.GetName()); @@ -1282,19 +1384,24 @@ std::string fileTypeString; std::string productTypeString; std::string productName; - this->CreateBuildSettings(cmtarget, - buildSettings, fileTypeString, - productTypeString, productName, 0); - if(m_XcodeVersion > 20) + const char* globalConfig = 0; + if(this->XcodeVersion > 20) { this->AddConfigurations(target, cmtarget); } + else + { + globalConfig = this->CurrentMakefile->GetDefinition("CMAKE_BUILD_TYPE"); + } + this->CreateBuildSettings(cmtarget, + buildSettings, fileTypeString, + productTypeString, productName, globalConfig); target->AddAttribute("buildSettings", buildSettings); cmXCodeObject* dependencies = this->CreateObject(cmXCodeObject::OBJECT_LIST); target->AddAttribute("dependencies", dependencies); target->AddAttribute("name", this->CreateString(productName.c_str())); target->AddAttribute("productName",this->CreateString(productName.c_str())); - target->SetcmTarget(&cmtarget); + target->SetTarget(&cmtarget); return target; } @@ -1302,7 +1409,7 @@ void cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target, cmTarget& cmtarget) { - std::string configTypes = m_CurrentMakefile->GetRequiredDefinition("CMAKE_CONFIGURATION_TYPES"); + std::string configTypes = this->CurrentMakefile->GetRequiredDefinition("CMAKE_CONFIGURATION_TYPES"); std::vector configVectorIn; std::vector configVector; configVectorIn.push_back(configTypes); @@ -1328,10 +1435,10 @@ std::string fileTypeString; std::string productTypeString; std::string productName; - std::string buildtype = cmSystemTools::UpperCase(configVector[i]); this->CreateBuildSettings(cmtarget, buildSettings, fileTypeString, - productTypeString, productName, buildtype.c_str()); + productTypeString, productName, + configVector[i].c_str()); config->AddAttribute("name", this->CreateString(configVector[i].c_str())); config->SetComment(configVector[i].c_str()); config->AddAttribute("buildSettings", buildSettings); @@ -1359,13 +1466,18 @@ std::string fileTypeString; std::string productTypeString; std::string productName; - if(m_XcodeVersion > 20) + const char* globalConfig = 0; + if(this->XcodeVersion > 20) { this->AddConfigurations(target, cmtarget); } + else + { + globalConfig = this->CurrentMakefile->GetDefinition("CMAKE_BUILD_TYPE"); + } this->CreateBuildSettings(cmtarget, buildSettings, fileTypeString, - productTypeString, productName, 0); + productTypeString, productName, globalConfig); target->AddAttribute("buildSettings", buildSettings); cmXCodeObject* dependencies = this->CreateObject(cmXCodeObject::OBJECT_LIST); target->AddAttribute("dependencies", dependencies); @@ -1384,7 +1496,7 @@ this->CreateObjectReference(fileRef)); target->AddAttribute("productType", this->CreateString(productTypeString.c_str())); - target->SetcmTarget(&cmtarget); + target->SetTarget(&cmtarget); return target; } @@ -1395,11 +1507,11 @@ { return 0; } - for(std::vector::iterator i = m_XCodeObjects.begin(); - i != m_XCodeObjects.end(); ++i) + for(std::vector::iterator i = this->XCodeObjects.begin(); + i != this->XCodeObjects.end(); ++i) { cmXCodeObject* o = *i; - if(o->GetcmTarget() == t) + if(o->GetTarget() == t) { return o; } @@ -1435,13 +1547,13 @@ this->CreateObject(cmXCodeObject::PBXContainerItemProxy); container->SetComment("PBXContainerItemProxy"); container->AddAttribute("containerPortal", - this->CreateObjectReference(m_RootObject)); + this->CreateObjectReference(this->RootObject)); container->AddAttribute("proxyType", this->CreateString("1")); container->AddAttribute("remoteGlobalIDString", this->CreateObjectReference(dependTarget)); container->AddAttribute("remoteInfo", this->CreateString( - dependTarget->GetcmTarget()->GetName())); + dependTarget->GetTarget()->GetName())); targetdep = this->CreateObject(cmXCodeObject::PBXTargetDependency); targetdep->SetComment("PBXTargetDependency"); @@ -1468,193 +1580,103 @@ //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::AppendOrAddBuildSetting(cmXCodeObject* settings, - const char* attribute, - const char* value) + const char* attribute, + const char* value) { - if(settings) - { - cmXCodeObject* attr = settings->GetObject(attribute); - if(!attr) - { - settings->AddAttribute(attribute, this->CreateString(value)); - } - else - { - std::string oldValue = attr->GetString(); - cmSystemTools::ReplaceString(oldValue, "\"", ""); - oldValue += " "; - oldValue += value; - attr->SetString(oldValue.c_str()); - } - } + if(settings) + { + cmXCodeObject* attr = settings->GetObject(attribute); + if(!attr) + { + settings->AddAttribute(attribute, this->CreateString(value)); + } + else + { + std::string oldValue = attr->GetString(); + cmSystemTools::ReplaceString(oldValue, "\"", ""); + oldValue += " "; + oldValue += value; + attr->SetString(oldValue.c_str()); + } + } } //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::AppendBuildSettingAttribute(cmXCodeObject* target, const char* attribute, - const char* value) + const char* value, + const char* configName) { - if(m_XcodeVersion < 21) + if(this->XcodeVersion < 21) { + // There is only one configuration. Add the setting to the buildSettings + // of the target. this->AppendOrAddBuildSetting(target->GetObject("buildSettings"), attribute, value); } else { + // There are multiple configurations. Add the setting to the + // buildSettings of the configuration name given. cmXCodeObject* configurationList = target->GetObject("buildConfigurationList")->GetObject(); cmXCodeObject* buildConfigs = configurationList->GetObject("buildConfigurations"); std::vector list = buildConfigs->GetObjectList(); // each configuration and the target itself has a buildSettings in it - list.push_back(target); + //list.push_back(target); for(std::vector::iterator i = list.begin(); i != list.end(); ++i) { - cmXCodeObject* settings = (*i)->GetObject("buildSettings"); - this->AppendOrAddBuildSetting(settings, attribute, value); + if(configName) + { + if(strcmp((*i)->GetObject("name")->GetString(), configName) == 0) + { + cmXCodeObject* settings = (*i)->GetObject("buildSettings"); + this->AppendOrAddBuildSetting(settings, attribute, value); + } + } + else + { + cmXCodeObject* settings = (*i)->GetObject("buildSettings"); + this->AppendOrAddBuildSetting(settings, attribute, value); + } } } } //---------------------------------------------------------------------------- -void cmGlobalXCodeGenerator::AddLinkLibrary(cmXCodeObject* target, - const char* library, - cmTarget* dtarget) -{ - if(dtarget) - { - target->AddDependLibrary(this->GetTargetFullPath(dtarget).c_str()); - } - - // if the library is not a full path then add it with a -l flag - // to the settings of the target - cmsys::RegularExpression reg("^([ \t]*\\-[lLWRB])|([ \t]*\\-framework)|(\\${)|([ \t]*\\-pthread)|([ \t]*`)"); - // if the library is not already in the form required by the compiler - // add a -l infront of the name - std::string link; - if(!reg.find(library)) - { - link += "-l"; - } - link += library; - this->AppendBuildSettingAttribute(target, "OTHER_LDFLAGS", link.c_str()); -} - -//---------------------------------------------------------------------------- -std::string cmGlobalXCodeGenerator::GetTargetFullPath(cmTarget* target) -{ - std::string libPath; - cmXCodeObject* xtarget = this->FindXCodeTarget(target); - cmXCodeObject* bset = xtarget->GetObject("buildSettings"); - cmXCodeObject* spath = bset->GetObject("SYMROOT"); - if(m_XcodeVersion > 15) - { - libPath += "$(CONFIGURATION)/"; - } - - libPath = spath->GetString(); - libPath = libPath.substr(1, libPath.size()-2); - if(target->GetType() == cmTarget::STATIC_LIBRARY) - { - libPath += "lib"; - libPath += target->GetName(); - libPath += ".a"; - } - else if(target->GetType() == cmTarget::SHARED_LIBRARY) - { - libPath += "lib"; - libPath += target->GetName(); - libPath += ".dylib"; - } - else - { - libPath += target->GetName(); - } - return libPath; -} - -//---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) { - cmTarget* cmtarget = target->GetcmTarget(); + cmTarget* cmtarget = target->GetTarget(); if(!cmtarget) { cmSystemTools::Error("Error no target on xobject\n"); return; } - // compute the correct order for link libraries - cmOrderLinkDirectories orderLibs; - std::string ext = - m_CurrentMakefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_SUFFIX"); - if(ext.size()) - { - orderLibs.AddLinkExtension(ext.c_str()); - } - ext = - m_CurrentMakefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_PREFIX"); - if(ext.size()) - { - orderLibs.SetLinkPrefix(ext.c_str()); - } - ext = - m_CurrentMakefile->GetSafeDefinition("CMAKE_SHARED_LIBRARY_SUFFIX"); - if(ext.size()) - { - orderLibs.AddLinkExtension(ext.c_str()); - } - ext = - m_CurrentMakefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_SUFFIX"); - if(ext.size()) - { - orderLibs.AddLinkExtension(ext.c_str()); - } - const char* targetLibrary = cmtarget->GetName(); - if(cmtarget->GetType() == cmTarget::EXECUTABLE) - { - targetLibrary = 0; - } - orderLibs.SetLinkInformation(*cmtarget, cmTarget::GENERAL, targetLibrary); - orderLibs.DetermineLibraryPathOrder(); - std::vector libdirs; - std::vector linkItems; - orderLibs.GetLinkerInformation(libdirs, linkItems); - std::string linkDirs; - // add the library search paths - for(std::vector::const_iterator libDir = libdirs.begin(); - libDir != libdirs.end(); ++libDir) - { - if(libDir->size() && *libDir != "/usr/lib") - { - if(m_XcodeVersion > 15) - { - // now add the same one but append $(CONFIGURATION) to it: - linkDirs += " "; - linkDirs += this->XCodeEscapePath(libDir->c_str()); - linkDirs += "/$(CONFIGURATION)"; - } - linkDirs += " "; - linkDirs += this->XCodeEscapePath(libDir->c_str()); - } - } - this->AppendBuildSettingAttribute(target, "LIBRARY_SEARCH_PATHS", linkDirs.c_str()); - // now add the link libraries - for(std::vector::iterator lib = linkItems.begin(); - lib != linkItems.end(); ++lib) + + // Add dependencies on other CMake targets. + if(cmtarget->GetType() != cmTarget::STATIC_LIBRARY) { - cmTarget* t = this->FindTarget(m_CurrentProject.c_str(), - lib->c_str()); - cmXCodeObject* dptarget = this->FindXCodeTarget(t); - if(dptarget) - { - this->AddDependTarget(target, dptarget); - if(cmtarget->GetType() != cmTarget::STATIC_LIBRARY) - { - this->AddLinkLibrary(target, t->GetName(), t); - } - } - else - { - if(cmtarget->GetType() != cmTarget::STATIC_LIBRARY) - { - this->AddLinkLibrary(target, lib->c_str()); + // Keep track of dependencies already listed. + std::set emitted; + + // A target should not depend on itself. + emitted.insert(cmtarget->GetName()); + + // Loop over all library dependencies. + const cmTarget::LinkLibraryVectorType& tlibs = cmtarget->GetLinkLibraries(); + for(cmTarget::LinkLibraryVectorType::const_iterator lib = tlibs.begin(); + lib != tlibs.end(); ++lib) + { + // Don't emit the same library twice for this target. + if(emitted.insert(lib->first).second) + { + // Add this dependency. + cmTarget* t = this->FindTarget(this->CurrentProject.c_str(), + lib->first.c_str()); + cmXCodeObject* dptarget = this->FindXCodeTarget(t); + if(dptarget) + { + this->AddDependTarget(target, dptarget); + } } } } @@ -1664,7 +1686,7 @@ = cmtarget->GetUtilities().begin(); i != cmtarget->GetUtilities().end(); ++i) { - cmTarget* t = this->FindTarget(m_CurrentProject.c_str(), + cmTarget* t = this->FindTarget(this->CurrentProject.c_str(), i->c_str()); // if the target is in this project then make target depend // on it. It may not be in this project if this is a sub @@ -1692,17 +1714,69 @@ m += "\n"; m += "But it has no xcode target created yet??\n"; m += "Current project is "; - m += m_CurrentProject.c_str(); + m += this->CurrentProject.c_str(); cmSystemTools::Error(m.c_str()); } } } - std::vector fullPathLibs; - orderLibs.GetFullPathLibraries(fullPathLibs); - for(std::vector::iterator i = fullPathLibs.begin(); - i != fullPathLibs.end(); ++i) + + // Loop over configuration types and set per-configuration info. + for(std::vector::iterator i = + this->CurrentConfigurationTypes.begin(); + i != this->CurrentConfigurationTypes.end(); ++i) { - target->AddDependLibrary(i->c_str()); + // Get the current configuration name. + const char* configName = i->c_str(); + if(!*configName) + { + configName = 0; + } + + // Compute the link library and directory information. + std::vector libNames; + std::vector libDirs; + std::vector fullPathLibs; + this->CurrentLocalGenerator->ComputeLinkInformation(*cmtarget, configName, + libNames, libDirs, + &fullPathLibs); + + // Add dependencies directly on library files. + for(std::vector::iterator j = fullPathLibs.begin(); + j != fullPathLibs.end(); ++j) + { + target->AddDependLibrary(configName, j->c_str()); + } + + std::string linkDirs; + // add the library search paths + for(std::vector::const_iterator libDir = libDirs.begin(); + libDir != libDirs.end(); ++libDir) + { + if(libDir->size() && *libDir != "/usr/lib") + { + if(this->XcodeVersion > 15) + { + // now add the same one but append $(CONFIGURATION) to it: + linkDirs += " "; + linkDirs += this->XCodeEscapePath(libDir->c_str()); + linkDirs += "/$(CONFIGURATION)"; + } + linkDirs += " "; + linkDirs += this->XCodeEscapePath(libDir->c_str()); + } + } + this->AppendBuildSettingAttribute(target, "LIBRARY_SEARCH_PATHS", + linkDirs.c_str(), configName); + // now add the link libraries + if(cmtarget->GetType() != cmTarget::STATIC_LIBRARY) + { + for(std::vector::iterator lib = libNames.begin(); + lib != libNames.end(); ++lib) + { + this->AppendBuildSettingAttribute(target, "OTHER_LDFLAGS", + lib->c_str(), configName); + } + } } } @@ -1724,6 +1798,17 @@ for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { cmTarget& cmtarget = l->second; + // add the soon to be generated Info.plist file as a source for a MACOSX_BUNDLE + // file + if(cmtarget.GetPropertyAsBool("MACOSX_BUNDLE")) + { + cmSourceFile file; + file.SetName("Info", + this->CurrentMakefile->GetCurrentOutputDirectory(), + "plist", false); + cmtarget.GetSourceFiles().push_back(this->CurrentMakefile->AddSource(file)); + } + std::vector & classes = cmtarget.GetSourceFiles(); for(std::vector::const_iterator s = classes.begin(); s != classes.end(); s++) @@ -1734,7 +1819,7 @@ cmSourceGroup& sourceGroup = mf->FindSourceGroup(source.c_str(), sourceGroups); cmXCodeObject* pbxgroup = this->CreateOrGetPBXGroup(cmtarget, &sourceGroup); - m_GroupMap[sf] = pbxgroup; + this->GroupMap[sf] = pbxgroup; } } } @@ -1746,31 +1831,31 @@ cmStdString s = cmtarget.GetName(); s += "/"; s += sg->GetName(); - std::map::iterator i = m_GroupNameMap.find(s); - if(i != m_GroupNameMap.end()) + std::map::iterator i = this->GroupNameMap.find(s); + if(i != this->GroupNameMap.end()) { return i->second; } - i = m_TargetGroup.find(cmtarget.GetName()); + i = this->TargetGroup.find(cmtarget.GetName()); cmXCodeObject* tgroup = 0; - if(i != m_TargetGroup.end()) + if(i != this->TargetGroup.end()) { tgroup = i->second; } else { tgroup = this->CreateObject(cmXCodeObject::PBXGroup); - m_TargetGroup[cmtarget.GetName()] = tgroup; + this->TargetGroup[cmtarget.GetName()] = tgroup; cmXCodeObject* tgroupChildren = this->CreateObject(cmXCodeObject::OBJECT_LIST); tgroup->AddAttribute("name", this->CreateString(cmtarget.GetName())); tgroup->AddAttribute("children", tgroupChildren); - if(m_XcodeVersion == 15) + if(this->XcodeVersion == 15) { - tgroup->AddAttribute("refType", this->CreateString("4")); + tgroup->AddAttribute("refType", this->CreateString("4")); } tgroup->AddAttribute("sourceTree", this->CreateString("")); - m_SourcesGroupChildren->AddObject(tgroup); + this->SourcesGroupChildren->AddObject(tgroup); } cmXCodeObject* tgroupChildren = tgroup->GetObject("children"); @@ -1779,13 +1864,13 @@ this->CreateObject(cmXCodeObject::OBJECT_LIST); group->AddAttribute("name", this->CreateString(sg->GetName())); group->AddAttribute("children", groupChildren); - if(m_XcodeVersion == 15) + if(this->XcodeVersion == 15) { - group->AddAttribute("refType", this->CreateString("4")); + group->AddAttribute("refType", this->CreateString("4")); } group->AddAttribute("sourceTree", this->CreateString("")); tgroupChildren->AddObject(group); - m_GroupNameMap[s] = group; + this->GroupNameMap[s] = group; return group; } @@ -1796,16 +1881,16 @@ ) { this->ClearXCodeObjects(); - m_RootObject = 0; - m_SourcesGroupChildren = 0; - m_MainGroupChildren = 0; + this->RootObject = 0; + this->SourcesGroupChildren = 0; + this->MainGroupChildren = 0; cmXCodeObject* group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); group->AddAttribute("COPY_PHASE_STRIP", this->CreateString("NO")); cmXCodeObject* developBuildStyle = this->CreateObject(cmXCodeObject::PBXBuildStyle); - if(m_XcodeVersion == 15) + if(this->XcodeVersion == 15) { - developBuildStyle->AddAttribute("name", this->CreateString("Development")); + developBuildStyle->AddAttribute("name", this->CreateString("Development")); } else { @@ -1818,9 +1903,9 @@ group->AddAttribute("COPY_PHASE_STRIP", this->CreateString("YES")); cmXCodeObject* deployBuildStyle = this->CreateObject(cmXCodeObject::PBXBuildStyle); - if(m_XcodeVersion == 15) + if(this->XcodeVersion == 15) { - deployBuildStyle->AddAttribute("name", this->CreateString("Deployment")); + deployBuildStyle->AddAttribute("name", this->CreateString("Deployment")); } else { @@ -1834,50 +1919,50 @@ listObjs->AddObject(developBuildStyle); listObjs->AddObject(deployBuildStyle); cmXCodeObject* mainGroup = this->CreateObject(cmXCodeObject::PBXGroup); - m_MainGroupChildren = + this->MainGroupChildren = this->CreateObject(cmXCodeObject::OBJECT_LIST); - mainGroup->AddAttribute("children", m_MainGroupChildren); - if(m_XcodeVersion == 15) + mainGroup->AddAttribute("children", this->MainGroupChildren); + if(this->XcodeVersion == 15) { - mainGroup->AddAttribute("refType", this->CreateString("4")); + mainGroup->AddAttribute("refType", this->CreateString("4")); } mainGroup->AddAttribute("sourceTree", this->CreateString("")); cmXCodeObject* sourcesGroup = this->CreateObject(cmXCodeObject::PBXGroup); - m_SourcesGroupChildren = + this->SourcesGroupChildren = this->CreateObject(cmXCodeObject::OBJECT_LIST); sourcesGroup->AddAttribute("name", this->CreateString("Sources")); - sourcesGroup->AddAttribute("children", m_SourcesGroupChildren); - if(m_XcodeVersion == 15) + sourcesGroup->AddAttribute("children", this->SourcesGroupChildren); + if(this->XcodeVersion == 15) { - sourcesGroup->AddAttribute("refType", this->CreateString("4")); + sourcesGroup->AddAttribute("refType", this->CreateString("4")); } sourcesGroup->AddAttribute("sourceTree", this->CreateString("")); - m_MainGroupChildren->AddObject(sourcesGroup); + this->MainGroupChildren->AddObject(sourcesGroup); // now create the cmake groups this->CreateGroups(root, generators); cmXCodeObject* productGroup = this->CreateObject(cmXCodeObject::PBXGroup); productGroup->AddAttribute("name", this->CreateString("Products")); - if(m_XcodeVersion == 15) + if(this->XcodeVersion == 15) { - productGroup->AddAttribute("refType", this->CreateString("4")); + productGroup->AddAttribute("refType", this->CreateString("4")); } productGroup->AddAttribute("sourceTree", this->CreateString("")); cmXCodeObject* productGroupChildren = this->CreateObject(cmXCodeObject::OBJECT_LIST); productGroup->AddAttribute("children", productGroupChildren); - m_MainGroupChildren->AddObject(productGroup); + this->MainGroupChildren->AddObject(productGroup); - m_RootObject = this->CreateObject(cmXCodeObject::PBXProject); - m_RootObject->SetComment("Project object"); + this->RootObject = this->CreateObject(cmXCodeObject::PBXProject); + this->RootObject->SetComment("Project object"); group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); - m_RootObject->AddAttribute("mainGroup", + this->RootObject->AddAttribute("mainGroup", this->CreateObjectReference(mainGroup)); - m_RootObject->AddAttribute("buildSettings", group); - m_RootObject->AddAttribute("buildStyles", listObjs); - m_RootObject->AddAttribute("hasScannedForEncodings", + this->RootObject->AddAttribute("buildSettings", group); + this->RootObject->AddAttribute("buildStyles", listObjs); + this->RootObject->AddAttribute("hasScannedForEncodings", this->CreateString("0")); cmXCodeObject* configlist = this->CreateObject(cmXCodeObject::XCConfigurationList); cmXCodeObject* configDebug = this->CreateObject(cmXCodeObject::XCBuildConfiguration); @@ -1889,7 +1974,7 @@ configlist->AddAttribute("buildConfigurations", buildConfigurations); std::string comment = "Build configuration list for PBXProject "; comment += " \""; - comment += m_CurrentProject; + comment += this->CurrentProject; comment += "\""; configlist->SetComment(comment.c_str()); configlist->AddAttribute("defaultConfigurationIsVisible", this->CreateString("0")); @@ -1901,8 +1986,8 @@ configRelease->AddAttribute("name", this->CreateString("Release")); configRelease->AddAttribute("buildSettings", buildSettings); - m_RootObject->AddAttribute("buildConfigurationList", - this->CreateObjectReference(configlist)); + this->RootObject->AddAttribute("buildConfigurationList", + this->CreateObjectReference(configlist)); std::vector targets; for(std::vector::iterator i = generators.begin(); @@ -1935,7 +2020,7 @@ productGroupChildren->AddObject(productRef->GetObject()); } } - m_RootObject->AddAttribute("targets", allTargets); + this->RootObject->AddAttribute("targets", allTargets); } @@ -1944,36 +2029,53 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( std::vector& targets) { - cmGeneratedFileStream makefileStream(m_CurrentXCodeHackMakefile.c_str()); + cmGeneratedFileStream makefileStream(this->CurrentXCodeHackMakefile.c_str()); if(!makefileStream) { cmSystemTools::Error("Could not create", - m_CurrentXCodeHackMakefile.c_str()); + this->CurrentXCodeHackMakefile.c_str()); return; } - + makefileStream.SetCopyIfDifferent(true); // one more pass for external depend information not handled // correctly by xcode makefileStream << "# DO NOT EDIT\n"; makefileStream << "# This makefile makes sure all linkable targets are \n"; makefileStream << "# up-to-date with anything they link to,avoiding a bug in XCode 1.5\n"; - makefileStream << "all: "; - for(std::vector::iterator i = targets.begin(); - i != targets.end(); ++i) + for(std::vector::const_iterator + ct = this->CurrentConfigurationTypes.begin(); + ct != this->CurrentConfigurationTypes.end(); ++ct) { - cmXCodeObject* target = *i; - cmTarget* t =target->GetcmTarget(); - if(t->GetType() == cmTarget::EXECUTABLE || - t->GetType() == cmTarget::SHARED_LIBRARY || - t->GetType() == cmTarget::MODULE_LIBRARY) + if(this->XcodeVersion < 21 || ct->empty()) + { + makefileStream << "all: "; + } + else + { + makefileStream << "all." << *ct << ": "; + } + const char* configName = 0; + if(!ct->empty()) { - makefileStream << "\\\n\t" - << this-> - ConvertToRelativeForMake(this->GetTargetFullPath(target->GetcmTarget()).c_str()); + configName = ct->c_str(); } + for(std::vector::iterator i = targets.begin(); + i != targets.end(); ++i) + { + cmXCodeObject* target = *i; + cmTarget* t =target->GetTarget(); + if(t->GetType() == cmTarget::EXECUTABLE || + t->GetType() == cmTarget::SHARED_LIBRARY || + t->GetType() == cmTarget::MODULE_LIBRARY) + { + makefileStream << "\\\n\t" << + this->ConvertToRelativeForMake( + t->GetFullPath(configName).c_str()); + } + } + makefileStream << "\n\n"; } - makefileStream << "\n\n"; makefileStream << "# For each target create a dummy rule " "so the target does not have to exist\n"; @@ -1982,43 +2084,72 @@ i != targets.end(); ++i) { cmXCodeObject* target = *i; - std::vector const& deplibs = target->GetDependLibraries(); - for(std::vector::const_iterator d = deplibs.begin(); - d != deplibs.end(); ++d) + std::map const& deplibs = + target->GetDependLibraries(); + for(std::map::const_iterator ci = deplibs.begin(); + ci != deplibs.end(); ++ci) { - if(emitted.insert(*d).second) + for(cmXCodeObject::StringVec::const_iterator d = ci->second.begin(); + d != ci->second.end(); ++d) { - makefileStream << this->ConvertToRelativeForMake(d->c_str()) << ":\n"; + if(emitted.insert(*d).second) + { + makefileStream << + this->ConvertToRelativeForMake(d->c_str()) << ":\n"; + } } } } makefileStream << "\n\n"; + + // Write rules to help Xcode relink things at the right time. makefileStream << - "# Each linkable target depends on everything it links to.\n"; - makefileStream - << "#And the target is removed if it is older than what it linkes to\n"; - - for(std::vector::iterator i = targets.begin(); - i != targets.end(); ++i) - { - cmXCodeObject* target = *i; - cmTarget* t =target->GetcmTarget(); - if(t->GetType() == cmTarget::EXECUTABLE || - t->GetType() == cmTarget::SHARED_LIBRARY || - t->GetType() == cmTarget::MODULE_LIBRARY) - { - std::vector const& deplibs = target->GetDependLibraries(); - std::string tfull = this->GetTargetFullPath(target->GetcmTarget()); - makefileStream << this->ConvertToRelativeForMake(tfull.c_str()) << ": "; - for(std::vector::const_iterator d = deplibs.begin(); - d != deplibs.end(); ++d) - { - makefileStream << "\\\n\t" << this->ConvertToRelativeForMake(d->c_str()); + "# Rules to remove targets that are older than anything to which they\n" + "# link. This forces Xcode to relink the targets from scratch. It\n" + "# does not seem to check these dependencies itself.\n"; + for(std::vector::const_iterator + ct = this->CurrentConfigurationTypes.begin(); + ct != this->CurrentConfigurationTypes.end(); ++ct) + { + const char* configName = 0; + if(!ct->empty()) + { + configName = ct->c_str(); + } + for(std::vector::iterator i = targets.begin(); + i != targets.end(); ++i) + { + cmXCodeObject* target = *i; + cmTarget* t =target->GetTarget(); + if(t->GetType() == cmTarget::EXECUTABLE || + t->GetType() == cmTarget::SHARED_LIBRARY || + t->GetType() == cmTarget::MODULE_LIBRARY) + { + // Create a rule for this target. + std::string tfull = t->GetFullPath(configName); + makefileStream << this->ConvertToRelativeForMake(tfull.c_str()) << ":"; + + // List dependencies if any exist. + std::map::const_iterator + x = target->GetDependLibraries().find(*ct); + if(x != target->GetDependLibraries().end()) + { + std::vector const& deplibs = x->second; + for(std::vector::const_iterator d = deplibs.begin(); + d != deplibs.end(); ++d) + { + makefileStream << "\\\n\t" << + this->ConvertToRelativeForMake(d->c_str()); + } + } + + // Write the action to remove the target if it is out of date. + makefileStream << "\n"; + makefileStream << "\t/bin/rm -f " + << this->ConvertToRelativeForMake(tfull.c_str()) + << "\n"; + makefileStream << "\n\n"; } - makefileStream << "\n"; - makefileStream << "\t/bin/rm -f " - << this->ConvertToRelativeForMake(tfull.c_str()) << "\n"; - makefileStream << "\n\n"; } } } @@ -2033,13 +2164,85 @@ { return; } +#if 1 + // TODO: This block should be moved to a central location for all + // generators. It is duplicated in every generator. + for(std::vector::iterator g = generators.begin(); + g != generators.end(); ++g) + { + if(this->IsExcluded(root, *g)) + { + continue; + } + cmMakefile* mf = (*g)->GetMakefile(); + std::vector sourceGroups = mf->GetSourceGroups(); + cmTargets &tgts = mf->GetTargets(); + // Call TraceVSDependencies on all targets + for(cmTargets::iterator l = tgts.begin(); + l != tgts.end(); l++) + { + // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace + // so don't build a projectfile for it + if ((l->second.GetType() != cmTarget::INSTALL_FILES) + && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS) + && (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0)) + { + cmTarget& target = l->second; + target.TraceVSDependencies(target.GetName(), mf); + } + } + // now for all custom commands that are not used directly in a + // target, add them to all targets in the current directory or + // makefile + std::set banned; + banned.insert("ALL_BUILD"); + banned.insert("XCODE_DEPEND_HELPER"); + banned.insert("install"); + std::vector & classesmf = mf->GetSourceFiles(); + for(std::vector::const_iterator i = classesmf.begin(); + i != classesmf.end(); i++) + { + if(cmCustomCommand* cc = (*i)->GetCustomCommand()) + { + if(!cc->IsUsed()) + { + for(cmTargets::iterator l = tgts.begin(); + l != tgts.end(); l++) + { + if ((l->second.GetType() != cmTarget::INSTALL_FILES) + && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS) + && (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0) + && banned.find(l->second.GetName()) == banned.end()) + { + cmTarget& target = l->second; + bool sameAsTarget = false; + // make sure we don't add a custom command that depends on + // this target + for(unsigned int k =0; k < cc->GetDepends().size(); k++) + { + if(cmSystemTools::GetFilenameName(cc->GetDepends()[k]) == target.GetFullName()) + { + sameAsTarget = true; + } + } + if(!sameAsTarget) + { + target.GetSourceFiles().push_back(*i); + } + } + } + } + } + } + } +#endif this->CreateXCodeObjects(root, generators); std::string xcodeDir = root->GetMakefile()->GetStartOutputDirectory(); xcodeDir += "/"; xcodeDir += root->GetMakefile()->GetProjectName(); xcodeDir += ".xcode"; - if(m_XcodeVersion > 20) + if(this->XcodeVersion > 20) { xcodeDir += "proj"; } @@ -2071,9 +2274,9 @@ fout << "};\n"; cmXCodeObject::Indent(1, fout); fout << "objectVersion = 39;\n"; - cmXCodeObject::PrintList(m_XCodeObjects, fout); + cmXCodeObject::PrintList(this->XCodeObjects, fout); cmXCodeObject::Indent(1, fout); - fout << "rootObject = " << m_RootObject->GetId() << ";\n"; + fout << "rootObject = " << this->RootObject->GetId() << ";\n"; fout << "}\n"; } @@ -2089,14 +2292,14 @@ //---------------------------------------------------------------------------- std::string cmGlobalXCodeGenerator::ConvertToRelativeForMake(const char* p) { - if ( !m_CurrentMakefile->IsOn("CMAKE_USE_RELATIVE_PATHS") ) + if ( !this->CurrentMakefile->IsOn("CMAKE_USE_RELATIVE_PATHS") ) { return cmSystemTools::ConvertToOutputPath(p); } else { std::string ret = - this->ConvertToRelativePath(m_CurrentOutputDirectoryComponents, p); + this->ConvertToRelativePath(this->CurrentOutputDirectoryComponents, p); return cmSystemTools::ConvertToOutputPath(ret.c_str()); } } @@ -2104,14 +2307,14 @@ //---------------------------------------------------------------------------- std::string cmGlobalXCodeGenerator::ConvertToRelativeForXCode(const char* p) { - if ( !m_CurrentMakefile->IsOn("CMAKE_USE_RELATIVE_PATHS") ) + if ( !this->CurrentMakefile->IsOn("CMAKE_USE_RELATIVE_PATHS") ) { return cmSystemTools::ConvertToOutputPath(p); } else { std::string ret = - this->ConvertToRelativePath(m_ProjectOutputDirectoryComponents, p); + this->ConvertToRelativePath(this->ProjectOutputDirectoryComponents, p); return cmSystemTools::ConvertToOutputPath(ret.c_str()); } } @@ -2128,3 +2331,45 @@ } return ret; } + +//---------------------------------------------------------------------------- +void +cmGlobalXCodeGenerator +::AppendDirectoryForConfig(const char* prefix, + const char* config, + const char* suffix, + std::string& dir) +{ + if(this->XcodeVersion > 20) + { + if(config) + { + dir += prefix; + dir += config; + dir += suffix; + } + } +} + +//---------------------------------------------------------------------------- +std::string cmGlobalXCodeGenerator::LookupFlags(const char* varNamePrefix, + const char* varNameLang, + const char* varNameSuffix, + const char* default_flags) +{ + if(varNameLang) + { + std::string varName = varNamePrefix; + varName += varNameLang; + varName += varNameSuffix; + if(const char* varValue = + this->CurrentMakefile->GetDefinition(varName.c_str())) + { + if(*varValue) + { + return varValue; + } + } + } + return default_flags; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalXCodeGenerator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalXCodeGenerator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlobalXCodeGenerator.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlobalXCodeGenerator.h 2006-03-16 00:02:03.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalXCodeGenerator.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.24.2.4 $ + Date: $Date: 2006/03/15 16:02:03 $ + Version: $Revision: 1.40 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -35,8 +35,8 @@ public: cmGlobalXCodeGenerator(); static cmGlobalGenerator* New(); - - void SetVersion(int v) { m_XcodeVersion = v;} + + void SetVersion(int v) { this->XcodeVersion = v;} ///! Get the name for the generator. virtual const char* GetName() const { return cmGlobalXCodeGenerator::GetActualName();} @@ -59,8 +59,11 @@ * loaded commands, not as part of the usual build process. */ virtual std::string GenerateBuildCommand(const char* makeProgram, - const char *projectName, const char *targetName, const char* config, - bool ignoreErrors); + const char *projectName, + const char* additionalOptions, + const char *targetName, + const char* config, + bool ignoreErrors); /** * Generate the all required files for building this project/tree. This @@ -69,6 +72,15 @@ */ virtual void Generate(); + /** Append the subdirectory for the given configuration. */ + virtual void AppendDirectoryForConfig(const char* prefix, + const char* config, + const char* suffix, + std::string& dir); + + ///! What is the configurations directory variable called? + virtual const char* GetCMakeCFGInitDirectory() { return "."; } + private: cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget, cmSourceGroup* sg); @@ -92,7 +104,7 @@ const char* commandFileName); cmXCodeObject* FindXCodeTarget(cmTarget*); // create cmXCodeObject from these functions so that memory can be managed - // correctly. All objects created are stored in m_XCodeObjects. + // correctly. All objects created are stored in this->XCodeObjects. cmXCodeObject* CreateObject(cmXCodeObject::PBXType ptype); cmXCodeObject* CreateObject(cmXCodeObject::Type type); cmXCodeObject* CreateString(const char* s); @@ -104,7 +116,7 @@ void AppendOrAddBuildSetting(cmXCodeObject* settings, const char* attr, const char* value); void AppendBuildSettingAttribute(cmXCodeObject* target, const char* attr, - const char* value); + const char* value, const char* configName); cmXCodeObject* CreateUtilityTarget(cmTarget& target); void AddDependAndLinkInformation(cmXCodeObject* target); void CreateBuildSettings(cmTarget& target, @@ -114,25 +126,23 @@ std::string& projectName, const char* buildType); std::string ExtractFlag(const char* flag, std::string& flags); - // delete all objects in the m_XCodeObjects vector. + // delete all objects in the this->XCodeObjects vector. void ClearXCodeObjects(); void CreateXCodeObjects(cmLocalGenerator* root, std::vector& generators); void OutputXCodeProject(cmLocalGenerator* root, std::vector& generators); virtual void WriteXCodePBXProj(std::ostream& fout, - cmLocalGenerator* root, - std::vector& generators); + cmLocalGenerator* root, + std::vector& generators); cmXCodeObject* CreateXCodeSourceFile(cmLocalGenerator* gen, - cmSourceFile* sf); + cmSourceFile* sf, + cmTarget& cmtarget); void CreateXCodeTargets(cmLocalGenerator* gen, std::vector&); void AddDependTarget(cmXCodeObject* target, cmXCodeObject* dependTarget); - void AddLinkLibrary(cmXCodeObject* target, - const char* lib, cmTarget* dtarget = 0); void ConfigureOutputPaths(); void CreateXCodeDependHackTarget(std::vector& targets); - std::string GetTargetFullPath(cmTarget*); bool SpecialTargetEmitted(std::string const& tname); void AddExtraTargets(cmLocalGenerator* root, std::vector& gens); @@ -141,27 +151,36 @@ cmTarget& cmtarget, const std::vector&); void CreateReRunCMakeFile(cmLocalGenerator* root); + + std::string LookupFlags(const char* varNamePrefix, + const char* varNameLang, + const char* varNameSuffix, + const char* default_flags); protected: - int m_XcodeVersion; - std::vector m_XCodeObjects; - cmXCodeObject* m_RootObject; + virtual const char* GetInstallTargetName() { return "install"; } + virtual const char* GetPackageTargetName() { return "package"; } + + int XcodeVersion; + std::vector XCodeObjects; + cmXCodeObject* RootObject; private: - cmXCodeObject* m_MainGroupChildren; - cmXCodeObject* m_SourcesGroupChildren; - cmMakefile* m_CurrentMakefile; - cmLocalGenerator* m_CurrentLocalGenerator; - std::string m_CurrentReRunCMakeMakefile; - std::string m_CurrentXCodeHackMakefile; - std::string m_CurrentProject; - std::string m_OutputDir; - std::string m_LibraryOutputPath; - std::string m_ExecutableOutputPath; - std::set m_TargetDoneSet; - std::vector m_CurrentOutputDirectoryComponents; - std::vector m_ProjectOutputDirectoryComponents; - std::map m_GroupMap; - std::map m_GroupNameMap; - std::map m_TargetGroup; + cmXCodeObject* MainGroupChildren; + cmXCodeObject* SourcesGroupChildren; + cmMakefile* CurrentMakefile; + cmLocalGenerator* CurrentLocalGenerator; + std::vector CurrentConfigurationTypes; + std::string CurrentReRunCMakeMakefile; + std::string CurrentXCodeHackMakefile; + std::string CurrentProject; + std::string OutputDir; + std::string LibraryOutputPath; + std::string ExecutableOutputPath; + std::set TargetDoneSet; + std::vector CurrentOutputDirectoryComponents; + std::vector ProjectOutputDirectoryComponents; + std::map GroupMap; + std::map GroupNameMap; + std::map TargetGroup; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlob.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlob.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlob.cxx 2004-09-16 02:08:09.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlob.cxx 2006-03-16 00:02:02.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlob.cxx,v $ Language: C++ - Date: $Date: 2004/09/15 18:08:09 $ - Version: $Revision: 1.14 $ + Date: $Date: 2006/03/15 16:02:02 $ + Version: $Revision: 1.15 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -42,13 +42,13 @@ cmGlob::cmGlob() { - m_Internals = new cmGlobInternal; - m_Recurse = false; + this->Internals = new cmGlobInternal; + this->Recurse = false; } cmGlob::~cmGlob() { - delete m_Internals; + delete this->Internals; } void cmGlob::Escape(int ch, char* buffer) @@ -73,7 +73,7 @@ std::vector& cmGlob::GetFiles() { - return m_Internals->Files; + return this->Internals->Files; } std::string cmGlob::ConvertExpression(const std::string& expr) @@ -200,9 +200,9 @@ if ( !dir_only || !cmsys::SystemTools::FileIsDirectory(realname.c_str()) ) { - if ( m_Internals->Expressions[m_Internals->Expressions.size()-1].find(fname.c_str()) ) + if ( this->Internals->Expressions[this->Internals->Expressions.size()-1].find(fname.c_str()) ) { - m_Internals->Files.push_back(realname); + this->Internals->Files.push_back(realname); } } if ( cmsys::SystemTools::FileIsDirectory(realname.c_str()) ) @@ -216,8 +216,8 @@ const std::string& dir, bool dir_only) { //std::cout << "ProcessDirectory: " << dir << std::endl; - bool last = ( start == m_Internals->Expressions.size()-1 ); - if ( last && m_Recurse ) + bool last = ( start == this->Internals->Expressions.size()-1 ); + if ( last && this->Recurse ) { this->RecurseDirectory(start, dir, dir_only); return; @@ -264,7 +264,7 @@ } //std::cout << "Look at file: " << fname << std::endl; - //std::cout << "Match: " << m_Internals->TextExpressions[start].c_str() << std::endl; + //std::cout << "Match: " << this->Internals->TextExpressions[start].c_str() << std::endl; //std::cout << "Full name: " << fullname << std::endl; if ( (!dir_only || !last) && !cmsys::SystemTools::FileIsDirectory(realname.c_str()) ) @@ -272,11 +272,11 @@ continue; } - if ( m_Internals->Expressions[start].find(fname.c_str()) ) + if ( this->Internals->Expressions[start].find(fname.c_str()) ) { if ( last ) { - m_Internals->Files.push_back(realname); + this->Internals->Files.push_back(realname); } else { @@ -292,8 +292,8 @@ std::string::size_type cc; std::string expr = inexpr; - m_Internals->Expressions.clear(); - m_Internals->Files.clear(); + this->Internals->Expressions.clear(); + this->Internals->Files.clear(); if ( !cmsys::SystemTools::FileIsFullPath(expr.c_str()) ) { @@ -393,9 +393,9 @@ void cmGlob::AddExpression(const char* expr) { - m_Internals->Expressions.push_back( + this->Internals->Expressions.push_back( cmsys::RegularExpression( this->ConvertExpression(expr).c_str())); - m_Internals->TextExpressions.push_back(this->ConvertExpression(expr)); + this->Internals->TextExpressions.push_back(this->ConvertExpression(expr)); } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlob.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlob.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmGlob.h 2004-09-16 02:08:09.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmGlob.h 2006-03-16 00:02:02.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlob.h,v $ Language: C++ - Date: $Date: 2004/09/15 18:08:09 $ - Version: $Revision: 1.3 $ + Date: $Date: 2006/03/15 16:02:02 $ + Version: $Revision: 1.4 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -41,8 +41,8 @@ //! Set recurse to true to match subdirectories. void RecurseOn() { this->SetRecurse(true); } void RecurseOff() { this->SetRecurse(false); } - void SetRecurse(bool i) { m_Recurse = i; } - bool GetRecurse() { return m_Recurse; } + void SetRecurse(bool i) { this->Recurse = i; } + bool GetRecurse() { return this->Recurse; } protected: //! Process directory @@ -65,8 +65,8 @@ //! Add regular expression void AddExpression(const char* expr); - cmGlobInternal* m_Internals; - bool m_Recurse; + cmGlobInternal* Internals; + bool Recurse; }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmIfCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmIfCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmIfCommand.cxx 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmIfCommand.cxx 2006-03-16 00:02:03.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmIfCommand.cxx,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.55.2.1 $ + Date: $Date: 2006/03/15 16:02:03 $ + Version: $Revision: 1.60 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -22,25 +22,25 @@ bool cmIfFunctionBlocker:: IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf) { - const char* name = lff.m_Name.c_str(); - const std::vector& args = lff.m_Arguments; + const char* name = lff.Name.c_str(); + const std::vector& args = lff.Arguments; // always let if statements through - if (cmSystemTools::LowerCase(lff.m_Name) == "if") + if (cmSystemTools::LowerCase(lff.Name) == "if") { return false; } // watch for our ELSE or ENDIF - if (cmSystemTools::LowerCase(lff.m_Name) == "else" || - cmSystemTools::LowerCase(lff.m_Name) == "endif") + if (cmSystemTools::LowerCase(lff.Name) == "else" || + cmSystemTools::LowerCase(lff.Name) == "endif") { - if (args == m_Args) + if (args == this->Args) { // if it was an else statement then we should change state // and block this Else Command - if (cmSystemTools::LowerCase(lff.m_Name) == "else") + if (cmSystemTools::LowerCase(lff.Name) == "else") { - m_IsBlocking = !m_IsBlocking; + this->IsBlocking = !this->IsBlocking; return true; } // otherwise it must be an ENDIF statement, in that case remove the @@ -55,8 +55,8 @@ err += ". Did you mean "; err += name; err += "( "; - for(std::vector::const_iterator a = m_Args.begin(); - a != m_Args.end();++a) + for(std::vector::const_iterator a = this->Args.begin(); + a != this->Args.end();++a) { err += (a->Quoted?"\"":""); err += a->Value; @@ -67,15 +67,15 @@ cmSystemTools::Error(err.c_str()); } } - return m_IsBlocking; + return this->IsBlocking; } bool cmIfFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, cmMakefile&) { - if (cmSystemTools::LowerCase(lff.m_Name) == "endif") + if (cmSystemTools::LowerCase(lff.Name) == "endif") { - if (lff.m_Arguments == m_Args) + if (lff.Arguments == this->Args) { return true; } @@ -89,8 +89,8 @@ std::string errmsg = "The end of a CMakeLists file was reached with an IF statement that was not closed properly.\nWithin the directory: "; errmsg += mf.GetCurrentDirectory(); errmsg += "\nThe arguments are: "; - for(std::vector::const_iterator j = m_Args.begin(); - j != m_Args.end(); ++j) + for(std::vector::const_iterator j = this->Args.begin(); + j != this->Args.end(); ++j) { errmsg += (j->Quoted?"\"":""); errmsg += j->Value; @@ -105,8 +105,8 @@ char* errorString = 0; std::vector expandedArguments; - m_Makefile->ExpandArguments(args, expandedArguments); - bool isTrue = cmIfCommand::IsTrue(expandedArguments,&errorString,m_Makefile); + this->Makefile->ExpandArguments(args, expandedArguments); + bool isTrue = cmIfCommand::IsTrue(expandedArguments,&errorString,this->Makefile); if (errorString) { @@ -129,9 +129,9 @@ cmIfFunctionBlocker *f = new cmIfFunctionBlocker(); // if is isn't true block the commands - f->m_IsBlocking = !isTrue; - f->m_Args = args; - m_Makefile->AddFunctionBlocker(f); + f->IsBlocking = !isTrue; + f->Args = args; + this->Makefile->AddFunctionBlocker(f); return true; } @@ -262,7 +262,17 @@ // is a variable defined if (*arg == "DEFINED" && argP1 != newArgs.end()) { - def = makefile->GetDefinition((argP1)->c_str()); + unsigned int argP1len = argP1->size(); + if(argP1len > 4 && argP1->substr(0, 4) == "ENV{" && + argP1->operator[](argP1len-1) == '}') + { + std::string env = argP1->substr(4, argP1len-5); + def = cmSystemTools::GetEnv(env.c_str()); + } + else + { + def = makefile->GetDefinition((argP1)->c_str()); + } if(def) { *arg = "1"; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmIfCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmIfCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmIfCommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmIfCommand.h 2006-03-16 00:02:03.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmIfCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.28.2.1 $ + Date: $Date: 2006/03/15 16:02:03 $ + Version: $Revision: 1.30 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -36,8 +36,8 @@ cmMakefile &mf); virtual void ScopeEnded(cmMakefile &mf); - std::vector m_Args; - bool m_IsBlocking; + std::vector Args; + bool IsBlocking; }; /** \class cmIfCommand diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmIncludeCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmIncludeCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmIncludeCommand.cxx 2005-06-09 04:55:30.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmIncludeCommand.cxx 2006-03-16 00:02:03.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmIncludeCommand.cxx,v $ Language: C++ - Date: $Date: 2005/06/08 20:55:30 $ - Version: $Revision: 1.16 $ + Date: $Date: 2006/03/15 16:02:03 $ + Version: $Revision: 1.17 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -40,13 +40,13 @@ // Not a path. Maybe module. std::string module = fname; module += ".cmake"; - std::string mfile = m_Makefile->GetModulesFile(module.c_str()); + std::string mfile = this->Makefile->GetModulesFile(module.c_str()); if ( mfile.size() ) { fname = mfile.c_str(); } } - bool readit = m_Makefile->ReadListFile( m_Makefile->GetCurrentListFile(), + bool readit = this->Makefile->ReadListFile( this->Makefile->GetCurrentListFile(), fname.c_str() ); if(!optional && !readit && !cmSystemTools::GetFatalErrorOccured()) { diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmIncludeCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmIncludeCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmIncludeCommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmIncludeCommand.h 2005-11-17 03:11:09.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmIncludeCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.13.2.1 $ + Date: $Date: 2005/11/16 19:11:09 $ + Version: $Revision: 1.14 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmIncludeDirectoryCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmIncludeDirectoryCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmIncludeDirectoryCommand.cxx 2004-10-29 03:40:24.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmIncludeDirectoryCommand.cxx 2006-03-16 00:02:04.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmIncludeDirectoryCommand.cxx,v $ Language: C++ - Date: $Date: 2004/10/28 19:40:24 $ - Version: $Revision: 1.15 $ + Date: $Date: 2006/03/15 16:02:04 $ + Version: $Revision: 1.16 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -39,7 +39,7 @@ { cmSystemTools::Error("Empty Include Directory Passed into INCLUDE_DIRECTORIES command."); } - m_Makefile->AddIncludeDirectory((*i).c_str(), before); + this->Makefile->AddIncludeDirectory((*i).c_str(), before); } return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmIncludeExternalMSProjectCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmIncludeExternalMSProjectCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmIncludeExternalMSProjectCommand.cxx 2005-02-22 23:32:43.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmIncludeExternalMSProjectCommand.cxx 2006-03-16 00:02:04.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmIncludeExternalMSProjectCommand.cxx,v $ Language: C++ - Date: $Date: 2005/02/22 15:32:43 $ - Version: $Revision: 1.11 $ + Date: $Date: 2006/03/15 16:02:04 $ + Version: $Revision: 1.13 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -26,7 +26,7 @@ } // only compile this for win32 to avoid coverage errors #ifdef _WIN32 - if(m_Makefile->GetDefinition("WIN32")) + if(this->Makefile->GetDefinition("WIN32")) { std::string location = args[1]; @@ -44,8 +44,10 @@ utility_name += args[0]; const char* no_output = 0; - m_Makefile->AddUtilityCommand(utility_name.c_str(), true, + const char* no_working_directory = 0; + this->Makefile->AddUtilityCommand(utility_name.c_str(), true, no_output, depends, + no_working_directory, args[0].c_str(), args[1].c_str()); } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmIncludeRegularExpressionCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmIncludeRegularExpressionCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmIncludeRegularExpressionCommand.cxx 2002-10-24 06:03:26.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmIncludeRegularExpressionCommand.cxx 2006-03-16 00:02:04.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmIncludeRegularExpressionCommand.cxx,v $ Language: C++ - Date: $Date: 2002/10/23 22:03:26 $ - Version: $Revision: 1.7 $ + Date: $Date: 2006/03/15 16:02:04 $ + Version: $Revision: 1.8 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -24,11 +24,11 @@ this->SetError("called with incorrect number of arguments"); return false; } - m_Makefile->SetIncludeRegularExpression(args[0].c_str()); + this->Makefile->SetIncludeRegularExpression(args[0].c_str()); if(args.size() > 1) { - m_Makefile->SetComplainRegularExpression(args[1].c_str()); + this->Makefile->SetComplainRegularExpression(args[1].c_str()); } return true; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallCommand.cxx 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallCommand.cxx 2006-03-16 00:02:04.000000000 +0800 @@ -0,0 +1,524 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmInstallCommand.cxx,v $ + Language: C++ + Date: $Date: 2006/03/15 16:02:04 $ + Version: $Revision: 1.7 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "cmInstallCommand.h" + +#include "cmInstallFilesGenerator.h" +#include "cmInstallScriptGenerator.h" +#include "cmInstallTargetGenerator.h" + +// cmInstallCommand +bool cmInstallCommand::InitialPass(std::vector const& args) +{ + // Allow calling with no arguments so that arguments may be built up + // using a variable that may be left empty. + if(args.empty()) + { + return true; + } + + // Switch among the command modes. + if(args[0] == "SCRIPT") + { + return this->HandleScriptMode(args); + } + else if(args[0] == "TARGETS") + { + return this->HandleTargetsMode(args); + } + else if(args[0] == "FILES") + { + return this->HandleFilesMode(args); + } + else if(args[0] == "PROGRAMS") + { + return this->HandleFilesMode(args); + } + + // Unknown mode. + cmStdString e = "called with unknown mode "; + e += args[0]; + this->SetError(e.c_str()); + return false; +} + +//---------------------------------------------------------------------------- +bool cmInstallCommand::HandleScriptMode(std::vector const& args) +{ + bool doing_script = false; + for(size_t i=0; i < args.size(); ++i) + { + if(args[i] == "SCRIPT") + { + doing_script = true; + } + else if(doing_script) + { + doing_script = false; + std::string script = args[i]; + if(!cmSystemTools::FileIsFullPath(script.c_str())) + { + script = this->Makefile->GetCurrentDirectory(); + script += "/"; + script += args[i]; + } + if(cmSystemTools::FileIsDirectory(script.c_str())) + { + this->SetError("given a directory as value of SCRIPT argument."); + return false; + } + this->Makefile->AddInstallGenerator( + new cmInstallScriptGenerator(script.c_str())); + } + } + if(doing_script) + { + this->SetError("given no value for SCRIPT argument."); + return false; + } + return true; +} + +//---------------------------------------------------------------------------- +bool cmInstallCommand::HandleTargetsMode(std::vector const& args) +{ + // This is the TARGETS mode. + bool doing_targets = true; + bool doing_destination = false; + bool doing_permissions = false; + bool library_settings = true; + bool runtime_settings = true; + std::vector targets; + const char* library_destination = 0; + const char* runtime_destination = 0; + std::string library_permissions; + std::string runtime_permissions; + for(unsigned int i=1; i < args.size(); ++i) + { + if(args[i] == "DESTINATION") + { + // Switch to setting the destination property. + doing_targets = false; + doing_destination = true; + doing_permissions = false; + } + else if(args[i] == "PERMISSIONS") + { + // Switch to setting the permissions property. + doing_targets = false; + doing_destination = false; + doing_permissions = true; + } + else if(args[i] == "LIBRARY") + { + // Switch to setting only library properties. + doing_targets = false; + doing_destination = false; + doing_permissions = false; + library_settings = true; + runtime_settings = false; + } + else if(args[i] == "RUNTIME") + { + // Switch to setting only runtime properties. + doing_targets = false; + doing_destination = false; + doing_permissions = false; + library_settings = false; + runtime_settings = true; + } + else if(doing_targets) + { + // Lookup this target in the current directory. + if(cmTarget* target = this->Makefile->FindTarget(args[i].c_str())) + { + // Found the target. Check its type. + if(target->GetType() != cmTarget::EXECUTABLE && + target->GetType() != cmTarget::STATIC_LIBRARY && + target->GetType() != cmTarget::SHARED_LIBRARY && + target->GetType() != cmTarget::MODULE_LIBRARY) + { + cmOStringStream e; + e << "TARGETS given target \"" << args[i] + << "\" which is not an executable, library, or module."; + this->SetError(e.str().c_str()); + return false; + } + + // Store the target in the list to be installed. + targets.push_back(target); + } + else + { + // Did not find the target. + cmOStringStream e; + e << "TARGETS given target \"" << args[i] + << "\" which does not exist in this directory."; + this->SetError(e.str().c_str()); + return false; + } + } + else if(doing_destination) + { + // Set the destination in the active set(s) of properties. + if(library_settings) + { + library_destination = args[i].c_str(); + } + if(runtime_settings) + { + runtime_destination = args[i].c_str(); + } + doing_destination = false; + } + else if(doing_permissions) + { + // Set the permissions in the active set(s) of properties. + if(library_settings) + { + // Check the requested permission. + if(!this->CheckPermissions(args[i], library_permissions)) + { + cmOStringStream e; + e << args[0] << " given invalid permission \"" + << args[i] << "\"."; + this->SetError(e.str().c_str()); + return false; + } + } + if(runtime_settings) + { + // Check the requested permission. + if(!this->CheckPermissions(args[i], runtime_permissions)) + { + cmOStringStream e; + e << args[0] << " given invalid permission \"" + << args[i] << "\"."; + this->SetError(e.str().c_str()); + return false; + } + } + } + else + { + // Unknown argument. + cmOStringStream e; + e << "TARGETS given unknown argument \"" << args[i] << "\"."; + this->SetError(e.str().c_str()); + return false; + } + } + + // Check if there is something to do. + if(targets.empty()) + { + return true; + } + if(!library_destination && !runtime_destination) + { + this->SetError("TARGETS given no DESTINATION!"); + return false; + } + + // Compute destination paths. + std::string library_dest; + std::string runtime_dest; + this->ComputeDestination(library_destination, library_dest); + this->ComputeDestination(runtime_destination, runtime_dest); + + // Generate install script code to install the given targets. + for(std::vector::iterator ti = targets.begin(); + ti != targets.end(); ++ti) + { + // Handle each target type. + cmTarget& target = *(*ti); + switch(target.GetType()) + { + case cmTarget::SHARED_LIBRARY: + { + // Shared libraries are handled differently on DLL and non-DLL + // platforms. All windows platforms are DLL platforms + // including cygwin. Currently no other platform is a DLL + // platform. +#if defined(_WIN32) || defined(__CYGWIN__) + // This is a DLL platform. + if(library_destination) + { + // The import library uses the LIBRARY properties. + this->Makefile->AddInstallGenerator( + new cmInstallTargetGenerator(target, library_dest.c_str(), true, + library_permissions.c_str())); + } + if(runtime_destination) + { + // The DLL uses the RUNTIME properties. + this->Makefile->AddInstallGenerator( + new cmInstallTargetGenerator(target, runtime_dest.c_str(), false, + runtime_permissions.c_str())); + } +#else + // This is a non-DLL platform. + if(library_destination) + { + // The shared library uses the LIBRARY properties. + this->Makefile->AddInstallGenerator( + new cmInstallTargetGenerator(target, library_dest.c_str(), false, + library_permissions.c_str())); + } +#endif + } + break; + case cmTarget::STATIC_LIBRARY: + case cmTarget::MODULE_LIBRARY: + { + // Static libraries and modules use LIBRARY properties. + if(library_destination) + { + this->Makefile->AddInstallGenerator( + new cmInstallTargetGenerator(target, library_dest.c_str(), false, + library_permissions.c_str())); + } + else + { + cmOStringStream e; + e << "TARGETS given no LIBRARY DESTINATION for "; + if(target.GetType() == cmTarget::STATIC_LIBRARY) + { + e << "static library"; + } + else + { + e << "module"; + } + e << " target \"" << target.GetName() << "\"."; + this->SetError(e.str().c_str()); + return false; + } + } + break; + case cmTarget::EXECUTABLE: + { + // Executables use the RUNTIME properties. + if(runtime_destination) + { + this->Makefile->AddInstallGenerator( + new cmInstallTargetGenerator(target, runtime_dest.c_str(), false, + runtime_permissions.c_str())); + } + else + { + cmOStringStream e; + e << "TARGETS given no RUNTIME DESTINATION for executable target \"" + << target.GetName() << "\"."; + this->SetError(e.str().c_str()); + return false; + } + } + break; + default: + // This should never happen due to the above type check. + // Ignore the case. + break; + } + } + + return true; +} + +//---------------------------------------------------------------------------- +bool cmInstallCommand::HandleFilesMode(std::vector const& args) +{ + // This is the FILES mode. + bool programs = (args[0] == "PROGRAMS"); + bool doing_files = true; + bool doing_destination = false; + bool doing_permissions = false; + bool doing_rename = false; + std::vector files; + const char* destination = 0; + std::string rename; + std::string permissions; + for(unsigned int i=1; i < args.size(); ++i) + { + if(args[i] == "DESTINATION") + { + // Switch to setting the destination property. + doing_files = false; + doing_destination = true; + doing_permissions = false; + doing_rename = false; + } + else if(args[i] == "PERMISSIONS") + { + // Switch to setting the permissions property. + doing_files = false; + doing_destination = false; + doing_permissions = true; + doing_rename = false; + } + else if(args[i] == "RENAME") + { + // Switch to setting the rename property. + doing_files = false; + doing_destination = false; + doing_permissions = false; + doing_rename = true; + } + else if(doing_files) + { + // Convert this file to a full path. + std::string file = args[i]; + if(!cmSystemTools::FileIsFullPath(file.c_str())) + { + file = this->Makefile->GetCurrentDirectory(); + file += "/"; + file += args[i]; + } + + // Make sure the file is not a directory. + if(cmSystemTools::FileIsDirectory(file.c_str())) + { + cmOStringStream e; + e << args[0] << " given directory \"" << args[i] << "\" to install."; + this->SetError(e.str().c_str()); + return false; + } + + // Store the file for installation. + files.push_back(file); + } + else if(doing_destination) + { + destination = args[i].c_str(); + doing_destination = false; + } + else if(doing_permissions) + { + // Check the requested permission. + if(!this->CheckPermissions(args[i], permissions)) + { + cmOStringStream e; + e << args[0] << " given invalid permission \"" + << args[i] << "\"."; + this->SetError(e.str().c_str()); + return false; + } + } + else if(doing_rename) + { + rename = args[i]; + doing_rename = false; + } + else + { + // Unknown argument. + cmOStringStream e; + e << args[0] << " given unknown argument \"" << args[i] << "\"."; + this->SetError(e.str().c_str()); + return false; + } + } + + // Check if there is something to do. + if(files.empty()) + { + return true; + } + if(!destination) + { + // A destination is required. + cmOStringStream e; + e << args[0] << " given no DESTINATION!"; + this->SetError(e.str().c_str()); + return false; + } + if(!rename.empty() && files.size() > 1) + { + // The rename option works only with one file. + cmOStringStream e; + e << args[0] << " given RENAME option with more than one file."; + this->SetError(e.str().c_str()); + return false; + } + + // Compute destination path. + std::string dest; + this->ComputeDestination(destination, dest); + + // Create the files install generator. + this->Makefile->AddInstallGenerator( + new cmInstallFilesGenerator(files, dest.c_str(), programs, + permissions.c_str(), rename.c_str())); + + return true; +} + +//---------------------------------------------------------------------------- +void cmInstallCommand::ComputeDestination(const char* destination, + std::string& dest) +{ + if(destination) + { + if(cmSystemTools::FileIsFullPath(destination)) + { + // Full paths are absolute. + dest = destination; + } + else + { + // Relative paths are treated with respect to the installation prefix. + dest = "${CMAKE_INSTALL_PREFIX}/"; + dest += destination; + } + + // Format the path nicely. Note this also removes trailing + // slashes. + cmSystemTools::ConvertToUnixSlashes(dest); + } + else + { + dest = ""; + } +} + +//---------------------------------------------------------------------------- +bool cmInstallCommand::CheckPermissions(std::string const& arg, + std::string& permissions) +{ + // Table of valid permissions. + const char* table[] = + { + "OWNER_READ", "OWNER_WRITE", "OWNER_EXECUTE", + "GROUP_READ", "GROUP_WRITE", "GROUP_EXECUTE", + "WORLD_READ", "WORLD_WRITE", "WORLD_EXECUTE", + "SETUID", "SETGID", 0 + }; + + // Check the permission against the table. + for(const char** valid = table; *valid; ++valid) + { + if(arg == *valid) + { + // This is a valid permission. + permissions += " "; + permissions += arg; + return true; + } + } + + // This is not a valid permission. + return false; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallCommand.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallCommand.h 2006-03-04 08:29:35.000000000 +0800 @@ -0,0 +1,170 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmInstallCommand.h,v $ + Language: C++ + Date: $Date: 2006/03/04 00:29:35 $ + Version: $Revision: 1.5 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef cmInstallCommand_h +#define cmInstallCommand_h + +#include "cmCommand.h" + +/** \class cmInstallCommand + * \brief Specifies where to install some files + * + * cmInstallCommand is a general-purpose interface command for + * specifying install rules. + */ +class cmInstallCommand : public cmCommand +{ +public: + /** + * This is a virtual constructor for the command. + */ + virtual cmCommand* Clone() + { + return new cmInstallCommand; + } + + /** + * This is called when the command is first encountered in + * the CMakeLists.txt file. + */ + virtual bool InitialPass(std::vector const& args); + + /** + * The name of the command as specified in CMakeList.txt. + */ + virtual const char* GetName() { return "INSTALL";} + + /** + * Succinct documentation. + */ + virtual const char* GetTerseDocumentation() + { + return "Specify rules to run at install time."; + } + + /** + * More documentation. + */ + virtual const char* GetFullDocumentation() + { + return + "This command generates installation rules for a project. " + "Rules specified by calls to this command within a source directory " + "are executed in order during installation. " + "The order across directories is not defined." + "\n" + "There are multiple signatures for this command. Some of them define " + "installation properties for files and targets. Properties common to " + "multiple signatures are covered here but they are valid only for " + "signatures that specify them. " + "DESTINATION arguments specify " + "the directory on disk to which a file will be installed. " + "If a full path (with a leading slash or drive letter) is given it " + "is used directly. If a relative path is given it is interpreted " + "relative to the value of CMAKE_INSTALL_PREFIX. " + "PERMISSIONS arguments specify permissions for installed files. " + "Valid permissions are " + "OWNER_READ, OWNER_WRITE, OWNER_EXECUTE, " + "GROUP_READ, GROUP_WRITE, GROUP_EXECUTE, " + "WORLD_READ, WORLD_WRITE, WORLD_EXECUTE, " + "SETUID, and SETGID. " + "Permissions that do not make sense on certain platforms are ignored " + "on those platforms. " + "The RENAME argument specifies a name for an installed file that " + "may be different from the original file. Renaming is allowed only " + "when a single file is installed by the command. " + "\n" + "The TARGETS signature:\n" + " INSTALL(TARGETS targets... [[LIBRARY|RUNTIME]\n" + " [DESTINATION ]\n" + " [PERMISSIONS permissions...]\n" + " ] [...])\n" + "The TARGETS form specifies rules for installing targets from a " + "project. There are two kinds of target files that may be " + "installed: library and runtime. Static libraries and modules " + "are always treated as library targets. Executables are always " + "treated as runtime targets. For non-DLL platforms, shared libraries " + "are treated as library targets. For DLL platforms, the DLL part of " + "a shared library is treated as a runtime target and the corresponding " + "import library is treated as a library target. All Windows-based " + "systems including Cygwin are DLL platforms. The LIBRARY and RUNTIME " + "arguments change the type of target to which the following properties " + "apply. If neither is given the installation properties apply to " + "both target types. If only one is given then only targets of that " + "type will be installed (which can be used to install just a DLL or " + "just an import library)." + "\n" + "One or more groups of properties may be specified in a single call " + "to the TARGETS form of this command. A target may be installed more " + "than once to different locations. Consider hypothetical " + "targets \"myExe\", \"mySharedLib\", and \"myStaticLib\". The code\n" + " INSTALL(TARGETS myExe mySharedLib myStaticLib\n" + " RUNTIME DESTINATION bin\n" + " LIBRARY DESTINATION lib)\n" + " INSTALL(TARGETS mySharedLib DESTINATION /some/full/path)\n" + "will install myExe to /bin and myStaticLib to /lib. " + "On non-DLL platforms mySharedLib will be installed to /lib and " + "/some/full/path. On DLL platforms the mySharedLib DLL will be " + "installed to /bin and /some/full/path and its import library " + "will be installed to /lib and /some/full/path. On non-DLL " + "platforms mySharedLib will be installed to /lib and " + "/some/full/path." + "\n" + "The FILES signature:\n" + " INSTALL(FILES files... DESTINATION \n" + " [PERMISSIONS permissions...] [RENAME ])\n" + "The FILES form specifies rules for installing files for a " + "project. File names given as relative paths are interpreted with " + "respect to the current source directory. Files installed by this " + "form are given the same permissions as the original file by default." + "\n" + "The PROGRAMS signature:\n" + " INSTALL(PROGRAMS files... DESTINATION \n" + " [PERMISSIONS permissions...] [RENAME ])\n" + "The PROGRAMS form is identical to the FILES form except that the " + "default permissions for the installed file mark it as executable. " + "This form is intended to install programs that are not targets, " + "such as shell scripts. Use the TARGETS form to install targets " + "built within the project." + "\n" + "The SCRIPT signature:\n" + " INSTALL(SCRIPT [SCRIPT [...]])\n" + "The SCRIPT form will invoke the given CMake script files during " + "installation. If the script file name is a relative path " + "it will be interpreted with respect to the current source directory." + "\n" + "NOTE: This command supercedes the INSTALL_TARGETS command and the " + "target properties PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT. " + "It also replaces the FILES forms of the INSTALL_FILES and " + "INSTALL_PROGRAMS commands. " + "The processing order of these install rules relative to those " + "generated by INSTALL_TARGETS, INSTALL_FILES, and INSTALL_PROGRAMS " + "commands is not defined.\n" + ; + } + + cmTypeMacro(cmInstallCommand, cmCommand); + +private: + bool HandleScriptMode(std::vector const& args); + bool HandleTargetsMode(std::vector const& args); + bool HandleFilesMode(std::vector const& args); + void ComputeDestination(const char* destination, std::string& dest); + bool CheckPermissions(std::string const& arg, std::string& permissions); +}; + + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallFilesCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallFilesCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallFilesCommand.cxx 2004-09-23 02:42:05.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallFilesCommand.cxx 2006-03-16 00:02:04.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmInstallFilesCommand.cxx,v $ Language: C++ - Date: $Date: 2004/09/22 18:42:05 $ - Version: $Revision: 1.19 $ + Date: $Date: 2006/03/15 16:02:04 $ + Version: $Revision: 1.20 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -25,18 +25,18 @@ return false; } std::vector args; - m_Makefile->ExpandSourceListArguments(argsIn, args, 2); + this->Makefile->ExpandSourceListArguments(argsIn, args, 2); // Create an INSTALL_FILES target specifically for this path. - m_TargetName = "INSTALL_FILES_"+args[0]; - cmTarget& target = m_Makefile->GetTargets()[m_TargetName]; + this->TargetName = "INSTALL_FILES_"+args[0]; + cmTarget& target = this->Makefile->GetTargets()[this->TargetName]; target.SetInAll(false); - target.SetType(cmTarget::INSTALL_FILES, m_TargetName.c_str()); + target.SetType(cmTarget::INSTALL_FILES, this->TargetName.c_str()); target.SetInstallPath(args[0].c_str()); if((args.size() > 1) && (args[1] == "FILES")) { - m_IsFilesForm = true; + this->IsFilesForm = true; for(std::vector::const_iterator s = args.begin()+2; s != args.end(); ++s) { @@ -47,11 +47,11 @@ } else { - m_IsFilesForm = false; + this->IsFilesForm = false; std::vector::const_iterator s = args.begin(); for (++s;s != args.end(); ++s) { - m_FinalArgs.push_back(*s); + this->FinalArgs.push_back(*s); } } @@ -61,24 +61,24 @@ void cmInstallFilesCommand::FinalPass() { // No final pass for "FILES" form of arguments. - if(m_IsFilesForm) + if(this->IsFilesForm) { return; } std::string testf; - std::string ext = m_FinalArgs[0]; + std::string ext = this->FinalArgs[0]; std::vector& targetSourceLists = - m_Makefile->GetTargets()[m_TargetName].GetSourceLists(); + this->Makefile->GetTargets()[this->TargetName].GetSourceLists(); // two different options - if (m_FinalArgs.size() > 1) + if (this->FinalArgs.size() > 1) { // now put the files into the list - std::vector::iterator s = m_FinalArgs.begin(); + std::vector::iterator s = this->FinalArgs.begin(); ++s; // for each argument, get the files - for (;s != m_FinalArgs.end(); ++s) + for (;s != this->FinalArgs.end(); ++s) { // replace any variables std::string temps = *s; @@ -99,8 +99,8 @@ else // reg exp list { std::vector files; - std::string regex = m_FinalArgs[0].c_str(); - cmSystemTools::Glob(m_Makefile->GetCurrentDirectory(), + std::string regex = this->FinalArgs[0].c_str(); + cmSystemTools::Glob(this->Makefile->GetCurrentDirectory(), regex.c_str(), files); std::vector::iterator s = files.begin(); @@ -127,10 +127,10 @@ } // This is a relative path. - std::string tb = m_Makefile->GetCurrentOutputDirectory(); + std::string tb = this->Makefile->GetCurrentOutputDirectory(); tb += "/"; tb += name; - std::string ts = m_Makefile->GetCurrentDirectory(); + std::string ts = this->Makefile->GetCurrentDirectory(); ts += "/"; ts += name; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallFilesCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallFilesCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallFilesCommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallFilesCommand.h 2006-03-16 00:02:04.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmInstallFilesCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.13.2.1 $ + Date: $Date: 2006/03/15 16:02:04 $ + Version: $Revision: 1.16 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -52,7 +52,7 @@ */ virtual const char* GetTerseDocumentation() { - return "Create install rules for files."; + return "Old installation command. Use the INSTALL command."; } /** @@ -69,7 +69,12 @@ virtual const char* GetFullDocumentation() { return - " INSTALL_FILES( extension file file ...)\n" + "This command has been superceded by the INSTALL command. It " + "is provided for compatibility with older CMake code. " + "The FILES form is directly replaced by the FILES form of the " + "INSTALL command. The regexp form can be expressed " + "more clearly using the GLOB form of the FILE command.\n" + " INSTALL_FILES( extension file file ...)\n" "Create rules to install the listed files with the given extension " "into the given directory. " "Only files existing in the current source tree or its corresponding " @@ -95,9 +100,9 @@ std::string FindInstallSource(const char* name) const; private: - std::string m_TargetName; - std::vector m_FinalArgs; - bool m_IsFilesForm; + std::string TargetName; + std::vector FinalArgs; + bool IsFilesForm; }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallFilesGenerator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallFilesGenerator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallFilesGenerator.cxx 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallFilesGenerator.cxx 2006-03-04 07:44:32.000000000 +0800 @@ -0,0 +1,53 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmInstallFilesGenerator.cxx,v $ + Language: C++ + Date: $Date: 2006/03/03 23:44:32 $ + Version: $Revision: 1.2 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "cmInstallFilesGenerator.h" + +#include "cmTarget.h" + +//---------------------------------------------------------------------------- +cmInstallFilesGenerator +::cmInstallFilesGenerator(std::vector const& files, + const char* dest, bool programs, + const char* permissions, const char* rename): + Files(files), Destination(dest), Programs(programs), + Permissions(permissions), Rename(rename) +{ +} + +//---------------------------------------------------------------------------- +cmInstallFilesGenerator +::~cmInstallFilesGenerator() +{ +} + +//---------------------------------------------------------------------------- +void cmInstallFilesGenerator::GenerateScript(std::ostream& os) +{ + // Write code to install the files. + for(std::vector::const_iterator fi = this->Files.begin(); + fi != this->Files.end(); ++fi) + { + bool not_optional = false; + const char* no_properties = 0; + this->AddInstallRule(os, this->Destination.c_str(), + (this->Programs + ? cmTarget::INSTALL_PROGRAMS + : cmTarget::INSTALL_FILES), fi->c_str(), + not_optional, no_properties, + this->Permissions.c_str(), this->Rename.c_str()); + } +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallFilesGenerator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallFilesGenerator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallFilesGenerator.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallFilesGenerator.h 2006-03-04 07:44:32.000000000 +0800 @@ -0,0 +1,42 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmInstallFilesGenerator.h,v $ + Language: C++ + Date: $Date: 2006/03/03 23:44:32 $ + Version: $Revision: 1.2 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef cmInstallFilesGenerator_h +#define cmInstallFilesGenerator_h + +#include "cmInstallGenerator.h" + +/** \class cmInstallFilesGenerator + * \brief Generate file installation rules. + */ +class cmInstallFilesGenerator: public cmInstallGenerator +{ +public: + cmInstallFilesGenerator(std::vector const& files, + const char* dest, bool programs, + const char* permissions, const char* rename); + virtual ~cmInstallFilesGenerator(); + +protected: + virtual void GenerateScript(std::ostream& os); + std::vector Files; + std::string Destination; + bool Programs; + std::string Permissions; + std::string Rename; +}; + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallGenerator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallGenerator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallGenerator.cxx 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallGenerator.cxx 2006-03-04 07:44:32.000000000 +0800 @@ -0,0 +1,89 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmInstallGenerator.cxx,v $ + Language: C++ + Date: $Date: 2006/03/03 23:44:32 $ + Version: $Revision: 1.4 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "cmInstallGenerator.h" + +#include "cmSystemTools.h" +#include "cmTarget.h" + +//---------------------------------------------------------------------------- +cmInstallGenerator +::cmInstallGenerator() +{ + this->ConfigurationName = 0; + this->ConfigurationTypes = 0; +} + +//---------------------------------------------------------------------------- +cmInstallGenerator +::~cmInstallGenerator() +{ +} + +//---------------------------------------------------------------------------- +void +cmInstallGenerator +::Generate(std::ostream& os, const char* config, + std::vector const& configurationTypes) +{ + this->ConfigurationName = config; + this->ConfigurationTypes = &configurationTypes; + this->GenerateScript(os); + this->ConfigurationName = 0; + this->ConfigurationTypes = 0; +} + +//---------------------------------------------------------------------------- +void cmInstallGenerator::AddInstallRule(std::ostream& os, + const char* dest, + int type, + const char* file, + bool optional /* = false */, + const char* properties /* = 0 */, + const char* permissions /* = 0 */, + const char* rename /* = 0 */) +{ + // Use the FILE command to install the file. + std::string stype; + switch(type) + { + case cmTarget::INSTALL_PROGRAMS: stype = "PROGRAM"; break; + case cmTarget::EXECUTABLE: stype = "EXECUTABLE"; break; + case cmTarget::STATIC_LIBRARY: stype = "STATIC_LIBRARY"; break; + case cmTarget::SHARED_LIBRARY: stype = "SHARED_LIBRARY"; break; + case cmTarget::MODULE_LIBRARY: stype = "MODULE"; break; + case cmTarget::INSTALL_FILES: + default: stype = "FILE"; break; + } + os << "FILE(INSTALL DESTINATION \"" << dest << "\" TYPE " << stype.c_str(); + if(optional) + { + os << " OPTIONAL"; + } + if(properties && *properties) + { + os << " PROPERTIES" << properties; + } + if(permissions && *permissions) + { + os << " PERMISSIONS" << permissions; + } + if(rename && *rename) + { + os << " RENAME \"" << rename << "\""; + } + os << " FILES \"" << file << "\")\n"; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallGenerator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallGenerator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallGenerator.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallGenerator.h 2006-03-04 07:44:32.000000000 +0800 @@ -0,0 +1,50 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmInstallGenerator.h,v $ + Language: C++ + Date: $Date: 2006/03/03 23:44:32 $ + Version: $Revision: 1.3 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef cmInstallGenerator_h +#define cmInstallGenerator_h + +#include "cmStandardIncludes.h" + +class cmLocalGenerator; + +/** \class cmInstallGenerator + * \brief Support class for generating install scripts. + * + */ +class cmInstallGenerator +{ +public: + cmInstallGenerator(); + virtual ~cmInstallGenerator(); + + void Generate(std::ostream& os, const char* config, + std::vector const& configurationTypes); + + static void AddInstallRule(std::ostream& os, const char* dest, int type, + const char* file, bool optional = false, + const char* properties = 0, + const char* permissions = 0, + const char* rename = 0); + +protected: + virtual void GenerateScript(std::ostream& os)=0; + + const char* ConfigurationName; + std::vector const* ConfigurationTypes; +}; + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallProgramsCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallProgramsCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallProgramsCommand.cxx 2005-03-02 01:13:37.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallProgramsCommand.cxx 2006-03-16 00:02:04.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmInstallProgramsCommand.cxx,v $ Language: C++ - Date: $Date: 2005/03/01 17:13:37 $ - Version: $Revision: 1.12 $ + Date: $Date: 2006/03/15 16:02:04 $ + Version: $Revision: 1.13 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -26,16 +26,16 @@ } // Create an INSTALL_PROGRAMS target specifically for this path. - m_TargetName = "INSTALL_PROGRAMS_"+args[0]; - cmTarget& target = m_Makefile->GetTargets()[m_TargetName]; + this->TargetName = "INSTALL_PROGRAMS_"+args[0]; + cmTarget& target = this->Makefile->GetTargets()[this->TargetName]; target.SetInAll(false); - target.SetType(cmTarget::INSTALL_PROGRAMS, m_TargetName.c_str()); + target.SetType(cmTarget::INSTALL_PROGRAMS, this->TargetName.c_str()); target.SetInstallPath(args[0].c_str()); std::vector::const_iterator s = args.begin(); for (++s;s != args.end(); ++s) { - m_FinalArgs.push_back(*s); + this->FinalArgs.push_back(*s); } return true; @@ -44,25 +44,25 @@ void cmInstallProgramsCommand::FinalPass() { std::vector& targetSourceLists = - m_Makefile->GetTargets()[m_TargetName].GetSourceLists(); + this->Makefile->GetTargets()[this->TargetName].GetSourceLists(); bool files_mode = false; - if(!m_FinalArgs.empty() && m_FinalArgs[0] == "FILES") + if(!this->FinalArgs.empty() && this->FinalArgs[0] == "FILES") { files_mode = true; } // two different options - if (m_FinalArgs.size() > 1 || files_mode) + if (this->FinalArgs.size() > 1 || files_mode) { // for each argument, get the programs - std::vector::iterator s = m_FinalArgs.begin(); + std::vector::iterator s = this->FinalArgs.begin(); if(files_mode) { // Skip the FILES argument in files mode. ++s; } - for(;s != m_FinalArgs.end(); ++s) + for(;s != this->FinalArgs.end(); ++s) { // add to the result targetSourceLists.push_back(this->FindInstallSource(s->c_str())); @@ -71,8 +71,8 @@ else // reg exp list { std::vector programs; - cmSystemTools::Glob(m_Makefile->GetCurrentDirectory(), - m_FinalArgs[0].c_str(), programs); + cmSystemTools::Glob(this->Makefile->GetCurrentDirectory(), + this->FinalArgs[0].c_str(), programs); std::vector::iterator s = programs.begin(); // for each argument, get the programs @@ -98,10 +98,10 @@ } // This is a relative path. - std::string tb = m_Makefile->GetCurrentOutputDirectory(); + std::string tb = this->Makefile->GetCurrentOutputDirectory(); tb += "/"; tb += name; - std::string ts = m_Makefile->GetCurrentDirectory(); + std::string ts = this->Makefile->GetCurrentDirectory(); ts += "/"; ts += name; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallProgramsCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallProgramsCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallProgramsCommand.h 2005-03-02 01:13:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallProgramsCommand.h 2006-03-16 00:02:04.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmInstallProgramsCommand.h,v $ Language: C++ - Date: $Date: 2005/03/01 17:13:38 $ - Version: $Revision: 1.11 $ + Date: $Date: 2006/03/15 16:02:04 $ + Version: $Revision: 1.13 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -52,7 +52,7 @@ */ virtual const char* GetTerseDocumentation() { - return "Create install rules for programs."; + return "Old installation command. Use the INSTALL command."; } /** @@ -69,6 +69,11 @@ virtual const char* GetFullDocumentation() { return + "This command has been superceded by the INSTALL command. It " + "is provided for compatibility with older CMake code. " + "The FILES form is directly replaced by the PROGRAMS form of the " + "INSTALL command. The regexp form can be expressed more clearly " + "using the GLOB form of the FILE command.\n" " INSTALL_PROGRAMS( file1 file2 [file3 ...])\n" " INSTALL_PROGRAMS( FILES file1 [file2 ...])\n" "Create rules to install the listed programs into the given directory. " @@ -78,7 +83,8 @@ "In the second form any program in the current source directory that " "matches the regular expression will be installed.\n" "This command is intended to install programs that are not built " - "by cmake, such as shell scripts. See INSTALL_TARGETS to " + "by cmake, such as shell scripts. See the TARGETS form of " + "the INSTALL command to " "create installation rules for targets built by cmake.\n" "The directory is relative to the installation prefix, which " "is stored in the variable CMAKE_INSTALL_PREFIX."; @@ -89,8 +95,8 @@ protected: std::string FindInstallSource(const char* name) const; private: - std::string m_TargetName; - std::vector m_FinalArgs; + std::string TargetName; + std::vector FinalArgs; }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallScriptGenerator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallScriptGenerator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallScriptGenerator.cxx 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallScriptGenerator.cxx 2006-02-20 04:25:27.000000000 +0800 @@ -0,0 +1,35 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmInstallScriptGenerator.cxx,v $ + Language: C++ + Date: $Date: 2006/02/19 20:25:27 $ + Version: $Revision: 1.1 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "cmInstallScriptGenerator.h" + +//---------------------------------------------------------------------------- +cmInstallScriptGenerator +::cmInstallScriptGenerator(const char* script): Script(script) +{ +} + +//---------------------------------------------------------------------------- +cmInstallScriptGenerator +::~cmInstallScriptGenerator() +{ +} + +//---------------------------------------------------------------------------- +void cmInstallScriptGenerator::GenerateScript(std::ostream& os) +{ + os << "INCLUDE(\"" << this->Script << "\")\n"; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallScriptGenerator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallScriptGenerator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallScriptGenerator.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallScriptGenerator.h 2006-02-20 04:25:27.000000000 +0800 @@ -0,0 +1,36 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmInstallScriptGenerator.h,v $ + Language: C++ + Date: $Date: 2006/02/19 20:25:27 $ + Version: $Revision: 1.1 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef cmInstallScriptGenerator_h +#define cmInstallScriptGenerator_h + +#include "cmInstallGenerator.h" + +/** \class cmInstallScriptGenerator + * \brief Generate target installation rules. + */ +class cmInstallScriptGenerator: public cmInstallGenerator +{ +public: + cmInstallScriptGenerator(const char* script); + virtual ~cmInstallScriptGenerator(); + +protected: + virtual void GenerateScript(std::ostream& os); + std::string Script; +}; + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallTargetGenerator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallTargetGenerator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallTargetGenerator.cxx 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallTargetGenerator.cxx 2006-03-16 00:02:04.000000000 +0800 @@ -0,0 +1,368 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmInstallTargetGenerator.cxx,v $ + Language: C++ + Date: $Date: 2006/03/15 16:02:04 $ + Version: $Revision: 1.9 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "cmInstallTargetGenerator.h" + +#include "cmGlobalGenerator.h" +#include "cmLocalGenerator.h" +#include "cmMakefile.h" +#include "cmTarget.h" + +//---------------------------------------------------------------------------- +cmInstallTargetGenerator +::cmInstallTargetGenerator(cmTarget& t, const char* dest, bool implib, + const char* permissions): + Target(&t), Destination(dest), ImportLibrary(implib), + Permissions(permissions) +{ + this->Target->SetHaveInstallRule(true); +} + +//---------------------------------------------------------------------------- +cmInstallTargetGenerator +::~cmInstallTargetGenerator() +{ +} + +//---------------------------------------------------------------------------- +void cmInstallTargetGenerator::GenerateScript(std::ostream& os) +{ + // Compute the build tree directory from which to copy the target. + std::string fromDir; + if(this->Target->NeedRelinkBeforeInstall()) + { + fromDir = this->Target->GetMakefile()->GetStartOutputDirectory(); + fromDir += "/CMakeFiles/CMakeRelink.dir/"; + } + else + { + fromDir = this->Target->GetDirectory(); + fromDir += "/"; + } + + // Write variable settings to do per-configuration references. + this->PrepareScriptReference(os, this->Target, "BUILD", true, false); + + // Create the per-configuration reference. + std::string fromName = this->GetScriptReference(this->Target, "BUILD", + false); + std::string fromFile = fromDir; + fromFile += fromName; + + // Choose the final destination. This may be modified for certain + // target types. + std::string destination = this->Destination; + + // Setup special properties for some target types. + std::string props; + const char* properties = 0; + cmTarget::TargetType type = this->Target->GetType(); + switch(type) + { + case cmTarget::SHARED_LIBRARY: + { + // Add shared library installation properties if this platform + // supports them. + const char* lib_version = this->Target->GetProperty("VERSION"); + const char* lib_soversion = this->Target->GetProperty("SOVERSION"); + if(!this->Target->GetMakefile() + ->GetDefinition("CMAKE_SHARED_LIBRARY_SONAME_C_FLAG")) + { + // Versioning is supported only for shared libraries and modules, + // and then only when the platform supports an soname flag. + lib_version = 0; + lib_soversion = 0; + } + if(lib_version) + { + props += " VERSION "; + props += lib_version; + } + if(lib_soversion) + { + props += " SOVERSION "; + props += lib_soversion; + } + properties = props.c_str(); + } + break; + case cmTarget::EXECUTABLE: + { + // Add executable installation properties if this platform + // supports them. +#if defined(_WIN32) && !defined(__CYGWIN__) + const char* exe_version = 0; +#else + const char* exe_version = this->Target->GetProperty("VERSION"); +#endif + if(exe_version) + { + props += " VERSION "; + props += exe_version; + properties = props.c_str(); + } + + // Handle OSX Bundles. + if(this->Target->GetPropertyAsBool("MACOSX_BUNDLE")) + { + // Compute the source locations of the bundle executable and + // Info.plist file. + this->PrepareScriptReference(os, this->Target, "INSTALL", + false, false); + std::string plist = fromFile; + plist += ".app/Contents/Info.plist"; + fromFile += ".app/Contents/MacOS/"; + fromFile += this->GetScriptReference(this->Target, "INSTALL", + false); + + // Compute the destination locations of the bundle Info.plist file. + destination += "/"; + destination += this->GetScriptReference(this->Target, "INSTALL", + false); + destination += ".app/Contents"; + + + // Install the Info.plist file. + this->AddInstallRule(os, destination.c_str(), cmTarget::INSTALL_FILES, + plist.c_str()); + + // Compute the destination locations of the bundle executable file. + destination += "/MacOS"; + } + } + break; + case cmTarget::STATIC_LIBRARY: + case cmTarget::MODULE_LIBRARY: + // Nothing special for modules or static libraries. + break; + default: + break; + } + + // An import library looks like a static library. + if(this->ImportLibrary) + { + type = cmTarget::STATIC_LIBRARY; + } + + // Write code to install the target file. + this->AddInstallRule(os, destination.c_str(), type, fromFile.c_str(), + this->ImportLibrary, properties, + this->Permissions.c_str()); + + // Fix the install_name settings in installed binaries. + if(type == cmTarget::SHARED_LIBRARY || + type == cmTarget::MODULE_LIBRARY || + type == cmTarget::EXECUTABLE) + { + this->AddInstallNamePatchRule(os, destination.c_str()); + } +} + +//---------------------------------------------------------------------------- +void +cmInstallTargetGenerator +::PrepareScriptReference(std::ostream& os, cmTarget* target, + const char* place, bool useConfigDir, + bool useSOName) +{ + // If the target name may vary with the configuration type then + // store all possible names ahead of time in variables. + std::string fname; + for(std::vector::const_iterator i = + this->ConfigurationTypes->begin(); + i != this->ConfigurationTypes->end(); ++i) + { + // Initialize the name. + fname = ""; + + if(useConfigDir) + { + // Start with the configuration's subdirectory. + target->GetMakefile()->GetLocalGenerator()->GetGlobalGenerator()-> + AppendDirectoryForConfig("", i->c_str(), "/", fname); + } + + // Compute the name of the library. + std::string targetName; + std::string targetNameSO; + std::string targetNameReal; + std::string targetNameImport; + target->GetLibraryNames(targetName, targetNameSO, targetNameReal, + targetNameImport, i->c_str()); + if(this->ImportLibrary) + { + // Use the import library name. + fname += targetNameImport; + } + else if(useSOName) + { + // Use the soname. + fname += targetNameSO; + } + else + { + // Use the canonical name. + fname += targetName; + } + + // Set a variable with the target name for this configuration. + os << "SET(" << target->GetName() << "_" << place + << (this->ImportLibrary? "_IMPNAME_" : "_NAME_") << *i + << " \"" << fname << "\")\n"; + } +} + +//---------------------------------------------------------------------------- +std::string cmInstallTargetGenerator::GetScriptReference(cmTarget* target, + const char* place, + bool useSOName) +{ + if(this->ConfigurationTypes->empty()) + { + // Reference the target by its one configuration name. + std::string targetName; + std::string targetNameSO; + std::string targetNameReal; + std::string targetNameImport; + target->GetLibraryNames(targetName, targetNameSO, targetNameReal, + targetNameImport, this->ConfigurationName); + if(this->ImportLibrary) + { + // Use the import library name. + return targetNameImport; + } + else if(useSOName) + { + // Use the soname. + return targetNameSO; + } + else + { + // Use the canonical name. + return targetName; + } + } + else + { + // Reference the target using the per-configuration variable. + std::string ref = "${"; + ref += target->GetName(); + if(this->ImportLibrary) + { + ref += "_"; + ref += place; + ref += "_IMPNAME_"; + } + else + { + ref += "_"; + ref += place; + ref += "_NAME_"; + } + ref += "${CMAKE_INSTALL_CONFIG_NAME}}"; + return ref; + } +} + +//---------------------------------------------------------------------------- +void cmInstallTargetGenerator::AddInstallNamePatchRule(std::ostream& os, + const char* destination) +{ + // Build a map of build-tree install_name to install-tree install_name for + // shared libraries linked to this target. + std::map install_name_remap; + cmTarget::LinkLibraryType linkType = cmTarget::OPTIMIZED; + const char* config = this->ConfigurationName; + if(config && cmSystemTools::UpperCase(config) == "DEBUG") + { + linkType = cmTarget::DEBUG; + } + // TODO: Merge with ComputeLinkInformation. + const cmTarget::LinkLibraryVectorType& inLibs = + this->Target->GetLinkLibraries(); + for(cmTarget::LinkLibraryVectorType::const_iterator j = inLibs.begin(); + j != inLibs.end(); ++j) + { + std::string lib = j->first; + if((this->Target->GetType() == cmTarget::EXECUTABLE || + lib != this->Target->GetName()) && + (j->second == cmTarget::GENERAL || j->second == linkType)) + { + if(cmTarget* tgt = this->Target->GetMakefile()->GetLocalGenerator()->GetGlobalGenerator()->FindTarget(0, lib.c_str())) + { + if(tgt->GetType() == cmTarget::SHARED_LIBRARY) + { + // If the build tree and install tree use different path components + // of the install_name field then we need to create a mapping to be + // applied after installation. + std::string for_build = tgt->GetInstallNameDirForBuildTree(config); + std::string for_install = + tgt->GetInstallNameDirForInstallTree(config); + if(for_build != for_install) + { + // Map from the build-tree install_name. + this->PrepareScriptReference(os, tgt, "REMAP_FROM", + !for_build.empty(), true); + for_build += this->GetScriptReference(tgt, "REMAP_FROM", true); + + // Map to the install-tree install_name. + this->PrepareScriptReference(os, tgt, "REMAP_TO", + false, true); + for_install += this->GetScriptReference(tgt, "REMAP_TO", true); + + // Store the mapping entry. + install_name_remap[for_build] = for_install; + } + } + } + } + } + + // Edit the install_name of the target itself if necessary. + this->PrepareScriptReference(os, this->Target, "REMAPPED", false, true); + std::string new_id; + if(this->Target->GetType() == cmTarget::SHARED_LIBRARY) + { + std::string for_build = this->Target->GetInstallNameDirForBuildTree(config); + std::string for_install = this->Target->GetInstallNameDirForInstallTree(config); + if(for_build != for_install) + { + // Prepare to refer to the install-tree install_name. + new_id = for_install; + new_id += this->GetScriptReference(this->Target, "REMAPPED", true); + } + } + + // Write a rule to run install_name_tool to set the install-tree + // install_name value and references. + if(!new_id.empty() || !install_name_remap.empty()) + { + os << "EXECUTE_PROCESS(COMMAND install_name_tool"; + if(!new_id.empty()) + { + os << "\n -id \"" << new_id << "\""; + } + for(std::map::const_iterator + i = install_name_remap.begin(); + i != install_name_remap.end(); ++i) + { + os << "\n -change \"" << i->first << "\" \"" << i->second << "\""; + } + os << "\n \"" << destination << "/" + << this->GetScriptReference(this->Target, "REMAPPED", true) << "\")\n"; + } +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallTargetGenerator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallTargetGenerator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallTargetGenerator.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallTargetGenerator.h 2006-03-04 08:29:35.000000000 +0800 @@ -0,0 +1,48 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmInstallTargetGenerator.h,v $ + Language: C++ + Date: $Date: 2006/03/04 00:29:35 $ + Version: $Revision: 1.4 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef cmInstallTargetGenerator_h +#define cmInstallTargetGenerator_h + +#include "cmInstallGenerator.h" + +class cmTarget; + +/** \class cmInstallTargetGenerator + * \brief Generate target installation rules. + */ +class cmInstallTargetGenerator: public cmInstallGenerator +{ +public: + cmInstallTargetGenerator(cmTarget& t, const char* dest, bool implib, + const char* permissions = ""); + virtual ~cmInstallTargetGenerator(); + +protected: + virtual void GenerateScript(std::ostream& os); + void PrepareScriptReference(std::ostream& os, cmTarget* target, + const char* place, bool useConfigDir, + bool useSOName); + std::string GetScriptReference(cmTarget* target, const char* place, + bool useSOName); + void AddInstallNamePatchRule(std::ostream& os, const char* destination); + cmTarget* Target; + std::string Destination; + bool ImportLibrary; + std::string Permissions; +}; + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallTargetsCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallTargetsCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallTargetsCommand.cxx 2004-01-28 01:37:30.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallTargetsCommand.cxx 2006-03-16 00:02:04.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmInstallTargetsCommand.cxx,v $ Language: C++ - Date: $Date: 2004/01/27 17:37:30 $ - Version: $Revision: 1.9 $ + Date: $Date: 2006/03/15 16:02:04 $ + Version: $Revision: 1.12 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -25,7 +25,7 @@ return false; } - cmTargets &tgts = m_Makefile->GetTargets(); + cmTargets &tgts = this->Makefile->GetTargets(); std::vector::const_iterator s = args.begin(); ++s; std::string runtime_dir = "/bin"; @@ -46,9 +46,16 @@ { tgts[*s].SetInstallPath(args[0].c_str()); tgts[*s].SetRuntimeInstallPath(runtime_dir.c_str()); + tgts[*s].SetHaveInstallRule(true); + } + else + { + std::string str = "Cannot find target: \"" + *s + "\" to install."; + this->SetError(str.c_str()); + return false; } } - + return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallTargetsCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallTargetsCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmInstallTargetsCommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmInstallTargetsCommand.h 2006-02-20 04:25:27.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmInstallTargetsCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.9.2.1 $ + Date: $Date: 2006/02/19 20:25:27 $ + Version: $Revision: 1.11 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -53,7 +53,7 @@ */ virtual const char* GetTerseDocumentation() { - return "Create install rules for targets."; + return "Old installation command. Use the INSTALL command."; } /** @@ -62,6 +62,8 @@ virtual const char* GetFullDocumentation() { return + "This command has been superceded by the INSTALL command. It " + "is provided for compatibility with older CMake code.\n" " INSTALL_TARGETS( [RUNTIME_DIRECTORY dir] target target)\n" "Create rules to install the listed targets into the given directory. " "The directory is relative to the installation prefix, which " diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmITKWrapTclCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmITKWrapTclCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmITKWrapTclCommand.cxx 2005-06-16 22:23:43.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmITKWrapTclCommand.cxx 1970-01-01 08:00:00.000000000 +0800 @@ -1,244 +0,0 @@ -/*========================================================================= - - Program: CMake - Cross-Platform Makefile Generator - Module: $RCSfile: cmITKWrapTclCommand.cxx,v $ - Language: C++ - Date: $Date: 2005/06/16 14:23:43 $ - Version: $Revision: 1.16 $ - - Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ -#include "cmITKWrapTclCommand.h" -#include "cmMakeDepend.h" - -cmITKWrapTclCommand::cmITKWrapTclCommand(): - m_MakeDepend(new cmMakeDepend) -{ -} - -cmITKWrapTclCommand::~cmITKWrapTclCommand() -{ - delete m_MakeDepend; -} - - - -void -cmITKWrapTclCommand::AddDependencies(cmDependInformation const *info, - std::vector& depends, - std::set& visited) -{ - if(!info) - { - return; - } - // add info to the visited set - visited.insert(info); - - // add this dependency and the recurse - // now recurse with info's dependencies - for(cmDependInformation::DependencySet::const_iterator d = - info->m_DependencySet.begin(); - d != info->m_DependencySet.end(); ++d) - { - if (visited.find(*d) == visited.end()) - { - if((*d)->m_FullPath != "") - { - depends.push_back((*d)->m_FullPath); - } - this->AddDependencies(*d,depends,visited); - } - } -} - -// cmITKWrapTclCommand -bool cmITKWrapTclCommand::InitialPass(std::vector const& args) -{ - // deprecated - const char* versionValue - = m_Makefile->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY"); - if (atof(versionValue) > 2.2) - { - this->SetError("The ITK_WRAP_TCL command was deprecated in CMake version 2.2 and will be removed in later versions of CMake. You should modify your CMakeLists.txt files to use the MACRO command or use CMake 2.2 or earlier for this project.\n"); - return false; - } - if (atof(versionValue) > 2.0) - { - cmSystemTools::Message("The ITK_WRAP_TCL command was deprecated in CMake version 2.2 and will be removed in later versions. You should modify your CMakeLists.txt files to use a MACRO or use CMake 2.2 or earlier.\n","Warning"); - } - - if(args.size() < 2 ) - { - this->SetError("called with incorrect number of arguments"); - return false; - } - // keep the target name - m_TargetName = args[0]; - m_Target = &m_Makefile->GetTargets().find(m_TargetName)->second; - - // Prepare the dependency generator. - m_MakeDepend->SetMakefile(m_Makefile); - - for(std::vector::const_iterator i = (args.begin() + 1); - i != args.end(); ++i) - { - if(!this->CreateCableRule((*i).c_str())) { return false; } - } - - return true; -} - -bool cmITKWrapTclCommand::CreateCableRule(const char* configFile) -{ - std::string tclFile = - cmSystemTools::GetFilenameWithoutExtension(configFile); - tclFile += "_tcl"; - - std::string inFile = m_Makefile->GetCurrentDirectory(); - inFile += "/"; - inFile += configFile; - - std::string outDir = m_Makefile->GetCurrentOutputDirectory(); - - // Generate the rule to run cable to generate wrappers. - std::string command = this->GetCableFromCache(); - std::vector depends; - - // Special case for CMake's wrapping test. Don't add dependency if - // it is a dummy executable. - if(command != "echo") - { - depends.push_back(command); - } - - cmCustomCommandLine commandLine; - commandLine.push_back(command); - commandLine.push_back(inFile); - commandLine.push_back("-tcl"); - std::string tmp = tclFile+".cxx"; - commandLine.push_back(tmp); -#if !defined(_WIN32) || defined(__CYGWIN__) - tmp = "${CMAKE_CXX_COMPILER}"; - m_Makefile->ExpandVariablesInString(tmp); - if(tmp.length() > 0) - { - commandLine.push_back("--gccxml-compiler"); - commandLine.push_back(tmp); - tmp = "${CMAKE_CXX_FLAGS}"; - m_Makefile->ExpandVariablesInString(tmp); - commandLine.push_back("--gccxml-cxxflags"); - commandLine.push_back(tmp); - } -#else - const char* genName = m_Makefile->GetDefinition("CMAKE_GENERATOR"); - if (genName) - { - std::string gen = genName; - if(gen == "Visual Studio 6") - { - commandLine.push_back("--gccxml-compiler"); - commandLine.push_back("msvc6"); - tmp = "${CMAKE_CXX_FLAGS}"; - m_Makefile->ExpandVariablesInString(tmp); - commandLine.push_back("--gccxml-cxxflags"); - commandLine.push_back(tmp); - } - else if(gen == "Visual Studio 7") - { - commandLine.push_back("--gccxml-compiler"); - commandLine.push_back("msvc7"); - tmp = "${CMAKE_CXX_FLAGS}"; - m_Makefile->ExpandVariablesInString(tmp); - commandLine.push_back("--gccxml-cxxflags"); - commandLine.push_back(tmp); - } - else if(gen == "NMake Makefiles") - { - tmp = "${CMAKE_CXX_COMPILER}"; - m_Makefile->ExpandVariablesInString(tmp); - commandLine.push_back("--gccxml-compiler"); - commandLine.push_back(tmp); - tmp = "${CMAKE_CXX_FLAGS}"; - m_Makefile->ExpandVariablesInString(tmp); - commandLine.push_back("--gccxml-cxxflags"); - commandLine.push_back(tmp); - } - } -#endif - const char* gccxml = m_Makefile->GetDefinition("ITK_GCCXML_EXECUTABLE"); - if(gccxml) - { - commandLine.push_back("--gccxml"); - commandLine.push_back(gccxml); - } - tmp = "-I"; - tmp += m_Makefile->GetStartDirectory(); - commandLine.push_back(tmp); - const std::vector& includes = - m_Makefile->GetIncludeDirectories(); - for(std::vector::const_iterator i = includes.begin(); - i != includes.end(); ++i) - { - tmp = "-I"; - tmp += i->c_str(); - m_Makefile->ExpandVariablesInString(tmp); - commandLine.push_back(tmp); - } - - // Get the dependencies. - const cmDependInformation* info = - m_MakeDepend->FindDependencies(inFile.c_str()); - if (info) - { - std::set visited; - this->AddDependencies(info, depends, visited); - } - - std::string output; - output = outDir+"/"+tclFile+".cxx"; - - // Add the source to the makefile. - cmSourceFile file; - file.SetName(tclFile.c_str(), outDir.c_str(), "cxx", false); - // Set dependency hints. - file.GetDepends().push_back(inFile.c_str()); - file.GetDepends().push_back("CableTclFacility/ctCalls.h"); - m_Makefile->AddSource(file); - - const char* no_comment = 0; - cmCustomCommandLines commandLines; - commandLines.push_back(commandLine); - m_Makefile->AddCustomCommandToOutput(output.c_str(), depends, - inFile.c_str(), commandLines, - no_comment); - - // Add the generated source to the package's source list. - m_Target->GetSourceLists().push_back(output); - - return true; -} - -/** - * Get the "CABLE" cache entry value. If there is no cache entry for CABLE, - * one will be created and initialized to NOTFOUND. - */ -std::string cmITKWrapTclCommand::GetCableFromCache() const -{ - const char* cable = - m_Makefile->GetDefinition("CABLE"); - if(cable) - { return cable; } - - m_Makefile->AddCacheDefinition("CABLE", - "CABLE-NOTFOUND", - "Path to CABLE executable.", - cmCacheManager::FILEPATH); - return "CABLE-NOTFOUND"; -} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmITKWrapTclCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmITKWrapTclCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmITKWrapTclCommand.h 2003-08-11 06:30:53.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmITKWrapTclCommand.h 1970-01-01 08:00:00.000000000 +0800 @@ -1,75 +0,0 @@ -/*========================================================================= - - Program: CMake - Cross-Platform Makefile Generator - Module: $RCSfile: cmITKWrapTclCommand.h,v $ - Language: C++ - Date: $Date: 2003/08/10 22:30:53 $ - Version: $Revision: 1.6 $ - - Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ -#ifndef cmITKWrapTclCommand_h -#define cmITKWrapTclCommand_h - -#include "cmCommand.h" -class cmDependInformation; -class cmMakeDepend; - -/** \class cmITKWrapTclCommand - * \brief Run CABLE to generate Tcl wrappers. - * - * cmITKWrapTclCommand runs CABLE on the specified configuration files - * and combines them into a package on a given target. - */ -class cmITKWrapTclCommand : public cmCommand -{ -public: - cmITKWrapTclCommand(); - ~cmITKWrapTclCommand(); - - /** This is a virtual constructor for the command. */ - virtual cmCommand* Clone() { return new cmITKWrapTclCommand; } - - /** This is called when the command is first encountered in - * the CMakeLists.txt file. */ - virtual bool InitialPass(std::vector const& args); - - /** The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() {return "ITK_WRAP_TCL";} - - /** Succinct documentation. */ - virtual const char* GetTerseDocumentation() - { return "Run CABLE to generate Tcl wrappers."; } - - /** More documentation. */ - virtual const char* GetFullDocumentation() - { - return - " ITK_WRAP_TCL(target-name config-file1 [config-file2 ...])\n" - "Run CABLE on all the configuration files to generate Tcl wrappers. " - "The generated sources are added to a target of the given name. This " - "command is provided for use by the Insight Toolkit (ITK) because it " - "was originally written before loaded commands were supported."; - } - - cmTypeMacro(cmITKWrapTclCommand, cmCommand); -protected: - void AddDependencies(cmDependInformation const*info, - std::vector& depends, - std::set& visited); - cmStdString m_TargetName; - cmTarget* m_Target; - - bool CreateCableRule(const char* configFile); - std::string GetCableFromCache() const; - - cmMakeDepend* m_MakeDepend; -}; - -#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLinkDirectoriesCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLinkDirectoriesCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLinkDirectoriesCommand.cxx 2002-12-12 07:13:33.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLinkDirectoriesCommand.cxx 2006-03-16 00:02:04.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmLinkDirectoriesCommand.cxx,v $ Language: C++ - Date: $Date: 2002/12/11 23:13:33 $ - Version: $Revision: 1.9 $ + Date: $Date: 2006/03/15 16:02:04 $ + Version: $Revision: 1.10 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -27,7 +27,7 @@ for(std::vector::const_iterator i = args.begin(); i != args.end(); ++i) { - m_Makefile->AddLinkDirectory((*i).c_str()); + this->Makefile->AddLinkDirectory((*i).c_str()); } return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLinkLibrariesCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLinkLibrariesCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLinkLibrariesCommand.cxx 2004-07-29 23:45:14.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLinkLibrariesCommand.cxx 2006-03-16 00:02:04.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmLinkLibrariesCommand.cxx,v $ Language: C++ - Date: $Date: 2004/07/29 15:45:14 $ - Version: $Revision: 1.20 $ + Date: $Date: 2006/03/15 16:02:04 $ + Version: $Revision: 1.22 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -36,7 +36,7 @@ this->SetError("The \"debug\" argument must be followed by a library"); return false; } - m_Makefile->AddLinkLibrary(i->c_str(), + this->Makefile->AddLinkLibrary(i->c_str(), cmTarget::DEBUG); } else if (*i == "optimized") @@ -47,27 +47,12 @@ this->SetError("The \"optimized\" argument must be followed by a library"); return false; } - m_Makefile->AddLinkLibrary(i->c_str(), + this->Makefile->AddLinkLibrary(i->c_str(), cmTarget::OPTIMIZED); } else { - m_Makefile->AddLinkLibrary(i->c_str()); - } - - const char* ldir = m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"); - if (cmSystemTools::IsOff(ldir)) - { - std::string libPath = *i + "_CMAKE_PATH"; - const char* dir = m_Makefile->GetDefinition(libPath.c_str()); - if( dir && *dir ) - { - m_Makefile->AddLinkDirectory( dir ); - } - } - else - { - m_Makefile->AddLinkDirectory( ldir ); + this->Makefile->AddLinkLibrary(i->c_str()); } } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmListCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmListCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmListCommand.cxx 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmListCommand.cxx 2006-03-16 00:02:04.000000000 +0800 @@ -0,0 +1,359 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmListCommand.cxx,v $ + Language: C++ + Date: $Date: 2006/03/15 16:02:04 $ + Version: $Revision: 1.2 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "cmListCommand.h" +#include +#include + +#include // required for atoi +#include +//---------------------------------------------------------------------------- +bool cmListCommand::InitialPass(std::vector const& args) +{ + if(args.size() < 1) + { + this->SetError("must be called with at least one argument."); + return false; + } + + const std::string &subCommand = args[0]; + if(subCommand == "LENGTH") + { + return this->HandleLengthCommand(args); + } + if(subCommand == "GET") + { + return this->HandleGetCommand(args); + } + if(subCommand == "SET") + { + return this->HandleSetCommand(args); + } + if(subCommand == "INSERT") + { + return this->HandleInsertCommand(args); + } + if(subCommand == "REMOVE") + { + return this->HandleRemoveCommand(args); + } + if(subCommand == "REMOVE_ITEM") + { + return this->HandleRemoveItemCommand(args); + } + + std::string e = "does not recognize sub-command "+subCommand; + this->SetError(e.c_str()); + return false; +} + +//---------------------------------------------------------------------------- +bool cmListCommand::GetListString(std::string& listString, const char* var) +{ + if ( !var ) + { + return false; + } + // get the old value + const char* cacheValue + = this->Makefile->GetDefinition(var); + if(!cacheValue) + { + cmOStringStream str; + str << "cannot find variable: " << var; + this->SetError(str.str().c_str()); + return false; + } + listString = cacheValue; + return true; +} + +//---------------------------------------------------------------------------- +bool cmListCommand::GetList(std::vector& list, const char* var) +{ + std::string listString; + if ( !this->GetListString(listString, var) ) + { + return false; + } + // expand the variable + cmSystemTools::ExpandListArgument(listString, list); + return true; +} + +//---------------------------------------------------------------------------- +bool cmListCommand::HandleLengthCommand(std::vector const& args) +{ + if(args.size() != 3) + { + this->SetError("sub-command LENGTH requires two arguments."); + return false; + } + + const std::string& listName = args[1]; + const std::string& variableName = args[args.size() - 1]; + std::vector varArgsExpanded; + if ( !this->GetList(varArgsExpanded, listName.c_str()) ) + { + return false; + } + + size_t length = varArgsExpanded.size(); + char buffer[1024]; + sprintf(buffer, "%d", static_cast(length)); + + this->Makefile->AddDefinition(variableName.c_str(), buffer); + return true; +} + +//---------------------------------------------------------------------------- +bool cmListCommand::HandleGetCommand(std::vector const& args) +{ + if(args.size() < 4) + { + this->SetError("sub-command GET requires at least three arguments."); + return false; + } + + const std::string& listName = args[1]; + const std::string& variableName = args[args.size() - 1]; + // expand the variable + std::vector varArgsExpanded; + if ( !this->GetList(varArgsExpanded, listName.c_str()) ) + { + return false; + } + + std::string value; + size_t cc; + for ( cc = 2; cc < args.size()-1; cc ++ ) + { + int item = atoi(args[cc].c_str()); + if (value.size()) + { + value += ";"; + } + int nitem = varArgsExpanded.size(); + if ( item < 0 ) + { + item = nitem + item; + } + if ( item < 0 || nitem <= item ) + { + cmOStringStream str; + str << "index: " << item << " out of range (-" << varArgsExpanded.size() << ", " << varArgsExpanded.size()-1 << ")"; + this->SetError(str.str().c_str()); + return false; + } + value += varArgsExpanded[item]; + } + + this->Makefile->AddDefinition(variableName.c_str(), value.c_str()); + return true; +} + +//---------------------------------------------------------------------------- +bool cmListCommand::HandleSetCommand(std::vector const& args) +{ + if(args.size() < 3) + { + this->SetError("sub-command SET requires at least two arguments."); + return false; + } + + const std::string& listName = args[1]; + // expand the variable + std::string listString; + if ( !this->GetListString(listString, listName.c_str()) ) + { + return false; + } + size_t cc; + for ( cc = 2; cc < args.size(); ++ cc ) + { + if ( listString.size() ) + { + listString += ";"; + } + listString += args[cc]; + } + + this->Makefile->AddDefinition(listName.c_str(), listString.c_str()); + return true; +} + +//---------------------------------------------------------------------------- +bool cmListCommand::HandleInsertCommand(std::vector const& args) +{ + if(args.size() < 4) + { + this->SetError("sub-command INSERT requires at least three arguments."); + return false; + } + + const std::string& listName = args[1]; + // expand the variable + std::vector varArgsExpanded; + if ( !this->GetList(varArgsExpanded, listName.c_str()) ) + { + return false; + } + + int item = atoi(args[2].c_str()); + + int nitem = varArgsExpanded.size(); + if ( item < 0 ) + { + item = nitem + item; + } + if ( item < 0 || nitem <= item ) + { + cmOStringStream str; + str << "index: " << item << " out of range (-" << varArgsExpanded.size() << ", " << varArgsExpanded.size()-1 << ")"; + this->SetError(str.str().c_str()); + return false; + } + size_t cc; + size_t cnt = 0; + for ( cc = 3; cc < args.size(); ++ cc ) + { + varArgsExpanded.insert(varArgsExpanded.begin()+item+cnt, args[cc]); + cnt ++; + } + + std::string value; + for ( cc = 0; cc < varArgsExpanded.size(); cc ++ ) + { + if (value.size()) + { + value += ";"; + } + value += varArgsExpanded[cc]; + } + + this->Makefile->AddDefinition(listName.c_str(), value.c_str()); + return true; +} + +//---------------------------------------------------------------------------- +bool cmListCommand::HandleRemoveCommand(std::vector const& args) +{ + if(args.size() < 3) + { + this->SetError("sub-command REMOVE requires at least two arguments."); + return false; + } + + const std::string& listName = args[1]; + // expand the variable + std::vector varArgsExpanded; + if ( !this->GetList(varArgsExpanded, listName.c_str()) ) + { + return false; + } + + size_t cc; + for ( cc = 2; cc < args.size(); ++ cc ) + { + size_t kk = 0; + while ( kk < varArgsExpanded.size() ) + { + if ( varArgsExpanded[kk] == args[cc] ) + { + varArgsExpanded.erase(varArgsExpanded.begin()+kk); + } + kk ++; + } + } + + std::string value; + for ( cc = 0; cc < varArgsExpanded.size(); cc ++ ) + { + if (value.size()) + { + value += ";"; + } + value += varArgsExpanded[cc]; + } + + this->Makefile->AddDefinition(listName.c_str(), value.c_str()); + return true; +} + +//---------------------------------------------------------------------------- +bool cmListCommand::HandleRemoveItemCommand(std::vector const& args) +{ + if(args.size() < 3) + { + this->SetError("sub-command REMOVE_ITEM requires at least two arguments."); + return false; + } + + const std::string& listName = args[1]; + // expand the variable + std::vector varArgsExpanded; + if ( !this->GetList(varArgsExpanded, listName.c_str()) ) + { + return false; + } + + size_t cc; + std::vector removed; + for ( cc = 2; cc < args.size(); ++ cc ) + { + int item = atoi(args[cc].c_str()); + int nitem = varArgsExpanded.size(); + if ( item < 0 ) + { + item = nitem + item; + } + if ( item < 0 || nitem <= item ) + { + cmOStringStream str; + str << "index: " << item << " out of range (-" << varArgsExpanded.size() << ", " << varArgsExpanded.size()-1 << ")"; + this->SetError(str.str().c_str()); + return false; + } + removed.push_back(static_cast(item)); + } + + std::string value; + for ( cc = 0; cc < varArgsExpanded.size(); ++ cc ) + { + size_t kk; + bool found = false; + for ( kk = 0; kk < removed.size(); ++ kk ) + { + if ( cc == removed[kk] ) + { + found = true; + } + } + + if ( !found ) + { + if (value.size()) + { + value += ";"; + } + value += varArgsExpanded[cc]; + } + } + + this->Makefile->AddDefinition(listName.c_str(), value.c_str()); + return true; +} + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmListCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmListCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmListCommand.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmListCommand.h 2006-03-11 02:54:57.000000000 +0800 @@ -0,0 +1,100 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmListCommand.h,v $ + Language: C++ + Date: $Date: 2006/03/10 18:54:57 $ + Version: $Revision: 1.2 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef cmListCommand_h +#define cmListCommand_h + +#include "cmCommand.h" + +/** \class cmListCommand + * \brief Common list operations + * + */ +class cmListCommand : public cmCommand +{ +public: + /** + * This is a virtual constructor for the command. + */ + virtual cmCommand* Clone() + { + return new cmListCommand; + } + + /** + * This is called when the command is first encountered in + * the CMakeLists.txt file. + */ + virtual bool InitialPass(std::vector const& args); + + /** + * This determines if the command is invoked when in script mode. + */ + virtual bool IsScriptable() { return true; } + + /** + * The name of the command as specified in CMakeList.txt. + */ + virtual const char* GetName() { return "LIST";} + + /** + * Succinct documentation. + */ + virtual const char* GetTerseDocumentation() + { + return "List operations."; + } + + /** + * More documentation. + */ + virtual const char* GetFullDocumentation() + { + return + " LIST(LENGTH )\n" + " LIST(GET [ ...] " + ")\n" + " LIST(SET [ ...])\n" + " LIST(INSERT [ ...])\n" + " LIST(REMOVE [ ...])\n" + " LIST(REMOVE_ITEM [ ...])\n" + " LIST(SORT )\n" + " LIST(REVERSE )\n" + "LENGTH will return a given list's length.\n" + "GET will return list of elements specified by indices from the list.\n" + "SET will append elements to the list.\n" + "INSERT will insert elements to the list to the specified location.\n" + "When specifying an index, negative value corresponds to index from the" + " end of the list.\n" + ; + } + + cmTypeMacro(cmListCommand, cmCommand); +protected: + bool HandleLengthCommand(std::vector const& args); + bool HandleGetCommand(std::vector const& args); + bool HandleSetCommand(std::vector const& args); + bool HandleInsertCommand(std::vector const& args); + bool HandleRemoveCommand(std::vector const& args); + bool HandleRemoveItemCommand(std::vector const& args); + + + bool GetList(std::vector& list, const char* var); + bool GetListString(std::string& listString, const char* var); +}; + + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmListFileCache.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmListFileCache.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmListFileCache.cxx 2005-07-07 03:25:05.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmListFileCache.cxx 2006-03-16 00:02:04.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmListFileCache.cxx,v $ Language: C++ - Date: $Date: 2005/07/06 19:25:05 $ - Version: $Revision: 1.24 $ + Date: $Date: 2006/03/15 16:02:04 $ + Version: $Revision: 1.27 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -25,72 +25,12 @@ cmListFileFunction& function, const char* filename); -cmListFileCache* cmListFileCache::Instance = 0; - - -cmListFileCache* cmListFileCache::GetInstance() -{ - if(!cmListFileCache::Instance) - { - cmListFileCache::Instance = new cmListFileCache; - } - return cmListFileCache::Instance; -} - - -void cmListFileCache::ClearCache() -{ - delete cmListFileCache::Instance; - cmListFileCache::Instance = 0; -} - - - -cmListFile* cmListFileCache::GetFileCache(const char* path, - bool requireProjectCommand) -{ - ListFileMap::iterator sl = m_ListFileCache.find(path); - if (sl == m_ListFileCache.end()) - { - // if not already in the map, then parse and store the - // file - if(!this->CacheFile(path, requireProjectCommand)) - { - return 0; - } - sl = m_ListFileCache.find(path); - if (sl == m_ListFileCache.end()) - { - cmSystemTools::Error("Fatal error, in cmListFileCache CacheFile failed", - path); - return 0; - } - } - cmListFile& ret = sl->second; - if(cmSystemTools::ModifiedTime(path) > ret.m_ModifiedTime ) - { - if(!this->CacheFile(path, requireProjectCommand)) - { - return 0; - } - else - { - sl = m_ListFileCache.find(path); - return &sl->second; - } - } - return &ret; -} - - -bool cmListFileCache::CacheFile(const char* path, bool requireProjectCommand) +bool cmListFile::ParseFile(const char* filename, bool requireProjectCommand) { - if(!cmSystemTools::FileExists(path)) + if(!cmSystemTools::FileExists(filename)) { return false; } - // Get a pointer to a persistent copy of the name. - const char* filename = this->GetUniqueStringPointer(path); // Create the scanner. cmListFileLexer* lexer = cmListFileLexer_New(); @@ -110,8 +50,7 @@ // Use a simple recursive-descent parser to process the token // stream. - cmListFile inFile; - inFile.m_ModifiedTime = cmSystemTools::ModifiedTime(filename); + this->ModifiedTime = cmSystemTools::ModifiedTime(filename); bool parseError = false; bool haveNewline = true; cmListFileLexer_Token* token; @@ -127,12 +66,12 @@ { haveNewline = false; cmListFileFunction inFunction; - inFunction.m_Name = token->text; - inFunction.m_FilePath = filename; - inFunction.m_Line = token->line; + inFunction.Name = token->text; + inFunction.FilePath = filename; + inFunction.Line = token->line; if(cmListFileCacheParseFunction(lexer, inFunction, filename)) { - inFile.m_Functions.push_back(inFunction); + this->Functions.push_back(inFunction); } else { @@ -166,7 +105,7 @@ } if (parseError) { - inFile.m_ModifiedTime = 0; + this->ModifiedTime = 0; } cmListFileLexer_Delete(lexer); @@ -176,10 +115,10 @@ bool hasProject = false; // search for a project command for(std::vector::iterator i - = inFile.m_Functions.begin(); - i != inFile.m_Functions.end(); ++i) + = this->Functions.begin(); + i != this->Functions.end(); ++i) { - if(cmSystemTools::LowerCase(i->m_Name) == "project") + if(cmSystemTools::LowerCase(i->Name) == "project") { hasProject = true; break; @@ -189,26 +128,15 @@ if(!hasProject) { cmListFileFunction project; - project.m_Name = "PROJECT"; + project.Name = "PROJECT"; cmListFileArgument prj("Project", false, filename, 0); - project.m_Arguments.push_back(prj); - inFile.m_Functions.insert(inFile.m_Functions.begin(),project); + project.Arguments.push_back(prj); + this->Functions.insert(this->Functions.begin(),project); } } - m_ListFileCache[filename] = inFile; return true; } -void cmListFileCache::FlushCache(const char* path) -{ - ListFileMap::iterator it = m_ListFileCache.find(path); - if ( it != m_ListFileCache.end() ) - { - m_ListFileCache.erase(it); - return; - } -} - bool cmListFileCacheParseFunction(cmListFileLexer* lexer, cmListFileFunction& function, const char* filename) @@ -249,13 +177,13 @@ { cmListFileArgument a(token->text, false, filename, token->line); - function.m_Arguments.push_back(a); + function.Arguments.push_back(a); } else if(token->type == cmListFileLexer_Token_ArgumentQuoted) { cmListFileArgument a(token->text, true, filename, token->line); - function.m_Arguments.push_back(a); + function.Arguments.push_back(a); } else if(token->type != cmListFileLexer_Token_Newline) { @@ -282,26 +210,3 @@ return false; } - -//---------------------------------------------------------------------------- -const char* cmListFileCache::GetUniqueStringPointer(const char* name) -{ - UniqueStrings::iterator i = m_UniqueStrings.find(name); - if(i == m_UniqueStrings.end()) - { - char* str = new char[strlen(name)+1]; - strcpy(str, name); - i = m_UniqueStrings.insert(UniqueStrings::value_type(name, str)).first; - } - return i->second; -} - -//---------------------------------------------------------------------------- -cmListFileCache::~cmListFileCache() -{ - for(UniqueStrings::iterator i = m_UniqueStrings.begin(); - i != m_UniqueStrings.end(); ++i) - { - delete [] i->second; - } -} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmListFileCache.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmListFileCache.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmListFileCache.h 2004-08-04 22:45:11.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmListFileCache.h 2006-03-16 00:02:04.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmListFileCache.h,v $ Language: C++ - Date: $Date: 2004/08/04 14:45:11 $ - Version: $Revision: 1.14 $ + Date: $Date: 2006/03/15 16:02:04 $ + Version: $Revision: 1.17 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -50,54 +50,22 @@ struct cmListFileFunction { - std::string m_Name; - std::vector m_Arguments; - const char* m_FilePath; - long m_Line; + std::string Name; + std::vector Arguments; + const char* FilePath; + long Line; }; struct cmListFile { cmListFile() - :m_ModifiedTime(0) + :ModifiedTime(0) { } - long int m_ModifiedTime; - std::vector m_Functions; -}; - -class cmListFileCache -{ -public: - static cmListFileCache* GetInstance(); - static void ClearCache(); - - - /** Return the cached version of the given file. - * If the file is not already in the cache, a cache entry - * will be made. If there is an error loading the file, - * NULL is returned. If requireProjectCommand is true, - * then a PROJECT(Project) command will be added to the file - * if it does not have a PROJECT command in it. - */ - cmListFile* GetFileCache(const char* path, bool requireProjectCommand); - - //! Flush cache file out of cache. - void FlushCache(const char* path); - - ~cmListFileCache(); -private: - // Cache the file - bool CacheFile(const char* path, bool requireProjectCommand); - // private data - typedef std::map ListFileMap; - ListFileMap m_ListFileCache; // file name to ListFile map - - typedef std::map UniqueStrings; - UniqueStrings m_UniqueStrings; - const char* GetUniqueStringPointer(const char* name); + bool ParseFile(const char* path, bool requireProjectCommand); - static cmListFileCache* Instance; // singelton pointer + long int ModifiedTime; + std::vector Functions; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmListFileLexer.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmListFileLexer.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmListFileLexer.c 2005-10-07 03:28:33.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmListFileLexer.c 2005-09-20 05:20:48.000000000 +0800 @@ -478,8 +478,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmListFileLexer.c,v $ Language: C++ - Date: $Date: 2005/10/06 19:28:33 $ - Version: $Revision: 1.10.2.2 $ + Date: $Date: 2005/09/19 21:20:48 $ + Version: $Revision: 1.12 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmListFileLexer.in.l /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmListFileLexer.in.l --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmListFileLexer.in.l 2005-10-07 03:28:33.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmListFileLexer.in.l 2005-09-20 05:20:48.000000000 +0800 @@ -4,8 +4,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmListFileLexer.in.l,v $ Language: C++ - Date: $Date: 2005/10/06 19:28:33 $ - Version: $Revision: 1.10.2.2 $ + Date: $Date: 2005/09/19 21:20:48 $ + Version: $Revision: 1.12 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLoadCacheCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLoadCacheCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLoadCacheCommand.cxx 2004-09-30 04:07:07.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLoadCacheCommand.cxx 2006-03-16 00:02:04.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmLoadCacheCommand.cxx,v $ Language: C++ - Date: $Date: 2004/09/29 20:07:07 $ - Version: $Revision: 1.16 $ + Date: $Date: 2006/03/15 16:02:04 $ + Version: $Revision: 1.17 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -84,7 +84,7 @@ { break; } - m_Makefile->GetCacheManager()->LoadCache(args[i].c_str(), false, + this->Makefile->GetCacheManager()->LoadCache(args[i].c_str(), false, excludes, includes); } @@ -188,11 +188,11 @@ var = this->Prefix + var; if(value.length()) { - m_Makefile->AddDefinition(var.c_str(), value.c_str()); + this->Makefile->AddDefinition(var.c_str(), value.c_str()); } else { - m_Makefile->RemoveDefinition(var.c_str()); + this->Makefile->RemoveDefinition(var.c_str()); } } } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLoadCacheCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLoadCacheCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLoadCacheCommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLoadCacheCommand.h 2005-11-17 03:38:55.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmLoadCacheCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.11.2.1 $ + Date: $Date: 2005/11/16 19:38:55 $ + Version: $Revision: 1.12 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLoadCommandCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLoadCommandCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLoadCommandCommand.cxx 2005-03-18 23:41:40.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLoadCommandCommand.cxx 2006-03-17 06:09:08.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmLoadCommandCommand.cxx,v $ Language: C++ - Date: $Date: 2005/03/18 15:41:40 $ - Version: $Revision: 1.22 $ + Date: $Date: 2006/03/16 22:09:08 $ + Version: $Revision: 1.25 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -18,6 +18,9 @@ #include "cmCPluginAPI.h" #include "cmCPluginAPI.cxx" #include "cmDynamicLoader.h" + +#include + #include extern "C" void TrapsForSignalsCFunction(int sig); @@ -170,7 +173,8 @@ argv[i] = strdup(args[i].c_str()); } cmLoadedCommand::InstallSignalHandlers(info.Name); - int result = info.InitialPass((void *)&info,(void *)this->m_Makefile,argc,argv); + int result = info.InitialPass((void *)&info, + (void *)this->Makefile,argc,argv); cmLoadedCommand::InstallSignalHandlers(info.Name, 1); cmFreeArguments(argc,argv); @@ -192,7 +196,7 @@ if (this->info.FinalPass) { cmLoadedCommand::InstallSignalHandlers(info.Name); - this->info.FinalPass((void *)&this->info,(void *)this->m_Makefile); + this->info.FinalPass((void *)&this->info,(void *)this->Makefile); cmLoadedCommand::InstallSignalHandlers(info.Name, 1); } } @@ -223,11 +227,14 @@ // Start by removing the definition in case of failure. std::string reportVar = "CMAKE_LOADED_COMMAND_"; reportVar += args[0]; - m_Makefile->RemoveDefinition(reportVar.c_str()); + this->Makefile->RemoveDefinition(reportVar.c_str()); // the file must exist - std::string fullPath = cmDynamicLoader::LibPrefix(); - fullPath += "cm" + args[0] + cmDynamicLoader::LibExtension(); + std::string moduleName = + this->Makefile->GetRequiredDefinition("CMAKE_SHARED_MODULE_PREFIX"); + moduleName += "cm" + args[0]; + moduleName += + this->Makefile->GetRequiredDefinition("CMAKE_SHARED_MODULE_SUFFIX"); // search for the file std::vector path; @@ -242,23 +249,24 @@ } // Try to find the program. - fullPath = cmSystemTools::FindFile(fullPath.c_str(), path); + std::string fullPath = cmSystemTools::FindFile(moduleName.c_str(), path); if (fullPath == "") { - fullPath = "Attempt to load command failed from file : "; - fullPath += cmDynamicLoader::LibPrefix(); - fullPath += "cm" + args[0] + cmDynamicLoader::LibExtension(); - this->SetError(fullPath.c_str()); + cmOStringStream e; + e << "Attempt to load command failed from file \"" + << moduleName << "\""; + this->SetError(e.str().c_str()); return false; } // try loading the shared library / dll - cmLibHandle lib = cmDynamicLoader::OpenLibrary(fullPath.c_str()); + cmsys::DynamicLoader::LibraryHandle lib + = cmDynamicLoader::OpenLibrary(fullPath.c_str()); if(!lib) { std::string err = "Attempt to load the library "; err += fullPath + " failed."; - const char* error = cmDynamicLoader::LastError(); + const char* error = cmsys::DynamicLoader::LastError(); if ( error ) { err += " Additional error info is:\n"; @@ -269,20 +277,20 @@ } // Report what file was loaded for this command. - m_Makefile->AddDefinition(reportVar.c_str(), fullPath.c_str()); + this->Makefile->AddDefinition(reportVar.c_str(), fullPath.c_str()); // find the init function std::string initFuncName = args[0] + "Init"; CM_INIT_FUNCTION initFunction = (CM_INIT_FUNCTION) - cmDynamicLoader::GetSymbolAddress(lib, initFuncName.c_str()); + cmsys::DynamicLoader::GetSymbolAddress(lib, initFuncName.c_str()); if ( !initFunction ) { initFuncName = "_"; initFuncName += args[0]; initFuncName += "Init"; initFunction = (CM_INIT_FUNCTION)( - cmDynamicLoader::GetSymbolAddress(lib, initFuncName.c_str())); + cmsys::DynamicLoader::GetSymbolAddress(lib, initFuncName.c_str())); } // if the symbol is found call it to set the name on the // function blocker @@ -291,7 +299,7 @@ // create a function blocker and set it up cmLoadedCommand *f = new cmLoadedCommand(); (*initFunction)(&f->info); - m_Makefile->AddCommand(f); + this->Makefile->AddCommand(f); return true; } this->SetError("Attempt to load command failed. " diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLocalGenerator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLocalGenerator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLocalGenerator.cxx 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLocalGenerator.cxx 2006-03-17 03:51:54.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmLocalGenerator.cxx,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.72.2.4 $ + Date: $Date: 2006/03/16 19:51:54 $ + Version: $Revision: 1.114 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -15,43 +15,49 @@ =========================================================================*/ #include "cmLocalGenerator.h" + +#include "cmGeneratedFileStream.h" #include "cmGlobalGenerator.h" -#include "cmake.h" +#include "cmInstallGenerator.h" +#include "cmInstallFilesGenerator.h" +#include "cmInstallScriptGenerator.h" +#include "cmInstallTargetGenerator.h" #include "cmMakefile.h" -#include "cmGeneratedFileStream.h" -#include "cmSourceFile.h" #include "cmOrderLinkDirectories.h" +#include "cmSourceFile.h" #include "cmTest.h" +#include "cmake.h" + #include // for isalpha cmLocalGenerator::cmLocalGenerator() { - m_Makefile = new cmMakefile; - m_Makefile->SetLocalGenerator(this); - m_ExcludeFromAll = false; - m_Parent = 0; - m_WindowsShell = false; - m_IgnoreLibPrefix = false; - m_UseRelativePaths = false; + this->Makefile = new cmMakefile; + this->Makefile->SetLocalGenerator(this); + this->ExcludeFromAll = false; + this->Parent = 0; + this->WindowsShell = false; + this->IgnoreLibPrefix = false; + this->UseRelativePaths = false; this->Configured = false; } cmLocalGenerator::~cmLocalGenerator() { - delete m_Makefile; + delete this->Makefile; } void cmLocalGenerator::Configure() { // make sure the CMakeFiles dir is there - std::string filesDir = m_Makefile->GetStartOutputDirectory(); + std::string filesDir = this->Makefile->GetStartOutputDirectory(); filesDir += "/CMakeFiles"; cmSystemTools::MakeDirectory(filesDir.c_str()); // find & read the list file - std::string currentStart = m_Makefile->GetStartDirectory(); + std::string currentStart = this->Makefile->GetStartDirectory(); currentStart += "/CMakeLists.txt"; - m_Makefile->ReadListFile(currentStart.c_str()); + this->Makefile->ReadListFile(currentStart.c_str()); // at the end of the ReadListFile handle any old style subdirs // first get all the subdirectories @@ -63,7 +69,7 @@ { if (!(*sdi)->Configured) { - m_Makefile->ConfigureSubDirectory(*sdi); + this->Makefile->ConfigureSubDirectory(*sdi); } } @@ -71,7 +77,7 @@ // Check whether relative paths should be used for optionally // relative paths. - m_UseRelativePaths = m_Makefile->IsOn("CMAKE_USE_RELATIVE_PATHS"); + this->UseRelativePaths = this->Makefile->IsOn("CMAKE_USE_RELATIVE_PATHS"); this->Configured = true; } @@ -82,45 +88,45 @@ // Convert std::string outdir; outdir = - cmSystemTools::CollapseFullPath(m_Makefile->GetHomeDirectory()); - cmSystemTools::SplitPath(outdir.c_str(), m_HomeDirectoryComponents); + cmSystemTools::CollapseFullPath(this->Makefile->GetHomeDirectory()); + cmSystemTools::SplitPath(outdir.c_str(), this->HomeDirectoryComponents); outdir = - cmSystemTools::CollapseFullPath(m_Makefile->GetStartDirectory()); - cmSystemTools::SplitPath(outdir.c_str(), m_StartDirectoryComponents); + cmSystemTools::CollapseFullPath(this->Makefile->GetStartDirectory()); + cmSystemTools::SplitPath(outdir.c_str(), this->StartDirectoryComponents); outdir = - cmSystemTools::CollapseFullPath(m_Makefile->GetHomeOutputDirectory()); - cmSystemTools::SplitPath(outdir.c_str(), m_HomeOutputDirectoryComponents); + cmSystemTools::CollapseFullPath(this->Makefile->GetHomeOutputDirectory()); + cmSystemTools::SplitPath(outdir.c_str(), this->HomeOutputDirectoryComponents); outdir = - cmSystemTools::CollapseFullPath(m_Makefile->GetStartOutputDirectory()); -cmSystemTools::SplitPath(outdir.c_str(), m_StartOutputDirectoryComponents); + cmSystemTools::CollapseFullPath(this->Makefile->GetStartOutputDirectory()); +cmSystemTools::SplitPath(outdir.c_str(), this->StartOutputDirectoryComponents); } void cmLocalGenerator::SetGlobalGenerator(cmGlobalGenerator *gg) { - m_GlobalGenerator = gg; + this->GlobalGenerator = gg; // setup the home directories - m_Makefile->SetHomeDirectory( + this->Makefile->SetHomeDirectory( gg->GetCMakeInstance()->GetHomeDirectory()); - m_Makefile->SetHomeOutputDirectory( + this->Makefile->SetHomeOutputDirectory( gg->GetCMakeInstance()->GetHomeOutputDirectory()); } void cmLocalGenerator::ConfigureFinalPass() { - m_Makefile->ConfigureFinalPass(); + this->Makefile->ConfigureFinalPass(); } void cmLocalGenerator::GenerateTestFiles() { - if ( !m_Makefile->IsOn("CMAKE_TESTING_ENABLED") ) + if ( !this->Makefile->IsOn("CMAKE_TESTING_ENABLED") ) { return; } - std::string file = m_Makefile->GetStartOutputDirectory(); + std::string file = this->Makefile->GetStartOutputDirectory(); file += "/"; - if ( m_Makefile->IsSet("CTEST_NEW_FORMAT") ) + if ( this->Makefile->IsSet("CTEST_NEW_FORMAT") ) { file += "CTestTestfile.cmake"; } @@ -132,8 +138,8 @@ fout.SetCopyIfDifferent(true); fout << "# CMake generated Testfile for " << std::endl - << "# Source directory: " << m_Makefile->GetStartDirectory() << std::endl - << "# Build directory: " << m_Makefile->GetStartOutputDirectory() << std::endl + << "# Source directory: " << this->Makefile->GetStartDirectory() << std::endl + << "# Build directory: " << this->Makefile->GetStartOutputDirectory() << std::endl << "# " << std::endl << "# This file replicates the SUBDIRS() and ADD_TEST() commands from the source" << std::endl << "# tree CMakeLists.txt file, skipping any SUBDIRS() or ADD_TEST() commands" << std::endl @@ -142,13 +148,13 @@ << "# The next line is critical for Dart to work" << std::endl << "# Duh :-)" << std::endl << std::endl; - const char* testIncludeFile = m_Makefile->GetProperty("TEST_INCLUDE_FILE"); + const char* testIncludeFile = this->Makefile->GetProperty("TEST_INCLUDE_FILE"); if ( testIncludeFile ) { fout << "INCLUDE(\"" << testIncludeFile << "\")" << std::endl; } - const std::vector *tests = m_Makefile->GetTests(); + const std::vector *tests = this->Makefile->GetTests(); std::vector::const_iterator it; for ( it = tests->begin(); it != tests->end(); ++ it ) { @@ -222,7 +228,7 @@ { fout << "SUBDIRS("; size_t i; - std::string outDir = m_Makefile->GetStartOutputDirectory(); + std::string outDir = this->Makefile->GetStartOutputDirectory(); outDir += "/"; for(i = 0; i < this->Children.size(); ++i) { @@ -238,11 +244,11 @@ } } +//---------------------------------------------------------------------------- void cmLocalGenerator::GenerateInstallRules() { - cmTargets &tgts = m_Makefile->GetTargets(); - const char* prefix - = m_Makefile->GetDefinition("CMAKE_INSTALL_PREFIX"); + // Compute the install prefix. + const char* prefix = this->Makefile->GetDefinition("CMAKE_INSTALL_PREFIX"); #if defined(_WIN32) && !defined(__CYGWIN__) std::string prefix_win32; if(!prefix) @@ -251,7 +257,7 @@ { prefix_win32 = "C:"; } - const char* project_name = m_Makefile->GetDefinition("PROJECT_NAME"); + const char* project_name = this->Makefile->GetDefinition("PROJECT_NAME"); if(project_name && project_name[0]) { prefix_win32 += "/Program Files/"; @@ -270,9 +276,22 @@ } #endif - std::string file = m_Makefile->GetStartOutputDirectory(); - std::string homedir = m_Makefile->GetHomeOutputDirectory(); - std::string currdir = m_Makefile->GetCurrentOutputDirectory(); + // Compute the set of configurations. + std::vector configurationTypes; + if(const char* types = this->Makefile->GetDefinition("CMAKE_CONFIGURATION_TYPES")) + { + cmSystemTools::ExpandListArgument(types, configurationTypes); + } + const char* config = 0; + if(configurationTypes.empty()) + { + config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); + } + + // Create the install script file. + std::string file = this->Makefile->GetStartOutputDirectory(); + std::string homedir = this->Makefile->GetHomeOutputDirectory(); + std::string currdir = this->Makefile->GetCurrentOutputDirectory(); cmSystemTools::ConvertToUnixSlashes(file); cmSystemTools::ConvertToUnixSlashes(homedir); cmSystemTools::ConvertToUnixSlashes(currdir); @@ -285,234 +304,43 @@ cmGeneratedFileStream fout(file.c_str()); fout.SetCopyIfDifferent(true); - fout << "# Install script for directory: " << m_Makefile->GetCurrentDirectory() - << std::endl << std::endl; - - const char* cmakeDebugPosfix = m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX"); - if ( cmakeDebugPosfix ) + // Write the header. + fout << "# Install script for directory: " + << this->Makefile->GetCurrentDirectory() << std::endl << std::endl; + fout << "# Set the install prefix" << std::endl + << "IF(NOT DEFINED CMAKE_INSTALL_PREFIX)" << std::endl + << " SET(CMAKE_INSTALL_PREFIX \"" << prefix << "\")" << std::endl + << "ENDIF(NOT DEFINED CMAKE_INSTALL_PREFIX)" << std::endl + << "STRING(REGEX REPLACE \"/$\" \"\" CMAKE_INSTALL_PREFIX \"${CMAKE_INSTALL_PREFIX}\")" << std::endl + << std::endl; + + // Write support code for generating per-configuration install rules. + fout << + "# Set the install configuration name.\n" + "IF(NOT CMAKE_INSTALL_CONFIG_NAME)\n" + " IF(BUILD_TYPE)\n" + " STRING(REGEX REPLACE \"^[^A-Za-z0-9_]+\" \"\"\n" + " CMAKE_INSTALL_CONFIG_NAME \"${BUILD_TYPE}\")\n" + " ELSE(BUILD_TYPE)\n" + " SET(CMAKE_INSTALL_CONFIG_NAME Release)\n" + " ENDIF(BUILD_TYPE)\n" + " MESSAGE(STATUS \"Install configuration: \\\"${CMAKE_INSTALL_CONFIG_NAME}\\\"\")\n" + "ENDIF(NOT CMAKE_INSTALL_CONFIG_NAME)\n" + "\n"; + + // Ask each install generator to write its code. + std::vector const& installers = + this->Makefile->GetInstallGenerators(); + for(std::vector::const_iterator gi = installers.begin(); + gi != installers.end(); ++gi) { - fout << "SET(CMAKE_DEBUG_POSTFIX \"" << cmakeDebugPosfix << "\")" - << std::endl << std::endl; + (*gi)->Generate(fout, config, configurationTypes); } - std::string libOutPath = ""; - if (m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH")) - { - libOutPath = m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"); - if(libOutPath.size()) - { - if(libOutPath[libOutPath.size() -1] != '/') - { - libOutPath += "/"; - } - } - } - - std::string exeOutPath = ""; - if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH")) - { - exeOutPath = - m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"); - if(exeOutPath.size()) - { - if(exeOutPath[exeOutPath.size() -1] != '/') - { - exeOutPath += "/"; - } - } - } - if ( libOutPath.size() == 0 ) - { - // LIBRARY_OUTPUT_PATH not defined - libOutPath = currdir + "/"; - } - if ( exeOutPath.size() == 0 ) - { - // EXECUTABLE_OUTPUT_PATH not defined - exeOutPath = currdir + "/"; - } - - std::string destination; - for(cmTargets::iterator l = tgts.begin(); - l != tgts.end(); l++) - { - const char* preinstall = l->second.GetProperty("PRE_INSTALL_SCRIPT"); - const char* postinstall = l->second.GetProperty("POST_INSTALL_SCRIPT"); - if ( preinstall ) - { - fout << "INCLUDE(\"" << preinstall << "\")" << std::endl; - } - if (l->second.GetInstallPath() != "") - { - destination = prefix + l->second.GetInstallPath(); - cmSystemTools::ConvertToUnixSlashes(destination); - const char* dest = destination.c_str(); - int type = l->second.GetType(); - - - std::string fname; - const char* files; - // now install the target - switch (type) - { - case cmTarget::STATIC_LIBRARY: - case cmTarget::MODULE_LIBRARY: - fname = libOutPath; - fname += l->second.GetFullName(m_Makefile); - files = fname.c_str(); - this->AddInstallRule(fout, dest, type, files); - break; - case cmTarget::SHARED_LIBRARY: - { - // Special code to handle DLL - fname = libOutPath; - fname += l->second.GetFullName(m_Makefile); - std::string ext = cmSystemTools::GetFilenameExtension(fname); - ext = cmSystemTools::LowerCase(ext); - if ( ext == ".dll" ) - { - std::string libname = libOutPath; - libname += cmSystemTools::GetFilenameWithoutExtension(fname); - libname += ".lib"; - files = libname.c_str(); - this->AddInstallRule(fout, dest, cmTarget::STATIC_LIBRARY, files, true); - std::string dlldest = prefix + l->second.GetRuntimeInstallPath(); - files = fname.c_str(); - this->AddInstallRule(fout, dlldest.c_str(), type, files); - } - else - { - files = fname.c_str(); - std::string properties; - const char* lib_version = l->second.GetProperty("VERSION"); - const char* lib_soversion = l->second.GetProperty("SOVERSION"); - if(!m_Makefile->GetDefinition("CMAKE_SHARED_LIBRARY_SONAME_C_FLAG")) - { - // Versioning is supported only for shared libraries and modules, - // and then only when the platform supports an soname flag. - lib_version = 0; - lib_soversion = 0; - } - if ( lib_version ) - { - properties += " VERSION "; - properties += lib_version; - } - if ( lib_soversion ) - { - properties += " SOVERSION "; - properties += lib_soversion; - } - this->AddInstallRule(fout, dest, type, files, false, properties.c_str()); - } - } - break; - case cmTarget::EXECUTABLE: - { - std::string properties; -#if defined(_WIN32) && !defined(__CYGWIN__) - const char* exe_version = 0; -#else - const char* exe_version = l->second.GetProperty("VERSION"); -#endif - if(exe_version) - { - properties += " VERSION "; - properties += exe_version; - } - if(l->second.GetPropertyAsBool("MACOSX_BUNDLE")) - { - fname = exeOutPath; - fname += l->second.GetFullName(m_Makefile); - std::string plist = fname; - plist += ".app/Contents/Info.plist"; - fname += ".app/Contents/MacOS/"; - fname += l->second.GetName(); - files = fname.c_str(); - std::string bdest = dest; - bdest += "/"; - bdest += l->second.GetName(); - std::string pdest = bdest; - pdest += ".app/Contents"; - bdest += ".app/Contents/MacOS"; - // first install the actual executable - this->AddInstallRule(fout, bdest.c_str(), type, files, - false, properties.c_str()); - files = plist.c_str(); - // now install the Info.plist file - this->AddInstallRule(fout, pdest.c_str(), - cmTarget::INSTALL_FILES, files); - } - else - { - fname = exeOutPath; - fname += l->second.GetFullName(m_Makefile); - files = fname.c_str(); - this->AddInstallRule(fout, dest, type, files, false, - properties.c_str()); - } - } - break; - case cmTarget::INSTALL_FILES: - { - std::string sourcePath = m_Makefile->GetCurrentDirectory(); - std::string binaryPath = m_Makefile->GetCurrentOutputDirectory(); - sourcePath += "/"; - binaryPath += "/"; - const std::vector &sf = l->second.GetSourceLists(); - std::vector::const_iterator i; - for (i = sf.begin(); i != sf.end(); ++i) - { - std::string f = *i; - if(f.substr(0, sourcePath.length()) == sourcePath) - { - f = f.substr(sourcePath.length()); - } - else if(f.substr(0, binaryPath.length()) == binaryPath) - { - f = f.substr(binaryPath.length()); - } - - files = i->c_str(); - this->AddInstallRule(fout, dest, type, files); - } - } - break; - case cmTarget::INSTALL_PROGRAMS: - { - std::string sourcePath = m_Makefile->GetCurrentDirectory(); - std::string binaryPath = m_Makefile->GetCurrentOutputDirectory(); - sourcePath += "/"; - binaryPath += "/"; - const std::vector &sf = l->second.GetSourceLists(); - std::vector::const_iterator i; - for (i = sf.begin(); i != sf.end(); ++i) - { - std::string f = *i; - if(f.substr(0, sourcePath.length()) == sourcePath) - { - f = f.substr(sourcePath.length()); - } - else if(f.substr(0, binaryPath.length()) == binaryPath) - { - f = f.substr(binaryPath.length()); - } - files = i->c_str(); - this->AddInstallRule(fout, dest, type, files); - } - } - break; - case cmTarget::UTILITY: - default: - break; - } - } - if ( postinstall ) - { - fout << "INCLUDE(\"" << postinstall << "\")" << std::endl; - } - } + // Write rules from old-style specification stored in targets. + this->GenerateTargetInstallRules(fout, config, configurationTypes); + // Include install scripts from subdirectories. if ( this->Children.size()) { std::vector::const_iterator i = this->Children.begin(); @@ -525,6 +353,8 @@ } fout << std::endl;; } + + // Record the install manifest. if ( toplevel_install ) { fout << "FILE(WRITE \"" << homedir.c_str() << "/install_manifest.txt\" " @@ -536,36 +366,6 @@ } } -void cmLocalGenerator::AddInstallRule(std::ostream& fout, const char* dest, - int type, const char* files, bool optional /* = false */, const char* properties /* = 0 */) -{ - std::string sfiles = files; - std::string destination = dest; - std::string stype; - switch ( type ) - { - case cmTarget::INSTALL_PROGRAMS: stype = "PROGRAM"; break; - case cmTarget::EXECUTABLE: stype = "EXECUTABLE"; break; - case cmTarget::STATIC_LIBRARY: stype = "STATIC_LIBRARY"; break; - case cmTarget::SHARED_LIBRARY: stype = "SHARED_LIBRARY"; break; - case cmTarget::MODULE_LIBRARY: stype = "MODULE"; break; - case cmTarget::INSTALL_FILES: - default: stype = "FILE"; break; - } - std::string fname = cmSystemTools::GetFilenameName(sfiles.c_str()); - fout - << "MESSAGE(STATUS \"Installing " << destination.c_str() - << "/" << fname.c_str() << "\")\n" - << "FILE(INSTALL DESTINATION \"" << destination.c_str() - << "\" TYPE " << stype.c_str() << (optional?" OPTIONAL":"") ; - if ( properties && *properties ) - { - fout << " PROPERTIES" << properties; - } - fout - << " FILES \"" << sfiles.c_str() << "\")\n"; -} - void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, const char* lang, cmSourceFile& source, @@ -578,27 +378,25 @@ varString += lang; varString += "_COMPILE_OBJECT"; std::vector rules; - rules.push_back(m_Makefile->GetRequiredDefinition(varString.c_str())); + rules.push_back(this->Makefile->GetRequiredDefinition(varString.c_str())); varString = "CMAKE_"; varString += lang; varString += "_FLAGS"; std::string flags; - flags += m_Makefile->GetSafeDefinition(varString.c_str()); + flags += this->Makefile->GetSafeDefinition(varString.c_str()); flags += " "; flags += this->GetIncludeFlags(lang); std::vector commands; cmSystemTools::ExpandList(rules, commands); + cmLocalGenerator::RuleVariables vars; + vars.Language = lang; + vars.Source = sourceFile.c_str(); + vars.Object = objectFile.c_str(); + vars.Flags = flags.c_str(); for(std::vector::iterator i = commands.begin(); i != commands.end(); ++i) { - this->ExpandRuleVariables(*i, - lang, - 0, // no objects - 0, // no target - 0, // no link libs - sourceFile.c_str(), - objectFile.c_str(), - flags.c_str()); + this->ExpandRuleVariables(*i, vars); } std::vector sourceAndDeps; sourceAndDeps.push_back(sourceFile); @@ -624,7 +422,7 @@ cmSystemTools::SplitProgramFromArgs(commands[0].c_str(), command, args); std::vector argsv; argsv.push_back(args); - m_Makefile->AddCustomCommandToOutput(ofname, + this->Makefile->AddCustomCommandToOutput(ofname, command.c_str(), argsv, source.GetFullPath().c_str(), @@ -646,11 +444,11 @@ !(*i)->GetCustomCommand()) { std::string outExt = - m_GlobalGenerator->GetLanguageOutputExtensionFromExtension( + this->GlobalGenerator->GetLanguageOutputExtensionFromExtension( (*i)->GetSourceExtension().c_str()); if(outExt.size() && !(*i)->GetPropertyAsBool("EXTERNAL_OBJECT") ) { - std::string ofname = m_Makefile->GetCurrentOutputDirectory(); + std::string ofname = this->Makefile->GetCurrentOutputDirectory(); ofname += "/"; ofname += (*i)->GetSourceName() + outExt; objVector.push_back(ofname); @@ -663,7 +461,7 @@ std::string createRule = "CMAKE_"; createRule += llang; createRule += target.GetCreateRuleVariable(); - std::string targetName = target.GetFullName(m_Makefile); + std::string targetName = target.GetFullName(); // Executable : // Shared Library: // Static Library: @@ -672,36 +470,21 @@ std::string flags; // should be set std::string linkFlags; // should be set this->GetTargetFlags(linkLibs, flags, linkFlags, target); - std::string rule = m_Makefile->GetRequiredDefinition(createRule.c_str()); - this->ExpandRuleVariables(rule, - llang, // language - objs.c_str(), // objects - targetName.c_str(), // target - linkLibs.c_str(), // link libs - 0, // source - 0, // object - flags.c_str(), // flags - 0, // objects quoted - 0, // target base name - 0, // target so name, - linkFlags.c_str() // link flags - ); -#if 0 - std::string command; - std::string args; - cmSystemTools::SplitProgramFromArgs(rule.c_str(), command, args); - // Just like ADD_CUSTOM_TARGET(foo ALL DEPENDS a.o b.o) - // Add a custom command for generating each .o file - cmCustomCommand cc(command.c_str(), args.c_str(), objVector, - targetName.c_str(), 0); - target.GetPostBuildCommands().push_back(cc); -#endif + std::string rule = this->Makefile->GetRequiredDefinition(createRule.c_str()); + cmLocalGenerator::RuleVariables vars; + vars.Language = llang; + vars.Objects = objs.c_str(); + vars.Target = targetName.c_str(); + vars.LinkLibraries = linkLibs.c_str(); + vars.Flags = flags.c_str(); + vars.LinkFlags = linkFlags.c_str(); + this->ExpandRuleVariables(rule, vars); } void cmLocalGenerator::CreateCustomTargetsAndCommands(std::set const& lang) { - cmTargets &tgts = m_Makefile->GetTargets(); + cmTargets &tgts = this->Makefile->GetTargets(); for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { @@ -729,6 +512,7 @@ } break; case cmTarget::UTILITY: + case cmTarget::GLOBAL_TARGET: case cmTarget::INSTALL_FILES: case cmTarget::INSTALL_PROGRAMS: break; @@ -762,133 +546,124 @@ std::string cmLocalGenerator::ExpandRuleVariable(std::string const& variable, - const char* lang, - const char* objects, - const char* target, - const char* linkLibs, - const char* source, - const char* object, - const char* flags, - const char* objectsquoted, - const char* targetBase, - const char* targetSOName, - const char* linkFlags) + const RuleVariables& replaceValues) { - if(linkFlags) + if(replaceValues.LinkFlags) { if(variable == "LINK_FLAGS") { - return linkFlags; + return replaceValues.LinkFlags; } } - if(flags) + if(replaceValues.Flags) { if(variable == "FLAGS") { - return flags; + return replaceValues.Flags; } } - if(source) + if(replaceValues.Source) { if(variable == "SOURCE") { - return source; + return replaceValues.Source; } } - if(object) + if(replaceValues.Object) { if(variable == "OBJECT") { - return object; + return replaceValues.Object; } } - if(objects) + if(replaceValues.Objects) { if(variable == "OBJECTS") { - return objects; + return replaceValues.Objects; } } - if(objectsquoted) + if(replaceValues.ObjectsQuoted) { if(variable == "OBJECTS_QUOTED") { - return objectsquoted; + return replaceValues.ObjectsQuoted; } } - if(target) + if(replaceValues.Target) { if(variable == "TARGET_QUOTED") { - std::string targetQuoted = target; + std::string targetQuoted = replaceValues.Target; if(targetQuoted.size() && targetQuoted[0] != '\"') { targetQuoted = '\"'; - targetQuoted += target; + targetQuoted += replaceValues.Target; targetQuoted += '\"'; return targetQuoted; } } + if(variable == "LANGUAGE_COMPILE_FLAGS") + { + return replaceValues.LanguageCompileFlags; + } if(variable == "TARGET") { - return target; + return replaceValues.Target; } - } - if(targetBase) - { - if(variable == "TARGET_BASE.lib" || variable == "TARGET_BASE.dll") + if(variable == "TARGET_IMPLIB") { - // special case for quoted paths with spaces - // if you see .lib then put the .lib inside - // the quotes, same for .dll - if((strlen(targetBase) > 1) && targetBase[0] == '\"') - { - std::string base = targetBase; - base[base.size()-1] = '.'; - std::string baseLib = base + "lib\""; - std::string baseDll = base + "dll\""; - if(variable == "TARGET_BASE.lib" ) - { - return baseLib; - } - if(variable == "TARGET_BASE.dll" ) - { - return baseDll; - } - } + return this->TargetImplib; } if(variable == "TARGET_BASE") { - return targetBase; + // Strip the last extension off the target name. + std::string targetBase = replaceValues.Target; + std::string::size_type pos = targetBase.rfind("."); + if(pos != targetBase.npos) + { + return targetBase.substr(0, pos); + } + else + { + return targetBase; + } } } - if(targetSOName) + if(replaceValues.TargetSOName) { if(variable == "TARGET_SONAME") { - if(lang) + if(replaceValues.Language) { std::string name = "CMAKE_SHARED_LIBRARY_SONAME_"; - name += lang; + name += replaceValues.Language; name += "_FLAG"; - if(m_Makefile->GetDefinition(name.c_str())) + if(this->Makefile->GetDefinition(name.c_str())) { - return targetSOName; + return replaceValues.TargetSOName; } } return ""; } } - if(linkLibs) + if(replaceValues.TargetInstallNameDir) + { + if(variable == "TARGET_INSTALLNAME_DIR") + { + return replaceValues.TargetInstallNameDir; + } + } + if(replaceValues.LinkLibraries) { if(variable == "LINK_LIBRARIES") { - return linkLibs; + return replaceValues.LinkLibraries; } } std::vector enabledLanguages; - m_GlobalGenerator->GetEnabledLanguages(enabledLanguages); + this->GlobalGenerator->GetEnabledLanguages(enabledLanguages); // loop over language specific replace variables int pos = 0; while(ruleReplaceVars[pos]) @@ -896,7 +671,7 @@ for(std::vector::iterator i = enabledLanguages.begin(); i != enabledLanguages.end(); ++i) { - lang = i->c_str(); + const char* lang = i->c_str(); std::string actualReplace = ruleReplaceVars[pos]; // If this is the compiler then look for the extra variable // _COMPILER_ARG1 which must be the first argument to the compiler @@ -905,7 +680,7 @@ { std::string arg1 = actualReplace + "_ARG1"; cmSystemTools::ReplaceString(arg1, "${LANG}", lang); - compilerArg1 = m_Makefile->GetDefinition(arg1.c_str()); + compilerArg1 = this->Makefile->GetDefinition(arg1.c_str()); } if(actualReplace.find("${LANG}") != actualReplace.npos) { @@ -913,7 +688,7 @@ } if(actualReplace == variable) { - std::string replace = m_Makefile->GetSafeDefinition(variable.c_str()); + std::string replace = this->Makefile->GetSafeDefinition(variable.c_str()); // if the variable is not a FLAG then treat it like a path if(variable.find("_FLAG") == variable.npos) { @@ -937,20 +712,10 @@ void cmLocalGenerator::ExpandRuleVariables(std::string& s, - const char* lang, - const char* objects, - const char* target, - const char* linkLibs, - const char* source, - const char* object, - const char* flags, - const char* objectsquoted, - const char* targetBase, - const char* targetSOName, - const char* linkFlags) + const RuleVariables& replaceValues) { std::vector enabledLanguages; - m_GlobalGenerator->GetEnabledLanguages(enabledLanguages); + this->GlobalGenerator->GetEnabledLanguages(enabledLanguages); std::string::size_type start = s.find('<'); // no variables to expand if(start == s.npos) @@ -978,12 +743,8 @@ { // extract the var std::string var = s.substr(start+1, end - start-1); - std::string replace = this->ExpandRuleVariable(var, lang, objects, - target, linkLibs, - source, object, flags, - objectsquoted, - targetBase, targetSOName, - linkFlags); + std::string replace = this->ExpandRuleVariable(var, + replaceValues); expandedInput += s.substr(pos, start-pos); expandedInput += replace; // move to next one @@ -1022,9 +783,9 @@ { return ""; } - if(m_LanguageToIncludeFlags.count(lang)) + if(this->LanguageToIncludeFlags.count(lang)) { - return m_LanguageToIncludeFlags[lang].c_str(); + return this->LanguageToIncludeFlags[lang].c_str(); } cmOStringStream includeFlags; std::vector includes; @@ -1033,11 +794,15 @@ std::string flagVar = "CMAKE_INCLUDE_FLAG_"; flagVar += lang; - const char* includeFlag = m_Makefile->GetDefinition(flagVar.c_str()); + const char* includeFlag = this->Makefile->GetDefinition(flagVar.c_str()); flagVar = "CMAKE_INCLUDE_FLAG_SEP_"; flagVar += lang; - const char* sep = m_Makefile->GetDefinition(flagVar.c_str()); - + const char* sep = this->Makefile->GetDefinition(flagVar.c_str()); + bool quotePaths = false; + if(this->Makefile->GetDefinition("CMAKE_QUOTE_INCLUDE_PATHS")) + { + quotePaths = true; + } bool repeatFlag = true; // should the include flag be repeated like ie. -IA -IB if(!sep) { @@ -1050,15 +815,39 @@ repeatFlag = false; } bool flagUsed = false; + std::set emitted; for(i = includes.begin(); i != includes.end(); ++i) { +#ifdef __APPLE__ + if(cmSystemTools::IsPathToFramework(i->c_str())) + { + std::string frameworkDir = *i; + frameworkDir += "/../"; + frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str()); + if(emitted.insert(frameworkDir).second) + { + includeFlags << "-F" << this->ConvertToOutputForExisting(frameworkDir.c_str()) << " "; + } + continue; + } +#endif std::string include = *i; if(!flagUsed || repeatFlag) { includeFlags << includeFlag; flagUsed = true; } - includeFlags << this->ConvertToOutputForExisting(i->c_str()) << sep; + std::string includePath = this->ConvertToOutputForExisting(i->c_str()); + if(quotePaths && includePath.size() && includePath[0] != '\"') + { + includeFlags << "\""; + } + includeFlags << includePath; + if(quotePaths && includePath.size() && includePath[0] != '\"') + { + includeFlags << "\""; + } + includeFlags << sep; } std::string flags = includeFlags.str(); // remove trailing separators @@ -1066,77 +855,115 @@ { flags[flags.size()-1] = ' '; } - flags += m_Makefile->GetDefineFlags(); - m_LanguageToIncludeFlags[lang] = flags; - return m_LanguageToIncludeFlags[lang].c_str(); + flags += this->Makefile->GetDefineFlags(); + this->LanguageToIncludeFlags[lang] = flags; + + // Use this temorary variable for the return value to work-around a + // bogus GCC 2.95 warning. + const char* ret = this->LanguageToIncludeFlags[lang].c_str(); + return ret; } //---------------------------------------------------------------------------- void cmLocalGenerator::GetIncludeDirectories(std::vector& dirs) { - // Output Include paths - std::set implicitIncludes; + // Need to decide whether to automatically include the source and + // binary directories at the beginning of the include path. + bool includeSourceDir = false; + bool includeBinaryDir = false; + + // When automatic include directories are requested for an + // out-of-source build then include the source and binary + // directories at the beginning of the include path to approximate + // include file behavior for an in-source build. This does not + // account for the case of a source file in a subdirectory of the + // current source directory but we cannot fix this because not all + // native build tools support per-source-file include paths. + bool inSource = + cmSystemTools::ComparePath(this->Makefile->GetStartDirectory(), + this->Makefile->GetStartOutputDirectory()); + if(!inSource && this->Makefile->IsOn("CMAKE_INCLUDE_CURRENT_DIR")) + { + includeSourceDir = true; + includeBinaryDir = true; + } // CMake versions below 2.0 would add the source tree to the -I path // automatically. Preserve compatibility. - bool includeSourceDir = false; const char* versionValue = - m_Makefile->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY"); - if(versionValue) + this->Makefile->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY"); + int major = 0; + int minor = 0; + if(versionValue && sscanf(versionValue, "%d.%d", &major, &minor) != 2) { - int major = 0; - int minor = 0; - if(sscanf(versionValue, "%d.%d", &major, &minor) == 2 && major < 2) - { - includeSourceDir = true; - } + versionValue = 0; } + if(versionValue && major < 2) + { + includeSourceDir = true; + } + + // Hack for VTK 4.0 - 4.4 which depend on the old behavior but do + // not set the backwards compatibility level automatically. const char* vtkSourceDir = - m_Makefile->GetDefinition("VTK_SOURCE_DIR"); + this->Makefile->GetDefinition("VTK_SOURCE_DIR"); if(vtkSourceDir) { - // Special hack for VTK 4.0 - 4.4. - const char* vtk_major = m_Makefile->GetDefinition("VTK_MAJOR_VERSION"); - const char* vtk_minor = m_Makefile->GetDefinition("VTK_MINOR_VERSION"); + const char* vtk_major = this->Makefile->GetDefinition("VTK_MAJOR_VERSION"); + const char* vtk_minor = this->Makefile->GetDefinition("VTK_MINOR_VERSION"); vtk_major = vtk_major? vtk_major : "4"; vtk_minor = vtk_minor? vtk_minor : "4"; - int major = 0; - int minor = 0; - if(sscanf(vtk_major, "%d", &major) && sscanf(vtk_minor, "%d", &minor) && - major == 4 && minor <= 4) + int vmajor = 0; + int vminor = 0; + if(sscanf(vtk_major, "%d", &vmajor) && sscanf(vtk_minor, "%d", &vminor) && + vmajor == 4 && vminor <= 4) { includeSourceDir = true; } } + // Do not repeat an include path. + std::set emitted; + + // Store the automatic include paths. + if(includeBinaryDir) + { + dirs.push_back(this->Makefile->GetStartOutputDirectory()); + emitted.insert(this->Makefile->GetStartOutputDirectory()); + } if(includeSourceDir) { - dirs.push_back(m_Makefile->GetStartDirectory()); + if(emitted.find(this->Makefile->GetStartDirectory()) == emitted.end()) + { + dirs.push_back(this->Makefile->GetStartDirectory()); + emitted.insert(this->Makefile->GetStartDirectory()); + } } // Do not explicitly add the standard include path "/usr/include". // This can cause problems with certain standard library // implementations because the wrong headers may be found first. - implicitIncludes.insert("/usr/include"); - if(m_Makefile->GetDefinition("CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES")) + emitted.insert("/usr/include"); + if(const char* implicitIncludes = + this->Makefile->GetDefinition("CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES")) { - std::string arg = m_Makefile->GetDefinition("CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES"); std::vector implicitIncludeVec; - cmSystemTools::ExpandListArgument(arg, implicitIncludeVec); - for(unsigned int k =0; k < implicitIncludeVec.size(); k++) + cmSystemTools::ExpandListArgument(implicitIncludes, implicitIncludeVec); + for(unsigned int k = 0; k < implicitIncludeVec.size(); ++k) { - implicitIncludes.insert(implicitIncludeVec[k]); + emitted.insert(implicitIncludeVec[k]); } } // Construct the ordered list. - std::vector& includes = m_Makefile->GetIncludeDirectories(); + std::vector& includes = this->Makefile->GetIncludeDirectories(); for(std::vector::iterator i = includes.begin(); i != includes.end(); ++i) { - if(implicitIncludes.find(*i) == implicitIncludes.end()) + if(emitted.find(*i) == emitted.end()) { dirs.push_back(*i); + emitted.insert(*i); } } } @@ -1146,7 +973,7 @@ std::string& linkFlags, cmTarget& target) { - std::string buildType = m_Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); + std::string buildType = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); buildType = cmSystemTools::UpperCase(buildType); const char* libraryLinkVariable = "CMAKE_SHARED_LINKER_FLAGS"; // default to shared library @@ -1166,17 +993,17 @@ libraryLinkVariable = "CMAKE_MODULE_LINKER_FLAGS"; case cmTarget::SHARED_LIBRARY: { - linkFlags = m_Makefile->GetSafeDefinition(libraryLinkVariable); + linkFlags = this->Makefile->GetSafeDefinition(libraryLinkVariable); linkFlags += " "; if(buildType.size()) { std::string build = libraryLinkVariable; build += "_"; build += buildType; - linkFlags += m_Makefile->GetSafeDefinition(build.c_str()); + linkFlags += this->Makefile->GetSafeDefinition(build.c_str()); linkFlags += " "; } - if(m_Makefile->IsOn("WIN32") && !(m_Makefile->IsOn("CYGWIN") || m_Makefile->IsOn("MINGW"))) + if(this->Makefile->IsOn("WIN32") && !(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW"))) { const std::vector& sources = target.GetSourceFiles(); for(std::vector::const_iterator i = sources.begin(); @@ -1184,7 +1011,7 @@ { if((*i)->GetSourceExtension() == "def") { - linkFlags += m_Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG"); + linkFlags += this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG"); linkFlags += this->Convert((*i)->GetFullPath().c_str(),START_OUTPUT,MAKEFILE); linkFlags += " "; } @@ -1197,19 +1024,19 @@ linkFlags += " "; } cmOStringStream linklibsStr; - this->OutputLinkLibraries(linklibsStr, target.GetName(), target); + this->OutputLinkLibraries(linklibsStr, target, false); linkLibs = linklibsStr.str(); } break; case cmTarget::EXECUTABLE: { - linkFlags += m_Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS"); + linkFlags += this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS"); linkFlags += " "; if(buildType.size()) { std::string build = "CMAKE_EXE_LINKER_FLAGS_"; build += buildType; - linkFlags += m_Makefile->GetSafeDefinition(build.c_str()); + linkFlags += this->Makefile->GetSafeDefinition(build.c_str()); linkFlags += " "; } const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator()); @@ -1225,28 +1052,28 @@ std::string sharedFlagsVar = "CMAKE_SHARED_LIBRARY_"; sharedFlagsVar += linkLanguage; sharedFlagsVar += "_FLAGS"; - flags += m_Makefile->GetSafeDefinition(flagsVar.c_str()); + flags += this->Makefile->GetSafeDefinition(flagsVar.c_str()); flags += " "; - flags += m_Makefile->GetSafeDefinition(sharedFlagsVar.c_str()); + flags += this->Makefile->GetSafeDefinition(sharedFlagsVar.c_str()); flags += " "; cmOStringStream linklibs; - this->OutputLinkLibraries(linklibs, 0, target); + this->OutputLinkLibraries(linklibs, target, false); linkLibs = linklibs.str(); - if(cmSystemTools::IsOn(m_Makefile->GetDefinition("BUILD_SHARED_LIBS"))) + if(cmSystemTools::IsOn(this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) { std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_") + linkLanguage + std::string("_FLAGS"); - linkFlags += m_Makefile->GetSafeDefinition(sFlagVar.c_str()); + linkFlags += this->Makefile->GetSafeDefinition(sFlagVar.c_str()); linkFlags += " "; } if ( target.GetPropertyAsBool("WIN32_EXECUTABLE") ) { - linkFlags += m_Makefile->GetSafeDefinition("CMAKE_CREATE_WIN32_EXE"); + linkFlags += this->Makefile->GetSafeDefinition("CMAKE_CREATE_WIN32_EXE"); linkFlags += " "; } else { - linkFlags += m_Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE"); + linkFlags += this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE"); linkFlags += " "; } const char* targetLinkFlags = target.GetProperty("LINK_FLAGS"); @@ -1258,6 +1085,7 @@ } break; case cmTarget::UTILITY: + case cmTarget::GLOBAL_TARGET: case cmTarget::INSTALL_FILES: case cmTarget::INSTALL_PROGRAMS: break; @@ -1270,8 +1098,8 @@ * to the name of the library. This will not link a library against itself. */ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout, - const char* targetLibrary, - cmTarget &tgt) + cmTarget& tgt, + bool relink) { // Try to emit each search path once std::set emitted; @@ -1279,19 +1107,8 @@ bool outputRuntime = true; std::string runtimeFlag; std::string runtimeSep; - std::vector runtimeDirs; - std::string buildType = m_Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - buildType = cmSystemTools::UpperCase(buildType); - cmTarget::LinkLibraryType cmakeBuildType = cmTarget::GENERAL; - if(buildType == "DEBUG") - { - cmakeBuildType = cmTarget::DEBUG; - } - else if(buildType.size()) - { - cmakeBuildType = cmTarget::OPTIMIZED; - } + const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); const char* linkLanguage = tgt.GetLinkerLanguage(this->GetGlobalGenerator()); if(!linkLanguage) { @@ -1304,12 +1121,12 @@ runTimeFlagVar += linkLanguage; runTimeFlagVar += "_FLAG"; std::string runTimeFlagSepVar = runTimeFlagVar + "_SEP"; - runtimeFlag = m_Makefile->GetSafeDefinition(runTimeFlagVar.c_str()); - runtimeSep = m_Makefile->GetSafeDefinition(runTimeFlagSepVar.c_str()); + runtimeFlag = this->Makefile->GetSafeDefinition(runTimeFlagVar.c_str()); + runtimeSep = this->Makefile->GetSafeDefinition(runTimeFlagSepVar.c_str()); // concatenate all paths or no? bool runtimeConcatenate = ( runtimeSep!="" ); - if(runtimeFlag == "" || m_Makefile->IsOn("CMAKE_SKIP_RPATH") ) + if(runtimeFlag == "" || this->Makefile->IsOn("CMAKE_SKIP_RPATH")) { outputRuntime = false; } @@ -1317,8 +1134,8 @@ // Some search paths should never be emitted emitted.insert(""); emitted.insert("/usr/lib"); - std::string libPathFlag = m_Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG"); - std::string libLinkFlag = m_Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_FLAG"); + std::string libPathFlag = this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG"); + std::string libLinkFlag = this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_FLAG"); // collect all the flags needed for linking libraries std::string linkLibs; @@ -1328,54 +1145,51 @@ linkFlagsVar += "_FLAGS"; if( tgt.GetType() == cmTarget::EXECUTABLE ) { - linkLibs = m_Makefile->GetSafeDefinition(linkFlagsVar.c_str()); + linkLibs = this->Makefile->GetSafeDefinition(linkFlagsVar.c_str()); linkLibs += " "; } - - cmOrderLinkDirectories orderLibs; - std::string ext = - m_Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_SUFFIX"); - if(ext.size()) - { - orderLibs.AddLinkExtension(ext.c_str()); - } - ext = - m_Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_PREFIX"); - if(ext.size()) - { - orderLibs.SetLinkPrefix(ext.c_str()); - } - ext = - m_Makefile->GetSafeDefinition("CMAKE_SHARED_LIBRARY_SUFFIX"); - if(ext.size()) + + // Compute the link library and directory information. + std::vector libNames; + std::vector libDirs; + this->ComputeLinkInformation(tgt, config, libNames, libDirs); + + // Select whether to generate an rpath for the install tree or the + // build tree. + bool linking_for_install = + relink || tgt.GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH"); + bool use_install_rpath = + outputRuntime && tgt.HaveInstallTreeRPATH() && linking_for_install; + bool use_build_rpath = + outputRuntime && tgt.HaveBuildTreeRPATH() && !linking_for_install; + + // Construct the RPATH. + std::vector runtimeDirs; + if(use_install_rpath) { - orderLibs.AddLinkExtension(ext.c_str()); + const char* install_rpath = tgt.GetProperty("INSTALL_RPATH"); + cmSystemTools::ExpandListArgument(install_rpath, runtimeDirs); + for(unsigned int i=0; i < runtimeDirs.size(); ++i) + { + runtimeDirs[i] = + this->Convert(runtimeDirs[i].c_str(), FULL, SHELL, false); + } } - ext = - m_Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_SUFFIX"); - if(ext.size()) + + // Append the library search path flags. + for(std::vector::const_iterator libDir = libDirs.begin(); + libDir != libDirs.end(); ++libDir) { - orderLibs.AddLinkExtension(ext.c_str()); - } - // compute the correct order for -L paths - orderLibs.SetLinkInformation(tgt, cmakeBuildType, targetLibrary); - orderLibs.DetermineLibraryPathOrder(); - std::vector libdirs; - std::vector linkItems; - orderLibs.GetLinkerInformation(libdirs, linkItems); - for(std::vector::const_iterator libDir = libdirs.begin(); - libDir != libdirs.end(); ++libDir) - { - std::string libpath = this->ConvertToOutputForExisting(libDir->c_str()); + std::string libpath = this->ConvertToOutputForExisting(libDir->c_str()); if(emitted.insert(libpath).second) { std::string fullLibPath; - if(!m_WindowsShell && m_UseRelativePaths) + if(!this->WindowsShell && this->UseRelativePaths) { fullLibPath = "\"`cd "; } fullLibPath += libpath; - if(!m_WindowsShell && m_UseRelativePaths) + if(!this->WindowsShell && this->UseRelativePaths) { fullLibPath += ";pwd`\""; } @@ -1384,7 +1198,7 @@ && libDir->find("${") == std::string::npos) { linkLibs += libPathFlag; - if(outputRuntime) + if(use_build_rpath) { runtimeDirs.push_back( fullLibPath ); } @@ -1394,37 +1208,17 @@ } } - std::string linkSuffix = - m_Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_SUFFIX"); - std::string regexp = ".*\\"; - regexp += linkSuffix; - regexp += "$"; - cmsys::RegularExpression hasSuffix(regexp.c_str()); - std::string librariesLinked; - for(std::vector::iterator lib = linkItems.begin(); - lib != linkItems.end(); ++lib) - { - cmStdString& linkItem = *lib; - // check to see if the link item has a -l already - cmsys::RegularExpression reg("^([ \t]*\\-[lLWRB])|([ \t]*\\-framework)|(\\${)|([ \t]*\\-pthread)|([ \t]*`)"); - if(!reg.find(linkItem)) - { - librariesLinked += libLinkFlag; - } - librariesLinked += linkItem; - - if(linkSuffix.size() && !hasSuffix.find(linkItem)) - { - librariesLinked += linkSuffix; - } - librariesLinked += " "; + // Append the link libraries. + for(std::vector::iterator lib = libNames.begin(); + lib != libNames.end(); ++lib) + { + linkLibs += *lib; + linkLibs += " "; } - linkLibs += librariesLinked; - fout << linkLibs; - if(outputRuntime && runtimeDirs.size()>0) + if(!runtimeDirs.empty()) { // For the runtime search directories, do a "-Wl,-rpath,a:b:c" or // a "-R a -R b -R c" type link line @@ -1445,28 +1239,199 @@ } fout << " "; } - if(m_Makefile->GetDefinition("CMAKE_STANDARD_LIBRARIES")) + if(this->Makefile->GetDefinition("CMAKE_STANDARD_LIBRARIES")) { - fout << m_Makefile->GetDefinition("CMAKE_STANDARD_LIBRARIES") << " "; + fout << this->Makefile->GetDefinition("CMAKE_STANDARD_LIBRARIES") << " "; } } +//---------------------------------------------------------------------------- +void +cmLocalGenerator::ComputeLinkInformation(cmTarget& target, + const char* config, + std::vector& outLibs, + std::vector& outDirs, + std::vector* fullPathLibs) +{ + // Compute which library configuration to link. + cmTarget::LinkLibraryType linkType = cmTarget::OPTIMIZED; + if(config && cmSystemTools::UpperCase(config) == "DEBUG") + { + linkType = cmTarget::DEBUG; + } + + // Get the list of libraries against which this target wants to link. + std::vector linkLibraries; + const cmTarget::LinkLibraryVectorType& inLibs = target.GetLinkLibraries(); + for(cmTarget::LinkLibraryVectorType::const_iterator j = inLibs.begin(); + j != inLibs.end(); ++j) + { + // For backwards compatibility variables may have been expanded + // inside library names. Clean up the resulting name. + std::string lib = j->first; + std::string::size_type pos = lib.find_first_not_of(" \t\r\n"); + if(pos != lib.npos) + { + lib = lib.substr(pos, lib.npos); + } + pos = lib.find_last_not_of(" \t\r\n"); + if(pos != lib.npos) + { + lib = lib.substr(0, pos+1); + } + if(lib.empty()) + { + continue; + } + + // Link to a library if it is not the same target and is meant for + // this configuration type. + if((target.GetType() == cmTarget::EXECUTABLE || + lib != target.GetName()) && + (j->second == cmTarget::GENERAL || j->second == linkType)) + { + // Compute the proper name to use to link this library. + cmTarget* tgt = this->GlobalGenerator->FindTarget(0, lib.c_str()); + if(tgt) + { + // This is a CMake target. Ask the target for its real name. + linkLibraries.push_back(tgt->GetFullName(config)); + if(fullPathLibs) + { + fullPathLibs->push_back(tgt->GetFullPath(config)); + } + } + else + { + // This is not a CMake target. Use the name given. + linkLibraries.push_back(lib); + } + } + } + + // Get the list of directories the target wants to search for libraries. + const std::vector& + linkDirectories = target.GetLinkDirectories(); + + // Compute the link directory order needed to link the libraries. + cmOrderLinkDirectories orderLibs; + orderLibs.SetLinkPrefix( + this->Makefile->GetDefinition("CMAKE_STATIC_LIBRARY_PREFIX")); + orderLibs.AddLinkExtension( + this->Makefile->GetDefinition("CMAKE_STATIC_LIBRARY_SUFFIX")); + orderLibs.AddLinkExtension( + this->Makefile->GetDefinition("CMAKE_SHARED_LIBRARY_SUFFIX")); + orderLibs.AddLinkExtension( + this->Makefile->GetDefinition("CMAKE_LINK_LIBRARY_SUFFIX")); + orderLibs.SetLinkInformation(target.GetName(), + linkLibraries, + linkDirectories); + orderLibs.DetermineLibraryPathOrder(); + std::vector orderedLibs; + orderLibs.GetLinkerInformation(outDirs, orderedLibs); + if(fullPathLibs) + { + orderLibs.GetFullPathLibraries(*fullPathLibs); + } + + // Make sure libraries are linked with the proper syntax. + std::string libLinkFlag = + this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_FLAG"); + std::string libLinkSuffix = + this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_SUFFIX"); + for(std::vector::iterator l = orderedLibs.begin(); + l != orderedLibs.end(); ++l) + { + std::string lib = *l; + if(lib[0] == '-' || lib[0] == '$' || lib[0] == '`') + { + // The library is linked with special syntax by the user. + outLibs.push_back(lib); + } + else + { + // Generate the proper link syntax. + lib = libLinkFlag; + lib += *l; + lib += libLinkSuffix; + outLibs.push_back(lib); + } + } +} //---------------------------------------------------------------------------- void cmLocalGenerator::AddLanguageFlags(std::string& flags, - const char* lang) + const char* lang, + const char* config) { // Add language-specific flags. std::string flagsVar = "CMAKE_"; flagsVar += lang; flagsVar += "_FLAGS"; - this->AddConfigVariableFlags(flags, flagsVar.c_str()); + this->AddConfigVariableFlags(flags, flagsVar.c_str(), config); +} + +//---------------------------------------------------------------------------- +std::string cmLocalGenerator::GetRealDependency(const char* inName, + const char* config) +{ + // Older CMake code may specify the dependency using the target + // output file rather than the target name. Such code would have + // been written before there was support for target properties that + // modify the name so stripping down to just the file name should + // produce the target name in this case. + std::string name = cmSystemTools::GetFilenameName(inName); + if(cmSystemTools::GetFilenameLastExtension(name) == ".exe") + { + name = cmSystemTools::GetFilenameWithoutLastExtension(name); + } + + // Look for a CMake target with the given name. + if(cmTarget* target = this->GlobalGenerator->FindTarget(0, name.c_str())) + { + switch (target->GetType()) + { + case cmTarget::EXECUTABLE: + case cmTarget::STATIC_LIBRARY: + case cmTarget::SHARED_LIBRARY: + case cmTarget::MODULE_LIBRARY: + { + // Get the location of the target's output file and depend on it. + if(const char* location = target->GetLocation(config)) + { + return location; + } + } + break; + case cmTarget::UTILITY: + case cmTarget::GLOBAL_TARGET: + // Depending on a utility target may not work but just trust + // the user to have given a valid name. + return inName; + case cmTarget::INSTALL_FILES: + case cmTarget::INSTALL_PROGRAMS: + break; + } + } + + // The name was not that of a CMake target. It must name a file. + if(cmSystemTools::FileIsFullPath(inName)) + { + // This is a full path. Return it as given. + return inName; + } + // Treat the name as relative to the source directory in which it + // was given. + name = this->Makefile->GetCurrentDirectory(); + name += "/"; + name += inName; + return name; } //---------------------------------------------------------------------------- void cmLocalGenerator::AddSharedFlags(std::string& flags, - const char* lang, - bool shared) + const char* lang, + bool shared) { std::string flagsVar; @@ -1476,34 +1441,34 @@ flagsVar = "CMAKE_SHARED_LIBRARY_"; flagsVar += lang; flagsVar += "_FLAGS"; - this->AppendFlags(flags, m_Makefile->GetDefinition(flagsVar.c_str())); + this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar.c_str())); } // Add flags specific to shared builds. - if(cmSystemTools::IsOn(m_Makefile->GetDefinition("BUILD_SHARED_LIBS"))) + if(cmSystemTools::IsOn(this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) { flagsVar = "CMAKE_SHARED_BUILD_"; flagsVar += lang; flagsVar += "_FLAGS"; - this->AppendFlags(flags, m_Makefile->GetDefinition(flagsVar.c_str())); + this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar.c_str())); } } //---------------------------------------------------------------------------- void cmLocalGenerator::AddConfigVariableFlags(std::string& flags, - const char* var) + const char* var, + const char* config) { // Add the flags from the variable itself. std::string flagsVar = var; - this->AppendFlags(flags, m_Makefile->GetDefinition(flagsVar.c_str())); + this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar.c_str())); // Add the flags from the build-type specific variable. - const char* buildType = m_Makefile->GetDefinition("CMAKE_BUILD_TYPE"); - if(buildType && *buildType) + if(config && *config) { flagsVar += "_"; - flagsVar += cmSystemTools::UpperCase(buildType); - this->AppendFlags(flags, m_Makefile->GetDefinition(flagsVar.c_str())); + flagsVar += cmSystemTools::UpperCase(config); + this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar.c_str())); } } @@ -1524,10 +1489,18 @@ //---------------------------------------------------------------------------- std::string cmLocalGenerator::ConstructScript(const cmCustomCommandLines& commandLines, + const char* workingDirectory, const char* newline) + { // Store the script in a string. std::string script; + if(workingDirectory) + { + script += "cd "; + script += this->Convert(workingDirectory, START_OUTPUT, SHELL); + script += newline; + } // Write each command on a single line. for(cmCustomCommandLines::const_iterator cl = commandLines.begin(); @@ -1566,29 +1539,29 @@ // Convert the path to a relative path. std::string result = source; - if (!optional || m_UseRelativePaths) + if (!optional || this->UseRelativePaths) { switch (relative) { case HOME: //result = cmSystemTools::CollapseFullPath(result.c_str()); - result = m_GlobalGenerator-> - ConvertToRelativePath(m_HomeDirectoryComponents, result.c_str()); + result = this->GlobalGenerator-> + ConvertToRelativePath(this->HomeDirectoryComponents, result.c_str()); break; case START: //result = cmSystemTools::CollapseFullPath(result.c_str()); - result = m_GlobalGenerator-> - ConvertToRelativePath(m_StartDirectoryComponents, result.c_str()); + result = this->GlobalGenerator-> + ConvertToRelativePath(this->StartDirectoryComponents, result.c_str()); break; case HOME_OUTPUT: //result = cmSystemTools::CollapseFullPath(result.c_str()); - result = m_GlobalGenerator-> - ConvertToRelativePath(m_HomeOutputDirectoryComponents, result.c_str()); + result = this->GlobalGenerator-> + ConvertToRelativePath(this->HomeOutputDirectoryComponents, result.c_str()); break; case START_OUTPUT: //result = cmSystemTools::CollapseFullPath(result.c_str()); - result = m_GlobalGenerator-> - ConvertToRelativePath(m_StartOutputDirectoryComponents, result.c_str()); + result = this->GlobalGenerator-> + ConvertToRelativePath(this->StartOutputDirectoryComponents, result.c_str()); break; case FULL: result = cmSystemTools::CollapseFullPath(result.c_str()); @@ -1599,10 +1572,123 @@ } // Now convert it to an output path. - if (output == MAKEFILE || output == SHELL) + if (output == MAKEFILE) { result = cmSystemTools::ConvertToOutputPath(result.c_str()); } - + if( output == SHELL) + { + // for shell commands if force unix is on, but this->WindowsShell + // is true, then turn off force unix paths for the output path + // so that the path is windows style and will work with windows + // cmd.exe. + bool forceOn = cmSystemTools::GetForceUnixPaths(); + if(forceOn && this->WindowsShell) + { + cmSystemTools::SetForceUnixPaths(false); + } + result = cmSystemTools::ConvertToOutputPath(result.c_str()); + if(forceOn && this->WindowsShell) + { + cmSystemTools::SetForceUnixPaths(true); + } + } return result; } + +//---------------------------------------------------------------------------- +void +cmLocalGenerator +::GenerateTargetInstallRules( + std::ostream& os, const char* config, + std::vector const& configurationTypes) +{ + // Convert the old-style install specification from each target to + // an install generator and run it. + cmTargets& tgts = this->Makefile->GetTargets(); + for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l) + { + // Include the user-specified pre-install script for this target. + if(const char* preinstall = l->second.GetProperty("PRE_INSTALL_SCRIPT")) + { + cmInstallScriptGenerator g(preinstall); + g.Generate(os, config, configurationTypes); + } + + // Install this target if a destination is given. + if(l->second.GetInstallPath() != "") + { + // Compute the full install destination. Note that converting + // to unix slashes also removes any trailing slash. + std::string destination = "${CMAKE_INSTALL_PREFIX}"; + destination += l->second.GetInstallPath(); + cmSystemTools::ConvertToUnixSlashes(destination); + + // Generate the proper install generator for this target type. + switch(l->second.GetType()) + { + case cmTarget::EXECUTABLE: + case cmTarget::STATIC_LIBRARY: + case cmTarget::MODULE_LIBRARY: + { + // Use a target install generator. + cmInstallTargetGenerator g(l->second, destination.c_str(), false); + g.Generate(os, config, configurationTypes); + } + break; + case cmTarget::SHARED_LIBRARY: + { +#if defined(_WIN32) || defined(__CYGWIN__) + // Special code to handle DLL. Install the import library + // to the normal destination and the DLL to the runtime + // destination. + cmInstallTargetGenerator g1(l->second, destination.c_str(), true); + g1.Generate(os, config, configurationTypes); + destination = "${CMAKE_INSTALL_PREFIX}"; + destination += l->second.GetRuntimeInstallPath(); + cmSystemTools::ConvertToUnixSlashes(destination); + cmInstallTargetGenerator g2(l->second, destination.c_str(), false); + g2.Generate(os, config, configurationTypes); +#else + // Use a target install generator. + cmInstallTargetGenerator g(l->second, destination.c_str(), false); + g.Generate(os, config, configurationTypes); +#endif + } + break; + case cmTarget::INSTALL_FILES: + { + // Use a file install generator. + const char* no_permissions = ""; + const char* no_rename = ""; + cmInstallFilesGenerator g(l->second.GetSourceLists(), + destination.c_str(), false, + no_permissions, no_rename); + g.Generate(os, config, configurationTypes); + } + break; + case cmTarget::INSTALL_PROGRAMS: + { + // Use a file install generator. + const char* no_permissions = ""; + const char* no_rename = ""; + cmInstallFilesGenerator g(l->second.GetSourceLists(), + destination.c_str(), true, + no_permissions, no_rename); + g.Generate(os, config, configurationTypes); + } + break; + case cmTarget::UTILITY: + default: + break; + } + } + + // Include the user-specified post-install script for this target. + if(const char* postinstall = l->second.GetProperty("POST_INSTALL_SCRIPT")) + { + cmInstallScriptGenerator g(postinstall); + g.Generate(os, config, configurationTypes); + } + } +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLocalGenerator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLocalGenerator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLocalGenerator.h 2005-08-12 02:02:20.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLocalGenerator.h 2006-03-16 00:02:04.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmLocalGenerator.h,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:20 $ - Version: $Revision: 1.35.2.1 $ + Date: $Date: 2006/03/15 16:02:04 $ + Version: $Revision: 1.52 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -45,7 +45,7 @@ /** * Process the CMakeLists files for this directory to fill in the - * m_Makefile ivar + * Makefile ivar */ virtual void Configure(); @@ -67,11 +67,11 @@ ///! Get the makefile for this generator cmMakefile *GetMakefile() { - return this->m_Makefile; }; + return this->Makefile; }; ///! Get the GlobalGenerator this is associated with cmGlobalGenerator *GetGlobalGenerator() { - return m_GlobalGenerator; }; + return this->GlobalGenerator; }; ///! Set the Global Generator, done on creation by the GlobalGenerator void SetGlobalGenerator(cmGlobalGenerator *gg); @@ -111,29 +111,41 @@ // flag to determine if this project should be included in a parent project bool GetExcludeAll() { - return m_ExcludeFromAll; + return this->ExcludeFromAll; } void SetExcludeAll(bool b) { - m_ExcludeFromAll = b; + this->ExcludeFromAll = b; } ///! set/get the parent generator - cmLocalGenerator* GetParent(){return m_Parent;} - void SetParent(cmLocalGenerator* g) { m_Parent = g; g->AddChild(this); } + cmLocalGenerator* GetParent(){return this->Parent;} + void SetParent(cmLocalGenerator* g) { this->Parent = g; g->AddChild(this); } ///! set/get the children void AddChild(cmLocalGenerator* g) { this->Children.push_back(g); } std::vector& GetChildren() { return this->Children; }; - void AddLanguageFlags(std::string& flags, const char* lang); + void AddLanguageFlags(std::string& flags, const char* lang, + const char* config); void AddSharedFlags(std::string& flags, const char* lang, bool shared); - void AddConfigVariableFlags(std::string& flags, const char* var); + void AddConfigVariableFlags(std::string& flags, const char* var, + const char* config); void AppendFlags(std::string& flags, const char* newFlags); ///! Get the include flags for the current makefile and language const char* GetIncludeFlags(const char* lang); + /** Translate a dependency as given in CMake code to the name to + appear in a generated build file. If the given name is that of + a CMake target it will be transformed to the real output + location of that target for the given configuration. If the + given name is the full path to a file it will be returned. + Otherwise the name is treated as a relative path with respect to + the source directory of this generator. This should only be + used for dependencies of custom commands. */ + std::string GetRealDependency(const char* name, const char* config); + ///! for existing files convert to output path and short path if spaces std::string ConvertToOutputForExisting(const char* p); @@ -143,54 +155,76 @@ bool /* clear */) {}; /** Called from command-line hook to scan dependencies. */ - virtual bool ScanDependencies(std::vector const& /* args */) {return true;}; + virtual bool ScanDependencies(std::vector const& /* args */) + {return true;}; + + /** Compute the list of link libraries and directories for the given + target and configuration. */ + void ComputeLinkInformation(cmTarget& target, const char* config, + std::vector& outLibs, + std::vector& outDirs, + std::vector* fullPathLibs=0); + + /** Get the include flags for the current makefile and language. */ + void GetIncludeDirectories(std::vector& dirs); + + // Create a struct to hold the varibles passed into + // ExpandRuleVariables + struct RuleVariables + { + RuleVariables() + { + this->Language= 0; + this->Objects= 0; + this->Target= 0; + this->LinkLibraries= 0; + this->Source= 0; + this->Object= 0; + this->Flags= 0; + this->ObjectsQuoted= 0; + this->TargetSOName= 0; + this->TargetInstallNameDir = 0; + this->LinkFlags= 0; + } + const char* Language; + const char* Objects; + const char* Target; + const char* LinkLibraries; + const char* Source; + const char* Object; + const char* Flags; + const char* ObjectsQuoted; + const char* TargetSOName; + const char* TargetInstallNameDir; + const char* LinkFlags; + const char* LanguageCompileFlags; + }; protected: /** Construct a script from the given list of command lines. */ std::string ConstructScript(const cmCustomCommandLines& commandLines, + const char* workingDirectory, const char* newline = "\n"); - ///! Fill out these strings for the given target. Libraries to link, flags, and linkflags. + /** Fill out these strings for the given target. Libraries to link, + * flags, and linkflags. */ void GetTargetFlags(std::string& linkLibs, std::string& flags, std::string& linkFlags, cmTarget&target); ///! put all the libraries for a target on into the given stream - virtual void OutputLinkLibraries(std::ostream&, const char* name,cmTarget &); - - - /** Get the include flags for the current makefile and language. */ - void GetIncludeDirectories(std::vector& dirs); + virtual void OutputLinkLibraries(std::ostream&, cmTarget&, bool relink); // Expand rule variables in CMake of the type found in language rules void ExpandRuleVariables(std::string& string, - const char* language, - const char* objects=0, - const char* target=0, - const char* linkLibs=0, - const char* source=0, - const char* object =0, - const char* flags = 0, - const char* objectsquoted = 0, - const char* targetBase = 0, - const char* targetSOName = 0, - const char* linkFlags = 0); + const RuleVariables& replaceValues); // Expand rule variables in a single string std::string ExpandRuleVariable(std::string const& variable, - const char* lang, - const char* objects, - const char* target, - const char* linkLibs, - const char* source, - const char* object, - const char* flags, - const char* objectsquoted, - const char* targetBase, - const char* targetSOName, - const char* linkFlags); + const RuleVariables& replaceValues); - ///! Convert a target to a utility target for unsupported languages of a generator + /** Convert a target to a utility target for unsupported + * languages of a generator */ void AddBuildTargetRule(const char* llang, cmTarget& target); ///! add a custom command to build a .o file that is part of a target void AddCustomCommandToCreateObject(const char* ofname, @@ -203,26 +237,34 @@ // of the types listed will be compiled as custom commands and added // to a custom target. void CreateCustomTargetsAndCommands(std::set const&); - virtual void AddInstallRule(std::ostream& fout, const char* dest, int type, - const char* files, bool optional = false, const char* properties = 0); - cmMakefile *m_Makefile; - cmGlobalGenerator *m_GlobalGenerator; + // Handle old-style install rules stored in the targets. + void GenerateTargetInstallRules( + std::ostream& os, const char* config, + std::vector const& configurationTypes); + + cmMakefile *Makefile; + cmGlobalGenerator *GlobalGenerator; // members used for relative path function ConvertToMakefilePath - std::string m_RelativePathToSourceDir; - std::string m_RelativePathToBinaryDir; - std::vector m_HomeDirectoryComponents; - std::vector m_StartDirectoryComponents; - std::vector m_HomeOutputDirectoryComponents; - std::vector m_StartOutputDirectoryComponents; - bool m_ExcludeFromAll; - cmLocalGenerator* m_Parent; + std::string RelativePathToSourceDir; + std::string RelativePathToBinaryDir; + std::vector HomeDirectoryComponents; + std::vector StartDirectoryComponents; + std::vector HomeOutputDirectoryComponents; + std::vector StartOutputDirectoryComponents; + bool ExcludeFromAll; + cmLocalGenerator* Parent; std::vector Children; - std::map m_LanguageToIncludeFlags; - bool m_WindowsShell; - bool m_UseRelativePaths; - bool m_IgnoreLibPrefix; + std::map LanguageToIncludeFlags; + bool WindowsShell; + bool ForceUnixPath; + bool UseRelativePaths; + bool IgnoreLibPrefix; bool Configured; + + // Hack for ExpandRuleVariable until object-oriented version is + // committed. + std::string TargetImplib; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLocalKdevelopGenerator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLocalKdevelopGenerator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLocalKdevelopGenerator.cxx 2005-10-25 03:43:52.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLocalKdevelopGenerator.cxx 2005-10-19 04:09:34.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmLocalKdevelopGenerator.cxx,v $ Language: C++ - Date: $Date: 2005/10/24 19:43:52 $ - Version: $Revision: 1.17.2.1 $ + Date: $Date: 2005/10/18 20:09:34 $ + Version: $Revision: 1.18 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2004 Alexander Neundorf, neundorf@kde.org. All rights reserved. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLocalUnixMakefileGenerator3.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLocalUnixMakefileGenerator3.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLocalUnixMakefileGenerator3.cxx 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLocalUnixMakefileGenerator3.cxx 2006-03-16 05:32:40.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmLocalUnixMakefileGenerator3.cxx,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.48.2.6 $ + Date: $Date: 2006/03/15 21:32:40 $ + Version: $Revision: 1.123 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -20,6 +20,7 @@ #include "cmGeneratedFileStream.h" #include "cmGlobalUnixMakefileGenerator3.h" #include "cmMakefile.h" +#include "cmMakefileTargetGenerator.h" #include "cmSourceFile.h" #include "cmake.h" @@ -34,19 +35,18 @@ #include // auto_ptr #include -// TODO: Add "help" target. -// TODO: Identify remaining relative path violations. -// TODO: Need test for separate executable/library output path. - //---------------------------------------------------------------------------- cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3() { - m_WindowsShell = false; - m_IncludeDirective = "include"; - m_MakefileVariableSize = 0; - m_IgnoreLibPrefix = false; - m_PassMakeflags = false; - m_EchoNeedsQuote = true; + this->SilentNoColon = false; + this->WindowsShell = false; + this->IncludeDirective = "include"; + this->MakefileVariableSize = 0; + this->IgnoreLibPrefix = false; + this->PassMakeflags = false; + this->EchoNeedsQuote = true; + this->DefineWindowsNULL = false; + this->UnixCD = true; } //---------------------------------------------------------------------------- @@ -57,7 +57,14 @@ //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3::Configure() { - this->ComputeHomeRelativeOutputPath(); + // Include the rule file for each object. + this->HomeRelativeOutputPath = + cmSystemTools::RelativePath(this->Makefile->GetHomeOutputDirectory(), + this->Makefile->GetStartOutputDirectory()); + if (this->HomeRelativeOutputPath.size()) + { + this->HomeRelativeOutputPath += "/"; + } this->cmLocalGenerator::Configure(); } @@ -68,22 +75,17 @@ this->ConfigureOutputPaths(); // Generate the rule files for each target. - cmTargets& targets = m_Makefile->GetTargets(); + cmTargets& targets = this->Makefile->GetTargets(); std::string empty; for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) { - if((t->second.GetType() == cmTarget::EXECUTABLE) || - (t->second.GetType() == cmTarget::STATIC_LIBRARY) || - (t->second.GetType() == cmTarget::SHARED_LIBRARY) || - (t->second.GetType() == cmTarget::MODULE_LIBRARY)) - { - t->second.TraceVSDependencies(empty, m_Makefile); - this->WriteTargetRuleFiles(t->second); - } - else if(t->second.GetType() == cmTarget::UTILITY) - { - t->second.TraceVSDependencies(empty, m_Makefile); - this->WriteUtilityRuleFiles(t->second); + cmMakefileTargetGenerator *tg = + cmMakefileTargetGenerator::New(this, t->first, &(t->second)); + if (tg) + { + this->TargetGenerators.push_back(tg); + t->second.TraceVSDependencies(empty, this->Makefile); + tg->WriteRuleFiles(); } } @@ -92,6 +94,15 @@ // Write the cmake file with information for this directory. this->WriteDirectoryInformationFile(); + + // delete the makefile target generator objects + for (std::vector::iterator mtgIter = + this->TargetGenerators.begin(); + mtgIter != this->TargetGenerators.end(); ++mtgIter) + { + delete *mtgIter; + } + this->TargetGenerators.clear(); } @@ -99,15 +110,27 @@ void cmLocalUnixMakefileGenerator3::ConfigureOutputPaths() { // Format the library and executable output paths. - if(const char* libOut = m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH")) + if(const char* libOut = this->Makefile->GetDefinition("LIBRARY_OUTPUT_PATH")) + { + this->LibraryOutputPath = libOut; + this->FormatOutputPath(this->LibraryOutputPath, "LIBRARY"); + } + if(const char* exeOut = this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH")) + { + this->ExecutableOutputPath = exeOut; + this->FormatOutputPath(this->ExecutableOutputPath, "EXECUTABLE"); + } + + // Store the configuration name that will be generated. + if(const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE")) { - m_LibraryOutputPath = libOut; - this->FormatOutputPath(m_LibraryOutputPath, "LIBRARY"); + // Use the build type given by the user. + this->ConfigurationName = config; } - if(const char* exeOut = m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH")) + else { - m_ExecutableOutputPath = exeOut; - this->FormatOutputPath(m_ExecutableOutputPath, "EXECUTABLE"); + // No configuration type given. + this->ConfigurationName = ""; } } @@ -122,7 +145,7 @@ // relative to the current output directory for this makefile. path = cmSystemTools::CollapseFullPath(path.c_str(), - m_Makefile->GetStartOutputDirectory()); + this->Makefile->GetStartOutputDirectory()); // Add a trailing slash for easy appending later. if(path.empty() || path[path.size()-1] != '/') @@ -138,31 +161,133 @@ } // Add this as a link directory automatically. - m_Makefile->AddLinkDirectory(path.c_str()); + this->Makefile->AddLinkDirectory(path.c_str()); } } +//---------------------------------------------------------------------------- +void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() +{ + // generate the includes + std::string ruleFileName = "Makefile"; + + // Open the rule file. This should be copy-if-different because the + // rules may depend on this file itself. + std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName); + cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str()); + if(!ruleFileStream) + { + return; + } + // always write the top makefile + if (this->Parent) + { + ruleFileStream.SetCopyIfDifferent(true); + } + + // write the all rules + this->WriteLocalAllRules(ruleFileStream); + + // only write local targets unless at the top Keep track of targets already + // listed. + std::set emittedTargets; + if (this->Parent) + { + // write our targets, and while doing it collect up the object + // file rules + this->WriteLocalMakefileTargets(ruleFileStream,emittedTargets); + } + else + { + cmGlobalUnixMakefileGenerator3 *gg = + static_cast(this->GlobalGenerator); + gg->WriteConvenienceRules(ruleFileStream,emittedTargets); + } + + std::vector depends; + std::vector commands; + + // now write out the object rules + // for each object file name + for (std::map >::iterator lo = + this->LocalObjectFiles.begin(); + lo != this->LocalObjectFiles.end(); ++lo) + { + commands.clear(); + // for each target using the object file + for (std::vector::iterator to = + lo->second.begin(); to != lo->second.end(); ++to) + { + std::string tgtMakefileName = this->GetRelativeTargetDirectory(**to); + std::string targetName = tgtMakefileName; + tgtMakefileName += "/build.make"; + targetName += "/"; + targetName += lo->first.c_str(); + commands.push_back(this->GetRecursiveMakeCall + (tgtMakefileName.c_str(),targetName.c_str())); + this->CreateCDCommand(commands, + this->Makefile->GetHomeOutputDirectory(), + this->Makefile->GetStartOutputDirectory()); + } + this->WriteMakeRule(ruleFileStream, + "target for object file", + lo->first.c_str(), depends, commands, false); + } + + // add a help target as long as there isn;t a real target named help + if(emittedTargets.insert("help").second) + { + cmGlobalUnixMakefileGenerator3 *gg = + static_cast(this->GlobalGenerator); + gg->WriteHelpRule(ruleFileStream,this); + } + + this->WriteSpecialTargetsBottom(ruleFileStream); +} void cmLocalUnixMakefileGenerator3 -::WriteCustomCommands(std::ostream& ruleFileStream, - std::vector& cleanFiles) +::WriteLocalMakefileTargets(std::ostream& ruleFileStream, + std::set &emitted) { - // add custom commands to the clean rules? - const char* clean_no_custom = m_Makefile->GetProperty("CLEAN_NO_CUSTOM"); - bool clean = cmSystemTools::IsOff(clean_no_custom); - - // Generate the rule files for each custom command. - const std::vector &classes = m_Makefile->GetSourceFiles(); - for(std::vector::const_iterator i = classes.begin(); - i != classes.end(); i++) + std::vector depends; + std::vector commands; + + // for each target we just provide a rule to cd up to the top and do a make + // on the target + cmTargets& targets = this->Makefile->GetTargets(); + std::string localName; + for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) { - if(cmCustomCommand* cc = (*i)->GetCustomCommand()) + if((t->second.GetType() == cmTarget::EXECUTABLE) || + (t->second.GetType() == cmTarget::STATIC_LIBRARY) || + (t->second.GetType() == cmTarget::SHARED_LIBRARY) || + (t->second.GetType() == cmTarget::MODULE_LIBRARY) || + (t->second.GetType() == cmTarget::UTILITY)) { - this->GenerateCustomRuleFile(*cc,ruleFileStream); - if (clean) + emitted.insert(t->second.GetName()); + + // for subdirs add a rule to build this specific target by name. + localName = this->GetRelativeTargetDirectory(t->second); + localName += "/rule"; + commands.clear(); + depends.clear(); + + // Build the target for this pass. + commands.push_back(this->GetRecursiveMakeCall + ("CMakeFiles/Makefile2",localName.c_str())); + this->CreateCDCommand(commands, + this->Makefile->GetHomeOutputDirectory(), + this->Makefile->GetStartOutputDirectory()); + this->WriteMakeRule(ruleFileStream, "Convenience name for target.", + localName.c_str(), depends, commands, true); + + // Add a target with the canonical name (no prefix, suffix or path). + if(localName != t->second.GetName()) { - cleanFiles.push_back - (this->Convert(cc->GetOutput(),START_OUTPUT,SHELL)); + commands.clear(); + depends.push_back(localName); + this->WriteMakeRule(ruleFileStream, "Convenience name for target.", + t->second.GetName(), depends, commands, true); } } } @@ -171,7 +296,7 @@ //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile() { - std::string infoFileName = m_Makefile->GetStartOutputDirectory(); + std::string infoFileName = this->Makefile->GetStartOutputDirectory(); infoFileName += "/CMakeFiles/CMakeDirectoryInformation.cmake"; // Open the output file. @@ -220,13 +345,13 @@ infoFileStream << "SET(CMAKE_C_INCLUDE_REGEX_SCAN "; this->WriteCMakeArgument(infoFileStream, - m_Makefile->GetIncludeRegularExpression()); + this->Makefile->GetIncludeRegularExpression()); infoFileStream << ")\n"; infoFileStream << "SET(CMAKE_C_INCLUDE_REGEX_COMPLAIN "; this->WriteCMakeArgument(infoFileStream, - m_Makefile->GetComplainRegularExpression()); + this->Makefile->GetComplainRegularExpression()); infoFileStream << ")\n"; infoFileStream @@ -241,8 +366,8 @@ infoFileStream << "SET(CMAKE_GENERATED_FILES\n"; for(std::vector::const_iterator - i = m_Makefile->GetSourceFiles().begin(); - i != m_Makefile->GetSourceFiles().end(); ++i) + i = this->Makefile->GetSourceFiles().begin(); + i != this->Makefile->GetSourceFiles().end(); ++i) { cmSourceFile* src = *i; if(src->GetPropertyAsBool("GENERATED")) @@ -264,2021 +389,311 @@ cmLocalUnixMakefileGenerator3 ::ConvertToFullPath(const std::string& localPath) { - std::string dir = m_Makefile->GetStartOutputDirectory(); + std::string dir = this->Makefile->GetStartOutputDirectory(); dir += "/"; dir += localPath; return dir; } -//---------------------------------------------------------------------------- -void cmLocalUnixMakefileGenerator3::WriteDisclaimer(std::ostream& os) -{ - os - << "# CMAKE generated file: DO NOT EDIT!\n" - << "# Generated by \"" << m_GlobalGenerator->GetName() << "\"" - << " Generator, CMake Version " - << cmMakefile::GetMajorVersion() << "." - << cmMakefile::GetMinorVersion() << "\n\n"; -} - -void cmLocalUnixMakefileGenerator3::ComputeHomeRelativeOutputPath() -{ - // Include the rule file for each object. - m_HomeRelativeOutputPath = - cmSystemTools::RelativePath(m_Makefile->GetHomeOutputDirectory(), - m_Makefile->GetStartOutputDirectory()); - if (m_HomeRelativeOutputPath.size()) - { - m_HomeRelativeOutputPath += "/"; - } -} - const std::string &cmLocalUnixMakefileGenerator3::GetHomeRelativeOutputPath() { - return m_HomeRelativeOutputPath; + return this->HomeRelativeOutputPath; } + //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3 -::WriteTargetRuleFiles(cmTarget& target) +::WriteMakeRule(std::ostream& os, + const char* comment, + const char* target, + const std::vector& depends, + const std::vector& commands, + bool symbolic) { - // Create a directory for this target. - std::string dir = m_Makefile->GetStartOutputDirectory(); - dir += "/"; - dir += this->GetTargetDirectory(target); - cmSystemTools::MakeDirectory(dir.c_str()); - - // Generate the build-time dependencies file for this target. - std::string depBase = dir; - depBase += "/"; - depBase += target.GetName(); - - // Construct the rule file name. - std::string ruleFileName = dir; - ruleFileName += "/build.make"; - - // Open the rule file. This should be copy-if-different because the - // rules may depend on this file itself. - std::string ruleFileNameFull = ruleFileName; - cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str()); - ruleFileStream.SetCopyIfDifferent(true); - if(!ruleFileStream) + // Make sure there is a target. + if(!target || !*target) { + cmSystemTools::Error("No target for WriteMakeRule! called with comment: ", + comment); return; } - this->WriteDisclaimer(ruleFileStream); - - this->WriteMakeVariables(ruleFileStream); - - // Open the flags file. This should be copy-if-different because the - // rules may depend on this file itself. - std::string flagFileName = dir; - flagFileName += "/flags.make"; - std::string flagFileNameFull = flagFileName; - cmGeneratedFileStream flagFileStream(flagFileNameFull.c_str()); - flagFileStream.SetCopyIfDifferent(true); - if(!flagFileStream) + + std::string replace; + + // Write the comment describing the rule in the makefile. + if(comment) { - return; + replace = comment; + std::string::size_type lpos = 0; + std::string::size_type rpos; + while((rpos = replace.find('\n', lpos)) != std::string::npos) + { + os << "# " << replace.substr(lpos, rpos-lpos) << "\n"; + lpos = rpos+1; + } + os << "# " << replace.substr(lpos) << "\n"; } - this->WriteDisclaimer(flagFileStream); - // Include the dependencies for the target. - std::string depPath = dir; - depPath += "/depend.make"; - depPath = this->Convert(depPath.c_str(),HOME_OUTPUT,MAKEFILE); - ruleFileStream - << "# Include any dependencies generated for this target.\n" - << m_IncludeDirective << " " - << depPath - << "\n\n"; - - // Include the flags for the target. - flagFileName = this->Convert(flagFileName.c_str(), HOME_OUTPUT, MAKEFILE); - ruleFileStream - << "# Include the compile flags for this target's objects.\n" - << m_IncludeDirective << " " - << flagFileName - << "\n\n"; - - // make sure the depend file exists - depPath = dir; - depPath += "/depend.make"; - depPath = this->Convert(depPath.c_str(),FULL,UNCHANGED); - if (!cmSystemTools::FileExists(depPath.c_str())) - { - // Write an empty dependency file. - cmGeneratedFileStream depFileStream(depPath.c_str()); - depFileStream - << "# Empty dependencies file for " << target.GetName() << ".\n" - << "# This may be replaced when dependencies are built." << std::endl; + // Construct the left hand side of the rule. + replace = target; + std::string tgt = this->Convert(replace.c_str(),HOME_OUTPUT,MAKEFILE); + tgt = this->ConvertToMakeTarget(tgt.c_str()); + const char* space = ""; + if(tgt.size() == 1) + { + // Add a space before the ":" to avoid drive letter confusion on + // Windows. + space = " "; } - - // First generate the object rule files. Save a list of all object - // files for this target. - std::vector objects; - std::vector external_objects; - const std::vector& sources = target.GetSourceFiles(); - for(std::vector::const_iterator source = sources.begin(); - source != sources.end(); ++source) + + // Mark the rule as symbolic if requested. + if(symbolic) { - if(!(*source)->GetPropertyAsBool("HEADER_FILE_ONLY") && - !(*source)->GetCustomCommand()) + if(const char* sym = + this->Makefile->GetDefinition("CMAKE_MAKE_SYMBOLIC_RULE")) { - if(!m_GlobalGenerator->IgnoreFile((*source)->GetSourceExtension().c_str())) - { - // Generate this object file's rule file. - this->WriteObjectRuleFiles(target, *(*source), objects, - ruleFileStream, flagFileStream); - } - else if((*source)->GetPropertyAsBool("EXTERNAL_OBJECT")) - { - // This is an external object file. Just add it. - external_objects.push_back((*source)->GetFullPath()); - } - else - { - // We only get here if a source file is not an external object - // and has an extension that is listed as an ignored file type - // for this language. No message or diagnosis should be - // given. - } + os << tgt.c_str() << space << ": " << sym << "\n"; } } - - // write language flags for target - std::map& - checkSet = this->GetIntegrityCheckSet()[target.GetName()]; - for(std::map::const_iterator - l = checkSet.begin(); l != checkSet.end(); ++l) + + // Write the rule. + if(depends.empty()) + { + // No dependencies. The commands will always run. + os << tgt.c_str() << space << ":\n"; + } + else { - const char *lang = l->first.c_str(); - std::string flags; - // Add the export symbol definition for shared library objects. - bool shared = ((target.GetType() == cmTarget::SHARED_LIBRARY) || - (target.GetType() == cmTarget::MODULE_LIBRARY)); - if(shared) + // Split dependencies into multiple rule lines. This allows for + // very long dependency lists even on older make implementations. + for(std::vector::const_iterator dep = depends.begin(); + dep != depends.end(); ++dep) { - flags += "-D"; - if(const char* custom_export_name = target.GetProperty("DEFINE_SYMBOL")) - { - flags += custom_export_name; - } - else - { - std::string in = target.GetName(); - in += "_EXPORTS"; - flags += cmSystemTools::MakeCindentifier(in.c_str()); - } + replace = *dep; + replace = this->Convert(replace.c_str(),HOME_OUTPUT,MAKEFILE); + replace = this->ConvertToMakeTarget(replace.c_str()); + os << tgt.c_str() << space << ": " << replace.c_str() << "\n"; } - - // Add language-specific flags. - this->AddLanguageFlags(flags, lang); - - // Add shared-library flags if needed. - this->AddSharedFlags(flags, lang, shared); - - // Add include directory flags. - this->AppendFlags(flags, this->GetIncludeFlags(lang)); - flagFileStream << lang << "_FLAGS = " << flags - << "\n" - << "\n"; } - - // write the custom commands for this target - std::vector cleanFiles; - // Look for files registered for cleaning in this directory. - if(const char* additional_clean_files = - m_Makefile->GetProperty("ADDITIONAL_MAKE_CLEAN_FILES")) - { - cmSystemTools::ExpandListArgument(additional_clean_files, cleanFiles); - } - this->WriteCustomCommands(ruleFileStream,cleanFiles); - - // Include the rule file for each object. - std::string relPath = this->GetHomeRelativeOutputPath(); - std::string objTarget; - // Write the rule for this target type. - switch(target.GetType()) + // Write the list of commands. + for(std::vector::const_iterator i = commands.begin(); + i != commands.end(); ++i) { - case cmTarget::STATIC_LIBRARY: - this->WriteStaticLibraryRule(ruleFileStream, ruleFileName.c_str(), - target, objects, external_objects, - cleanFiles); - break; - case cmTarget::SHARED_LIBRARY: - this->WriteSharedLibraryRule(ruleFileStream, ruleFileName.c_str(), - target, objects, external_objects, - cleanFiles); - break; - case cmTarget::MODULE_LIBRARY: - this->WriteModuleLibraryRule(ruleFileStream, ruleFileName.c_str(), - target, objects, external_objects, - cleanFiles); - break; - case cmTarget::EXECUTABLE: - this->WriteExecutableRule(ruleFileStream, ruleFileName.c_str(), - target, objects, external_objects, - cleanFiles); - break; - default: - break; + replace = *i; + os << "\t" << replace.c_str() << "\n"; } - - // Write the requires target. - this->WriteTargetRequiresRule(ruleFileStream, target, objects); - - // Write clean target - this->WriteTargetCleanRule(ruleFileStream, target, cleanFiles); + os << "\n"; } //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3 -::WriteObjectDependRules(cmSourceFile& source, - std::vector& depends) +::WriteMakeVariables(std::ostream& makefileStream) { - // Create the list of dependencies known at cmake time. These are - // shared between the object file and dependency scanning rule. - depends.push_back(source.GetFullPath()); - if(const char* objectDeps = source.GetProperty("OBJECT_DEPENDS")) - { - std::vector deps; - cmSystemTools::ExpandListArgument(objectDeps, deps); - for(std::vector::iterator i = deps.begin(); - i != deps.end(); ++i) - { - depends.push_back(i->c_str()); - } - } -} - - -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::WriteObjectBuildFile(std::string &obj, - const char *lang, - cmTarget& target, - cmSourceFile& source, - std::vector& depends, - std::ostream &ruleFileStream, - std::ostream &flagFileStream) -{ - // Open the rule file for writing. This should be copy-if-different - // because the rules may depend on this file itself. - std::string ruleFileName = m_Makefile->GetStartOutputDirectory(); - ruleFileName += "/"; - ruleFileName += this->GetTargetDirectory(target); - ruleFileName += "/build.make"; - std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName); - - std::string flagFileName = this->GetTargetDirectory(target); - flagFileName += "/flags.make"; - std::string flagFileNameFull = this->ConvertToFullPath(flagFileName); - this->AppendRuleDepend(depends, flagFileNameFull.c_str()); - - // generate the depend scanning rule - this->WriteObjectDependRules(source, depends); - - std::string relativeObj = this->GetHomeRelativeOutputPath(); - relativeObj += obj; - - // Write the build rule. - // Build the set of compiler flags. - std::string flags; - - // Add flags from source file properties. - if (source.GetProperty("COMPILE_FLAGS")) - { - this->AppendFlags(flags, source.GetProperty("COMPILE_FLAGS")); - flagFileStream << "# Custom flags: " - << relativeObj << "_FLAGS = " - << source.GetProperty("COMPILE_FLAGS") - << "\n" - << "\n"; - } - - // Add language-specific flags. - std::string langFlags = "$("; - langFlags += lang; - langFlags += "_FLAGS)"; - this->AppendFlags(flags, langFlags.c_str()); - - // Get the output paths for source and object files. - std::string sourceFile = source.GetFullPath(); - if(m_UseRelativePaths) - { - sourceFile = this->Convert(sourceFile.c_str(),HOME_OUTPUT); - } - sourceFile = this->Convert(sourceFile.c_str(),NONE,SHELL); - std::string objectFile = this->Convert(obj.c_str(),START_OUTPUT,SHELL); - - // Construct the build message. - std::vector no_commands; - std::vector commands; - std::string buildEcho = "Building "; - buildEcho += lang; - buildEcho += " object "; - buildEcho += relativeObj; - this->AppendEcho(commands, buildEcho.c_str()); - - // Construct the compile rules. - std::string compileRuleVar = "CMAKE_"; - compileRuleVar += lang; - compileRuleVar += "_COMPILE_OBJECT"; - std::string compileRule = - m_Makefile->GetRequiredDefinition(compileRuleVar.c_str()); - cmSystemTools::ExpandListArgument(compileRule, commands); - - // Expand placeholders in the commands. - for(std::vector::iterator i = commands.begin(); - i != commands.end(); ++i) - { - this->ExpandRuleVariables(*i, - lang, - 0, // no objects - 0, // no target - 0, // no link libs - sourceFile.c_str(), - relativeObj.c_str(), - flags.c_str()); - } - - // Make the target dependency scanning rule include cmake-time-known - // dependencies. The others are handled by the check-build-system - // path. - std::string depMark = this->GetRelativeTargetDirectory(target); - depMark += "/depend.make.mark"; - this->WriteMakeRule(ruleFileStream, 0, - depMark.c_str(), depends, no_commands); - - // Write the rule. - this->WriteMakeRule(ruleFileStream, 0, - relativeObj.c_str(), depends, commands); - - // If the language needs provides-requires mode, create the - // corresponding targets. - std::string objectRequires = relativeObj; - objectRequires += ".requires"; - std::vector p_depends; - // always provide an empty requires target - this->WriteMakeRule(ruleFileStream, 0, - objectRequires.c_str(), p_depends, no_commands); - - // write a build rule to recursively build what this obj provides - std::string objectProvides = relativeObj; - objectProvides += ".provides"; - std::string temp = relativeObj; - temp += ".provides.build"; - std::vector r_commands; - std::string tgtMakefileName = this->GetRelativeTargetDirectory(target); - tgtMakefileName += "/build.make"; - r_commands.push_back(this->GetRecursiveMakeCall(tgtMakefileName.c_str(), - temp.c_str())); - p_depends.clear(); - p_depends.push_back(objectRequires); - this->WriteMakeRule(ruleFileStream, 0, - objectProvides.c_str(), p_depends, r_commands); - - // write the provides.build rule dependency on the obj file - p_depends.clear(); - p_depends.push_back(relativeObj); - this->WriteMakeRule(ruleFileStream, 0, - temp.c_str(), p_depends, no_commands); -} - -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::WriteObjectRuleFiles(cmTarget& target, cmSourceFile& source, - std::vector& objects, - std::ostream &ruleFileStream, - std::ostream &flagFileStream) -{ - // Identify the language of the source file. - const char* lang = this->GetSourceFileLanguage(source); - if(!lang) - { - // If language is not known, this is an error. - cmSystemTools::Error("Source file \"", source.GetFullPath().c_str(), - "\" has unknown type."); - return; - } - - // Get the full path name of the object file. - std::string obj = this->GetObjectFileName(target, source); - - // Avoid generating duplicate rules. - if(m_ObjectFiles.find(obj) == m_ObjectFiles.end()) - { - m_ObjectFiles.insert(obj); - } - else - { - cmOStringStream err; - err << "Warning: Source file \"" - << source.GetSourceName().c_str() << "." - << source.GetSourceExtension().c_str() - << "\" is listed multiple times for target \"" << target.GetName() - << "\"."; - cmSystemTools::Message(err.str().c_str(), "Warning"); - return; - } - - // Create the directory containing the object file. This may be a - // subdirectory under the target's directory. - std::string dir = cmSystemTools::GetFilenamePath(obj.c_str()); - cmSystemTools::MakeDirectory(this->ConvertToFullPath(dir).c_str()); - - // Save this in the target's list of object files. - objects.push_back(obj); - std::string relativeObj = this->GetHomeRelativeOutputPath(); - relativeObj += obj; - - // we compute some depends when writing the depend.make that we will also - // use in the build.make, same with depMakeFile - std::vector depends; - std::string depMakeFile; - - // generate the build rule file - this->WriteObjectBuildFile(obj, lang, target, source, depends, - ruleFileStream, flagFileStream); - - // The object file should be checked for dependency integrity. - m_CheckDependFiles[target.GetName()][lang].insert(&source); - - // add this to the list of objects for this local generator - m_LocalObjectFiles[cmSystemTools::GetFilenameName(obj)].push_back(&target); -} - -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::GenerateCustomRuleFile(const cmCustomCommand& cc, - std::ostream &ruleFileStream) -{ - // Convert the output name to a relative path if possible. - std::string output = this->Convert(cc.GetOutput(),START_OUTPUT); - - // Collect the commands. - std::vector commands; - std::string preEcho = "Generating "; - preEcho += output; - this->AppendEcho(commands, preEcho.c_str()); - this->AppendCustomCommand(commands, cc); - - // Collect the dependencies. - std::vector depends; - this->AppendCustomDepend(depends, cc); - - // Write the rule. - const char* comment = 0; - if(cc.GetComment() && *cc.GetComment()) - { - comment = cc.GetComment(); - } - this->WriteMakeRule(ruleFileStream, comment, - cc.GetOutput(), depends, commands); -} - -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::WriteUtilityRuleFiles(cmTarget& target) -{ - // Create a directory for this target. - std::string dir = this->GetTargetDirectory(target); - cmSystemTools::MakeDirectory(this->ConvertToFullPath(dir).c_str()); - - // Construct the name of the rule file. - std::string ruleFileName = dir; - ruleFileName += "/build.make"; - - // Open the rule file. This should be copy-if-different because the - // rules may depend on this file itself. - std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName); - cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str()); - ruleFileStream.SetCopyIfDifferent(true); - if(!ruleFileStream) - { - return; - } - this->WriteDisclaimer(ruleFileStream); - this->WriteMakeVariables(ruleFileStream); - ruleFileStream - << "# Utility rule file for " << target.GetName() << ".\n\n"; - - // write the custom commands for this target - std::vector cleanFiles; - if(const char* additional_clean_files = - m_Makefile->GetProperty("ADDITIONAL_MAKE_CLEAN_FILES")) - { - cmSystemTools::ExpandListArgument(additional_clean_files, cleanFiles); - } - this->WriteCustomCommands(ruleFileStream, cleanFiles); - - // Collect the commands and dependencies. - std::vector commands; - std::vector depends; - - // Utility targets store their rules in pre- and post-build commands. - this->AppendCustomDepends(depends, target.GetPreBuildCommands()); - this->AppendCustomDepends(depends, target.GetPostBuildCommands()); - this->AppendCustomCommands(commands, target.GetPreBuildCommands()); - this->AppendCustomCommands(commands, target.GetPostBuildCommands()); - - // Add dependencies on targets that must be built first. - this->AppendTargetDepends(depends, target); - - // Add a dependency on the rule file itself. - std::string relPath = this->GetHomeRelativeOutputPath(); - std::string objTarget = relPath; - objTarget += ruleFileName; - this->AppendRuleDepend(depends, objTarget.c_str()); - - // Write the rule. - this->WriteMakeRule(ruleFileStream, 0, - target.GetName(), depends, commands); - - // Write convenience targets. - dir = m_Makefile->GetStartOutputDirectory(); - dir += "/"; - dir += this->GetTargetDirectory(target); - std::string buildTargetRuleName = dir; - buildTargetRuleName += "/build"; - buildTargetRuleName = - this->Convert(buildTargetRuleName.c_str(),HOME_OUTPUT,MAKEFILE); - this->WriteConvenienceRule(ruleFileStream, target.GetName(), - buildTargetRuleName.c_str()); - - // Write clean target - this->WriteTargetCleanRule(ruleFileStream, target, cleanFiles); -} - -//---------------------------------------------------------------------------- -bool -cmLocalUnixMakefileGenerator3 -::GenerateDependsMakeFile(const std::string& lang, const char* objFile) -{ - // Construct a checker for the given language. - std::auto_ptr - checker(this->GetDependsChecker(lang,false)); - if(checker.get()) - { - // Check the dependencies. Ths is required because we need at least an - // empty depends.make for make to include, so at cmake time the - // ::Check() method will generate that if it does not exist - checker->Check(objFile); - - return true; - } - return false; -} - -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::WriteMakeRule(std::ostream& os, - const char* comment, - const char* target, - const std::vector& depends, - const std::vector& commands) -{ - // Make sure there is a target. - if(!target || !*target) - { - cmSystemTools::Error("No target for WriteMakeRule! called with comment: ", - comment); - return; - } - - std::string replace; - - // Write the comment describing the rule in the makefile. - if(comment) - { - replace = comment; - std::string::size_type lpos = 0; - std::string::size_type rpos; - while((rpos = replace.find('\n', lpos)) != std::string::npos) - { - os << "# " << replace.substr(lpos, rpos-lpos) << "\n"; - lpos = rpos+1; - } - os << "# " << replace.substr(lpos) << "\n"; - } - - // Construct the left hand side of the rule. - replace = target; - std::string tgt = this->Convert(replace.c_str(),HOME_OUTPUT,MAKEFILE); - tgt = this->ConvertToMakeTarget(tgt.c_str()); - const char* space = ""; - if(tgt.size() == 1) - { - // Add a space before the ":" to avoid drive letter confusion on - // Windows. - space = " "; - } - - // Write the rule. - if(depends.empty()) - { - // No dependencies. The commands will always run. - os << tgt.c_str() << space << ":\n"; - } - else - { - // Split dependencies into multiple rule lines. This allows for - // very long dependency lists even on older make implementations. - for(std::vector::const_iterator dep = depends.begin(); - dep != depends.end(); ++dep) - { - replace = *dep; - replace = this->Convert(replace.c_str(),HOME_OUTPUT,MAKEFILE); - replace = this->ConvertToMakeTarget(replace.c_str()); - os << tgt.c_str() << space << ": " << replace.c_str() << "\n"; - } - } - - // Write the list of commands. - for(std::vector::const_iterator i = commands.begin(); - i != commands.end(); ++i) - { - replace = *i; - os << "\t" << replace.c_str() << "\n"; - } - os << "\n"; -} - -//---------------------------------------------------------------------------- -void cmLocalUnixMakefileGenerator3::WriteDivider(std::ostream& os) -{ - os - << "#======================================" - << "=======================================\n"; -} - -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::WriteMakeVariables(std::ostream& makefileStream) -{ - this->WriteDivider(makefileStream); - makefileStream - << "# Set environment variables for the build.\n" - << "\n"; - if(m_WindowsShell) - { - makefileStream - << "!IF \"$(OS)\" == \"Windows_NT\"\n" - << "NULL=\n" - << "!ELSE\n" - << "NULL=nul\n" - << "!ENDIF\n"; - } - else - { - makefileStream - << "# The shell in which to execute make rules.\n" - << "SHELL = /bin/sh\n" - << "\n"; - } - - if(m_Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")) - { - makefileStream - << "# Produce verbose output by default.\n" - << "VERBOSE = 1\n" - << "\n"; + this->WriteDivider(makefileStream); + makefileStream + << "# Set environment variables for the build.\n" + << "\n"; + if(this->DefineWindowsNULL) + { + makefileStream + << "!IF \"$(OS)\" == \"Windows_NT\"\n" + << "NULL=\n" + << "!ELSE\n" + << "NULL=nul\n" + << "!ENDIF\n"; + } + if(this->WindowsShell) + { + makefileStream + << "SHELL = C:\\WINDOWS\\system32\\cmd.exe\n"; + } + else + { + makefileStream + << "# The shell in which to execute make rules.\n" + << "SHELL = /bin/sh\n" + << "\n"; } std::string cmakecommand = - m_Makefile->GetRequiredDefinition("CMAKE_COMMAND"); + this->Makefile->GetRequiredDefinition("CMAKE_COMMAND"); makefileStream << "# The CMake executable.\n" << "CMAKE_COMMAND = " - << this->Convert(cmakecommand.c_str(), FULL, MAKEFILE).c_str() + << this->Convert(cmakecommand.c_str(), FULL, SHELL).c_str() << "\n" << "\n"; makefileStream << "# The command to remove a file.\n" << "RM = " - << this->Convert(cmakecommand.c_str(),FULL,SHELL).c_str() - << " -E remove -f\n" - << "\n"; - - if(m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND")) - { - makefileStream - << "# The program to use to edit the cache.\n" - << "CMAKE_EDIT_COMMAND = " - << (this->ConvertToOutputForExisting( - m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND"))) << "\n" - << "\n"; - } - - makefileStream - << "# The top-level source directory on which CMake was run.\n" - << "CMAKE_SOURCE_DIR = " - << this->Convert(m_Makefile->GetHomeDirectory(), FULL, SHELL) - << "\n" - << "\n"; - makefileStream - << "# The top-level build directory on which CMake was run.\n" - << "CMAKE_BINARY_DIR = " - << this->Convert(m_Makefile->GetHomeOutputDirectory(), FULL, SHELL) - << "\n" - << "\n"; -} - -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::WriteSpecialTargetsTop(std::ostream& makefileStream) -{ - this->WriteDivider(makefileStream); - makefileStream - << "# Special targets provided by cmake.\n" - << "\n"; - - // Write the main entry point target. This must be the VERY first - // target so that make with no arguments will run it. - { - // Just depend on the all target to drive the build. - std::vector depends; - std::vector no_commands; - depends.push_back("all"); - - // Write the rule. - this->WriteMakeRule(makefileStream, - "Default target executed when no arguments are " - "given to make.", - "default_target", - depends, - no_commands); - } - - // Write special "test" target to run ctest. - if(m_Makefile->IsOn("CMAKE_TESTING_ENABLED")) - { - std::string ctest; - if(m_Makefile->GetDefinition("CMake_BINARY_DIR")) - { - // We are building CMake itself. Use the ctest that comes with - // this version of CMake instead of the one used to build it. - ctest = m_ExecutableOutputPath; - ctest += "ctest"; - ctest += cmSystemTools::GetExecutableExtension(); - ctest = this->Convert(ctest.c_str(),START_OUTPUT,SHELL); - ctest += " --force-new-ctest-process"; - } - else - { - // We are building another project. Use the ctest that comes with - // the CMake building it. - ctest = m_Makefile->GetRequiredDefinition("CMAKE_COMMAND"); - ctest = cmSystemTools::GetFilenamePath(ctest.c_str()); - ctest += "/"; - ctest += "ctest"; - ctest += cmSystemTools::GetExecutableExtension(); - ctest = this->ConvertToOutputForExisting(ctest.c_str()); - } - std::vector no_depends; - std::vector commands; - this->AppendEcho(commands, "Running tests..."); - ctest += " $(ARGS)"; - commands.push_back(ctest); - this->WriteMakeRule(makefileStream, - "Special rule to drive testing with ctest.", - "test", no_depends, commands); - } - - // Write special "install" target to run cmake_install.cmake script. - { - std::vector depends; - std::vector commands; - std::string cmd; - if(m_Makefile->GetDefinition("CMake_BINARY_DIR")) - { - // We are building CMake itself. We cannot use the original - // executable to install over itself. - cmd = m_ExecutableOutputPath; - cmd += "cmake"; - cmd = this->Convert(cmd.c_str(),START_OUTPUT,SHELL); - } - else - { - cmd = "$(CMAKE_COMMAND)"; - } - cmd += " -P cmake_install.cmake"; - commands.push_back(cmd); - const char* noall = - m_Makefile->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY"); - if(!noall || cmSystemTools::IsOff(noall)) - { - // Drive the build before installing. - depends.push_back("all"); - } - this->WriteMakeRule(makefileStream, - "Special rule to run installation script.", - "install", depends, commands); - } - - // Write special "rebuild_cache" target to re-run cmake. - { - std::vector no_depends; - std::vector commands; - this->AppendEcho(commands, "Running CMake to regenerate build system..."); - commands.push_back( - "$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)"); - this->WriteMakeRule(makefileStream, - "Special rule to re-run CMake using make.", - "rebuild_cache", - no_depends, - commands); - } - - // Use CMAKE_EDIT_COMMAND for the edit_cache rule if it is defined. - // Otherwise default to the interactive command-line interface. - if(m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND")) - { - std::vector no_depends; - std::vector commands; - this->AppendEcho(commands, "Running CMake cache editor..."); - commands.push_back( - "$(CMAKE_EDIT_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)"); - this->WriteMakeRule(makefileStream, - "Special rule to re-run CMake cache editor using make.", - "edit_cache", - no_depends, - commands); - } - else - { - std::vector no_depends; - std::vector commands; - this->AppendEcho(commands, - "Running interactive CMake command-line interface..."); - commands.push_back( - "$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) -i"); - this->WriteMakeRule(makefileStream, - "Special rule to re-run CMake cache editor using make.", - "edit_cache", - no_depends, - commands); - } - - // Write special target to silence make output. This must be after - // the default target in case VERBOSE is set (which changes the - // name). The setting of CMAKE_VERBOSE_MAKEFILE to ON will cause a - // "VERBOSE=1" to be added as a make variable which will change the - // name of this special target. This gives a make-time choice to - // the user. - std::vector commands; - commands.clear(); - std::vector no_depends; - this->WriteMakeRule(makefileStream, - "Suppress display of executed commands.", - "$(VERBOSE).SILENT", - no_depends, - commands); - - // Special target to cleanup operation of make tool. - std::vector depends; - this->WriteMakeRule(makefileStream, - "Disable implicit rules so canoncical targets will work.", - ".SUFFIXES", - depends, - commands); - // Add a fake suffix to keep HP happy. Must be max 32 chars for SGI make. - depends.push_back(".hpux_make_needs_suffix_list"); - this->WriteMakeRule(makefileStream, 0, - ".SUFFIXES", depends, commands); - -} - -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::WriteSpecialTargetsBottom(std::ostream& makefileStream) -{ - this->WriteDivider(makefileStream); - makefileStream - << "# Special targets to cleanup operation of make.\n" - << "\n"; - - // Write special "cmake_check_build_system" target to run cmake with - // the --check-build-system flag. - { - // Build command to run CMake to check if anything needs regenerating. - std::string cmakefileName = "CMakeFiles/Makefile.cmake"; - std::string runRule = - "$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)"; - runRule += " --check-build-system "; - runRule += this->Convert(cmakefileName.c_str(),NONE,SHELL); - runRule += " 0"; - - std::vector no_depends; - std::vector commands; - commands.push_back(runRule); - this->WriteMakeRule(makefileStream, - "Special rule to run CMake to check the build system " - "integrity.\n" - "No rule that depends on this can have " - "commands that come from listfiles\n" - "because they might be regenerated.", - "cmake_check_build_system", - no_depends, - commands); - } - - std::vector no_commands; - -} - - - -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::WriteConvenienceRule(std::ostream& ruleFileStream, - const char* realTarget, - const char* helpTarget) -{ - // A rule is only needed if the names are different. - if(strcmp(realTarget, helpTarget) != 0) - { - // The helper target depends on the real target. - std::vector depends; - depends.push_back(realTarget); - - // There are no commands. - std::vector no_commands; - - // Write the rule. - this->WriteMakeRule(ruleFileStream, "Convenience name for target.", - helpTarget, depends, no_commands); - } -} - -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::WriteTargetRequiresRule(std::ostream& ruleFileStream, cmTarget& target, - const std::vector& objects) -{ - std::vector depends; - std::vector no_commands; - - // Construct the name of the dependency generation target. - std::string depTarget = this->GetRelativeTargetDirectory(target); - depTarget += "/requires"; - - // This target drives dependency generation for all object files. - std::string relPath = this->GetHomeRelativeOutputPath(); - std::string objTarget; - for(std::vector::const_iterator obj = objects.begin(); - obj != objects.end(); ++obj) - { - objTarget = relPath; - objTarget += *obj; - objTarget += ".requires"; - depends.push_back(objTarget); - } - - // Write the rule. - this->WriteMakeRule(ruleFileStream, 0, - depTarget.c_str(), depends, no_commands); -} - -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::WriteExecutableRule(std::ostream& ruleFileStream, - const char* ruleFileName, - cmTarget& target, - const std::vector& objects, - const std::vector& external_objects, - std::vector& cleanFiles) -{ - // Write the dependency generation rule. - this->WriteTargetDependRule(ruleFileStream, target); - - std::vector commands; - - std::string relPath = this->GetHomeRelativeOutputPath(); - std::string objTarget; - - // Build list of dependencies. - std::vector depends; - for(std::vector::const_iterator obj = objects.begin(); - obj != objects.end(); ++obj) - { - objTarget = relPath; - objTarget += *obj; - depends.push_back(objTarget); - } - - // Add dependencies on targets that must be built first. - this->AppendTargetDepends(depends, target); - - // Add a dependency on the rule file itself. - this->AppendRuleDepend(depends, ruleFileName); - - for(std::vector::const_iterator obj = external_objects.begin(); - obj != external_objects.end(); ++obj) - { - depends.push_back(*obj); - } - - // from here up is the same for exe or lib - - // Get the name of the executable to generate. - std::string targetName; - std::string targetNameReal; - target.GetExecutableNames(m_Makefile, targetName, targetNameReal); - - // Construct the full path version of the names. - std::string outpath = m_ExecutableOutputPath; - if(outpath.length() == 0) - { - outpath = m_Makefile->GetStartOutputDirectory(); - outpath += "/"; - } -#ifdef __APPLE__ - if(target.GetPropertyAsBool("MACOSX_BUNDLE")) - { - // Make bundle directories - outpath += target.GetName(); - outpath += ".app/Contents/MacOS/"; - } -#endif - std::string targetFullPath = outpath + targetName; - std::string targetFullPathReal = outpath + targetNameReal; - - // Convert to the output path to use in constructing commands. - std::string targetOutPath = - this->Convert(targetFullPath.c_str(),START_OUTPUT,MAKEFILE); - std::string targetOutPathReal = - this->Convert(targetFullPathReal.c_str(),START_OUTPUT,MAKEFILE); - - // Get the language to use for linking this executable. - const char* linkLanguage = - target.GetLinkerLanguage(this->GetGlobalGenerator()); - - // Make sure we have a link language. - if(!linkLanguage) - { - cmSystemTools::Error("Cannot determine link language for target \"", - target.GetName(), "\"."); - return; - } - - // Add the link message. - std::string buildEcho = "Linking "; - buildEcho += linkLanguage; - buildEcho += " executable "; - buildEcho += targetOutPath; - this->AppendEcho(commands, buildEcho.c_str()); - - // Build a list of compiler flags and linker flags. - std::string flags; - std::string linkFlags; - - // Add flags to deal with shared libraries. Any library being - // linked in might be shared, so always use shared flags for an - // executable. - this->AddSharedFlags(linkFlags, linkLanguage, true); - - // Add flags to create an executable. - this->AddConfigVariableFlags(linkFlags, "CMAKE_EXE_LINKER_FLAGS"); - - - if(target.GetPropertyAsBool("WIN32_EXECUTABLE")) - { - this->AppendFlags(linkFlags, - m_Makefile->GetDefinition("CMAKE_CREATE_WIN32_EXE")); - } - else - { - this->AppendFlags(linkFlags, - m_Makefile->GetDefinition("CMAKE_CREATE_CONSOLE_EXE")); - } - - // Add language-specific flags. - this->AddLanguageFlags(flags, linkLanguage); - - // Add target-specific linker flags. - this->AppendFlags(linkFlags, target.GetProperty("LINK_FLAGS")); - - // Construct a list of files associated with this executable that - // may need to be cleaned. - std::vector exeCleanFiles; - { - std::string cleanName; - std::string cleanRealName; - target.GetExecutableCleanNames(m_Makefile, cleanName, - cleanRealName); - std::string cleanFullName = outpath + cleanName; - std::string cleanFullRealName = outpath + cleanRealName; - exeCleanFiles.push_back - (this->Convert(cleanFullName.c_str(),START_OUTPUT,MAKEFILE)); - if(cleanRealName != cleanName) - { - exeCleanFiles.push_back - (this->Convert(cleanFullRealName.c_str(),START_OUTPUT,MAKEFILE)); - } - } - // Add a command to remove any existing files for this executable. - this->AppendCleanCommand(commands, exeCleanFiles); - - // Add the pre-build and pre-link rules. - this->AppendCustomCommands(commands, target.GetPreBuildCommands()); - this->AppendCustomCommands(commands, target.GetPreLinkCommands()); - - // Construct the main link rule. - std::string linkRuleVar = "CMAKE_"; - linkRuleVar += linkLanguage; - linkRuleVar += "_LINK_EXECUTABLE"; - std::string linkRule = - m_Makefile->GetRequiredDefinition(linkRuleVar.c_str()); - std::vector commands1; - cmSystemTools::ExpandListArgument(linkRule, commands1); - this->CreateCDCommand(commands1,m_Makefile->GetStartOutputDirectory(), - m_Makefile->GetHomeOutputDirectory()); - commands.insert(commands.end(), commands1.begin(), commands1.end()); - - // Add a rule to create necessary symlinks for the library. - if(targetOutPath != targetOutPathReal) - { - std::string symlink = "$(CMAKE_COMMAND) -E cmake_symlink_executable "; - symlink += targetOutPathReal; - symlink += " "; - symlink += targetOutPath; - commands.push_back(symlink); - } - - // Add the post-build rules. - this->AppendCustomCommands(commands, target.GetPostBuildCommands()); - - // Collect up flags to link in needed libraries. - cmOStringStream linklibs; - this->OutputLinkLibraries(linklibs, 0, target); - - // Construct object file lists that may be needed to expand the - // rule. - std::string variableName; - std::string variableNameExternal; - this->WriteObjectsVariable(ruleFileStream, target, objects, external_objects, - variableName, variableNameExternal); - std::string buildObjs = "$("; - buildObjs += variableName; - buildObjs += ") $("; - buildObjs += variableNameExternal; - buildObjs += ")"; - std::string cleanObjs = "$("; - cleanObjs += variableName; - cleanObjs += ")"; - - // Expand placeholders in the commands. - for(std::vector::iterator i = commands.begin(); - i != commands.end(); ++i) - { - this->ExpandRuleVariables(*i, - linkLanguage, - buildObjs.c_str(), - targetOutPathReal.c_str(), - linklibs.str().c_str(), - 0, - 0, - flags.c_str(), - 0, - 0, - 0, - linkFlags.c_str()); - } - - // Write the build rule. - this->WriteMakeRule(ruleFileStream, 0, - targetFullPath.c_str(), depends, commands); - - // Write convenience targets. - std::string dir = m_Makefile->GetStartOutputDirectory(); - dir += "/"; - dir += this->GetTargetDirectory(target); - std::string buildTargetRuleName = dir; - buildTargetRuleName += "/build"; - buildTargetRuleName = - this->Convert(buildTargetRuleName.c_str(),HOME_OUTPUT,MAKEFILE); - this->WriteConvenienceRule(ruleFileStream, targetFullPath.c_str(), - buildTargetRuleName.c_str()); - - // Clean all the possible executable names and symlinks and object files. - cleanFiles.insert(cleanFiles.end(),exeCleanFiles.begin(),exeCleanFiles.end()); - cleanFiles.push_back(cleanObjs); -} - -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::WriteStaticLibraryRule(std::ostream& ruleFileStream, - const char* ruleFileName, - cmTarget& target, - const std::vector& objects, - const std::vector& external_objects, - std::vector& cleanFiles) -{ - const char* linkLanguage = - target.GetLinkerLanguage(this->GetGlobalGenerator()); - std::string linkRuleVar = "CMAKE_"; - if (linkLanguage) - { - linkRuleVar += linkLanguage; - } - linkRuleVar += "_CREATE_STATIC_LIBRARY"; - - std::string extraFlags; - this->AppendFlags(extraFlags, target.GetProperty("STATIC_LIBRARY_FLAGS")); - this->WriteLibraryRule(ruleFileStream, ruleFileName, target, - objects, external_objects, - linkRuleVar.c_str(), extraFlags.c_str(),cleanFiles); -} - -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::WriteSharedLibraryRule(std::ostream& ruleFileStream, - const char* ruleFileName, - cmTarget& target, - const std::vector& objects, - const std::vector& external_objects, - std::vector& cleanFiles) -{ - const char* linkLanguage = - target.GetLinkerLanguage(this->GetGlobalGenerator()); - std::string linkRuleVar = "CMAKE_"; - if (linkLanguage) - { - linkRuleVar += linkLanguage; - } - linkRuleVar += "_CREATE_SHARED_LIBRARY"; - - std::string extraFlags; - this->AppendFlags(extraFlags, target.GetProperty("LINK_FLAGS")); - this->AddConfigVariableFlags(extraFlags, "CMAKE_SHARED_LINKER_FLAGS"); - if(m_Makefile->IsOn("WIN32") && !(m_Makefile->IsOn("CYGWIN") || m_Makefile->IsOn("MINGW"))) - { - const std::vector& sources = target.GetSourceFiles(); - for(std::vector::const_iterator i = sources.begin(); - i != sources.end(); ++i) - { - if((*i)->GetSourceExtension() == "def") - { - extraFlags += " "; - extraFlags += m_Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG"); - extraFlags += - this->Convert((*i)->GetFullPath().c_str(),START_OUTPUT,MAKEFILE); - } - } - } - this->WriteLibraryRule(ruleFileStream, ruleFileName, target, - objects, external_objects, - linkRuleVar.c_str(), extraFlags.c_str(), cleanFiles); -} - -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::WriteModuleLibraryRule(std::ostream& ruleFileStream, - const char* ruleFileName, - cmTarget& target, - const std::vector& objects, - const std::vector& external_objects, - std::vector& cleanFiles) -{ - const char* linkLanguage = - target.GetLinkerLanguage(this->GetGlobalGenerator()); - std::string linkRuleVar = "CMAKE_"; - if (linkLanguage) - { - linkRuleVar += linkLanguage; - } - linkRuleVar += "_CREATE_SHARED_MODULE"; - - std::string extraFlags; - this->AppendFlags(extraFlags, target.GetProperty("LINK_FLAGS")); - this->AddConfigVariableFlags(extraFlags, "CMAKE_MODULE_LINKER_FLAGS"); - // TODO: .def files should be supported here also. - this->WriteLibraryRule(ruleFileStream, ruleFileName, target, - objects, external_objects, - linkRuleVar.c_str(), extraFlags.c_str(), cleanFiles); -} - -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::WriteLibraryRule(std::ostream& ruleFileStream, - const char* ruleFileName, - cmTarget& target, - const std::vector& objects, - const std::vector& external_objects, - const char* linkRuleVar, - const char* extraFlags, - std::vector& cleanFiles) -{ - // Write the dependency generation rule. - this->WriteTargetDependRule(ruleFileStream, target); - - // TODO: Merge the methods that call this method to avoid - // code duplication. - std::vector commands; - - std::string relPath = this->GetHomeRelativeOutputPath(); - std::string objTarget; - - // Build list of dependencies. - std::vector depends; - for(std::vector::const_iterator obj = objects.begin(); - obj != objects.end(); ++obj) - { - objTarget = relPath; - objTarget += *obj; - depends.push_back(objTarget); - } - - // Add dependencies on targets that must be built first. - this->AppendTargetDepends(depends, target); - - // Add a dependency on the rule file itself. - this->AppendRuleDepend(depends, ruleFileName); - - for(std::vector::const_iterator obj = external_objects.begin(); - obj != external_objects.end(); ++obj) - { - depends.push_back(*obj); - } - - // from here up is the same for exe or lib - - // Get the language to use for linking this library. - const char* linkLanguage = - target.GetLinkerLanguage(this->GetGlobalGenerator()); - - // Make sure we have a link language. - if(!linkLanguage) - { - cmSystemTools::Error("Cannot determine link language for target \"", - target.GetName(), "\"."); - return; - } - - // Create set of linking flags. - std::string linkFlags; - this->AppendFlags(linkFlags, extraFlags); - - // Construct the name of the library. - std::string targetName; - std::string targetNameSO; - std::string targetNameReal; - std::string targetNameBase; - target.GetLibraryNames(m_Makefile, - targetName, targetNameSO, - targetNameReal, targetNameBase); - - // Construct the full path version of the names. - std::string outpath = m_LibraryOutputPath; - if(outpath.length() == 0) - { - outpath = m_Makefile->GetStartOutputDirectory(); - outpath += "/"; - } - std::string targetFullPath = outpath + targetName; - std::string targetFullPathSO = outpath + targetNameSO; - std::string targetFullPathReal = outpath + targetNameReal; - std::string targetFullPathBase = outpath + targetNameBase; - - // Construct the output path version of the names for use in command - // arguments. - std::string targetOutPath = - this->Convert(targetFullPath.c_str(),START_OUTPUT,MAKEFILE); - std::string targetOutPathSO = - this->Convert(targetFullPathSO.c_str(),START_OUTPUT,MAKEFILE); - std::string targetOutPathReal = - this->Convert(targetFullPathReal.c_str(),START_OUTPUT,MAKEFILE); - std::string targetOutPathBase = - this->Convert(targetFullPathBase.c_str(),START_OUTPUT,MAKEFILE); - - // Add the link message. - std::string buildEcho = "Linking "; - buildEcho += linkLanguage; - switch(target.GetType()) - { - case cmTarget::STATIC_LIBRARY: - buildEcho += " static library "; break; - case cmTarget::SHARED_LIBRARY: - buildEcho += " shared library "; break; - case cmTarget::MODULE_LIBRARY: - buildEcho += " shared module "; break; - default: - buildEcho += " library "; break; - } - buildEcho += targetOutPath.c_str(); - this->AppendEcho(commands, buildEcho.c_str()); - - // Construct a list of files associated with this library that may - // need to be cleaned. - std::vector libCleanFiles; - { - std::string cleanStaticName; - std::string cleanSharedName; - std::string cleanSharedSOName; - std::string cleanSharedRealName; - target.GetLibraryCleanNames(m_Makefile, - cleanStaticName, - cleanSharedName, - cleanSharedSOName, - cleanSharedRealName); - std::string cleanFullStaticName = outpath + cleanStaticName; - std::string cleanFullSharedName = outpath + cleanSharedName; - std::string cleanFullSharedSOName = outpath + cleanSharedSOName; - std::string cleanFullSharedRealName = outpath + cleanSharedRealName; - libCleanFiles.push_back - (this->Convert(cleanFullStaticName.c_str(),START_OUTPUT,MAKEFILE)); - if(cleanSharedRealName != cleanStaticName) - { - libCleanFiles.push_back - (this->Convert(cleanFullSharedRealName.c_str(),START_OUTPUT,MAKEFILE)); - } - if(cleanSharedSOName != cleanStaticName && - cleanSharedSOName != cleanSharedRealName) - { - libCleanFiles.push_back - (this->Convert(cleanFullSharedSOName.c_str(),START_OUTPUT,MAKEFILE)); - } - if(cleanSharedName != cleanStaticName && - cleanSharedName != cleanSharedSOName && - cleanSharedName != cleanSharedRealName) - { - libCleanFiles.push_back - (this->Convert(cleanFullSharedName.c_str(),START_OUTPUT,MAKEFILE)); - } - } - - // Add a command to remove any existing files for this library. - this->AppendCleanCommand(commands, libCleanFiles); - - // Add the pre-build and pre-link rules. - this->AppendCustomCommands(commands, target.GetPreBuildCommands()); - this->AppendCustomCommands(commands, target.GetPreLinkCommands()); - - // Construct the main link rule. - std::string linkRule = m_Makefile->GetRequiredDefinition(linkRuleVar); - std::vector commands1; - cmSystemTools::ExpandListArgument(linkRule, commands1); - this->CreateCDCommand(commands1,m_Makefile->GetStartOutputDirectory(), - m_Makefile->GetHomeOutputDirectory()); - commands.insert(commands.end(), commands1.begin(), commands1.end()); - - // Add a rule to create necessary symlinks for the library. - if(targetOutPath != targetOutPathReal) - { - std::string symlink = "$(CMAKE_COMMAND) -E cmake_symlink_library "; - symlink += targetOutPathReal; - symlink += " "; - symlink += targetOutPathSO; - symlink += " "; - symlink += targetOutPath; - commands1.clear(); - commands1.push_back(symlink); - this->CreateCDCommand(commands1,m_Makefile->GetStartOutputDirectory(), - m_Makefile->GetHomeOutputDirectory()); - commands.insert(commands.end(), commands1.begin(), commands1.end()); - } - - // Add the post-build rules. - this->AppendCustomCommands(commands, target.GetPostBuildCommands()); - - // Collect up flags to link in needed libraries. - cmOStringStream linklibs; - this->OutputLinkLibraries(linklibs, target.GetName(), target); - - // Construct object file lists that may be needed to expand the - // rule. - std::string variableName; - std::string variableNameExternal; - this->WriteObjectsVariable(ruleFileStream, target, objects, external_objects, - variableName, variableNameExternal); - std::string buildObjs = "$("; - buildObjs += variableName; - buildObjs += ") $("; - buildObjs += variableNameExternal; - buildObjs += ")"; - std::string cleanObjs = "$("; - cleanObjs += variableName; - cleanObjs += ")"; - - // Expand placeholders in the commands. - for(std::vector::iterator i = commands.begin(); - i != commands.end(); ++i) - { - this->ExpandRuleVariables(*i, - linkLanguage, - buildObjs.c_str(), - targetOutPathReal.c_str(), - linklibs.str().c_str(), - 0, 0, 0, buildObjs.c_str(), - targetOutPathBase.c_str(), - targetNameSO.c_str(), - linkFlags.c_str()); - } - - // from here down is the same for exe or lib - - // Write the build rule. - this->WriteMakeRule(ruleFileStream, 0, - targetFullPath.c_str(), depends, commands); - - // Write convenience targets. - std::string dir = m_Makefile->GetStartOutputDirectory(); - dir += "/"; - dir += this->GetTargetDirectory(target); - std::string buildTargetRuleName = dir; - buildTargetRuleName += "/build"; - buildTargetRuleName = - this->Convert(buildTargetRuleName.c_str(),HOME_OUTPUT,MAKEFILE); - this->WriteConvenienceRule(ruleFileStream, targetFullPath.c_str(), - buildTargetRuleName.c_str()); - - // Clean all the possible library names and symlinks and object files. - cleanFiles.insert(cleanFiles.end(),libCleanFiles.begin(),libCleanFiles.end()); - cleanFiles.push_back(cleanObjs); -} - -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::WriteObjectsVariable(std::ostream& ruleFileStream, - cmTarget& target, - const std::vector& objects, - const std::vector& external_objects, - std::string& variableName, - std::string& variableNameExternal) -{ - // Write a make variable assignment that lists all objects for the - // target. - variableName = this->CreateMakeVariable(target.GetName(), "_OBJECTS"); - ruleFileStream - << "# Object files for target " << target.GetName() << "\n" - << variableName.c_str() << " ="; - std::string object; - for(std::vector::const_iterator i = objects.begin(); - i != objects.end(); ++i) - { - ruleFileStream - << " \\\n" - << this->ConvertToQuotedOutputPath(i->c_str()); - } - ruleFileStream - << "\n"; - - // Write a make variable assignment that lists all external objects - // for the target. - variableNameExternal = this->CreateMakeVariable(target.GetName(), - "_EXTERNAL_OBJECTS"); - ruleFileStream - << "\n" - << "# External object files for target " << target.GetName() << "\n" - << variableNameExternal.c_str() << " ="; - for(std::vector::const_iterator i = external_objects.begin(); - i != external_objects.end(); ++i) - { - object = this->Convert(i->c_str(),START_OUTPUT); - ruleFileStream - << " \\\n" - << this->ConvertToQuotedOutputPath(object.c_str()); - } - ruleFileStream - << "\n" - << "\n"; -} - -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::WriteTargetDependRule(std::ostream& ruleFileStream, cmTarget& target) -{ - // must write the targets depend info file - std::string dir = this->GetTargetDirectory(target); - std::string infoFileName = dir; - infoFileName += "/DependInfo.cmake"; - std::string ruleFileNameFull = this->ConvertToFullPath(infoFileName); - cmGeneratedFileStream infoFileStream(ruleFileNameFull.c_str()); - infoFileStream.SetCopyIfDifferent(true); - if(!infoFileStream) - { - return; - } - this->WriteDependLanguageInfo(infoFileStream,target); - - // and now write the rule to use it - std::vector depends; - std::vector commands; - - // Construct the name of the dependency generation target. - std::string depTarget = this->GetRelativeTargetDirectory(target); - depTarget += "/depend"; - - std::string depMark = depTarget; - depMark += ".make.mark"; - depends.push_back(depMark); - - this->WriteMakeRule(ruleFileStream, 0, - depTarget.c_str(), depends, commands); - depends.clear(); - - // Write the dependency generation rule. - std::string depEcho = "Scanning dependencies of target "; - depEcho += target.GetName(); - this->AppendEcho(commands, depEcho.c_str()); - - // Add a command to call CMake to scan dependencies. CMake will - // touch the corresponding depends file after scanning dependencies. - cmOStringStream depCmd; - // TODO: Account for source file properties and directory-level - // definitions when scanning for dependencies. - depCmd << "$(CMAKE_COMMAND) -E cmake_depends " - << " \"" - << m_GlobalGenerator->GetName() << "\" " - << this->Convert(m_Makefile->GetHomeOutputDirectory(),FULL,SHELL) - << " " - << this->Convert(m_Makefile->GetStartOutputDirectory(),FULL,SHELL) - << " " - << this->Convert(ruleFileNameFull.c_str(),FULL,SHELL); - commands.push_back(depCmd.str()); - - // Write the rule. - this->WriteMakeRule(ruleFileStream, 0, - depMark.c_str(), depends, commands); -} - -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::WriteTargetCleanRule(std::ostream& ruleFileStream, - cmTarget& target, - const std::vector& files) -{ - std::vector no_depends; - std::vector commands; - - // Construct the clean target name. - std::string cleanTarget = this->GetRelativeTargetDirectory(target); - cleanTarget += "/clean"; - - // Construct the clean command. - this->AppendCleanCommand(commands, files); - this->CreateCDCommand(commands,m_Makefile->GetStartOutputDirectory(), - m_Makefile->GetHomeOutputDirectory()); - // Write the rule. - this->WriteMakeRule(ruleFileStream, 0, - cleanTarget.c_str(), no_depends, commands); -} - - -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::WriteCMakeArgument(std::ostream& os, const char* s) -{ - // Write the given string to the stream with escaping to get it back - // into CMake through the lexical scanner. - os << "\""; - for(const char* c = s; *c; ++c) - { - if(*c == '\\') - { - os << "\\\\"; - } - else if(*c == '"') - { - os << "\\\""; - } - else - { - os << *c; - } - } - os << "\""; -} - -//---------------------------------------------------------------------------- -std::string -cmLocalUnixMakefileGenerator3::GetTargetDirectory(cmTarget& target) -{ - std::string dir; - // Put a prefix on the name if one is given by the CMake code. - if(const char* prefix = m_Makefile->GetDefinition("CMAKE_TARGET_DIR_PREFIX")) - { - dir += prefix; - } - else + << this->Convert(cmakecommand.c_str(),FULL,SHELL).c_str() + << " -E remove -f\n" + << "\n"; + + if(this->Makefile->GetDefinition("CMAKE_EDIT_COMMAND")) { - dir = "CMakeFiles/"; + makefileStream + << "# The program to use to edit the cache.\n" + << "CMAKE_EDIT_COMMAND = " + << (this->ConvertToOutputForExisting( + this->Makefile->GetDefinition("CMAKE_EDIT_COMMAND"))) << "\n" + << "\n"; } - dir += target.GetName(); - dir += ".dir"; - return dir; -} -//---------------------------------------------------------------------------- -std::string -cmLocalUnixMakefileGenerator3::GetRelativeTargetDirectory(cmTarget& target) -{ - std::string dir = m_Makefile->GetStartOutputDirectory(); - dir += "/"; - dir += this->GetTargetDirectory(target); - dir = cmSystemTools::RelativePath(m_Makefile->GetHomeOutputDirectory(), dir.c_str()); - return this->Convert(dir.c_str(),NONE,MAKEFILE); + makefileStream + << "# The top-level source directory on which CMake was run.\n" + << "CMAKE_SOURCE_DIR = " + << this->Convert(this->Makefile->GetHomeDirectory(), FULL, SHELL) + << "\n" + << "\n"; + makefileStream + << "# The top-level build directory on which CMake was run.\n" + << "CMAKE_BINARY_DIR = " + << this->Convert(this->Makefile->GetHomeOutputDirectory(), FULL, SHELL) + << "\n" + << "\n"; } //---------------------------------------------------------------------------- -std::string +void cmLocalUnixMakefileGenerator3 -::GetSubdirTargetName(const char* pass, const char* subdir) +::WriteSpecialTargetsTop(std::ostream& makefileStream) { - // Convert the subdirectory name to a relative path to keep it short. - std::string reldir = this->Convert(subdir,START_OUTPUT); - - // Convert the subdirectory name to a valid make target name. - std::string s = pass; - s += "_"; - s += reldir; - - // Replace "../" with 3 underscores. This allows one .. at the beginning. - size_t pos = s.find("../"); - if(pos != std::string::npos) - { - s.replace(pos, 3, "___"); - } - - // Replace "/" directory separators with a single underscore. - while((pos = s.find('/')) != std::string::npos) - { - s.replace(pos, 1, "_"); - } + this->WriteDivider(makefileStream); + makefileStream + << "# Special targets provided by cmake.\n" + << "\n"; - // Replace ":" drive specifier with a single underscore - while((pos = s.find(':')) != std::string::npos) + // Write special target to silence make output. This must be after + // the default target in case VERBOSE is set (which changes the + // name). The setting of CMAKE_VERBOSE_MAKEFILE to ON will cause a + // "VERBOSE=1" to be added as a make variable which will change the + // name of this special target. This gives a make-time choice to + // the user. + std::vector commands; + std::vector no_depends; + commands.clear(); + if(this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")) { - s.replace(pos, 1, "_"); + makefileStream + << "# Produce verbose output by default.\n" + << "VERBOSE = 1\n" + << "\n"; } - - return s; -} - -//---------------------------------------------------------------------------- -std::string -cmLocalUnixMakefileGenerator3 -::GetObjectFileName(cmTarget& target, - const cmSourceFile& source) -{ - // If the full path to the source file includes this directory, - // we want to use the relative path for the filename of the - // object file. Otherwise, we will use just the filename - // portion. - std::string objectName; - if((cmSystemTools::GetFilenamePath( - source.GetFullPath()).find( - m_Makefile->GetCurrentDirectory()) == 0) - || (cmSystemTools::GetFilenamePath( - source.GetFullPath()).find( - m_Makefile->GetStartOutputDirectory()) == 0)) + if(this->SilentNoColon) { - objectName = source.GetSourceName(); + makefileStream << "$(VERBOSE).SILENT\n"; } else { - objectName = cmSystemTools::GetFilenameName(source.GetSourceName()); + this->WriteMakeRule(makefileStream, + "Suppress display of executed commands.", + "$(VERBOSE).SILENT", + no_depends, + commands, false); } - // Append the object file extension. - objectName += - m_GlobalGenerator->GetLanguageOutputExtensionFromExtension( - source.GetSourceExtension().c_str()); - - // Convert to a safe name. - objectName = this->CreateSafeUniqueObjectFileName(objectName.c_str()); + // Special target to cleanup operation of make tool. + std::vector depends; + this->WriteMakeRule(makefileStream, + "Disable implicit rules so canoncical targets will work.", + ".SUFFIXES", + depends, + commands, false); + // Add a fake suffix to keep HP happy. Must be max 32 chars for SGI make. + depends.push_back(".hpux_make_needs_suffix_list"); + this->WriteMakeRule(makefileStream, 0, + ".SUFFIXES", depends, commands, false); - // Prepend the target directory. - std::string obj = this->GetTargetDirectory(target); - obj += "/"; - obj += objectName; - return obj; } //---------------------------------------------------------------------------- -const char* +void cmLocalUnixMakefileGenerator3 -::GetSourceFileLanguage(const cmSourceFile& source) +::WriteSpecialTargetsBottom(std::ostream& makefileStream) { - // Identify the language of the source file. - return (m_GlobalGenerator - ->GetLanguageFromExtension(source.GetSourceExtension().c_str())); -} + this->WriteDivider(makefileStream); + makefileStream + << "# Special targets to cleanup operation of make.\n" + << "\n"; -//---------------------------------------------------------------------------- -std::string -cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p) -{ - // Split the path into its components. - std::vector components; - cmSystemTools::SplitPath(p, components); + // Write special "cmake_check_build_system" target to run cmake with + // the --check-build-system flag. + { + // Build command to run CMake to check if anything needs regenerating. + std::string cmakefileName = "CMakeFiles/Makefile.cmake"; + std::string runRule = + "$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)"; + runRule += " --check-build-system "; + runRule += this->Convert(cmakefileName.c_str(),NONE,SHELL); + runRule += " 0"; - // Return an empty path if there are no components. - if(components.empty()) + std::vector no_depends; + std::vector commands; + commands.push_back(runRule); + if(this->Parent) { - return "\"\""; + this->CreateCDCommand(commands, + this->Makefile->GetHomeOutputDirectory(), + this->Makefile->GetStartOutputDirectory()); } + this->WriteMakeRule(makefileStream, + "Special rule to run CMake to check the build system " + "integrity.\n" + "No rule that depends on this can have " + "commands that come from listfiles\n" + "because they might be regenerated.", + "cmake_check_build_system", + no_depends, + commands, true); + } - // Choose a slash direction and fix root component. - const char* slash = "/"; -#if defined(_WIN32) && !defined(__CYGWIN__) - if(!cmSystemTools::GetForceUnixPaths()) - { - slash = "\\"; - for(std::string::iterator i = components[0].begin(); - i != components[0].end(); ++i) - { - if(*i == '/') - { - *i = '\\'; - } - } - } -#endif - - // Begin the quoted result with the root component. - std::string result = "\""; - result += components[0]; + std::vector no_commands; - // Now add the rest of the components separated by the proper slash - // direction for this platform. - bool first = true; - for(unsigned int i=1; i < components.size(); ++i) - { - // Only the last component can be empty to avoid double slashes. - if(components[i].length() > 0 || (i == (components.size()-1))) - { - if(!first) - { - result += slash; - } - result += components[i]; - first = false; - } - } +} - // Close the quoted result. - result += "\""; - return result; -} //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3 -::AppendTargetDepends(std::vector& depends, - cmTarget& target) +::WriteConvenienceRule(std::ostream& ruleFileStream, + const char* realTarget, + const char* helpTarget) { - if(target.GetType() == cmTarget::STATIC_LIBRARY) + // A rule is only needed if the names are different. + if(strcmp(realTarget, helpTarget) != 0) { - return; - } - - // Keep track of dependencies already listed. - std::set emitted; + // The helper target depends on the real target. + std::vector depends; + depends.push_back(realTarget); - // A target should not depend on itself. - emitted.insert(target.GetName()); + // There are no commands. + std::vector no_commands; - // Loop over all library dependencies. - const cmTarget::LinkLibraries& tlibs = target.GetLinkLibraries(); - for(cmTarget::LinkLibraries::const_iterator lib = tlibs.begin(); - lib != tlibs.end(); ++lib) - { - // Don't emit the same library twice for this target. - if(emitted.insert(lib->first).second) - { - // Add this dependency. - this->AppendAnyDepend(depends, lib->first.c_str()); - } + // Write the rule. + this->WriteMakeRule(ruleFileStream, "Convenience name for target.", + helpTarget, depends, no_commands, true); } } + //---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::AppendAnyDepend(std::vector& depends, const char* name, - bool assume_unknown_is_file) +std::string +cmLocalUnixMakefileGenerator3::GetRelativeTargetDirectory(cmTarget& target) { - // There are a few cases for the name of the target: - // - CMake target in this directory: depend on it. - // - CMake target in another directory: depend and add jump-and-build. - // - Full path to a file: depend on it. - // - Other format (like -lm): do nothing. - - // If it is an executable or library target there will be a - // definition for it. - std::string dirVar = name; - dirVar += "_CMAKE_PATH"; - const char* dir = m_Makefile->GetDefinition(dirVar.c_str()); - if(dir && *dir) - { - // This is a CMake target somewhere in this project. - // Get the type of the library. If it does not have a type then - // it is an executable. - std::string typeVar = name; - typeVar += "_LIBRARY_TYPE"; - const char* libType = m_Makefile->GetDefinition(typeVar.c_str()); - - // Get the output path for this target type. - std::string tgtOutputPath; - if(libType) - { - tgtOutputPath = m_LibraryOutputPath; - } - else - { - tgtOutputPath = m_ExecutableOutputPath; - } - - // Get the path to the target. - std::string tgtPath; - if(tgtOutputPath.size()) - { - tgtPath = tgtOutputPath; - } - else - { - tgtPath = dir; - tgtPath += "/"; - } + std::string dir = this->Makefile->GetStartOutputDirectory(); + dir += "/"; + dir += this->GetTargetDirectory(target); + dir = cmSystemTools::RelativePath(this->Makefile->GetHomeOutputDirectory(), dir.c_str()); + return this->Convert(dir.c_str(),NONE,MAKEFILE); +} - // Add the name of the targets's file. This depends on the type - // of the target. - std::string prefix; - std::string suffix; - if(!libType) - { - suffix = cmSystemTools::GetExecutableExtension(); - } - else if(strcmp(libType, "SHARED") == 0) - { - prefix = m_Makefile->GetSafeDefinition("CMAKE_SHARED_LIBRARY_PREFIX"); - suffix = m_Makefile->GetSafeDefinition("CMAKE_SHARED_LIBRARY_SUFFIX"); - } - else if(strcmp(libType, "MODULE") == 0) - { - prefix = m_Makefile->GetSafeDefinition("CMAKE_SHARED_MODULE_PREFIX"); - suffix = m_Makefile->GetSafeDefinition("CMAKE_SHARED_MODULE_SUFFIX"); - } - else if(strcmp(libType, "STATIC") == 0) - { - prefix = m_Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_PREFIX"); - suffix = m_Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_SUFFIX"); - } - tgtPath += prefix; - tgtPath += name; - tgtPath += suffix; - // Add a dependency on the target. - depends.push_back(tgtPath.c_str()); - } - else if(m_Makefile->GetTargets().find(name) != - m_Makefile->GetTargets().end()) - { - // This is a CMake target that is not an executable or library. - // It must be in this directory, so just depend on the name - // directly. - depends.push_back(name); - } - else if(cmSystemTools::FileIsFullPath(name)) - { - // This is a path to a file. Just trust the listfile author that - // it will be present or there is a rule to build it. - depends.push_back(cmSystemTools::CollapseFullPath(name)); - } - else if(assume_unknown_is_file) - { - // Just assume this is a file or make target that will be present. - depends.push_back(name); - } -} //---------------------------------------------------------------------------- void @@ -2288,7 +703,7 @@ { // Add a dependency on the rule file itself unless an option to skip // it is specifically enabled by the user or project. - const char* nodep = m_Makefile->GetDefinition("CMAKE_SKIP_RULE_DEPENDENCY"); + const char* nodep = this->Makefile->GetDefinition("CMAKE_SKIP_RULE_DEPENDENCY"); if(!nodep || cmSystemTools::IsOff(nodep)) { depends.push_back(ruleFileName); @@ -2317,8 +732,10 @@ for(std::vector::const_iterator d = cc.GetDepends().begin(); d != cc.GetDepends().end(); ++d) { - // Add this dependency. - this->AppendAnyDepend(depends, d->c_str()); + // Lookup the real name of the dependency in case it is a CMake target. + std::string dep = this->GetRealDependency(d->c_str(), + this->ConfigurationName.c_str()); + depends.push_back(dep); } } @@ -2364,34 +781,69 @@ for(unsigned int j=1; j < commandLine.size(); ++j) { cmd += " "; + bool forceOn = cmSystemTools::GetForceUnixPaths(); + if(forceOn && this->WindowsShell) + { + cmSystemTools::SetForceUnixPaths(false); + } cmd += cmSystemTools::EscapeSpaces(commandLine[j].c_str()); + if(forceOn && this->WindowsShell) + { + cmSystemTools::SetForceUnixPaths(true); + } } - commands1.push_back(cmd); } } - - // push back the custom commands - this->CreateCDCommand(commands1,m_Makefile->GetStartOutputDirectory(), - m_Makefile->GetHomeOutputDirectory()); - commands.insert(commands.end(), commands1.begin(), commands1.end()); + + // push back the custom commands + const char* dir = this->Makefile->GetStartOutputDirectory(); + // if the command specified a working directory use it. + if(cc.GetWorkingDirectory()) + { + dir = cc.GetWorkingDirectory(); + } + this->CreateCDCommand(commands1, dir, + this->Makefile->GetHomeOutputDirectory()); + + commands.insert(commands.end(), commands1.begin(), commands1.end()); } //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3 ::AppendCleanCommand(std::vector& commands, - const std::vector& files) + const std::vector& files, + cmTarget& target, const char* filename) { if(!files.empty()) { - std::string remove = "$(CMAKE_COMMAND) -E remove -f"; + std::string cleanfile = this->Makefile->GetCurrentOutputDirectory(); + cleanfile += "/"; + cleanfile += this->GetTargetDirectory(target); + cleanfile += "/cmake_clean"; + if(filename) + { + cleanfile += "_"; + cleanfile += filename; + } + cleanfile += ".cmake"; + std::string cleanfilePath = this->Convert(cleanfile.c_str(), FULL); + std::ofstream fout(cleanfilePath.c_str()); + if(!fout) + { + cmSystemTools::Error("Could not create ", cleanfilePath.c_str()); + } + fout << "FILE(REMOVE\n"; + std::string remove = "$(CMAKE_COMMAND) -P "; + remove += this->Convert(cleanfile.c_str(), START_OUTPUT, SHELL); for(std::vector::const_iterator f = files.begin(); f != files.end(); ++f) { - remove += " "; - remove += this->Convert(f->c_str(),START_OUTPUT,SHELL); + fout << "\"" << this->Convert(f->c_str(),START_OUTPUT,UNCHANGED) + << "\"\n"; } + fout << ")\n"; commands.push_back(remove); } } @@ -2412,12 +864,12 @@ { // Add a command to echo this line. std::string cmd = "@echo "; - if(m_EchoNeedsQuote) + if(this->EchoNeedsQuote) { cmd += "\""; } cmd += line; - if(m_EchoNeedsQuote) + if(this->EchoNeedsQuote) { cmd += "\""; } @@ -2441,24 +893,6 @@ } } -//============================================================================ -//---------------------------------------------------------------------------- -bool -cmLocalUnixMakefileGenerator3::SamePath(const char* path1, const char* path2) -{ - if (strcmp(path1, path2) == 0) - { - return true; - } -#if defined(_WIN32) || defined(__APPLE__) - return - (cmSystemTools::LowerCase(this->ConvertToOutputForExisting(path1)) == - cmSystemTools::LowerCase(this->ConvertToOutputForExisting(path2))); -#else - return false; -#endif -} - //---------------------------------------------------------------------------- // take a tgt path and convert it into a make target, it could be full, or relative std::string @@ -2485,12 +919,33 @@ std::string& cmLocalUnixMakefileGenerator3::CreateSafeUniqueObjectFileName(const char* sin) { - if ( m_Makefile->IsOn("CMAKE_MANGLE_OBJECT_FILE_NAMES") ) + // Look for an existing mapped name for this object file. + std::map::iterator it = + this->UniqueObjectNamesMap.find(sin); + + // If no entry exists create one. + if(it == this->UniqueObjectNamesMap.end()) { - std::map::iterator it = m_UniqueObjectNamesMap.find(sin); - if ( it == m_UniqueObjectNamesMap.end() ) + // Start with the original name. + std::string ssin = sin; + + // Avoid full paths by removing leading slashes. + std::string::size_type pos = 0; + for(;pos < ssin.size() && ssin[pos] == '/'; ++pos); + ssin = ssin.substr(pos); + + // Avoid full paths by removing colons. + cmSystemTools::ReplaceString(ssin, ":", "_"); + + // Avoid relative paths that go up the tree. + cmSystemTools::ReplaceString(ssin, "../", "__/"); + + // Avoid spaces. + cmSystemTools::ReplaceString(ssin, " ", "_"); + + // Mangle the name if necessary. + if(this->Makefile->IsOn("CMAKE_MANGLE_OBJECT_FILE_NAMES")) { - std::string ssin = sin; bool done; int cc = 0; char rpstr[100]; @@ -2500,9 +955,9 @@ do { done = true; - for ( it = m_UniqueObjectNamesMap.begin(); - it != m_UniqueObjectNamesMap.end(); - ++ it ) + for ( it = this->UniqueObjectNamesMap.begin(); + it != this->UniqueObjectNamesMap.end(); + ++ it ) { if ( it->second == ssin ) { @@ -2517,15 +972,16 @@ cmSystemTools::ReplaceString(ssin, "_p_", rpstr); sprintf(rpstr, "_p%d_", cc++); } - while ( !done ); - m_UniqueObjectNamesMap[sin] = ssin; - } - } - else - { - m_UniqueObjectNamesMap[sin] = sin; + while ( !done ); + } + + // Insert the newly mapped object file name. + std::map::value_type e(sin, ssin); + it = this->UniqueObjectNamesMap.insert(e).first; } - return m_UniqueObjectNamesMap[sin]; + + // Return the map entry. + return it->second; } //---------------------------------------------------------------------------- @@ -2540,45 +996,47 @@ // if there is no restriction on the length of make variables // and there are no "." charactors in the string, then return the // unmodified combination. - if(!m_MakefileVariableSize && unmodified.find('.') == s.npos) + if((!this->MakefileVariableSize && unmodified.find('.') == s.npos) + && (!this->MakefileVariableSize && unmodified.find('-') == s.npos)) { return unmodified; } // see if the variable has been defined before and return // the modified version of the variable - std::map::iterator i = m_MakeVariableMap.find(unmodified); - if(i != m_MakeVariableMap.end()) + std::map::iterator i = this->MakeVariableMap.find(unmodified); + if(i != this->MakeVariableMap.end()) { return i->second; } // start with the unmodified variable std::string ret = unmodified; - // if this there is no value for m_MakefileVariableSize then + // if this there is no value for this->MakefileVariableSize then // the string must have bad characters in it - if(!m_MakefileVariableSize) + if(!this->MakefileVariableSize) { cmSystemTools::ReplaceString(ret, ".", "_"); + cmSystemTools::ReplaceString(ret, "-", "__"); int ni = 0; char buffer[5]; // make sure the _ version is not already used, if // it is used then add number to the end of the variable - while(m_ShortMakeVariableMap.count(ret) && ni < 1000) + while(this->ShortMakeVariableMap.count(ret) && ni < 1000) { ++ni; sprintf(buffer, "%04d", ni); ret = unmodified + buffer; } - m_ShortMakeVariableMap[ret] = "1"; - m_MakeVariableMap[unmodified] = ret; + this->ShortMakeVariableMap[ret] = "1"; + this->MakeVariableMap[unmodified] = ret; return ret; } // if the string is greater the 32 chars it is an invalid vairable name // for borland make - if(static_cast(ret.size()) > m_MakefileVariableSize) + if(static_cast(ret.size()) > this->MakefileVariableSize) { - int keep = m_MakefileVariableSize - 8; + int keep = this->MakefileVariableSize - 8; int size = keep + 3; std::string str1 = s; std::string str2 = s2; @@ -2596,7 +1054,7 @@ int ni = 0; sprintf(buffer, "%04d", ni); ret = str1 + str2 + buffer; - while(m_ShortMakeVariableMap.count(ret) && ni < 1000) + while(this->ShortMakeVariableMap.count(ret) && ni < 1000) { ++ni; sprintf(buffer, "%04d", ni); @@ -2608,39 +1066,10 @@ return unmodified; } // once an unused variable is found - m_ShortMakeVariableMap[ret] = "1"; + this->ShortMakeVariableMap[ret] = "1"; } // always make an entry into the unmodified to variable map - m_MakeVariableMap[unmodified] = ret; - return ret; -} -//============================================================================ - -//---------------------------------------------------------------------------- -cmDepends* -cmLocalUnixMakefileGenerator3::GetDependsChecker(const std::string& lang, - bool verbose) -{ - cmDepends *ret = 0; - if(lang == "C" || lang == "CXX" || lang == "RC") - { - ret = new cmDependsC(); - } -#ifdef CMAKE_BUILD_WITH_CMAKE - else if(lang == "Fortran") - { - ret = new cmDependsFortran(); - } - else if(lang == "Java") - { - ret = new cmDependsJava(); - } -#endif - if (ret) - { - ret->SetVerbose(verbose); - ret->SetFileComparison(m_GlobalGenerator->GetCMakeInstance()->GetFileComparison()); - } + this->MakeVariableMap[unmodified] = ret; return ret; } @@ -2701,19 +1130,29 @@ // create the file stream for the depends file std::string dir = cmSystemTools::GetFilenamePath(infoFile); - dir += "/depend.make"; // Open the rule file. This should be copy-if-different because the // rules may depend on this file itself. std::string ruleFileNameFull = dir; + ruleFileNameFull += "/depend.make"; cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str()); ruleFileStream.SetCopyIfDifferent(true); if(!ruleFileStream) { return false; } + std::string internalRuleFileNameFull = dir; + internalRuleFileNameFull += "/depend.internal"; + cmGeneratedFileStream internalRuleFileStream(internalRuleFileNameFull.c_str()); + internalRuleFileStream.SetCopyIfDifferent(true); + if(!internalRuleFileStream) + { + return false; + } + this->WriteDisclaimer(ruleFileStream); - + this->WriteDisclaimer(internalRuleFileStream); + // Get the set of generated files. std::vector generatedFilesVec; if(haveDirectoryInfo) @@ -2775,16 +1214,20 @@ includeRegexComplain = complainRegex; } } - + // Create the scanner for this language cmDepends *scanner = 0; if(lang == "C" || lang == "CXX" || lang == "RC") { + std::string includeCacheFileName = dir; + includeCacheFileName += "/includecache."; + includeCacheFileName += lang; + // TODO: Handle RC (resource files) dependencies correctly. scanner = new cmDependsC(includes, - includeRegexScan.c_str(), + includeRegexScan.c_str(), includeRegexComplain.c_str(), - generatedFiles); + generatedFiles, includeCacheFileName); } #ifdef CMAKE_BUILD_WITH_CMAKE else if(lang == "Fortran") @@ -2799,32 +1242,32 @@ if (scanner) { - scanner->SetFileComparison(m_GlobalGenerator->GetCMakeInstance()->GetFileComparison()); - // for each file we need to scan - std::string srcLang = "CMAKE_DEPENDS_CHECK_"; - srcLang += lang; - const char *srcStr = mf->GetSafeDefinition(srcLang.c_str()); - std::vector srcs; - cmSystemTools::ExpandListArgument(srcStr, srcs); - for (std::vector::iterator si = - srcs.begin(); si != srcs.end(); ++si) - { - std::string &src = *si; - ++si; - // make sure the object file is relative to home output - std::string obj = *si; - obj = lg->Convert(obj.c_str(),HOME_OUTPUT,MAKEFILE); - scanner->Write(src.c_str(),obj.c_str(),ruleFileStream); - } - - // free the scanner for this language + scanner->SetFileComparison(this->GlobalGenerator->GetCMakeInstance()->GetFileComparison()); + // for each file we need to scan + std::string srcLang = "CMAKE_DEPENDS_CHECK_"; + srcLang += lang; + const char *srcStr = mf->GetSafeDefinition(srcLang.c_str()); + std::vector srcs; + cmSystemTools::ExpandListArgument(srcStr, srcs); + for (std::vector::iterator si = + srcs.begin(); si != srcs.end(); ++si) + { + std::string &src = *si; + ++si; + // make sure the object file is relative to home output + std::string obj = *si; + obj = lg->Convert(obj.c_str(),HOME_OUTPUT,MAKEFILE); + scanner->Write(src.c_str(),obj.c_str(),ruleFileStream, internalRuleFileStream); + } + + // free the scanner for this language delete scanner; } } // dependencies were generated, so touch the mark file - dir += ".mark"; - std::ofstream fmark(dir.c_str()); + ruleFileNameFull += ".mark"; + std::ofstream fmark(ruleFileNameFull.c_str()); fmark << "Dependencies updated>" << std::endl; return true; @@ -2836,37 +1279,130 @@ { this->WriteDisclaimer(ruleFileStream); this->WriteMakeVariables(ruleFileStream); + + // Write the main entry point target. This must be the VERY first + // target so that make with no arguments will run it. + { + // Just depend on the all target to drive the build. + std::vector depends; + std::vector no_commands; + depends.push_back("all"); + + // Write the rule. + this->WriteMakeRule(ruleFileStream, + "Default target executed when no arguments are " + "given to make.", + "default_target", + depends, + no_commands, true); + } + + // Write all global targets + cmTargets* targets = &(this->Makefile->GetTargets()); + cmTargets::iterator glIt; + for ( glIt = targets->begin(); glIt != targets->end(); ++ glIt ) + { + if ( glIt->second.GetType() == cmTarget::GLOBAL_TARGET ) + { + std::string targetString = "Special rule for the target " + glIt->first; + std::vector commands; + std::vector depends; + + const char* text = glIt->second.GetProperty("EchoString"); + if ( !text ) + { + text = "Running external command ..."; + } + std::set::const_iterator dit; + for ( dit = glIt->second.GetUtilities().begin(); + dit != glIt->second.GetUtilities().end(); + ++ dit ) + { + depends.push_back(dit->c_str()); + } + this->AppendEcho(commands, text); + + // Utility targets store their rules in pre- and post-build commands. + this->AppendCustomDepends(depends, + glIt->second.GetPreBuildCommands()); + this->AppendCustomDepends(depends, + glIt->second.GetPostBuildCommands()); + this->AppendCustomCommands(commands, + glIt->second.GetPreBuildCommands()); + this->AppendCustomCommands(commands, + glIt->second.GetPostBuildCommands()); + this->WriteMakeRule(ruleFileStream, targetString.c_str(), + glIt->first.c_str(), depends, commands, true); + } + } + this->WriteSpecialTargetsTop(ruleFileStream); - + std::vector depends; std::vector commands; // Write the all rule. - std::string dir = m_Makefile->GetStartOutputDirectory(); - dir += "/directorystart"; + std::string dir = this->Makefile->GetStartOutputDirectory(); + dir += "/all"; + dir = this->Convert(dir.c_str(),HOME_OUTPUT,MAKEFILE); - // if at the top the rule is called all - if (!m_Parent) - { - dir = "all"; - depends.push_back("cmake_check_build_system"); - } - this->CreateJumpCommand(commands,"CMakeFiles/Makefile2",dir); - this->WriteMakeRule(ruleFileStream, "The main all target", "all", depends, commands); + + depends.push_back("cmake_check_build_system"); + + commands.push_back + (this->GetRecursiveMakeCall("CMakeFiles/Makefile2",dir.c_str())); + this->CreateCDCommand(commands, + this->Makefile->GetHomeOutputDirectory(), + this->Makefile->GetStartOutputDirectory()); + this->WriteMakeRule(ruleFileStream, "The main all target", "all", + depends, commands, true); // Write the clean rule. - dir = m_Makefile->GetStartOutputDirectory(); + dir = this->Makefile->GetStartOutputDirectory(); dir += "/clean"; dir = this->Convert(dir.c_str(),HOME_OUTPUT,MAKEFILE); commands.clear(); depends.clear(); - this->CreateJumpCommand(commands,"CMakeFiles/Makefile2",dir); - this->WriteMakeRule(ruleFileStream, "The main clean target", "clean", depends, commands); + commands.push_back + (this->GetRecursiveMakeCall("CMakeFiles/Makefile2",dir.c_str())); + this->CreateCDCommand(commands, + this->Makefile->GetHomeOutputDirectory(), + this->Makefile->GetStartOutputDirectory()); + this->WriteMakeRule(ruleFileStream, "The main clean target", "clean", + depends, commands, true); + + // Write the preinstall rule. + dir = this->Makefile->GetStartOutputDirectory(); + dir += "/preinstall"; + dir = this->Convert(dir.c_str(), HOME_OUTPUT,MAKEFILE); + commands.clear(); + depends.clear(); + const char* noall = + this->Makefile->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY"); + if(!noall || cmSystemTools::IsOff(noall)) + { + // Drive the build before installing. + depends.push_back("all"); + } + else + { + // At least make sure the build system is up to date. + depends.push_back("cmake_check_build_system"); + } + commands.push_back + (this->GetRecursiveMakeCall("CMakeFiles/Makefile2", dir.c_str())); + this->CreateCDCommand(commands, + this->Makefile->GetHomeOutputDirectory(), + this->Makefile->GetStartOutputDirectory()); + this->WriteMakeRule(ruleFileStream, "Prepare targets for installation.", + "preinstall", depends, commands, true); // write the depend rule, really a recompute depends rule depends.clear(); commands.clear(); std::string cmakefileName = "CMakeFiles/Makefile.cmake"; + this->Convert(cmakefileName.c_str(),HOME_OUTPUT, + cmLocalGenerator::MAKEFILE); std::string runRule = "$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)"; runRule += " --check-build-system "; @@ -2876,132 +1412,303 @@ commands.push_back(runRule); this->WriteMakeRule(ruleFileStream, "clear depends", "depend", - depends, commands); + depends, commands, true); } + //---------------------------------------------------------------------------- -void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() +void cmLocalUnixMakefileGenerator3::CheckDependencies(cmMakefile* mf, + bool verbose, + bool clear) { - // generate the includes - std::string ruleFileName = "Makefile"; - - // Open the rule file. This should be copy-if-different because the - // rules may depend on this file itself. - std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName); - cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str()); - if(!ruleFileStream) + // Get the list of target files to check + const char* infoDef = mf->GetDefinition("CMAKE_DEPEND_INFO_FILES"); + if(!infoDef) { return; } - // always write the top makefile - if (m_Parent) + std::vector files; + cmSystemTools::ExpandListArgument(infoDef, files); + + // For each info file run the check + cmDependsC checker; + checker.SetVerbose(verbose); + checker.SetFileComparison(this->GlobalGenerator->GetCMakeInstance()->GetFileComparison()); + for(std::vector::iterator l = files.begin(); + l != files.end(); ++l) { - ruleFileStream.SetCopyIfDifferent(true); + // either clear or check the files + std::string dir = cmSystemTools::GetFilenamePath(l->c_str()); + std::string internalDependFile = dir + "/depend.internal"; + std::string dependFile = dir + "/depend.make"; + if (clear) + { + checker.Clear(internalDependFile.c_str()); + checker.Clear(dependFile.c_str()); + } + else + { + checker.Check(dependFile.c_str(), internalDependFile.c_str()); + } + } +} + + +void cmLocalUnixMakefileGenerator3 +::WriteDependLanguageInfo(std::ostream& cmakefileStream, cmTarget &target) +{ + // now write all the language stuff + // Set the set of files to check for dependency integrity. + std::set checkSetLangs; + std::map& + checkSet = this->GetIntegrityCheckSet()[target.GetName()]; + for(std::map::const_iterator + l = checkSet.begin(); l != checkSet.end(); ++l) + { + checkSetLangs.insert(l->first); } - // write the all rules - this->WriteLocalAllRules(ruleFileStream); + // list the languages + cmakefileStream + << "# The set of files whose dependency integrity should be checked:\n"; + cmakefileStream + << "SET(CMAKE_DEPENDS_LANGUAGES\n"; + for(std::set::iterator + l = checkSetLangs.begin(); l != checkSetLangs.end(); ++l) + { + cmakefileStream << " \"" << l->c_str() << "\"\n"; + } + cmakefileStream << " )\n"; - // only write local targets unless at the top Keep track of targets already - // listed. - std::set emittedTargets; - if (m_Parent) + // now list the files for each language + for(std::set::iterator + l = checkSetLangs.begin(); l != checkSetLangs.end(); ++l) { - // write our targets, and while doing it collect up the object - // file rules - this->WriteLocalMakefileTargets(ruleFileStream,emittedTargets); + cmakefileStream + << "SET(CMAKE_DEPENDS_CHECK_" << l->c_str() << "\n"; + // get the check set for this local gen and language + cmLocalUnixMakefileGenerator3::IntegrityCheckSet iCheckSet = + checkSet[*l]; + // for each file + for(cmLocalUnixMakefileGenerator3::IntegrityCheckSet::const_iterator + csIter = iCheckSet.begin(); + csIter != iCheckSet.end(); ++csIter) + { + cmakefileStream << " \"" << (*csIter)->GetFullPath() << "\"\n"; + // Get the full path name of the object file. + std::string obj = this->Makefile->GetStartOutputDirectory(); + obj += "/"; + obj += this->GetObjectFileName(target, **csIter); + cmakefileStream << " \"" << + this->Convert(obj.c_str(), + cmLocalGenerator::FULL).c_str() << "\"\n"; + } + cmakefileStream << " )\n"; } - else +} + +//---------------------------------------------------------------------------- +std::string +cmLocalUnixMakefileGenerator3 +::GetObjectFileName(cmTarget& target, + const cmSourceFile& source, + std::string* nameWithoutTargetDir) +{ + // If the source file is located below the current binary directory + // then use that relative path for the object file name. + std::string objectName = this->Convert(source.GetFullPath().c_str(), + START_OUTPUT); + if(cmSystemTools::FileIsFullPath(objectName.c_str()) || + objectName.empty() || objectName[0] == '.') + { + // If the source file is located below the current source + // directory then use that relative path for the object file name. + // Otherwise just use the relative path from the current binary + // directory. + std::string relFromSource = this->Convert(source.GetFullPath().c_str(), + START); + if(!cmSystemTools::FileIsFullPath(relFromSource.c_str()) && + !relFromSource.empty() && relFromSource[0] != '.') + { + objectName = relFromSource; + } + } + + // Replace the original source file extension with the object file + // extension. + std::string::size_type dot_pos = objectName.rfind("."); + if(dot_pos != std::string::npos) { - cmGlobalUnixMakefileGenerator3 *gg = - static_cast(m_GlobalGenerator); - gg->WriteConvenienceRules(ruleFileStream,emittedTargets); + objectName = objectName.substr(0, dot_pos); } + objectName += + this->GlobalGenerator->GetLanguageOutputExtensionFromExtension( + source.GetSourceExtension().c_str()); + + // Convert to a safe name. + objectName = this->CreateSafeUniqueObjectFileName(objectName.c_str()); + + // Prepend the target directory. + std::string obj = this->GetTargetDirectory(target); + obj += "/"; + obj += objectName; + if(nameWithoutTargetDir) + { + *nameWithoutTargetDir = objectName; + } + return obj; +} + +//---------------------------------------------------------------------------- +void cmLocalUnixMakefileGenerator3::WriteDisclaimer(std::ostream& os) +{ + os + << "# CMAKE generated file: DO NOT EDIT!\n" + << "# Generated by \"" << this->GlobalGenerator->GetName() << "\"" + << " Generator, CMake Version " + << cmMakefile::GetMajorVersion() << "." + << cmMakefile::GetMinorVersion() << "\n\n"; +} + +//---------------------------------------------------------------------------- +std::string +cmLocalUnixMakefileGenerator3 +::GetRecursiveMakeCall(const char *makefile, const char* tgt) +{ + // Call make on the given file. + std::string cmd; + cmd += "$(MAKE) -f "; + cmd += makefile; + cmd += " "; - std::vector depends; - std::vector commands; - - // now write out the object rules - // for each object file name - for (std::map >::iterator lo = - m_LocalObjectFiles.begin(); - lo != m_LocalObjectFiles.end(); ++lo) + // Passg down verbosity level. + if(this->GetMakeSilentFlag().size()) + { + cmd += this->GetMakeSilentFlag(); + cmd += " "; + } + + // Most unix makes will pass the command line flags to make down to + // sub-invoked makes via an environment variable. However, some + // makes do not support that, so you have to pass the flags + // explicitly. + if(this->GetPassMakeflags()) + { + cmd += "-$(MAKEFLAGS) "; + } + + // Add the target. + if (tgt && tgt[0] != '\0') + { + std::string tgt2 = this->Convert(tgt,HOME_OUTPUT,MAKEFILE); + tgt2 = this->ConvertToMakeTarget(tgt2.c_str()); + cmd += tgt2; + } + return cmd; +} + +//---------------------------------------------------------------------------- +void cmLocalUnixMakefileGenerator3::WriteDivider(std::ostream& os) +{ + os + << "#======================================" + << "=======================================\n"; +} + +//---------------------------------------------------------------------------- +void +cmLocalUnixMakefileGenerator3 +::WriteCMakeArgument(std::ostream& os, const char* s) +{ + // Write the given string to the stream with escaping to get it back + // into CMake through the lexical scanner. + os << "\""; + for(const char* c = s; *c; ++c) { - commands.clear(); - // for each target using the object file - for (std::vector::iterator to = - lo->second.begin(); to != lo->second.end(); ++to) + if(*c == '\\') { - std::string tgtMakefileName = this->GetRelativeTargetDirectory(**to); - std::string targetName = tgtMakefileName; - tgtMakefileName += "/build.make"; - targetName += "/"; - targetName += lo->first.c_str(); - this->CreateJumpCommand(commands,tgtMakefileName.c_str(),targetName); + os << "\\\\"; + } + else if(*c == '"') + { + os << "\\\""; + } + else + { + os << *c; } - this->WriteMakeRule(ruleFileStream, - "target for object file", - lo->first.c_str(), depends, commands); } + os << "\""; +} - // add a help target as long as there isn;t a real target named help - if(emittedTargets.insert("help").second) +//---------------------------------------------------------------------------- +std::string +cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p) +{ + + // Split the path into its components. + std::vector components; + cmSystemTools::SplitPath(p, components); + + // Return an empty path if there are no components. + if(components.empty()) { - cmGlobalUnixMakefileGenerator3 *gg = - static_cast(m_GlobalGenerator); - gg->WriteHelpRule(ruleFileStream,this); + return "\"\""; } - this->WriteSpecialTargetsBottom(ruleFileStream); -} + // Choose a slash direction and fix root component. + const char* slash = "/"; +#if defined(_WIN32) && !defined(__CYGWIN__) + if(!cmSystemTools::GetForceUnixPaths()) + { + slash = "\\"; + for(std::string::iterator i = components[0].begin(); + i != components[0].end(); ++i) + { + if(*i == '/') + { + *i = '\\'; + } + } + } +#endif -void cmLocalUnixMakefileGenerator3 -::WriteLocalMakefileTargets(std::ostream& ruleFileStream, - std::set &emitted) -{ - std::vector depends; - std::vector commands; + // Begin the quoted result with the root component. + std::string result = "\""; + result += components[0]; - // for each target we just provide a rule to cd up to the top and do a make - // on the target - cmTargets& targets = m_Makefile->GetTargets(); - std::string localName; - for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) + // Now add the rest of the components separated by the proper slash + // direction for this platform. + bool first = true; + for(unsigned int i=1; i < components.size(); ++i) { - if((t->second.GetType() == cmTarget::EXECUTABLE) || - (t->second.GetType() == cmTarget::STATIC_LIBRARY) || - (t->second.GetType() == cmTarget::SHARED_LIBRARY) || - (t->second.GetType() == cmTarget::MODULE_LIBRARY) || - (t->second.GetType() == cmTarget::UTILITY)) + // Only the last component can be empty to avoid double slashes. + if(components[i].length() > 0 || (i == (components.size()-1))) { - emitted.insert(t->second.GetName()); - - // for subdirs add a rule to build this specific target by name. - localName = this->GetRelativeTargetDirectory(t->second); - localName += "/rule"; - commands.clear(); - depends.clear(); - - // Build the target for this pass. - commands.push_back(this->GetRecursiveMakeCall - ("CMakeFiles/Makefile2",localName.c_str())); - - this->CreateCDCommand(commands, - m_Makefile->GetHomeOutputDirectory(), - m_Makefile->GetStartOutputDirectory()); - this->WriteMakeRule(ruleFileStream, "Convenience name for target.", - localName.c_str(), depends, commands); - - // Add a target with the canonical name (no prefix, suffix or path). - if(localName != t->second.GetName()) + if(!first) { - commands.clear(); - depends.push_back(localName); - this->WriteMakeRule(ruleFileStream, "Convenience name for target.", - t->second.GetName(), depends, commands); + result += slash; } + result += components[i]; + first = false; } } + + // Close the quoted result. + result += "\""; + + return result; +} + +//---------------------------------------------------------------------------- +std::string +cmLocalUnixMakefileGenerator3::GetTargetDirectory(cmTarget& target) +{ + std::string dir = "CMakeFiles/"; + dir += target.GetName(); + dir += ".dir"; + return dir; } void cmLocalUnixMakefileGenerator3 @@ -3014,7 +1721,7 @@ return; } - if(m_WindowsShell) + if(!this->UnixCD) { // On Windows we must perform each step separately and then change // back because the shell keeps the working directory between @@ -3042,7 +1749,7 @@ std::vector::iterator i = commands.begin(); for (; i != commands.end(); ++i) { - std::string cmd = "cd "; + std::string cmd = "cd "; cmd += this->ConvertToOutputForExisting(tgtDir); cmd += " && "; cmd += *i; @@ -3050,147 +1757,14 @@ } } } - -void cmLocalUnixMakefileGenerator3 -::CreateJumpCommand(std::vector& commands, - const char *MakefileName, - std::string& localName) -{ - // Build the target for this pass. - commands.push_back(this->GetRecursiveMakeCall - (MakefileName,localName.c_str())); - - this->CreateCDCommand(commands, - m_Makefile->GetHomeOutputDirectory(), - m_Makefile->GetStartOutputDirectory()); -} - -//---------------------------------------------------------------------------- -void cmLocalUnixMakefileGenerator3::CheckDependencies(cmMakefile* mf, - bool verbose, - bool clear) -{ - // Get the list of target files to check - const char* infoDef = mf->GetDefinition("CMAKE_DEPEND_INFO_FILES"); - if(!infoDef) - { - return; - } - std::vector files; - cmSystemTools::ExpandListArgument(infoDef, files); - - // For each info file run the check - cmDependsC checker; - checker.SetVerbose(verbose); - checker.SetFileComparison(m_GlobalGenerator->GetCMakeInstance()->GetFileComparison()); - for(std::vector::iterator l = files.begin(); - l != files.end(); ++l) - { - // either clear or check the files - std::string dependFile = cmSystemTools::GetFilenamePath(l->c_str()); - dependFile += "/depend.make"; - if (clear) - { - checker.Clear(dependFile.c_str()); - } - else - { - checker.Check(dependFile.c_str()); - } - } -} //---------------------------------------------------------------------------- -std::string +const char* cmLocalUnixMakefileGenerator3 -::GetRecursiveMakeCall(const char *Makefile, const char* tgt) +::GetSourceFileLanguage(const cmSourceFile& source) { - // Call make on the given file. - std::string cmd; - cmd += "$(MAKE) -f "; - cmd += Makefile; - cmd += " "; - - // Passg down verbosity level. - if(this->GetMakeSilentFlag().size()) - { - cmd += this->GetMakeSilentFlag(); - cmd += " "; - } - - // Most unix makes will pass the command line flags to make down to - // sub-invoked makes via an environment variable. However, some - // makes do not support that, so you have to pass the flags - // explicitly. - if(this->GetPassMakeflags()) - { - cmd += "-$(MAKEFLAGS) "; - } - - // Add the target. - if (tgt && tgt[0] != '\0') - { - std::string tgt2 = this->Convert(tgt,HOME_OUTPUT,MAKEFILE); - tgt2 = this->ConvertToMakeTarget(tgt2.c_str()); - cmd += tgt2; - } - return cmd; + // Identify the language of the source file. + return (this->GlobalGenerator + ->GetLanguageFromExtension(source.GetSourceExtension().c_str())); } - -void cmLocalUnixMakefileGenerator3 -::WriteDependLanguageInfo(std::ostream& cmakefileStream, cmTarget &target) -{ - // now write all the language stuff - // Set the set of files to check for dependency integrity. - std::set checkSetLangs; - std::map& - checkSet = this->GetIntegrityCheckSet()[target.GetName()]; - for(std::map::const_iterator - l = checkSet.begin(); l != checkSet.end(); ++l) - { - checkSetLangs.insert(l->first); - } - - // list the languages - cmakefileStream - << "# The set of files whose dependency integrity should be checked:\n"; - cmakefileStream - << "SET(CMAKE_DEPENDS_LANGUAGES\n"; - for(std::set::iterator - l = checkSetLangs.begin(); l != checkSetLangs.end(); ++l) - { - cmakefileStream << " \"" << l->c_str() << "\"\n"; - } - cmakefileStream << " )\n"; - - // now list the files for each language - for(std::set::iterator - l = checkSetLangs.begin(); l != checkSetLangs.end(); ++l) - { - cmakefileStream - << "SET(CMAKE_DEPENDS_CHECK_" << l->c_str() << "\n"; - // get the check set for this local gen and language - cmLocalUnixMakefileGenerator3::IntegrityCheckSet iCheckSet = - checkSet[*l]; - // for each file - for(cmLocalUnixMakefileGenerator3::IntegrityCheckSet::const_iterator - csIter = iCheckSet.begin(); - csIter != iCheckSet.end(); ++csIter) - { - cmakefileStream << " \"" << (*csIter)->GetFullPath() << "\"\n"; - // Get the full path name of the object file. - std::string obj = m_Makefile->GetStartOutputDirectory(); - obj += "/"; - obj += this->GetObjectFileName(target, **csIter); - cmakefileStream << " \"" << - this->Convert(obj.c_str(), - cmLocalGenerator::FULL).c_str() << "\"\n"; - } - cmakefileStream << " )\n"; - } - - - -} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLocalUnixMakefileGenerator3.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLocalUnixMakefileGenerator3.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLocalUnixMakefileGenerator3.h 2005-10-25 03:43:52.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLocalUnixMakefileGenerator3.h 2006-03-16 00:02:04.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmLocalUnixMakefileGenerator3.h,v $ Language: C++ - Date: $Date: 2005/10/24 19:43:52 $ - Version: $Revision: 1.20.2.2 $ + Date: $Date: 2006/03/15 16:02:04 $ + Version: $Revision: 1.43 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -23,6 +23,7 @@ class cmDependInformation; class cmDepends; class cmMakeDepend; +class cmMakefileTargetGenerator; class cmTarget; class cmSourceFile; @@ -30,7 +31,7 @@ * \brief Write a LocalUnix makefiles. * * cmLocalUnixMakefileGenerator3 produces a LocalUnix makefile from its - * member m_Makefile. + * member Makefile. */ class cmLocalUnixMakefileGenerator3 : public cmLocalGenerator { @@ -39,19 +40,29 @@ virtual ~cmLocalUnixMakefileGenerator3(); /** - * Generate the makefile for this directory. - */ - virtual void Generate(); - - /** * Process the CMakeLists files for this directory to fill in the - * m_Makefile ivar + * Makefile ivar */ virtual void Configure(); - /** creates the common disclainer text at the top of each makefile */ - void WriteDisclaimer(std::ostream& os); + /** + * Generate the makefile for this directory. + */ + virtual void Generate(); + + + + + + + + + + + + + // this returns the relative path between the HomeOutputDirectory and this // local generators StartOutputDirectory const std::string &GetHomeRelativeOutputPath(); @@ -61,67 +72,106 @@ const char* comment, const char* target, const std::vector& depends, - const std::vector& commands); + const std::vector& commands, + bool symbolic); // write the main variables used by the makefiles void WriteMakeVariables(std::ostream& makefileStream); - // write a comment line #====... in the stream - void WriteDivider(std::ostream& os); - /** * If true, then explicitly pass MAKEFLAGS on the make all target for makes * that do not use environment variables. * */ - void SetPassMakeflags(bool s){m_PassMakeflags = s;} - bool GetPassMakeflags() { return m_PassMakeflags; } + void SetPassMakeflags(bool s){this->PassMakeflags = s;} + bool GetPassMakeflags() { return this->PassMakeflags; } /** * Set the flag used to keep the make program silent. */ - void SetMakeSilentFlag(const char* s) { m_MakeSilentFlag = s; } - std::string &GetMakeSilentFlag() { return m_MakeSilentFlag; } - - /** used to create a recursive make call */ - std::string GetRecursiveMakeCall(const char *makefile, const char* tgt); + void SetMakeSilentFlag(const char* s) { this->MakeSilentFlag = s; } + std::string &GetMakeSilentFlag() { return this->MakeSilentFlag; } - - - - - - /** Set whether the echo command needs its argument quoted. */ - void SetEchoNeedsQuote(bool b) { m_EchoNeedsQuote = b; } + void SetEchoNeedsQuote(bool b) { this->EchoNeedsQuote = b; } /** * Set to true if the shell being used is the windows shell. * This controls if statements in the makefile and the SHELL variable. * The default is false. */ - void SetWindowsShell(bool v) {m_WindowsShell = v;} + void SetWindowsShell(bool v) {this->WindowsShell = v;} + + /** + * If set to true, then NULL is set to nil for non Windows_NT. + * This uses make syntax used by nmake and borland. + * The default is false. + */ + void SetDefineWindowsNULL(bool v) {this->DefineWindowsNULL = v;} + + /** + * If set to true, cd dir && command is used to + * run commands in a different directory. + */ + void SetUnixCD(bool v) {this->UnixCD = v;} + + /** + * Set Support Verbose Variable. If true, then .SILENT will + * be not end with : i.e. .SILENT: or .SILENT + */ + void SetSilentNoColon(bool v) {this->SilentNoColon = v;} /** * Set the string used to include one makefile into another default * is include. */ - void SetIncludeDirective(const char* s) { m_IncludeDirective = s; } - const char *GetIncludeDirective() { return m_IncludeDirective.c_str(); } + void SetIncludeDirective(const char* s) { this->IncludeDirective = s; } + const char *GetIncludeDirective() { return this->IncludeDirective.c_str(); } /** * Set max makefile variable size, default is 0 which means unlimited. */ - void SetMakefileVariableSize(int s) { m_MakefileVariableSize = s; } + void SetMakefileVariableSize(int s) { this->MakefileVariableSize = s; } /** * If ignore lib prefix is true, then do not strip lib from the name * of a library. */ - void SetIgnoreLibPrefix(bool s) { m_IgnoreLibPrefix = s; } + void SetIgnoreLibPrefix(bool s) { this->IgnoreLibPrefix = s; } + + // used in writing out Cmake files such as WriteDirectoryInformation + static void WriteCMakeArgument(std::ostream& os, const char* s); + + /** creates the common disclainer text at the top of each makefile */ + void WriteDisclaimer(std::ostream& os); + + // write a comment line #====... in the stream + void WriteDivider(std::ostream& os); - + /** used to create a recursive make call */ + std::string GetRecursiveMakeCall(const char *makefile, const char* tgt); + // append an echo command + void AppendEcho(std::vector& commands, const char* text); + + static std::string GetTargetDirectory(cmTarget& target); + + // create a command that cds to the start dir then runs the commands + void CreateCDCommand(std::vector& commands, + const char *targetDir, const char *returnDir); + + static std::string ConvertToQuotedOutputPath(const char* p); + + std::string& CreateSafeUniqueObjectFileName(const char* sin); + std::string CreateMakeVariable(const char* sin, const char* s2in); + + // cleanup the name of a potential target + std::string ConvertToMakeTarget(const char* tgt); + + + const char* GetSourceFileLanguage(const cmSourceFile& source); + + /** Called from command-line hook to scan dependencies. */ @@ -131,168 +181,74 @@ virtual void CheckDependencies(cmMakefile* mf, bool verbose, bool clear); - /** write some extra rules suahc as make test etc */ + /** write some extra rules such as make test etc */ void WriteSpecialTargetsTop(std::ostream& makefileStream); - void WriteSpecialTargetsBottom(std::ostream& makefileStream); + std::string GetRelativeTargetDirectory(cmTarget& target); // List the files for which to check dependency integrity. Each // language has its own list because integrity may be checked // differently. struct IntegrityCheckSet: public std::set {}; - struct IntegrityCheckSetMap: public std::map {}; + struct IntegrityCheckSetMap: public std::map + {}; std::map &GetIntegrityCheckSet() - { return m_CheckDependFiles;} + { return this->CheckDependFiles;} - void AppendTargetDepends(std::vector& depends, - cmTarget& target); - void AppendGlobalTargetDepends(std::vector& depends, cmTarget& target); - void AppendEcho(std::vector& commands, - const char* text); - // write the target rules for the local Makefile into the stream void WriteLocalAllRules(std::ostream& ruleFileStream); + + std::map > GetLocalObjectFiles() + { return this->LocalObjectFiles;} protected: + // these two methods just compute reasonable values for LibraryOutputPath + // and ExecutableOutputPath + void ConfigureOutputPaths(); + void FormatOutputPath(std::string& path, const char* name); - // write the depend info - void WriteDependLanguageInfo(std::ostream& cmakefileStream, cmTarget &tgt); + void WriteLocalMakefile(); // write the target rules for the local Makefile into the stream void WriteLocalMakefileTargets(std::ostream& ruleFileStream, std::set &emitted); - // write the local help rule - void WriteHelpRule(std::ostream& ruleFileStream); - - // create the cd to home commands - void CreateJumpCommand(std::vector& commands, - const char *MakefileName, - std::string & localName); + // this method Writes the Directory informaiton files + void WriteDirectoryInformationFile(); + + - // create a command that cds to the start dir then runs the commands - void CreateCDCommand(std::vector& commands, - const char *targetDir, const char *returnDir); - // these two methods just compute reasonable values for m_LibraryOutputPath - // and m_ExecutableOutputPath - void ConfigureOutputPaths(); - void FormatOutputPath(std::string& path, const char* name); - // this converts a file name that is relative to the StartOuputDirectory - // into a full path - std::string ConvertToFullPath(const std::string& localPath); - // this is responsible for writing all of the rules for all this - // directories custom commands (but not utility targets) - void WriteCustomCommands(std::ostream& os, - std::vector& cleanFiles); - - // this method Writes the Directory informaiton files - void WriteDirectoryInformationFile(); - // cleanup the name of a potential target - std::string ConvertToMakeTarget(const char* tgt); - // used in writing out Cmake files such as WriteDirectoryInformation - void WriteCMakeArgument(std::ostream& os, const char* s); - // write out all the rules for this target - void WriteTargetRuleFiles(cmTarget& target); - void WriteUtilityRuleFiles(cmTarget& target); - - // create the rule files for an object - void WriteObjectRuleFiles(cmTarget& target, - cmSourceFile& source, - std::vector& objects, - std::ostream &filestr, - std::ostream &flagstr); - - // write the build rule for an object - void WriteObjectBuildFile(std::string &obj, - const char *lang, - cmTarget& target, - cmSourceFile& source, - std::vector& depends, - std::ostream &filestr, - std::ostream &flagstr); - - // write the depend.make file for an object - void WriteObjectDependRules(cmSourceFile& source, - std::vector& depends); - - // this is used only by WriteObjectDependFile - bool GenerateDependsMakeFile(const std::string& lang, - const char* objFile); - - // return the appropriate depends checker - cmDepends* GetDependsChecker(const std::string& lang, - bool verbose); - - - void GenerateCustomRuleFile(const cmCustomCommand& cc, - std::ostream &ruleStream); - - // these three make some simple changes and then call WriteLibraryRule - void WriteStaticLibraryRule(std::ostream& ruleFileStream, - const char* ruleFileName, - cmTarget& target, - const std::vector& objects, - const std::vector& external_objects, - std::vector& cleanFiles); - - void WriteSharedLibraryRule(std::ostream& ruleFileStream, - const char* ruleFileName, - cmTarget& target, - const std::vector& objects, - const std::vector& external_objects, - std::vector& cleanFiles); - - void WriteModuleLibraryRule(std::ostream& ruleFileStream, - const char* ruleFileName, - cmTarget& target, - const std::vector& objects, - const std::vector& external_objects, - std::vector& cleanFiles); - - // the main code for writing the Executable target rules - void WriteExecutableRule(std::ostream& ruleFileStream, - const char* ruleFileName, - cmTarget& target, - const std::vector& objects, - const std::vector& external_objects, - std::vector& cleanFiles); - - // the main method for writing library rules - void WriteLibraryRule(std::ostream& ruleFileStream, - const char* ruleFileName, - cmTarget& target, - const std::vector& objects, - const std::vector& external_objects, - const char* linkRuleVar, - const char* extraLinkFlags, - std::vector& cleanFiles); - - void WriteLocalMakefile(); - + + + + + + + // write the depend info + void WriteDependLanguageInfo(std::ostream& cmakefileStream, cmTarget &tgt); + // write the local help rule + void WriteHelpRule(std::ostream& ruleFileStream); + // this converts a file name that is relative to the StartOuputDirectory + // into a full path + std::string ConvertToFullPath(const std::string& localPath); + - void WriteLocalRule(std::ostream& ruleFileStream, const char* pass, - const char* dependency); void WriteConvenienceRule(std::ostream& ruleFileStream, const char* realTarget, const char* helpTarget); - void WriteObjectsVariable(std::ostream& ruleFileStream, - cmTarget& target, - const std::vector& objects, - const std::vector& external_objects, - std::string& variableName, - std::string& variableNameExternal); + void WriteTargetDependRule(std::ostream& ruleFileStream, cmTarget& target); void WriteTargetCleanRule(std::ostream& ruleFileStream, @@ -302,15 +258,10 @@ cmTarget& target, const std::vector& objects); - std::string GetTargetDirectory(cmTarget& target); - std::string GetSubdirTargetName(const char* pass, const char* subdir); std::string GetObjectFileName(cmTarget& target, - const cmSourceFile& source); - const char* GetSourceFileLanguage(const cmSourceFile& source); - std::string ConvertToQuotedOutputPath(const char* p); + const cmSourceFile& source, + std::string* nameWithoutTargetDir = 0); - void AppendAnyDepend(std::vector& depends, const char* name, - bool assume_unknown_is_file=false); void AppendRuleDepend(std::vector& depends, const char* ruleFileName); void AppendCustomDepends(std::vector& depends, @@ -322,41 +273,42 @@ void AppendCustomCommand(std::vector& commands, const cmCustomCommand& cc); void AppendCleanCommand(std::vector& commands, - const std::vector& files); - - //========================================================================== - bool SamePath(const char* path1, const char* path2); - std::string& CreateSafeUniqueObjectFileName(const char* sin); - std::string CreateMakeVariable(const char* sin, const char* s2in); - //========================================================================== - - void ComputeHomeRelativeOutputPath(); + const std::vector& files, + cmTarget& target, const char* filename =0); private: - std::map m_CheckDependFiles; + friend class cmMakefileTargetGenerator; + friend class cmMakefileExecutableTargetGenerator; + friend class cmMakefileLibraryTargetGenerator; + friend class cmMakefileUtilityTargetGenerator; + + std::map CheckDependFiles; //========================================================================== // Configuration settings. - int m_MakefileVariableSize; - std::map m_MakeVariableMap; - std::map m_ShortMakeVariableMap; - std::map m_UniqueObjectNamesMap; - std::string m_IncludeDirective; - std::string m_MakeSilentFlag; - std::string m_ExecutableOutputPath; - std::string m_LibraryOutputPath; - bool m_PassMakeflags; - //========================================================================== - + int MakefileVariableSize; + std::string IncludeDirective; + std::string MakeSilentFlag; + std::string ExecutableOutputPath; + std::string LibraryOutputPath; + std::string ConfigurationName; + bool DefineWindowsNULL; + bool UnixCD; + bool PassMakeflags; + bool SilentNoColon; // Flag for whether echo command needs quotes. - bool m_EchoNeedsQuote; + bool EchoNeedsQuote; + //========================================================================== - std::string m_HomeRelativeOutputPath; + std::string HomeRelativeOutputPath; - // Set of object file names that will be built in this directory. - std::set m_ObjectFiles; + std::map > LocalObjectFiles; - std::map > m_LocalObjectFiles; + /* does the work for each target */ + std::vector TargetGenerators; + std::map MakeVariableMap; + std::map ShortMakeVariableMap; + std::map UniqueObjectNamesMap; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLocalVisualStudio6Generator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLocalVisualStudio6Generator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLocalVisualStudio6Generator.cxx 2005-08-30 04:19:32.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLocalVisualStudio6Generator.cxx 2006-03-16 00:02:04.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmLocalVisualStudio6Generator.cxx,v $ Language: C++ - Date: $Date: 2005/08/29 20:19:32 $ - Version: $Revision: 1.77.2.2 $ + Date: $Date: 2006/03/15 16:02:04 $ + Version: $Revision: 1.94 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -45,44 +45,129 @@ void cmLocalVisualStudio6Generator::OutputDSPFile() { // If not an in source build, then create the output directory - if(strcmp(m_Makefile->GetStartOutputDirectory(), - m_Makefile->GetHomeDirectory()) != 0) + if(strcmp(this->Makefile->GetStartOutputDirectory(), + this->Makefile->GetHomeDirectory()) != 0) { - if(!cmSystemTools::MakeDirectory(m_Makefile->GetStartOutputDirectory())) + if(!cmSystemTools::MakeDirectory(this->Makefile->GetStartOutputDirectory())) { cmSystemTools::Error("Error creating directory ", - m_Makefile->GetStartOutputDirectory()); + this->Makefile->GetStartOutputDirectory()); } } - // Setup /I and /LIBPATH options for the resulting DSP file - std::vector& includes = m_Makefile->GetIncludeDirectories(); - std::vector::iterator i; - for(i = includes.begin(); i != includes.end(); ++i) + // Setup /I and /LIBPATH options for the resulting DSP file. VS 6 + // truncates long include paths so make it as short as possible if + // the length threatents this problem. + unsigned int maxIncludeLength = 3000; + bool useShortPath = false; + for(int j=0; j < 2; ++j) { - m_IncludeOptions += " /I "; - std::string tmp = this->ConvertToOptionallyRelativeOutputPath(i->c_str()); + std::vector includes; + this->GetIncludeDirectories(includes); + std::vector::iterator i; + for(i = includes.begin(); i != includes.end(); ++i) + { + std::string tmp = + this->ConvertToOptionallyRelativeOutputPath(i->c_str()); + if(useShortPath) + { + cmSystemTools::GetShortPath(tmp.c_str(), tmp); + } + this->IncludeOptions += " /I "; - // quote if not already quoted - if (tmp[0] != '"') + // quote if not already quoted + if (tmp[0] != '"') + { + this->IncludeOptions += "\""; + this->IncludeOptions += tmp; + this->IncludeOptions += "\""; + } + else + { + this->IncludeOptions += tmp; + } + } + if(j == 0 && this->IncludeOptions.size() > maxIncludeLength) { - m_IncludeOptions += "\""; - m_IncludeOptions += tmp; - m_IncludeOptions += "\""; + this->IncludeOptions = ""; + useShortPath = true; } else { - m_IncludeOptions += tmp; + break; } } // Create the DSP or set of DSP's for libraries and executables // clear project names - m_CreatedProjectNames.clear(); + this->CreatedProjectNames.clear(); + // Call TraceVSDependencies on all targets + cmTargets &tgts = this->Makefile->GetTargets(); + for(cmTargets::iterator l = tgts.begin(); + l != tgts.end(); l++) + { + // Add a rule to regenerate the build system when the target + // specification source changes. + const char* suppRegenRule = + this->Makefile->GetDefinition("CMAKE_SUPPRESS_REGENERATION"); + if (!cmSystemTools::IsOn(suppRegenRule)) + { + this->AddDSPBuildRule(l->second); + } + // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace + // so don't build a projectfile for it + if ((l->second.GetType() != cmTarget::INSTALL_FILES) + && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS) + && (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0)) + { + cmTarget& target = l->second; + target.TraceVSDependencies(target.GetName(), this->Makefile); + } + } + // now for all custom commands that are not used directly in a + // target, add them to all targets in the current directory or + // makefile + std::vector & classesmf = this->Makefile->GetSourceFiles(); + for(std::vector::const_iterator i = classesmf.begin(); + i != classesmf.end(); i++) + { + if(cmCustomCommand* cc = (*i)->GetCustomCommand()) + { + if(!cc->IsUsed()) + { + for(cmTargets::iterator l = tgts.begin(); + l != tgts.end(); l++) + { + if ((l->second.GetType() != cmTarget::INSTALL_FILES) + && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS) + && (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0) + && (strcmp(l->first.c_str(), "ALL_BUILD") != 0) + && (strcmp(l->first.c_str(), "RUN_TESTS") != 0) + && (strcmp(l->first.c_str(), "INSTALL") != 0)) + { + cmTarget& target = l->second; + bool sameAsTarget = false; + // make sure we don't add a custom command that depends on + // this target + for(unsigned int k =0; k < cc->GetDepends().size(); k++) + { + if(cmSystemTools::GetFilenameName(cc->GetDepends()[k]) == target.GetFullName()) + { + sameAsTarget = true; + } + } + if(!sameAsTarget) + { + target.GetSourceFiles().push_back(*i); + } + } + } + } + } + } // build any targets - cmTargets &tgts = m_Makefile->GetTargets(); for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { @@ -99,6 +184,7 @@ this->SetBuildType(EXECUTABLE,l->first.c_str(), l->second); break; case cmTarget::UTILITY: + case cmTarget::GLOBAL_TARGET: this->SetBuildType(UTILITY, l->first.c_str(), l->second); break; case cmTarget::INSTALL_FILES: @@ -119,7 +205,7 @@ std::string::size_type pos = l->first.rfind('/'); if(pos != std::string::npos) { - std::string dir = m_Makefile->GetStartOutputDirectory(); + std::string dir = this->Makefile->GetStartOutputDirectory(); dir += "/"; dir += l->first.substr(0, pos); if(!cmSystemTools::MakeDirectory(dir.c_str())) @@ -136,10 +222,10 @@ { // add to the list of projects std::string pname = lname; - m_CreatedProjectNames.push_back(pname); + this->CreatedProjectNames.push_back(pname); // create the dsp.cmake file std::string fname; - fname = m_Makefile->GetStartOutputDirectory(); + fname = this->Makefile->GetStartOutputDirectory(); fname += "/"; fname += lname; fname += ".dsp"; @@ -159,31 +245,31 @@ } -void cmLocalVisualStudio6Generator::AddDSPBuildRule() +void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmTarget& tgt) { - std::string dspname = *(m_CreatedProjectNames.end()-1); + std::string dspname = tgt.GetName(); dspname += ".dsp.cmake"; - const char* dsprule = m_Makefile->GetRequiredDefinition("CMAKE_COMMAND"); + const char* dsprule = this->Makefile->GetRequiredDefinition("CMAKE_COMMAND"); cmCustomCommandLine commandLine; commandLine.push_back(dsprule); - std::string makefileIn = m_Makefile->GetStartDirectory(); + std::string makefileIn = this->Makefile->GetStartDirectory(); makefileIn += "/"; makefileIn += "CMakeLists.txt"; std::string args; args = "-H"; args += - this->Convert(m_Makefile->GetHomeDirectory(),START_OUTPUT, SHELL, true); + this->Convert(this->Makefile->GetHomeDirectory(),START_OUTPUT, SHELL, true); commandLine.push_back(args); args = "-B"; args += - this->Convert(m_Makefile->GetHomeOutputDirectory(), + this->Convert(this->Makefile->GetHomeOutputDirectory(), START_OUTPUT, SHELL, true); commandLine.push_back(args); std::string configFile = - m_Makefile->GetRequiredDefinition("CMAKE_ROOT"); + this->Makefile->GetRequiredDefinition("CMAKE_ROOT"); configFile += "/Templates/CMakeWindowsSystemConfig.cmake"; - std::vector listFiles = m_Makefile->GetListFiles(); + std::vector listFiles = this->Makefile->GetListFiles(); bool found = false; for(std::vector::iterator i = listFiles.begin(); i != listFiles.end(); ++i) @@ -201,30 +287,32 @@ cmCustomCommandLines commandLines; commandLines.push_back(commandLine); const char* no_comment = 0; - m_Makefile->AddCustomCommandToOutput(dspname.c_str(), listFiles, makefileIn.c_str(), - commandLines, no_comment, true); + const char* no_working_directory = 0; + this->Makefile->AddCustomCommandToOutput(dspname.c_str(), listFiles, makefileIn.c_str(), + commandLines, no_comment, no_working_directory, true); + if(cmSourceFile* file = this->Makefile->GetSource(makefileIn.c_str())) + { + tgt.GetSourceFiles().push_back(file); + } + else + { + cmSystemTools::Error("Error adding rule for ", makefileIn.c_str()); + } } void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, - const char *libName, - cmTarget &target) + const char *libName, + cmTarget &target) { - // if we should add regen rule then... - const char *suppRegenRule = - m_Makefile->GetDefinition("CMAKE_SUPPRESS_REGENERATION"); - if (!cmSystemTools::IsOn(suppRegenRule)) - { - this->AddDSPBuildRule(); - } - // For utility targets need custom command since pre- and post- // build does not do anything in Visual Studio 6. In order for the // rules to run in the correct order as custom commands, we need // special care for dependencies. The first rule must depend on all // the dependencies of all the rules. The later rules must each // depend only on the previous rule. - if (target.GetType() == cmTarget::UTILITY && + if ((target.GetType() == cmTarget::UTILITY || + target.GetType() == cmTarget::GLOBAL_TARGET) && (!target.GetPreBuildCommands().empty() || !target.GetPostBuildCommands().empty())) { @@ -251,25 +339,22 @@ target.GetPreBuildCommands().begin(); cr != target.GetPreBuildCommands().end(); ++cr) { - this->AddUtilityCommandHack(target, count++, depends, - cr->GetCommandLines()); + this->AddUtilityCommandHack(target, count++, depends, *cr); } for (std::vector::const_iterator cr = target.GetPostBuildCommands().begin(); cr != target.GetPostBuildCommands().end(); ++cr) { - this->AddUtilityCommandHack(target, count++, depends, - cr->GetCommandLines()); + this->AddUtilityCommandHack(target, count++, depends, *cr); } } // trace the visual studio dependencies std::string name = libName; name += ".dsp.cmake"; - target.TraceVSDependencies(name, m_Makefile); // We may be modifying the source groups temporarily, so make a copy. - std::vector sourceGroups = m_Makefile->GetSourceGroups(); + std::vector sourceGroups = this->Makefile->GetSourceGroups(); // get the classes from the source lists then add them to the groups std::vector & classes = target.GetSourceFiles(); @@ -281,7 +366,7 @@ { // Add the file to the list of sources. std::string source = (*i)->GetFullPath(); - cmSourceGroup& sourceGroup = m_Makefile->FindSourceGroup(source.c_str(), + cmSourceGroup& sourceGroup = this->Makefile->FindSourceGroup(source.c_str(), sourceGroups); sourceGroup.AssignSource(*i); // while we are at it, if it is a .rule file then for visual studio 6 we @@ -325,102 +410,107 @@ void cmLocalVisualStudio6Generator::WriteGroup(const cmSourceGroup *sg, cmTarget target, std::ostream &fout, const char *libName) { - const std::vector &sourceFiles = - sg->GetSourceFiles(); - // If the group is empty, don't write it at all. + const std::vector &sourceFiles = + sg->GetSourceFiles(); + // If the group is empty, don't write it at all. - if(sourceFiles.empty()) - { + if(sourceFiles.empty()) + { return; - } + } + + // If the group has a name, write the header. + std::string name = sg->GetName(); + if(name != "") + { + this->WriteDSPBeginGroup(fout, name.c_str(), ""); + } - // If the group has a name, write the header. - std::string name = sg->GetName(); - if(name != "") + // Loop through each source in the source group. + for(std::vector::const_iterator sf = + sourceFiles.begin(); sf != sourceFiles.end(); ++sf) + { + std::string source = (*sf)->GetFullPath(); + const cmCustomCommand *command = + (*sf)->GetCustomCommand(); + std::string compileFlags; + std::vector depends; + + // Add per-source file flags. + if(const char* cflags = (*sf)->GetProperty("COMPILE_FLAGS")) { - this->WriteDSPBeginGroup(fout, name.c_str(), ""); + compileFlags += cflags; } - - // Loop through each source in the source group. - for(std::vector::const_iterator sf = - sourceFiles.begin(); sf != sourceFiles.end(); ++sf) - { - std::string source = (*sf)->GetFullPath(); - const cmCustomCommand *command = - (*sf)->GetCustomCommand(); - std::string compileFlags; - std::vector depends; - const char* cflags = (*sf)->GetProperty("COMPILE_FLAGS"); - if(cflags) - { - compileFlags = cflags; - } - const char* lang = - m_GlobalGenerator->GetLanguageFromExtension((*sf)->GetSourceExtension().c_str()); - if(lang && strcmp(lang, "CXX") == 0) + + const char* lang = + this->GlobalGenerator->GetLanguageFromExtension((*sf)->GetSourceExtension().c_str()); + if(lang && strcmp(lang, "CXX") == 0) + { + // force a C++ file type + compileFlags += " /TP "; + } + + // Check for extra object-file dependencies. + const char* dependsValue = (*sf)->GetProperty("OBJECT_DEPENDS"); + if(dependsValue) + { + cmSystemTools::ExpandListArgument(dependsValue, depends); + } + if (source != libName || target.GetType() == cmTarget::UTILITY || + target.GetType() == cmTarget::GLOBAL_TARGET) + { + fout << "# Begin Source File\n\n"; + + // Tell MS-Dev what the source is. If the compiler knows how to + // build it, then it will. + fout << "SOURCE=" << + this->ConvertToOptionallyRelativeOutputPath(source.c_str()) << "\n\n"; + if(!depends.empty()) { - // force a C++ file type - compileFlags += " /TP "; + // Write out the dependencies for the rule. + fout << "USERDEP__HACK="; + for(std::vector::const_iterator d = depends.begin(); + d != depends.end(); ++d) + { + fout << "\\\n\t" << + this->ConvertToOptionallyRelativeOutputPath(d->c_str()); + } + fout << "\n"; } - - // Check for extra object-file dependencies. - const char* dependsValue = (*sf)->GetProperty("OBJECT_DEPENDS"); - if(dependsValue) + if (command) { - cmSystemTools::ExpandListArgument(dependsValue, depends); + std::string script = + this->ConstructScript(command->GetCommandLines(), + command->GetWorkingDirectory(), + "\\\n\t"); + const char* comment = command->GetComment(); + const char* flags = compileFlags.size() ? compileFlags.c_str(): 0; + this->WriteCustomRule(fout, source.c_str(), script.c_str(), + (*comment?comment:"Custom Rule"), + command->GetDepends(), + command->GetOutput(), flags); } - if (source != libName || target.GetType() == cmTarget::UTILITY) + else if(compileFlags.size()) { - fout << "# Begin Source File\n\n"; - - // Tell MS-Dev what the source is. If the compiler knows how to - // build it, then it will. - fout << "SOURCE=" << - this->ConvertToOptionallyRelativeOutputPath(source.c_str()) << "\n\n"; - if(!depends.empty()) - { - // Write out the dependencies for the rule. - fout << "USERDEP__HACK="; - for(std::vector::const_iterator d = depends.begin(); - d != depends.end(); ++d) - { - fout << "\\\n\t" << - this->ConvertToOptionallyRelativeOutputPath(d->c_str()); + for(std::vector::iterator i + = this->Configurations.begin(); i != this->Configurations.end(); ++i) + { + if (i == this->Configurations.begin()) + { + fout << "!IF \"$(CFG)\" == " << i->c_str() << std::endl; } - fout << "\n"; - } - if (command) - { - std::string script = - this->ConstructScript(command->GetCommandLines(), "\\\n\t"); - const char* comment = command->GetComment(); - const char* flags = compileFlags.size() ? compileFlags.c_str(): 0; - this->WriteCustomRule(fout, source.c_str(), script.c_str(), - (*comment?comment:"Custom Rule"), - command->GetDepends(), - command->GetOutput(), flags); - } - else if(compileFlags.size()) - { - for(std::vector::iterator i - = m_Configurations.begin(); i != m_Configurations.end(); ++i) - { - if (i == m_Configurations.begin()) - { - fout << "!IF \"$(CFG)\" == " << i->c_str() << std::endl; - } - else - { - fout << "!ELSEIF \"$(CFG)\" == " << i->c_str() << std::endl; - } - fout << "\n# ADD CPP " << compileFlags << "\n\n"; - } - fout << "!ENDIF\n\n"; - } - fout << "# End Source File\n"; + else + { + fout << "!ELSEIF \"$(CFG)\" == " << i->c_str() << std::endl; + } + fout << "\n# ADD CPP " << compileFlags << "\n\n"; + } + fout << "!ENDIF\n\n"; } + fout << "# End Source File\n"; } - + } + std::vector children = sg->GetGroupChildren(); for(unsigned int i=0;iWriteDSPEndGroup(fout); - } + // If the group has a name, write the footer. + if(name != "") + { + this->WriteDSPEndGroup(fout); + } } @@ -444,22 +534,22 @@ cmLocalVisualStudio6Generator ::AddUtilityCommandHack(cmTarget& target, int count, std::vector& depends, - const cmCustomCommandLines& commandLines) + const cmCustomCommand& origCommand) { // Create a fake output that forces the rule to run. - char* output = new char[(strlen(m_Makefile->GetStartOutputDirectory()) + + char* output = new char[(strlen(this->Makefile->GetStartOutputDirectory()) + strlen(target.GetName()) + 30)]; - sprintf(output,"%s/%s_force_%i", m_Makefile->GetStartOutputDirectory(), + sprintf(output,"%s/%s_force_%i", this->Makefile->GetStartOutputDirectory(), target.GetName(), count); // Add the rule with the given dependencies and commands. const char* no_main_dependency = 0; - const char* no_comment = 0; - m_Makefile->AddCustomCommandToOutput(output, + this->Makefile->AddCustomCommandToOutput(output, depends, no_main_dependency, - commandLines, - no_comment); + origCommand.GetCommandLines(), + origCommand.GetComment(), + origCommand.GetWorkingDirectory()); // Replace the dependencies with the output of this rule so that the // next rule added will run after this one. @@ -467,7 +557,7 @@ depends.push_back(output); // Add a source file representing this output to the project. - cmSourceFile* outsf = m_Makefile->GetSourceFileWithOutput(output); + cmSourceFile* outsf = this->Makefile->GetSourceFileWithOutput(output); target.GetSourceFiles().push_back(outsf); // Free the fake output name. @@ -475,18 +565,18 @@ } void cmLocalVisualStudio6Generator::WriteCustomRule(std::ostream& fout, - const char* source, - const char* command, - const char* comment, - const std::vector& depends, - const char *output, - const char* flags - ) + const char* source, + const char* command, + const char* comment, + const std::vector& depends, + const char *output, + const char* flags + ) { std::vector::iterator i; - for(i = m_Configurations.begin(); i != m_Configurations.end(); ++i) + for(i = this->Configurations.begin(); i != this->Configurations.end(); ++i) { - if (i == m_Configurations.begin()) + if (i == this->Configurations.begin()) { fout << "!IF \"$(CFG)\" == " << i->c_str() << std::endl; } @@ -503,40 +593,10 @@ for(std::vector::const_iterator d = depends.begin(); d != depends.end(); ++d) { - std::string dep = cmSystemTools::GetFilenameName(*d); - if (cmSystemTools::GetFilenameLastExtension(dep) == ".exe") - { - dep = cmSystemTools::GetFilenameWithoutLastExtension(dep); - } - std::string libPath = dep + "_CMAKE_PATH"; - const char* cacheValue = m_Makefile->GetDefinition(libPath.c_str()); - if (cacheValue && *cacheValue) - { - std::string exePath = ""; - if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH")) - { - exePath = m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"); - } - if(exePath.size()) - { - libPath = exePath; - } - else - { - libPath = cacheValue; - } - libPath += "/"; - libPath += "$(INTDIR)/"; - libPath += dep; - libPath += ".exe"; - fout << "\\\n\t" << - this->ConvertToOptionallyRelativeOutputPath(libPath.c_str()); - } - else - { - fout << "\\\n\t" << - this->ConvertToOptionallyRelativeOutputPath(d->c_str()); - } + // Lookup the real name of the dependency in case it is a CMake target. + std::string dep = this->GetRealDependency(d->c_str(), i->c_str()); + fout << "\\\n\t" << + this->ConvertToOptionallyRelativeOutputPath(dep.c_str()); } fout << "\n"; @@ -561,8 +621,8 @@ void cmLocalVisualStudio6Generator::WriteDSPBeginGroup(std::ostream& fout, - const char* group, - const char* filter) + const char* group, + const char* filter) { fout << "# Begin Group \"" << group << "\"\n" "# PROP Default_Filter \"" << filter << "\"\n"; @@ -581,8 +641,8 @@ const char* libName, cmTarget& target) { - std::string root= m_Makefile->GetRequiredDefinition("CMAKE_ROOT"); - const char *def= m_Makefile->GetDefinition( "MSPROJECT_TEMPLATE_DIRECTORY"); + std::string root= this->Makefile->GetRequiredDefinition("CMAKE_ROOT"); + const char *def= this->Makefile->GetDefinition( "MSPROJECT_TEMPLATE_DIRECTORY"); if( def) { @@ -596,53 +656,53 @@ switch(b) { case STATIC_LIBRARY: - m_DSPHeaderTemplate = root; - m_DSPHeaderTemplate += "/staticLibHeader.dsptemplate"; - m_DSPFooterTemplate = root; - m_DSPFooterTemplate += "/staticLibFooter.dsptemplate"; + this->DSPHeaderTemplate = root; + this->DSPHeaderTemplate += "/staticLibHeader.dsptemplate"; + this->DSPFooterTemplate = root; + this->DSPFooterTemplate += "/staticLibFooter.dsptemplate"; break; case DLL: - m_DSPHeaderTemplate = root; - m_DSPHeaderTemplate += "/DLLHeader.dsptemplate"; - m_DSPFooterTemplate = root; - m_DSPFooterTemplate += "/DLLFooter.dsptemplate"; + this->DSPHeaderTemplate = root; + this->DSPHeaderTemplate += "/DLLHeader.dsptemplate"; + this->DSPFooterTemplate = root; + this->DSPFooterTemplate += "/DLLFooter.dsptemplate"; break; case EXECUTABLE: if ( target.GetPropertyAsBool("WIN32_EXECUTABLE") ) { - m_DSPHeaderTemplate = root; - m_DSPHeaderTemplate += "/EXEWinHeader.dsptemplate"; - m_DSPFooterTemplate = root; - m_DSPFooterTemplate += "/EXEFooter.dsptemplate"; + this->DSPHeaderTemplate = root; + this->DSPHeaderTemplate += "/EXEWinHeader.dsptemplate"; + this->DSPFooterTemplate = root; + this->DSPFooterTemplate += "/EXEFooter.dsptemplate"; } else { - m_DSPHeaderTemplate = root; - m_DSPHeaderTemplate += "/EXEHeader.dsptemplate"; - m_DSPFooterTemplate = root; - m_DSPFooterTemplate += "/EXEFooter.dsptemplate"; + this->DSPHeaderTemplate = root; + this->DSPHeaderTemplate += "/EXEHeader.dsptemplate"; + this->DSPFooterTemplate = root; + this->DSPFooterTemplate += "/EXEFooter.dsptemplate"; } break; case UTILITY: - m_DSPHeaderTemplate = root; - m_DSPHeaderTemplate += "/UtilityHeader.dsptemplate"; - m_DSPFooterTemplate = root; - m_DSPFooterTemplate += "/UtilityFooter.dsptemplate"; + this->DSPHeaderTemplate = root; + this->DSPHeaderTemplate += "/UtilityHeader.dsptemplate"; + this->DSPFooterTemplate = root; + this->DSPFooterTemplate += "/UtilityFooter.dsptemplate"; break; } // once the build type is set, determine what configurations are // possible - std::ifstream fin(m_DSPHeaderTemplate.c_str()); + std::ifstream fin(this->DSPHeaderTemplate.c_str()); cmsys::RegularExpression reg("# Name "); if(!fin) { - cmSystemTools::Error("Error Reading ", m_DSPHeaderTemplate.c_str()); + cmSystemTools::Error("Error Reading ", this->DSPHeaderTemplate.c_str()); } - // reset m_Configurations - m_Configurations.erase(m_Configurations.begin(), m_Configurations.end()); + // reset this->Configurations + this->Configurations.erase(this->Configurations.begin(), this->Configurations.end()); // now add all the configurations possible std::string line; while(cmSystemTools::GetLineFromStream(fin, line)) @@ -650,7 +710,7 @@ cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME",libName); if (reg.find(line)) { - m_Configurations.push_back(line.substr(reg.end())); + this->Configurations.push_back(line.substr(reg.end())); } } } @@ -662,7 +722,7 @@ { std::string customRuleCode = ""; - if (target.GetType() >= cmTarget::UTILITY) + if (target.GetType() >= cmTarget::UTILITY ) { return customRuleCode; } @@ -698,6 +758,7 @@ prelink_newline = ""; } customRuleCode += this->ConstructScript(cr->GetCommandLines(), + cr->GetWorkingDirectory(), prelink_newline); } for (std::vector::const_iterator cr = @@ -709,6 +770,7 @@ prelink_newline = ""; } customRuleCode += this->ConstructScript(cr->GetCommandLines(), + cr->GetWorkingDirectory(), prelink_newline); } if(prelink_total > 0) @@ -734,6 +796,7 @@ postbuild_newline = ""; } customRuleCode += this->ConstructScript(cr->GetCommandLines(), + cr->GetWorkingDirectory(), postbuild_newline); } if(postbuild_total > 0) @@ -775,14 +838,14 @@ // suppoirt override in output directory std::string libPath = ""; - if (m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH")) + if (this->Makefile->GetDefinition("LIBRARY_OUTPUT_PATH")) { - libPath = m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"); + libPath = this->Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"); } std::string exePath = ""; - if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH")) + if (this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH")) { - exePath = m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"); + exePath = this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"); } if(libPath.size()) @@ -900,43 +963,48 @@ libMultiLineOptionsForDebug += " \n"; } } - // find link libraries - const cmTarget::LinkLibraries& libs = target.GetLinkLibraries(); - cmTarget::LinkLibraries::const_iterator j; + const cmTarget::LinkLibraryVectorType& libs = target.GetLinkLibraries(); + cmTarget::LinkLibraryVectorType::const_iterator j; for(j = libs.begin(); j != libs.end(); ++j) { // add libraries to executables and dlls (but never include // a library in a library, bad recursion) + // NEVER LINK STATIC LIBRARIES TO OTHER STATIC LIBRARIES if ((target.GetType() != cmTarget::SHARED_LIBRARY && target.GetType() != cmTarget::STATIC_LIBRARY && target.GetType() != cmTarget::MODULE_LIBRARY) || (target.GetType()==cmTarget::SHARED_LIBRARY && libName != j->first) || (target.GetType()==cmTarget::MODULE_LIBRARY && libName != j->first)) { - std::string lib = j->first; - std::string libDebug = j->first; - std::string libPath = j->first + "_CMAKE_PATH"; - const char* cacheValue - = m_GlobalGenerator->GetCMakeInstance()->GetCacheDefinition( - libPath.c_str()); - if ( cacheValue && *cacheValue && m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX") ) - { - libDebug += m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX"); - } - if(j->first.find(".lib") == std::string::npos) + // Compute the proper name to use to link this library. + std::string lib; + std::string libDebug; + cmTarget* tgt = this->GlobalGenerator->FindTarget(0, j->first.c_str()); + if(tgt) { + lib = cmSystemTools::GetFilenameWithoutExtension(tgt->GetFullName().c_str()); + libDebug = cmSystemTools::GetFilenameWithoutExtension(tgt->GetFullName("Debug").c_str()); lib += ".lib"; libDebug += ".lib"; } + else + { + lib = j->first.c_str(); + libDebug = j->first.c_str(); + if(j->first.find(".lib") == std::string::npos) + { + lib += ".lib"; + libDebug += ".lib"; + } + } lib = this->ConvertToOptionallyRelativeOutputPath(lib.c_str()); libDebug = this->ConvertToOptionallyRelativeOutputPath(libDebug.c_str()); - + if (j->second == cmTarget::GENERAL) { libOptions += " "; libOptions += lib; - libMultiLineOptions += "# ADD LINK32 "; libMultiLineOptions += lib; libMultiLineOptions += "\n"; @@ -966,10 +1034,16 @@ } std::string outputName = "(OUTPUT_NAME is for executables only)"; std::string extraLinkOptions; + // TODO: Fix construction of library/executable name through + // cmTarget. OUTPUT_LIBNAMEDEBUG_POSTFIX should be replaced by the + // library's debug configuration name. OUTPUT_LIBNAME should be + // replaced by the non-debug configuration name. This generator + // should just be re-written to not use template files and just + // generate the code. Setting up these substitutions is a pain. if(target.GetType() == cmTarget::EXECUTABLE) { extraLinkOptions = - m_Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS"); + this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS"); // Use the OUTPUT_NAME property if it was set. This is supported // only for executables. @@ -985,11 +1059,11 @@ } if(target.GetType() == cmTarget::SHARED_LIBRARY) { - extraLinkOptions = m_Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS"); + extraLinkOptions = this->Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS"); } if(target.GetType() == cmTarget::MODULE_LIBRARY) { - extraLinkOptions = m_Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS"); + extraLinkOptions = this->Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS"); } if(extraLinkOptions.size()) @@ -1004,7 +1078,7 @@ libMultiLineOptionsForDebug += extraLinkOptions; libMultiLineOptionsForDebug += " \n"; } - if(const char* stdLibs = m_Makefile->GetDefinition("CMAKE_STANDARD_LIBRARIES")) + if(const char* stdLibs = this->Makefile->GetDefinition("CMAKE_STANDARD_LIBRARIES")) { libOptions += " "; libOptions += stdLibs; @@ -1034,10 +1108,10 @@ // only if the target is a lib or exe std::string customRuleCode = this->CreateTargetRules(target, libName); - std::ifstream fin(m_DSPHeaderTemplate.c_str()); + std::ifstream fin(this->DSPHeaderTemplate.c_str()); if(!fin) { - cmSystemTools::Error("Error Reading ", m_DSPHeaderTemplate.c_str()); + cmSystemTools::Error("Error Reading ", this->DSPHeaderTemplate.c_str()); } std::string staticLibOptions; if(target.GetType() == cmTarget::STATIC_LIBRARY ) @@ -1063,7 +1137,7 @@ std::string line; while(cmSystemTools::GetLineFromStream(fin, line)) { - const char* mfcFlag = m_Makefile->GetDefinition("CMAKE_MFC_FLAG"); + const char* mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG"); if(!mfcFlag) { mfcFlag = "0"; @@ -1079,7 +1153,7 @@ cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS", staticLibOptions.c_str()); } - if(m_Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")) + if(this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")) { cmSystemTools::ReplaceString(line, "/nologo", ""); } @@ -1105,12 +1179,12 @@ cmSystemTools::ReplaceString(line, "OUTPUT_NAME", outputName.c_str()); cmSystemTools::ReplaceString(line, "BUILD_INCLUDES", - m_IncludeOptions.c_str()); + this->IncludeOptions.c_str()); cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME",libName); // because LIBRARY_OUTPUT_PATH and EXECUTABLE_OUTPUT_PATH // are already quoted in the template file, // we need to remove the quotes here, we still need - // to convert to output path for unix to win32 conversion + // to convert to output path for unix to win32 conversion cmSystemTools::ReplaceString(line, "LIBRARY_OUTPUT_PATH", removeQuotes( this->ConvertToOptionallyRelativeOutputPath(libPath.c_str())).c_str()); @@ -1121,11 +1195,11 @@ cmSystemTools::ReplaceString(line, "EXTRA_DEFINES", - m_Makefile->GetDefineFlags()); + this->Makefile->GetDefineFlags()); const char* debugPostfix - = m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX"); + = this->Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX"); cmSystemTools::ReplaceString(line, "DEBUG_POSTFIX", - debugPostfix?debugPostfix:""); + debugPostfix?debugPostfix:""); // store flags for each configuration std::string flags = " "; std::string flagsRelease = " "; @@ -1146,33 +1220,40 @@ std::string baseFlagVar = "CMAKE_"; baseFlagVar += linkLanguage; baseFlagVar += "_FLAGS"; - flags = m_Makefile->GetRequiredDefinition(baseFlagVar.c_str()); + flags = this->Makefile->GetRequiredDefinition(baseFlagVar.c_str()); std::string flagVar = baseFlagVar + "_RELEASE"; - flagsRelease = m_Makefile->GetRequiredDefinition(flagVar.c_str()); + flagsRelease = this->Makefile->GetRequiredDefinition(flagVar.c_str()); flagsRelease += " -DCMAKE_INTDIR=\\\"Release\\\" "; flagVar = baseFlagVar + "_MINSIZEREL"; - flagsMinSize = m_Makefile->GetRequiredDefinition(flagVar.c_str()); + flagsMinSize = this->Makefile->GetRequiredDefinition(flagVar.c_str()); flagsMinSize += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\" "; flagVar = baseFlagVar + "_DEBUG"; - flagsDebug = m_Makefile->GetRequiredDefinition(flagVar.c_str()); + flagsDebug = this->Makefile->GetRequiredDefinition(flagVar.c_str()); flagsDebug += " -DCMAKE_INTDIR=\\\"Debug\\\" "; flagVar = baseFlagVar + "_RELWITHDEBINFO"; - flagsDebugRel = m_Makefile->GetRequiredDefinition(flagVar.c_str()); + flagsDebugRel = this->Makefile->GetRequiredDefinition(flagVar.c_str()); flagsDebugRel += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" "; } // if unicode is not found, then add -D_MBCS - std::string defs = m_Makefile->GetDefineFlags(); + std::string defs = this->Makefile->GetDefineFlags(); if(flags.find("D_UNICODE") == flags.npos && defs.find("D_UNICODE") == flags.npos) { flags += " /D \"_MBCS\""; } - + + // Add per-target flags. + if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS")) + { + flags += " "; + flags += targetFlags; + } + // The template files have CXX FLAGS in them, that need to be replaced. // There are not separate CXX and C template files, so we use the same // variable names. The previous code sets up flags* variables to contain @@ -1188,11 +1269,11 @@ void cmLocalVisualStudio6Generator::WriteDSPFooter(std::ostream& fout) { - std::ifstream fin(m_DSPFooterTemplate.c_str()); + std::ifstream fin(this->DSPFooterTemplate.c_str()); if(!fin) { cmSystemTools::Error("Error Reading ", - m_DSPFooterTemplate.c_str()); + this->DSPFooterTemplate.c_str()); } std::string line; while(cmSystemTools::GetLineFromStream(fin, line)) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLocalVisualStudio6Generator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLocalVisualStudio6Generator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLocalVisualStudio6Generator.h 2005-08-12 02:02:20.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLocalVisualStudio6Generator.h 2006-03-16 00:02:05.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmLocalVisualStudio6Generator.h,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:20 $ - Version: $Revision: 1.8.2.1 $ + Date: $Date: 2006/03/15 16:02:05 $ + Version: $Revision: 1.12 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -29,7 +29,7 @@ * \brief Write a LocalUnix makefiles. * * cmLocalVisualStudio6Generator produces a LocalUnix makefile from its - * member m_Makefile. + * member this->Makefile. */ class cmLocalVisualStudio6Generator : public cmLocalGenerator { @@ -59,13 +59,13 @@ */ std::vector GetCreatedProjectNames() { - return m_CreatedProjectNames; + return this->CreatedProjectNames; } private: - std::string m_DSPHeaderTemplate; - std::string m_DSPFooterTemplate; - std::vector m_CreatedProjectNames; + std::string DSPHeaderTemplate; + std::string DSPFooterTemplate; + std::vector CreatedProjectNames; void CreateSingleDSP(const char *lname, cmTarget &tgt); void WriteDSPFile(std::ostream& fout, const char *libName, @@ -79,7 +79,7 @@ cmTarget &tgt, std::vector &sgs); void WriteDSPFooter(std::ostream& fout); - void AddDSPBuildRule(); + void AddDSPBuildRule(cmTarget& tgt); void WriteCustomRule(std::ostream& fout, const char* source, const char* command, @@ -89,13 +89,13 @@ const char* flags); void AddUtilityCommandHack(cmTarget& target, int count, std::vector& depends, - const cmCustomCommandLines& commandLines); + const cmCustomCommand& origCommand); void WriteGroup(const cmSourceGroup *sg, cmTarget target, std::ostream &fout, const char *libName); std::string CreateTargetRules(cmTarget &target, const char *libName); - std::string m_IncludeOptions; - std::vector m_Configurations; + std::string IncludeOptions; + std::vector Configurations; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLocalVisualStudio7Generator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLocalVisualStudio7Generator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLocalVisualStudio7Generator.cxx 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLocalVisualStudio7Generator.cxx 2006-03-16 00:02:05.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmLocalVisualStudio7Generator.cxx,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.82.2.3 $ + Date: $Date: 2006/03/15 16:02:05 $ + Version: $Revision: 1.118 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -24,7 +24,7 @@ cmLocalVisualStudio7Generator::cmLocalVisualStudio7Generator() { - m_Version = 7; + this->Version = 7; } cmLocalVisualStudio7Generator::~cmLocalVisualStudio7Generator() @@ -48,53 +48,145 @@ // for CommandLine= need to repleace quotes with " // write out configurations void cmLocalVisualStudio7Generator::OutputVCProjFile() -{ +{ // If not an in source build, then create the output directory - if(strcmp(m_Makefile->GetStartOutputDirectory(), - m_Makefile->GetHomeDirectory()) != 0) + if(strcmp(this->Makefile->GetStartOutputDirectory(), + this->Makefile->GetHomeDirectory()) != 0) { - if(!cmSystemTools::MakeDirectory(m_Makefile->GetStartOutputDirectory())) + if(!cmSystemTools::MakeDirectory(this->Makefile->GetStartOutputDirectory())) { cmSystemTools::Error("Error creating directory ", - m_Makefile->GetStartOutputDirectory()); + this->Makefile->GetStartOutputDirectory()); } } - - m_LibraryOutputPath = ""; - if (m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH")) + + this->LibraryOutputPath = ""; + if (this->Makefile->GetDefinition("LIBRARY_OUTPUT_PATH")) { - m_LibraryOutputPath = m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"); + this->LibraryOutputPath = + this->Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"); } - if(m_LibraryOutputPath.size()) + if(this->LibraryOutputPath.size()) { // make sure there is a trailing slash - if(m_LibraryOutputPath[m_LibraryOutputPath.size()-1] != '/') + if(this->LibraryOutputPath[this->LibraryOutputPath.size()-1] != '/') { - m_LibraryOutputPath += "/"; + this->LibraryOutputPath += "/"; } } - m_ExecutableOutputPath = ""; - if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH")) + this->ExecutableOutputPath = ""; + if (this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH")) { - m_ExecutableOutputPath = m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"); + this->ExecutableOutputPath = this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"); } - if(m_ExecutableOutputPath.size()) + if(this->ExecutableOutputPath.size()) { // make sure there is a trailing slash - if(m_ExecutableOutputPath[m_ExecutableOutputPath.size()-1] != '/') + if(this->ExecutableOutputPath[this->ExecutableOutputPath.size()-1] != '/') { - m_ExecutableOutputPath += "/"; + this->ExecutableOutputPath += "/"; } } - + // Create the VCProj or set of VCProj's for libraries and executables // clear project names - m_CreatedProjectNames.clear(); + this->CreatedProjectNames.clear(); - // build any targets - cmTargets &tgts = m_Makefile->GetTargets(); - for(cmTargets::iterator l = tgts.begin(); +#if 1 + // TODO: This block should be moved to a central location for all + // generators. It is duplicated in every generator. + + // Call TraceVSDependencies on all targets + cmTargets &tgts = this->Makefile->GetTargets(); + for(cmTargets::iterator l = tgts.begin(); + l != tgts.end(); l++) + { + // Add a rule to regenerate the build system when the target + // specification source changes. + const char* suppRegenRule = + this->Makefile->GetDefinition("CMAKE_SUPPRESS_REGENERATION"); + if (!cmSystemTools::IsOn(suppRegenRule) && + (strcmp(l->first.c_str(), CMAKE_CHECK_BUILD_SYSTEM_TARGET) != 0)) + { + this->AddVCProjBuildRule(l->second); + } + + // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace + // so don't build a projectfile for it + if ((l->second.GetType() != cmTarget::INSTALL_FILES) + && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS) + && (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0)) + { + cmTarget& target = l->second; + target.TraceVSDependencies(target.GetName(), this->Makefile); + } + } + // now for all custom commands that are not used directly in a + // target, add them to all targets in the current directory or + // makefile + std::vector & classesmf = this->Makefile->GetSourceFiles(); + for(std::vector::const_iterator i = classesmf.begin(); + i != classesmf.end(); i++) + { + if(cmCustomCommand* cc = (*i)->GetCustomCommand()) + { + // while we are at it, if it is a .rule file then for visual studio 7 we + // must generate it so that depend information works correctly + if ((*i)->GetSourceExtension() == "rule") + { + std::string source = (*i)->GetFullPath(); + if(!cmSystemTools::FileExists(source.c_str())) + { + cmSystemTools::ReplaceString(source, "$(IntDir)/", ""); +#if defined(_WIN32) || defined(__CYGWIN__) + std::ofstream fout(source.c_str(), + std::ios::binary | std::ios::out | std::ios::trunc); +#else + std::ofstream fout(source.c_str(), + std::ios::out | std::ios::trunc); +#endif + if(fout) + { + fout.write("# generated from CMake",22); + fout.flush(); + fout.close(); + } + } + } + if(!cc->IsUsed()) + { + for(cmTargets::iterator l = tgts.begin(); + l != tgts.end(); l++) + { + if ((l->second.GetType() != cmTarget::INSTALL_FILES) + && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS) + && (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0) + && (strcmp(l->first.c_str(), "ALL_BUILD") != 0) + && (strcmp(l->first.c_str(), CMAKE_CHECK_BUILD_SYSTEM_TARGET) != 0)) + { + cmTarget& target = l->second; + bool sameAsTarget = false; + // make sure we don't add a custom command that depends on + // this target + for(unsigned int k =0; k < cc->GetDepends().size(); k++) + { + if(cmSystemTools::GetFilenameName(cc->GetDepends()[k]) == target.GetFullName()) + { + sameAsTarget = true; + } + } + if(!sameAsTarget) + { + target.GetSourceFiles().push_back(*i); + } + } + } + } + } + } +#endif + for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace @@ -112,10 +204,10 @@ { // add to the list of projects std::string pname = lname; - m_CreatedProjectNames.push_back(pname); + this->CreatedProjectNames.push_back(pname); // create the dsp.cmake file std::string fname; - fname = m_Makefile->GetStartOutputDirectory(); + fname = this->Makefile->GetStartOutputDirectory(); fname += "/"; fname += lname; fname += ".vcproj"; @@ -134,31 +226,31 @@ } -void cmLocalVisualStudio7Generator::AddVCProjBuildRule() +void cmLocalVisualStudio7Generator::AddVCProjBuildRule(cmTarget& tgt) { - std::string dspname = *(m_CreatedProjectNames.end()-1); + std::string dspname = tgt.GetName(); dspname += ".vcproj.cmake"; - const char* dsprule = m_Makefile->GetRequiredDefinition("CMAKE_COMMAND"); + const char* dsprule = this->Makefile->GetRequiredDefinition("CMAKE_COMMAND"); cmCustomCommandLine commandLine; commandLine.push_back(dsprule); - std::string makefileIn = m_Makefile->GetStartDirectory(); + std::string makefileIn = this->Makefile->GetStartDirectory(); makefileIn += "/"; makefileIn += "CMakeLists.txt"; std::string args; args = "-H"; args += - this->Convert(m_Makefile->GetHomeDirectory(), START_OUTPUT, SHELL, true); + this->Convert(this->Makefile->GetHomeDirectory(), START_OUTPUT, SHELL, true); commandLine.push_back(args); args = "-B"; - args += - this->Convert(m_Makefile->GetHomeOutputDirectory(), + args += + this->Convert(this->Makefile->GetHomeOutputDirectory(), START_OUTPUT, SHELL, true); commandLine.push_back(args); - - std::string configFile = - m_Makefile->GetRequiredDefinition("CMAKE_ROOT"); + + std::string configFile = + this->Makefile->GetRequiredDefinition("CMAKE_ROOT"); configFile += "/Templates/CMakeWindowsSystemConfig.cmake"; - std::vector listFiles = m_Makefile->GetListFiles(); + std::vector listFiles = this->Makefile->GetListFiles(); bool found = false; for(std::vector::iterator i = listFiles.begin(); i != listFiles.end(); ++i) @@ -175,18 +267,27 @@ cmCustomCommandLines commandLines; commandLines.push_back(commandLine); + const char* no_working_directory = 0; const char* no_comment = 0; - m_Makefile->AddCustomCommandToOutput(dspname.c_str(), listFiles, makefileIn.c_str(), - commandLines, no_comment, true); + this->Makefile->AddCustomCommandToOutput(dspname.c_str(), listFiles, makefileIn.c_str(), + commandLines, no_comment, no_working_directory, true); + if(cmSourceFile* file = this->Makefile->GetSource(makefileIn.c_str())) + { + tgt.GetSourceFiles().push_back(file); + } + else + { + cmSystemTools::Error("Error adding rule for ", makefileIn.c_str()); + } } -void cmLocalVisualStudio7Generator::WriteConfigurations(std::ostream& fout, +void cmLocalVisualStudio7Generator::WriteConfigurations(std::ostream& fout, const char *libName, cmTarget &target) { - std::vector *configs = - static_cast(m_GlobalGenerator)->GetConfigurations(); + std::vector *configs = + static_cast(this->GlobalGenerator)->GetConfigurations(); fout << "\t\n"; for( std::vector::iterator i = configs->begin(); i != configs->end(); ++i) @@ -210,7 +311,7 @@ // NOTE: Make sure the longer commandFlag comes FIRST! cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] = { - // option flags (some flags map to the same option) + // option flags (some flags map to the same option) {"BasicRuntimeChecks", "GZ", "Stack frame checks", "1"}, {"BasicRuntimeChecks", "RTCsu", "Both stack and uninitialized checks ", "3"}, {"BasicRuntimeChecks", "RTCs", "Stack frame checks", "1"}, @@ -251,7 +352,7 @@ {"WarningLevel", "W3", "Warning level", "3"}, {"WarningLevel", "W4", "Warning level", "4"}, - // boolean flags + // boolean flags {"BufferSecurityCheck", "GS", "Buffer security check", "TRUE"}, {"EnableFibreSafeOptimization", "GT", "OmitFramePointers", "TRUE"}, {"EnableFunctionLevelLinking", "Gy", "EnableFunctionLevelLinking", "TRUE"}, @@ -273,24 +374,24 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorLinkFlagTable[] = { - // option flags (some flags map to the same option) + // option flags (some flags map to the same option) {"LinkIncremental", "INCREMENTAL:NO", "link incremental", "1"}, {"LinkIncremental", "INCREMENTAL:YES", "link incremental", "2"}, {0,0,0,0 } }; - - - -void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, + + + +void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, const char* configName, const char *libName, cmTarget &target) -{ +{ // create a map of xml tags to the values they should have in the output // for example, "BufferSecurityCheck" = "TRUE" // first fill this table with the values for the configuration @@ -303,7 +404,7 @@ // in the flags it will be turned on and we have /EHSC on by // default in the CXX flags, then this is the only way to turn this off flagMap["ExceptionHandling"] = "FALSE"; - const char* mfcFlag = m_Makefile->GetDefinition("CMAKE_MFC_FLAG"); + const char* mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG"); if(!mfcFlag) { mfcFlag = "0"; @@ -315,10 +416,10 @@ // 4 == static library // 2 == dll // 1 == executable - // 10 == utility + // 10 == utility const char* configType = "10"; switch(target.GetType()) - { + { case cmTarget::STATIC_LIBRARY: configType = "4"; break; @@ -326,20 +427,17 @@ case cmTarget::MODULE_LIBRARY: configType = "2"; break; - case cmTarget::EXECUTABLE: + case cmTarget::EXECUTABLE: configType = "1"; - break; + break; case cmTarget::UTILITY: + case cmTarget::GLOBAL_TARGET: configType = "10"; default: break; } - + std::string flags; - std::string flagsRelease = " "; - std::string flagsMinSize = " "; - std::string flagsDebug = " "; - std::string flagsDebugRel = " "; if(strcmp(configType, "10") != 0) { const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator()); @@ -350,78 +448,23 @@ return; } if(!(strcmp(linkLanguage, "RC") == 0 || strcmp(linkLanguage, "DEF") == 0)) - { + { std::string baseFlagVar = "CMAKE_"; baseFlagVar += linkLanguage; baseFlagVar += "_FLAGS"; - flags = m_Makefile->GetRequiredDefinition(baseFlagVar.c_str()); - - std::string flagVar = baseFlagVar + "_RELEASE"; - flagsRelease += m_Makefile->GetRequiredDefinition(flagVar.c_str()); - - flagVar = baseFlagVar + "_MINSIZEREL"; - flagsMinSize += m_Makefile->GetRequiredDefinition(flagVar.c_str()); - - flagVar = baseFlagVar + "_DEBUG"; - flagsDebug += m_Makefile->GetRequiredDefinition(flagVar.c_str()); - - flagVar = baseFlagVar + "_RELWITHDEBINFO"; - flagsDebugRel += m_Makefile->GetRequiredDefinition(flagVar.c_str()); - } - } - - std::string programDatabase; - const char* pre = "WIN32,_DEBUG,_WINDOWS"; - std::string debugPostfix = ""; - bool debug = !strcmp(configName,"Debug"); - if (debug && m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX")) - { - debugPostfix = m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX"); - } - // fill the flagMap for Debug, Release, MinSizeRel, and RelWithDebInfo - // also set the flags, and pre-defined macros - if(strcmp(configName, "Debug") == 0) - { - flagMap["InlineFunctionExpansion"] = "0"; - flagMap["Optimization"] = "0"; - flagMap["RuntimeLibrary"] = "3"; - flags += flagsDebug; - pre = "WIN32,_DEBUG,_WINDOWS"; - std::string libpath = m_LibraryOutputPath + - "$(OutDir)/" + libName + debugPostfix + ".pdb"; - programDatabase = "\t\t\t\tProgramDatabaseFileName=\""; - programDatabase += libpath; - programDatabase += "\""; - } - else if (strcmp(configName, "Release") == 0) - { - flagMap["InlineFunctionExpansion"] = "1"; - flagMap["Optimization"] = "2"; - flagMap["RuntimeLibrary"] = "2"; - flags += flagsRelease; - pre = "WIN32,_WINDOWS"; - flags += flagsRelease; - } - else if(strcmp(configName, "MinSizeRel") == 0) - { - flagMap["InlineFunctionExpansion"] = "1"; - flagMap["Optimization"] = "1"; - flagMap["RuntimeLibrary"] = "2"; - pre = "WIN32,_WINDOWS"; - flags += flagsMinSize; - } - else if(strcmp(configName, "RelWithDebInfo") == 0) - { - flagMap["InlineFunctionExpansion"] = "1"; - flagMap["Optimization"] = "2"; - flagMap["RuntimeLibrary"] = "2"; - pre = "WIN32,_WINDOWS"; - flags += flagsDebugRel; - std::string libpath = m_LibraryOutputPath + - "$(OutDir)/" + libName + debugPostfix + ".pdb"; - programDatabase = "\t\t\t\tProgramDatabaseFileName=\""; - programDatabase += libpath; - programDatabase += "\""; + flags = this->Makefile->GetRequiredDefinition(baseFlagVar.c_str()); + std::string flagVar = baseFlagVar + std::string("_") + + cmSystemTools::UpperCase(configName); + flags += " "; + flags += this->Makefile->GetRequiredDefinition(flagVar.c_str()); + } + } + + // Add the target-specific flags. + if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS")) + { + flags += " "; + flags += targetFlags; } // The intermediate directory name consists of a directory for the @@ -437,8 +480,8 @@ << "\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n"; // if -D_UNICODE or /D_UNICODE is found in the flags // change the character set to unicode, if not then - // default to MBCS - std::string defs = m_Makefile->GetDefineFlags(); + // default to MBCS + std::string defs = this->Makefile->GetDefineFlags(); if(flags.find("D_UNICODE") != flags.npos || defs.find("D_UNICODE") != flags.npos) { @@ -448,29 +491,30 @@ { fout << "\t\t\tCharacterSet=\"2\">\n"; } - + fout << "\t\t\tFillFlagMapFromCommandFlags(flagMap, + this->FillFlagMapFromCommandFlags(flagMap, &cmLocalVisualStudio7GeneratorFlagTable[0], flags); - std::string defineFlags = m_Makefile->GetDefineFlags(); + std::string defineFlags = this->Makefile->GetDefineFlags(); // now check the define flags for flags other than -D and // put them in the map, the -D flags will be left in the defineFlags // variable as -D is not in the flagMap - this->FillFlagMapFromCommandFlags(flagMap, + this->FillFlagMapFromCommandFlags(flagMap, &cmLocalVisualStudio7GeneratorFlagTable[0], - defineFlags); + defineFlags); // output remaining flags that were not mapped to anything fout << this->EscapeForXML(flags.c_str()).c_str(); - fout << " -DCMAKE_INTDIR=\\"" << configName << "\\"" + fout << " -DCMAKE_INTDIR=\\"" << configName << "\\"" << "\"\n"; fout << "\t\t\t\tAdditionalIncludeDirectories=\""; - std::vector& includes = m_Makefile->GetIncludeDirectories(); + std::vector includes; + this->GetIncludeDirectories(includes); std::vector::iterator i = includes.begin(); for(;i != includes.end(); ++i) { @@ -479,13 +523,13 @@ } fout << "\"\n"; // set a few cmake specific flags - if(m_Makefile->IsOn("CMAKE_CXX_USE_RTTI")) + if(this->Makefile->IsOn("CMAKE_CXX_USE_RTTI")) { flagMap["RuntimeTypeInfo"] = "TRUE"; } - if ( m_Makefile->GetDefinition("CMAKE_CXX_WARNING_LEVEL") ) + if ( this->Makefile->GetDefinition("CMAKE_CXX_WARNING_LEVEL") ) { - flagMap["WarningLevel"] = m_Makefile->GetDefinition("CMAKE_CXX_WARNING_LEVEL"); + flagMap["WarningLevel"] = this->Makefile->GetDefinition("CMAKE_CXX_WARNING_LEVEL"); } // Now copy the flag map into the xml for the file @@ -494,12 +538,13 @@ { fout << "\t\t\t\t" << m->first << "=\"" << m->second << "\"\n"; } - fout << "\t\t\t\tPreprocessorDefinitions=\"" << pre; + fout << "\t\t\t\tPreprocessorDefinitions=\""; if(target.GetType() == cmTarget::SHARED_LIBRARY || target.GetType() == cmTarget::MODULE_LIBRARY) { std::string exportSymbol; - if (const char* custom_export_name = target.GetProperty("DEFINE_SYMBOL")) + if (const char* custom_export_name = + target.GetProperty("DEFINE_SYMBOL")) { exportSymbol = custom_export_name; } @@ -515,9 +560,12 @@ fout << "\"\n"; fout << "\t\t\t\tAssemblerListingLocation=\"" << configName << "\"\n"; fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n"; - if(programDatabase.size()) + std::map::iterator mi = flagMap.find("DebugInformationFormat"); + if(mi != flagMap.end() && mi->second != "1") { - fout << programDatabase << "\n"; + fout << "\t\t\t\tProgramDatabaseFileName=\"" + << this->LibraryOutputPath + << "$(OutDir)/" << libName << ".pdb\"\n"; } fout << "/>\n"; // end of \n"; @@ -528,12 +576,27 @@ std::string ipath = this->ConvertToXMLOutputPath(i->c_str()); fout << ipath << ";"; } - // add the -D flags to the RC tool + // add the -D flags to the RC tool fout << "\"\n" - << "\t\t\t\tPreprocessorDefinitions=\"" << pre; + << "\t\t\t\tPreprocessorDefinitions=\""; this->OutputDefineFlags(defineFlags.c_str(), fout); fout << "\" />\n"; - fout << "\t\t\t\n"; + + fout << "\t\t\tOutputDefineFlags(defineFlags.c_str(), fout); + fout << "\"\n"; + fout << "\t\t\t\tMkTypLibCompatible=\"FALSE\"\n"; + fout << "\t\t\t\tTargetEnvironment=\"1\"\n"; + fout << "\t\t\t\tGenerateStublessProxies=\"TRUE\"\n"; + fout << "\t\t\t\tTypeLibraryName=\"$(InputName).tlb\"\n"; + fout << "\t\t\t\tOutputDirectory=\"$(IntDir)\"\n"; + fout << "\t\t\t\tHeaderFileName=\"$(InputName).h\"\n"; + fout << "\t\t\t\tDLLDataFileName=\"\"\n"; + fout << "\t\t\t\tInterfaceIdentifierFileName=\"$(InputName)_i.c\"\n"; + fout << "\t\t\t\tProxyFileName=\"$(InputName)_p.c\"/>\n"; + // end of OutputTargetRules(fout, target, libName); this->OutputBuildTool(fout, configName, libName, target); fout << "\t\t\n"; @@ -554,7 +617,7 @@ option += flagTable->commandFlag; while(flags.find(option) != flags.npos) { - // replace the flag + // replace the flag cmSystemTools::ReplaceString(flags, option.c_str(), ""); // now put value into flag map flagMap[flagTable->IDEName] = flagTable->value; @@ -563,7 +626,7 @@ option[0] = '/'; while(flags.find(option) != flags.npos) { - // replace the flag + // replace the flag cmSystemTools::ReplaceString(flags, option.c_str(), ""); // now put value into flag map flagMap[flagTable->IDEName] = flagTable->value; @@ -576,7 +639,7 @@ // was not given explicitly in the flags we want to add an attribute // to the generated project to disable logo suppression. Otherwise // the GUI default is to enable suppression. - if(m_Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")) + if(this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")) { if(flagMap.find("SuppressStartupBanner") == flagMap.end()) { @@ -585,35 +648,44 @@ } } +//---------------------------------------------------------------------------- +std::string +cmLocalVisualStudio7Generator +::GetBuildTypeLinkerFlags(std::string rootLinkerFlags, const char* configName) +{ + std::string configTypeUpper = cmSystemTools::UpperCase(configName); + std::string extraLinkOptionsBuildTypeDef = rootLinkerFlags + "_" + configTypeUpper; + std::string extraLinkOptionsBuildType = + this->Makefile->GetRequiredDefinition(extraLinkOptionsBuildTypeDef.c_str()); + + return extraLinkOptionsBuildType; +} void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, const char* configName, const char *libName, cmTarget &target) -{ +{ + std::string targetFullName = target.GetFullName(configName); std::string temp; - std::string debugPostfix = ""; - bool debug = !strcmp(configName,"Debug"); - if (debug && m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX")) - { - debugPostfix = m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX"); - } - std::string extraLinkOptions; if(target.GetType() == cmTarget::EXECUTABLE) { - extraLinkOptions = m_Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS"); + extraLinkOptions = this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS") + + std::string(" ") + GetBuildTypeLinkerFlags("CMAKE_EXE_LINKER_FLAGS", configName); } if(target.GetType() == cmTarget::SHARED_LIBRARY) { - extraLinkOptions = m_Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS"); + extraLinkOptions = this->Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS") + + std::string(" ") + GetBuildTypeLinkerFlags("CMAKE_SHARED_LINKER_FLAGS", configName); } if(target.GetType() == cmTarget::MODULE_LIBRARY) { - extraLinkOptions = m_Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS"); + extraLinkOptions = this->Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS") + + std::string(" ") + GetBuildTypeLinkerFlags("CMAKE_MODULE_LINKER_FLAGS", configName); } - + const char* targetLinkFlags = target.GetProperty("LINK_FLAGS"); if(targetLinkFlags) { @@ -623,28 +695,33 @@ std::map flagMap; this-> - FillFlagMapFromCommandFlags(flagMap, + FillFlagMapFromCommandFlags(flagMap, &cmLocalVisualStudio7GeneratorLinkFlagTable[0], extraLinkOptions); switch(target.GetType()) { case cmTarget::STATIC_LIBRARY: { - std::string libpath = m_LibraryOutputPath + - "$(OutDir)/" + libName + debugPostfix + ".lib"; + std::string libpath = this->LibraryOutputPath + + "$(OutDir)/" + targetFullName; fout << "\t\t\tConvertToXMLOutputPathSingle(libpath.c_str()) << ".\"/>\n"; break; } case cmTarget::SHARED_LIBRARY: case cmTarget::MODULE_LIBRARY: { + // Compute the link library and directory information. + std::vector linkLibs; + std::vector linkDirs; + this->ComputeLinkInformation(target, configName, linkLibs, linkDirs); + fout << "\t\t\tOutputLibraries(fout, configName, libName, target); + << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) " + << this->Makefile->GetRequiredDefinition("CMAKE_STANDARD_LIBRARIES") + << " "; + this->OutputLibraries(fout, linkLibs); fout << "\"\n"; - temp = m_LibraryOutputPath; + temp = this->LibraryOutputPath; temp += configName; temp += "/"; - temp += libName; - temp += debugPostfix; - temp += ".dll"; - fout << "\t\t\t\tOutputFile=\"" + temp += targetFullName; + fout << "\t\t\t\tOutputFile=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n"; for(std::map::iterator i = flagMap.begin(); i != flagMap.end(); ++i) @@ -671,15 +750,14 @@ fout << "\t\t\t\t" << i->first << "=\"" << i->second << "\"\n"; } fout << "\t\t\t\tAdditionalLibraryDirectories=\""; - this->OutputLibraryDirectories(fout, configName, libName, target); + this->OutputLibraryDirectories(fout, linkDirs); fout << "\"\n"; this->OutputModuleDefinitionFile(fout, target); - temp = m_LibraryOutputPath; + temp = this->LibraryOutputPath; temp += "$(OutDir)/"; temp += libName; - temp += debugPostfix; temp += ".pdb"; - fout << "\t\t\t\tProgramDatabaseFile=\"" << + fout << "\t\t\t\tProgramDatabaseFile=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n"; if(strcmp(configName, "Debug") == 0 || strcmp(configName, "RelWithDebInfo") == 0) @@ -696,52 +774,46 @@ std::string stackVar = "CMAKE_"; stackVar += linkLanguage; stackVar += "_STACK_SIZE"; - const char* stackVal = m_Makefile->GetDefinition(stackVar.c_str()); + const char* stackVal = this->Makefile->GetDefinition(stackVar.c_str()); if(stackVal) { fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"\n"; } - temp = m_LibraryOutputPath; + temp = this->LibraryOutputPath; temp += configName; temp += "/"; - temp += libName; - temp += debugPostfix; + temp += cmSystemTools::GetFilenameWithoutLastExtension(targetFullName.c_str()); temp += ".lib"; fout << "\t\t\t\tImportLibrary=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"/>\n"; } break; case cmTarget::EXECUTABLE: { - + // Compute the link library and directory information. + std::vector linkLibs; + std::vector linkDirs; + this->ComputeLinkInformation(target, configName, linkLibs, linkDirs); + fout << "\t\t\tGetRequiredDefinition("CMAKE_STANDARD_LIBRARIES") + << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) " + << this->Makefile->GetRequiredDefinition("CMAKE_STANDARD_LIBRARIES") << " "; - this->OutputLibraries(fout, configName, libName, target); + this->OutputLibraries(fout, linkLibs); fout << "\"\n"; - temp = m_ExecutableOutputPath; + temp = this->ExecutableOutputPath; temp += configName; temp += "/"; - - // do we have a different executable name? - if (target.GetProperty("OUTPUT_NAME")) - { - temp += target.GetProperty("OUTPUT_NAME"); - } - else - { - temp += libName; - } - - temp += ".exe"; + temp += targetFullName; fout << "\t\t\t\tOutputFile=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n"; for(std::map::iterator i = flagMap.begin(); i != flagMap.end(); ++i) @@ -749,11 +821,11 @@ fout << "\t\t\t\t" << i->first << "=\"" << i->second << "\"\n"; } fout << "\t\t\t\tAdditionalLibraryDirectories=\""; - this->OutputLibraryDirectories(fout, configName, libName, target); + this->OutputLibraryDirectories(fout, linkDirs); fout << "\"\n"; - fout << "\t\t\t\tProgramDatabaseFile=\"" << m_LibraryOutputPath + fout << "\t\t\t\tProgramDatabaseFile=\"" << this->LibraryOutputPath << "$(OutDir)\\" << libName << ".pdb\"\n"; - if(strcmp(configName, "Debug") == 0 + if(strcmp(configName, "Debug") == 0 || strcmp(configName, "RelWithDebInfo") == 0) { fout << "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n"; @@ -763,10 +835,10 @@ fout << "\t\t\t\tSubSystem=\"2\"\n"; } else - { + { fout << "\t\t\t\tSubSystem=\"1\"\n"; - } - const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator()); + } + const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator()); if(!linkLanguage) { cmSystemTools::Error("CMake can not determine linker language for target:", @@ -776,7 +848,7 @@ std::string stackVar = "CMAKE_"; stackVar += linkLanguage; stackVar += "_STACK_SIZE"; - const char* stackVal = m_Makefile->GetDefinition(stackVar.c_str()); + const char* stackVal = this->Makefile->GetDefinition(stackVar.c_str()); if(stackVal) { fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\""; @@ -785,6 +857,7 @@ break; } case cmTarget::UTILITY: + case cmTarget::GLOBAL_TARGET: break; } } @@ -793,9 +866,9 @@ cmTarget &target) { std::vector const& classes = target.GetSourceFiles(); - for(std::vector::const_iterator i = classes.begin(); + for(std::vector::const_iterator i = classes.begin(); i != classes.end(); i++) - { + { if(cmSystemTools::UpperCase((*i)->GetSourceExtension()) == "DEF") { fout << "\t\t\t\tModuleDefinitionFile=\"" @@ -804,111 +877,48 @@ return; } } - + } -void cmLocalVisualStudio7Generator::OutputLibraryDirectories(std::ostream& fout, - const char*, - const char*, - cmTarget &tgt) -{ - bool hasone = false; - if(m_LibraryOutputPath.size()) - { - hasone = true; - std::string temp = m_LibraryOutputPath; - temp += "$(OutDir)"; - - fout << this->ConvertToXMLOutputPath(temp.c_str()) << "," << - this->ConvertToXMLOutputPath(m_LibraryOutputPath.c_str()); - } - if(m_ExecutableOutputPath.size() && - (m_LibraryOutputPath != m_ExecutableOutputPath)) +//---------------------------------------------------------------------------- +void +cmLocalVisualStudio7Generator +::OutputLibraries(std::ostream& fout, + std::vector const& libs) +{ + for(std::vector::const_iterator l = libs.begin(); + l != libs.end(); ++l) { - if (hasone) - { - fout << ","; - } - hasone = true; - std::string temp = m_ExecutableOutputPath; - temp += "$(OutDir)"; - fout << this->ConvertToXMLOutputPath(temp.c_str()) << "," << - this->ConvertToXMLOutputPath(m_ExecutableOutputPath.c_str()); - } - - std::set pathEmitted; - std::vector::const_iterator i; - const std::vector& libdirs = tgt.GetLinkDirectories(); - for(i = libdirs.begin(); i != libdirs.end(); ++i) - { - std::string lpath = *i; - if(lpath[lpath.size()-1] != '/') - { - lpath += "/"; - } - if(pathEmitted.insert(lpath).second) - { - if(hasone) - { - fout << ","; - } - std::string lpathi = lpath + "$(OutDir)"; - fout << this->ConvertToXMLOutputPath(lpathi.c_str()) << "," << - this->ConvertToXMLOutputPath(lpath.c_str()); - hasone = true; - } + fout << this->ConvertToXMLOutputPath(l->c_str()) << " "; } } -void cmLocalVisualStudio7Generator::OutputLibraries(std::ostream& fout, - const char* configName, - const char* libName, - cmTarget &target) -{ - const cmTarget::LinkLibraries& libs = target.GetLinkLibraries(); - cmTarget::LinkLibraries::const_iterator j; - for(j = libs.begin(); j != libs.end(); ++j) - { - if(j->first != libName) - { - std::string lib = j->first; - std::string debugPostfix = ""; - // if this is a library we are building then watch for a debugPostfix - if (!strcmp(configName,"Debug")) - { - std::string libPath = j->first + "_CMAKE_PATH"; - const char* cacheValue - = m_GlobalGenerator->GetCMakeInstance()->GetCacheDefinition(libPath.c_str()); - if(cacheValue && *cacheValue && m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX")) - { - debugPostfix = m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX"); - } - } - // chop off the last 4 chars of the library string - - std::string lowerCaseLibExt = j->first; - if(lowerCaseLibExt.size() > 4) - { - lowerCaseLibExt = j->first.substr(j->first.size()-4, 4); - } - // lower case the extension - lowerCaseLibExt = cmSystemTools::LowerCase(lowerCaseLibExt); - // now check to see if it was a .lib, if not then add a .lib - if(lowerCaseLibExt != ".lib") - { - lib += debugPostfix + ".lib"; - } - lib = this->ConvertToXMLOutputPath(lib.c_str()); - if (j->second == cmTarget::GENERAL - || (j->second == cmTarget::DEBUG && strcmp(configName, "Debug") == 0) - || (j->second == cmTarget::OPTIMIZED && strcmp(configName, "Debug") != 0)) +//---------------------------------------------------------------------------- +void +cmLocalVisualStudio7Generator +::OutputLibraryDirectories(std::ostream& fout, + std::vector const& dirs) +{ + const char* comma = ""; + for(std::vector::const_iterator d = dirs.begin(); + d != dirs.end(); ++d) + { + std::string dir = *d; + if(!dir.empty()) + { + if(dir[dir.size()-1] != '/') { - fout << lib << " "; + dir += "/"; } + dir += "$(OutDir)"; + fout << comma << this->ConvertToXMLOutputPath(dir.c_str()) + << "," << this->ConvertToXMLOutputPath(d->c_str()); + comma = ","; } } } +//---------------------------------------------------------------------------- void cmLocalVisualStudio7Generator::OutputDefineFlags(const char* flags, std::ostream& fout) { @@ -943,51 +953,42 @@ { pos = defs.find("-D", nextpos); } - } + } } -void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, +void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, const char *libName, cmTarget &target) { // get the configurations - std::vector *configs = + std::vector *configs = static_cast - (m_GlobalGenerator)->GetConfigurations(); - - // if we should add regen rule then... - const char *suppRegenRule = - m_Makefile->GetDefinition("CMAKE_SUPPRESS_REGENERATION"); - if (!cmSystemTools::IsOn(suppRegenRule)) - { - this->AddVCProjBuildRule(); - } + (this->GlobalGenerator)->GetConfigurations(); // trace the visual studio dependencies std::string name = libName; name += ".vcproj.cmake"; - target.TraceVSDependencies(name, m_Makefile); // We may be modifying the source groups temporarily, so make a copy. - std::vector sourceGroups = m_Makefile->GetSourceGroups(); - + std::vector sourceGroups = this->Makefile->GetSourceGroups(); + // get the classes from the source lists then add them to the groups std::vector & classes = target.GetSourceFiles(); - for(std::vector::const_iterator i = classes.begin(); + for(std::vector::const_iterator i = classes.begin(); i != classes.end(); i++) { // Add the file to the list of sources. std::string source = (*i)->GetFullPath(); if(cmSystemTools::UpperCase((*i)->GetSourceExtension()) == "DEF") { - m_ModuleDefinitionFile = (*i)->GetFullPath(); + this->ModuleDefinitionFile = (*i)->GetFullPath(); } - cmSourceGroup& sourceGroup = - m_Makefile->FindSourceGroup(source.c_str(), sourceGroups); + cmSourceGroup& sourceGroup = + this->Makefile->FindSourceGroup(source.c_str(), sourceGroups); sourceGroup.AssignSource(*i); } - + // open the project this->WriteProjectStart(fout, libName, target, sourceGroups); // write the configuration information @@ -1004,7 +1005,7 @@ } //} - + fout << "\t\n"; // Write the VCProj file's footer. @@ -1013,21 +1014,21 @@ void cmLocalVisualStudio7Generator::WriteGroup(const cmSourceGroup *sg, cmTarget target, std::ostream &fout, const char *libName, std::vector *configs) { - const std::vector &sourceFiles = + const std::vector &sourceFiles = sg->GetSourceFiles(); // If the group is empty, don't write it at all. - if(sourceFiles.empty()) - { - return; + if(sourceFiles.empty() && sg->GetGroupChildren().empty()) + { + return; } - + // If the group has a name, write the header. std::string name = sg->GetName(); if(name != "") { this->WriteVCProjBeginGroup(fout, name.c_str(), ""); } - + // Loop through each source in the source group. for(std::vector::const_iterator sf = sourceFiles.begin(); sf != sourceFiles.end(); ++sf) @@ -1037,14 +1038,15 @@ std::string compileFlags; std::string additionalDeps; - // Check for extra compiler flags. + // Add per-source flags. const char* cflags = (*sf)->GetProperty("COMPILE_FLAGS"); if(cflags) { - compileFlags = cflags; + compileFlags += " "; + compileFlags += cflags; } - const char* lang = - m_GlobalGenerator->GetLanguageFromExtension((*sf)->GetSourceExtension().c_str()); + const char* lang = + this->GlobalGenerator->GetLanguageFromExtension((*sf)->GetSourceExtension().c_str()); if(lang && strcmp(lang, "CXX") == 0) { // force a C++ file type @@ -1067,7 +1069,8 @@ } } } - if (source != libName || target.GetType() == cmTarget::UTILITY) + if (source != libName || target.GetType() == cmTarget::UTILITY || + target.GetType() == cmTarget::GLOBAL_TARGET ) { fout << "\t\t\tConvertToXMLOutputPathSingle(source.c_str()); @@ -1077,7 +1080,8 @@ if (command) { // Construct the entire set of commands in one string. - std::string script = this->ConstructScript(command->GetCommandLines()); + std::string script = this->ConstructScript(command->GetCommandLines(), + command->GetWorkingDirectory()); const char* comment = command->GetComment(); const char* flags = compileFlags.size() ? compileFlags.c_str(): 0; this->WriteCustomRule(fout, source.c_str(), script.c_str(), @@ -1102,7 +1106,7 @@ { aCompilerTool = "VCCustomBuildTool"; } - for(std::vector::iterator i = configs->begin(); + for(std::vector::iterator i = configs->begin(); i != configs->end(); ++i) { fout << "\t\t\t\t\n"; } } - + std::vector children = sg->GetGroupChildren(); for(unsigned int i=0;iWriteGroup(&children[i], target, fout, libName, configs); } - + // If the group has a name, write the footer. if(name != "") { this->WriteVCProjEndGroup(fout); } -} +} void cmLocalVisualStudio7Generator:: WriteCustomRule(std::ostream& fout, @@ -1151,8 +1155,8 @@ const char* compileFlags) { std::vector::iterator i; - std::vector *configs = - static_cast(m_GlobalGenerator)->GetConfigurations(); + std::vector *configs = + static_cast(this->GlobalGenerator)->GetConfigurations(); for(i = configs->begin(); i != configs->end(); ++i) { fout << "\t\t\t\t::const_iterator d = depends.begin(); d != depends.end(); ++d) - { - std::string dep = cmSystemTools::GetFilenameName(*d); - if (cmSystemTools::GetFilenameLastExtension(dep) == ".exe") - { - dep = cmSystemTools::GetFilenameWithoutLastExtension(dep); - } - // check to see if the dependency is another target built by cmake - std::string libPath = dep + "_CMAKE_PATH"; - const char* cacheValue = m_Makefile->GetDefinition(libPath.c_str()); - if (cacheValue && *cacheValue) - { - std::string exePath = ""; - if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH")) - { - exePath = m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"); - } - if(exePath.size()) - { - libPath = exePath; - } - else - { - libPath = cacheValue; - } - libPath += "/"; - libPath += "$(OutDir)/"; - libPath += dep; - libPath += ".exe"; - fout << this->ConvertToXMLOutputPath(libPath.c_str()) - << ";"; - } - else - { - fout << this->ConvertToXMLOutputPath(d->c_str()) - << ";"; - } + { + // Lookup the real name of the dependency in case it is a CMake target. + std::string dep = this->GetRealDependency(d->c_str(), i->c_str()); + fout << this->ConvertToXMLOutputPath(dep.c_str()) + << ";"; } fout << "\"\n"; fout << "\t\t\t\t\tOutputs=\""; @@ -1219,7 +1192,7 @@ { fout << source << "_force"; } - + // Write a rule for the output generated by this command. fout << this->ConvertToXMLOutputPathSingle(output); fout << "\"/>\n"; @@ -1228,7 +1201,7 @@ } -void cmLocalVisualStudio7Generator::WriteVCProjBeginGroup(std::ostream& fout, +void cmLocalVisualStudio7Generator::WriteVCProjBeginGroup(std::ostream& fout, const char* group, const char* ) { @@ -1246,19 +1219,19 @@ // look for custom rules on a target and collect them together void cmLocalVisualStudio7Generator::OutputTargetRules(std::ostream& fout, - cmTarget &target, + cmTarget &target, const char * /*libName*/) { - if (target.GetType() > cmTarget::UTILITY) + if (target.GetType() > cmTarget::GLOBAL_TARGET) { return; } - + // add the pre build rules fout << "\t\t\t::const_iterator cr = - target.GetPreBuildCommands().begin(); + for (std::vector::const_iterator cr = + target.GetPreBuildCommands().begin(); cr != target.GetPreBuildCommands().end(); ++cr) { if(!init) @@ -1266,7 +1239,7 @@ fout << "\nCommandLine=\""; init = true; } - std::string script = this->ConstructScript(cr->GetCommandLines()); + std::string script = this->ConstructScript(cr->GetCommandLines(), cr->GetWorkingDirectory()); fout << this->EscapeForXML(script.c_str()).c_str(); } if (init) @@ -1278,8 +1251,8 @@ // add the pre Link rules fout << "\t\t\t::const_iterator cr = - target.GetPreLinkCommands().begin(); + for (std::vector::const_iterator cr = + target.GetPreLinkCommands().begin(); cr != target.GetPreLinkCommands().end(); ++cr) { if(!init) @@ -1287,7 +1260,8 @@ fout << "\nCommandLine=\""; init = true; } - std::string script = this->ConstructScript(cr->GetCommandLines()); + std::string script = this->ConstructScript(cr->GetCommandLines(), + cr->GetWorkingDirectory()); fout << this->EscapeForXML(script.c_str()).c_str(); } if (init) @@ -1295,12 +1269,12 @@ fout << "\""; } fout << "/>\n"; - + // add the PostBuild rules fout << "\t\t\t::const_iterator cr = - target.GetPostBuildCommands().begin(); + for (std::vector::const_iterator cr = + target.GetPostBuildCommands().begin(); cr != target.GetPostBuildCommands().end(); ++cr) { if(!init) @@ -1308,7 +1282,7 @@ fout << "\nCommandLine=\""; init = true; } - std::string script = this->ConstructScript(cr->GetCommandLines()); + std::string script = this->ConstructScript(cr->GetCommandLines(), cr->GetWorkingDirectory()); fout << this->EscapeForXML(script.c_str()).c_str(); } if (init) @@ -1318,22 +1292,22 @@ fout << "/>\n"; } -void -cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, +void +cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, const char *libName, - cmTarget & target, + cmTarget & target, std::vector &) { fout << "\n" << "Version == 71) { fout << "\tVersion=\"7.10\"\n"; } - else + else { - if (m_Version == 8) + if (this->Version == 8) { fout << "\tVersion=\"8.00\"\n"; } @@ -1353,9 +1327,9 @@ keyword = "Win32Proj"; } cmGlobalVisualStudio7Generator* gg = - static_cast(m_GlobalGenerator); + static_cast(this->GlobalGenerator); fout << "\tName=\"" << projLabel << "\"\n"; - if(m_Version == 8) + if(this->Version == 8) { fout << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\"\n"; } @@ -1410,10 +1384,10 @@ void cmLocalVisualStudio7Generator::ConfigureFinalPass() { cmLocalGenerator::ConfigureFinalPass(); - cmTargets &tgts = m_Makefile->GetTargets(); + cmTargets &tgts = this->Makefile->GetTargets(); - cmGlobalVisualStudio7Generator* gg = - static_cast(m_GlobalGenerator); + cmGlobalVisualStudio7Generator* gg = + static_cast(this->GlobalGenerator); for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { if (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0) @@ -1425,21 +1399,16 @@ } else { - gg->CreateGUID(l->first.c_str()); + gg->CreateGUID(l->first.c_str()); } } - + } //---------------------------------------------------------------------------- std::string cmLocalVisualStudio7Generator::GetTargetDirectory(cmTarget& target) { std::string dir; - // Put a prefix on the name if one is given by the CMake code. - if(const char* prefix = m_Makefile->GetDefinition("CMAKE_TARGET_DIR_PREFIX")) - { - dir = prefix; - } dir += target.GetName(); dir += ".dir"; return dir; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLocalVisualStudio7Generator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLocalVisualStudio7Generator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLocalVisualStudio7Generator.h 2005-08-12 02:02:20.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLocalVisualStudio7Generator.h 2006-03-16 23:53:14.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmLocalVisualStudio7Generator.h,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:20 $ - Version: $Revision: 1.12.2.1 $ + Date: $Date: 2006/03/16 15:53:14 $ + Version: $Revision: 1.20 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -30,7 +30,7 @@ * \brief Write a LocalUnix makefiles. * * cmLocalVisualStudio7Generator produces a LocalUnix makefile from its - * member m_Makefile. + * member Makefile. */ class cmLocalVisualStudio7Generator : public cmLocalGenerator { @@ -58,15 +58,17 @@ */ std::vector GetCreatedProjectNames() { - return m_CreatedProjectNames; + return this->CreatedProjectNames; } - void SetVersion71() {m_Version = 71;} - void SetVersion8() {m_Version = 8;} + void SetVersion71() {this->Version = 71;} + void SetVersion8() {this->Version = 8;} virtual void ConfigureFinalPass(); private: void FillFlagMapFromCommandFlags(std::map& flagMap, cmVS7FlagTable* flagTable, std::string& flags); + std::string GetBuildTypeLinkerFlags(std::string rootLinkerFlags, + const char* configName); void OutputVCProjFile(); void WriteVCProjHeader(std::ostream& fout, const char *libName, cmTarget &tgt, std::vector &sgs); @@ -74,7 +76,7 @@ void CreateSingleVCProj(const char *lname, cmTarget &tgt); void WriteVCProjFile(std::ostream& fout, const char *libName, cmTarget &tgt); - void AddVCProjBuildRule(); + void AddVCProjBuildRule(cmTarget& tgt); void WriteConfigurations(std::ostream& fout, const char *libName, cmTarget &tgt); void WriteConfiguration(std::ostream& fout, @@ -90,12 +92,9 @@ void OutputBuildTool(std::ostream& fout, const char* configName, const char* libname, cmTarget& t); void OutputLibraries(std::ostream& fout, - const char* configName, - const char* libName, - cmTarget &target); + std::vector const& libs); void OutputLibraryDirectories(std::ostream& fout, - const char* configName, - const char* libName, cmTarget &target); + std::vector const& dirs); void OutputModuleDefinitionFile(std::ostream& fout, cmTarget &target); void WriteProjectStart(std::ostream& fout, const char *libName, cmTarget &tgt, std::vector &sgs); @@ -111,14 +110,15 @@ const char* output, const char* extraFlags); - void WriteGroup(const cmSourceGroup *sg, cmTarget target, std::ostream &fout, const char *libName, std::vector *configs); + void WriteGroup(const cmSourceGroup *sg, cmTarget target, std::ostream &fout, + const char *libName, std::vector *configs); virtual std::string GetTargetDirectory(cmTarget&); - std::vector m_CreatedProjectNames; - std::string m_LibraryOutputPath; - std::string m_ExecutableOutputPath; - std::string m_ModuleDefinitionFile; - int m_Version; + std::vector CreatedProjectNames; + std::string LibraryOutputPath; + std::string ExecutableOutputPath; + std::string ModuleDefinitionFile; + int Version; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLocalXCodeGenerator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLocalXCodeGenerator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmLocalXCodeGenerator.h 2005-01-25 06:35:54.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmLocalXCodeGenerator.h 2006-03-16 23:53:14.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmLocalXCodeGenerator.h,v $ Language: C++ - Date: $Date: 2005/01/24 22:35:54 $ - Version: $Revision: 1.1 $ + Date: $Date: 2006/03/16 15:53:14 $ + Version: $Revision: 1.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -23,7 +23,7 @@ * \brief Write a local Xcode project * * cmLocalXCodeGenerator produces a LocalUnix makefile from its - * member m_Makefile. + * member Makefile. */ class cmLocalXCodeGenerator : public cmLocalGenerator { diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMacroCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMacroCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMacroCommand.cxx 2005-07-05 22:08:46.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMacroCommand.cxx 2006-03-16 00:02:05.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmMacroCommand.cxx,v $ Language: C++ - Date: $Date: 2005/07/05 14:08:46 $ - Version: $Revision: 1.23 $ + Date: $Date: 2006/03/15 16:02:05 $ + Version: $Revision: 1.25 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -23,22 +23,22 @@ { public: cmMacroHelperCommand() {} - + ///! clean up any memory allocated by the macro ~cmMacroHelperCommand() {}; - + /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { cmMacroHelperCommand *newC = new cmMacroHelperCommand; // we must copy when we clone - newC->m_Args = this->m_Args; - newC->m_Functions = this->m_Functions; + newC->Args = this->Args; + newC->Functions = this->Functions; return newC; } - + /** * This determines if the command is invoked when in script mode. */ @@ -51,22 +51,22 @@ virtual bool InvokeInitialPass(const std::vector& args); virtual bool InitialPass(std::vector const&) { return false; }; - + /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() { return this->m_Args[0].c_str(); } + virtual const char* GetName() { return this->Args[0].c_str(); } /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { std::string docs = "Macro named: "; docs += this->GetName(); return docs.c_str(); } - + /** * More documentation. */ @@ -74,11 +74,11 @@ { return this->GetTerseDocumentation(); } - + cmTypeMacro(cmMacroHelperCommand, cmCommand); - std::vector m_Args; - std::vector m_Functions; + std::vector Args; + std::vector Functions; }; @@ -87,71 +87,71 @@ { // Expand the argument list to the macro. std::vector expandedArgs; - m_Makefile->ExpandArguments(args, expandedArgs); - + this->Makefile->ExpandArguments(args, expandedArgs); + std::string tmps; cmListFileArgument arg; std::string variable; // make sure the number of arguments passed is at least the number // required by the signature - if (expandedArgs.size() < m_Args.size() - 1) + if (expandedArgs.size() < this->Args.size() - 1) { - std::string errorMsg = + std::string errorMsg = "Macro invoked with incorrect arguments for macro named: "; - errorMsg += m_Args[0]; + errorMsg += this->Args[0]; this->SetError(errorMsg.c_str()); return false; } - + // set the value of argc cmOStringStream argcDefStream; argcDefStream << expandedArgs.size(); std::string argcDef = argcDefStream.str(); - + // declare varuiables for ARGV ARGN but do not compute until needed std::string argvDef; std::string argnDef; bool argnDefInitialized = false; bool argvDefInitialized = false; - + // Invoke all the functions that were collected in the block. cmListFileFunction newLFF; // for each function - for(unsigned int c = 0; c < m_Functions.size(); ++c) + for(unsigned int c = 0; c < this->Functions.size(); ++c) { // Replace the formal arguments and then invoke the command. - newLFF.m_Arguments.clear(); - newLFF.m_Arguments.reserve(m_Functions[c].m_Arguments.size()); - newLFF.m_Name = m_Functions[c].m_Name; - newLFF.m_FilePath = m_Functions[c].m_FilePath; - newLFF.m_Line = m_Functions[c].m_Line; + newLFF.Arguments.clear(); + newLFF.Arguments.reserve(this->Functions[c].Arguments.size()); + newLFF.Name = this->Functions[c].Name; + newLFF.FilePath = this->Functions[c].FilePath; + newLFF.Line = this->Functions[c].Line; const char* def = - m_Makefile->GetDefinition("CMAKE_MACRO_REPORT_DEFINITION_LOCATION"); + this->Makefile->GetDefinition("CMAKE_MACRO_REPORT_DEFINITION_LOCATION"); bool macroReportLocation = false; if(def && !cmSystemTools::IsOff(def)) { macroReportLocation = true; } - + // for each argument of the current function for (std::vector::const_iterator k = - m_Functions[c].m_Arguments.begin(); - k != m_Functions[c].m_Arguments.end(); ++k) + this->Functions[c].Arguments.begin(); + k != this->Functions[c].Arguments.end(); ++k) { tmps = k->Value; // replace formal arguments - for (unsigned int j = 1; j < m_Args.size(); ++j) + for (unsigned int j = 1; j < this->Args.size(); ++j) { variable = "${"; - variable += m_Args[j]; + variable += this->Args[j]; variable += "}"; cmSystemTools::ReplaceString(tmps, variable.c_str(), expandedArgs[j-1].c_str()); } // replace argc cmSystemTools::ReplaceString(tmps, "${ARGC}",argcDef.c_str()); - + // repleace ARGN if (tmps.find("${ARGN}") != std::string::npos) { @@ -161,7 +161,7 @@ std::vector::size_type cnt = 0; for ( eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit ) { - if ( cnt >= m_Args.size()-1 ) + if ( cnt >= this->Args.size()-1 ) { if ( argnDef.size() > 0 ) { @@ -175,13 +175,13 @@ } cmSystemTools::ReplaceString(tmps, "${ARGN}", argnDef.c_str()); } - + // if the current argument of the current function has ${ARGV in it // then try replacing ARGV values if (tmps.find("${ARGV") != std::string::npos) { char argvName[60]; - + // repleace ARGV, compute it only once if (!argvDefInitialized) { @@ -197,7 +197,7 @@ argvDefInitialized = true; } cmSystemTools::ReplaceString(tmps, "${ARGV}", argvDef.c_str()); - + // also replace the ARGV1 ARGV2 ... etc for (unsigned int t = 0; t < expandedArgs.size(); ++t) { @@ -206,7 +206,7 @@ expandedArgs[t].c_str()); } } - + arg.Value = tmps; arg.Quoted = k->Quoted; if(macroReportLocation) @@ -231,15 +231,15 @@ arg.Line = 0; } } - newLFF.m_Arguments.push_back(arg); + newLFF.Arguments.push_back(arg); } - if(!m_Makefile->ExecuteCommand(newLFF)) + if(!this->Makefile->ExecuteCommand(newLFF)) { cmOStringStream error; error << "Error in cmake code at\n" << args[0].FilePath << ":" << args[0].Line << ":\n" << "A command failed during the invocation of macro \"" - << this->m_Args[0].c_str() << "\"."; + << this->Args[0].c_str() << "\"."; cmSystemTools::Error(error.str().c_str()); return false; } @@ -248,55 +248,55 @@ } bool cmMacroFunctionBlocker:: -IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf) +IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf) { // record commands until we hit the ENDMACRO // at the ENDMACRO call we shift gears and start looking for invocations - if(cmSystemTools::LowerCase(lff.m_Name) == "endmacro") + if(cmSystemTools::LowerCase(lff.Name) == "endmacro") { std::vector expandedArguments; - mf.ExpandArguments(lff.m_Arguments, expandedArguments); - if(!expandedArguments.empty() && (expandedArguments[0] == m_Args[0])) + mf.ExpandArguments(lff.Arguments, expandedArguments); + if(!expandedArguments.empty() && (expandedArguments[0] == this->Args[0])) { - std::string name = m_Args[0]; + std::string name = this->Args[0]; std::vector::size_type cc; name += "("; - for ( cc = 0; cc < m_Args.size(); cc ++ ) + for ( cc = 0; cc < this->Args.size(); cc ++ ) { - name += " " + m_Args[cc]; + name += " " + this->Args[cc]; } name += " )"; - mf.AddMacro(m_Args[0].c_str(), name.c_str()); - + mf.AddMacro(this->Args[0].c_str(), name.c_str()); // create a new command and add it to cmake cmMacroHelperCommand *f = new cmMacroHelperCommand(); - f->m_Args = this->m_Args; - f->m_Functions = this->m_Functions; - std::string newName = "_" + this->m_Args[0]; - mf.GetCMakeInstance()->RenameCommand(this->m_Args[0].c_str(), newName.c_str()); + f->Args = this->Args; + f->Functions = this->Functions; + std::string newName = "_" + this->Args[0]; + mf.GetCMakeInstance()->RenameCommand(this->Args[0].c_str(), + newName.c_str()); mf.AddCommand(f); - + // remove the function blocker now that the macro is defined mf.RemoveFunctionBlocker(lff); return true; } } - + // if it wasn't an endmacro and we are not executing then we must be // recording - m_Functions.push_back(lff); + this->Functions.push_back(lff); return true; } - + bool cmMacroFunctionBlocker:: -ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf) +ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf) { - if(cmSystemTools::LowerCase(lff.m_Name) == "endmacro") + if(cmSystemTools::LowerCase(lff.Name) == "endmacro") { std::vector expandedArguments; - mf.ExpandArguments(lff.m_Arguments, expandedArguments); - if(!expandedArguments.empty() && (expandedArguments[0] == m_Args[0])) + mf.ExpandArguments(lff.Arguments, expandedArguments); + if(!expandedArguments.empty() && (expandedArguments[0] == this->Args[0])) { return true; } @@ -305,12 +305,14 @@ } void cmMacroFunctionBlocker:: -ScopeEnded(cmMakefile &mf) +ScopeEnded(cmMakefile &mf) { - // macros should end with an EndMacro - cmSystemTools::Error("The end of a CMakeLists file was reached with a MACRO statement that was not closed properly. Within the directory: ", - mf.GetCurrentDirectory(), " with macro ", - m_Args[0].c_str()); + // macros should end with an EndMacro + cmSystemTools::Error( + "The end of a CMakeLists file was reached with a MACRO statement that " + "was not closed properly. Within the directory: ", + mf.GetCurrentDirectory(), " with macro ", + this->Args[0].c_str()); } bool cmMacroCommand::InitialPass(std::vector const& args) @@ -320,16 +322,15 @@ this->SetError("called with incorrect number of arguments"); return false; } - + // create a function blocker cmMacroFunctionBlocker *f = new cmMacroFunctionBlocker(); for(std::vector::const_iterator j = args.begin(); j != args.end(); ++j) { - f->m_Args.push_back(*j); + f->Args.push_back(*j); } - m_Makefile->AddFunctionBlocker(f); - + this->Makefile->AddFunctionBlocker(f); return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMacroCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMacroCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMacroCommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMacroCommand.h 2006-03-16 00:02:05.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmMacroCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.9.2.1 $ + Date: $Date: 2006/03/15 16:02:05 $ + Version: $Revision: 1.12 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -23,7 +23,7 @@ /** \class cmMacroFunctionBlocker * \brief subclass of function blocker * - * + * */ class cmMacroFunctionBlocker : public cmFunctionBlocker { @@ -34,8 +34,8 @@ virtual bool ShouldRemove(const cmListFileFunction&, cmMakefile &mf); virtual void ScopeEnded(cmMakefile &mf); - std::vector m_Args; - std::vector m_Functions; + std::vector Args; + std::vector Functions; }; /** \class cmMacroCommand @@ -49,7 +49,7 @@ /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { return new cmMacroCommand; } @@ -73,11 +73,11 @@ /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { return "Start recording a macro for later invocation as a command."; } - + /** * More documentation. */ @@ -93,8 +93,8 @@ "arg1 arg2 arg3 (...). Commands listed after MACRO, " "but before the matching ENDMACRO, are not invoked until the macro " "is invoked. When it is invoked, the commands recorded in the " - "macro are first modified by replacing formal parameters (${arg1}) with " - "the arguments passed, and then invoked as normal commands. In " + "macro are first modified by replacing formal parameters (${arg1}) " + "with the arguments passed, and then invoked as normal commands. In " "addition to referencing the formal parameters you can reference " "the variable ARGC which will be set to the number of arguments " "passed into the function as well as ARGV0 ARGV1 ARGV2 ... which " @@ -103,7 +103,7 @@ "ARGV holds the list of all arguments given to the macro and ARGN " "holds the list of argument pass the last expected argument."; } - + cmTypeMacro(cmMacroCommand, cmCommand); }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMakeDepend.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMakeDepend.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMakeDepend.cxx 2005-06-22 21:06:45.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMakeDepend.cxx 2006-03-16 00:38:47.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmMakeDepend.cxx,v $ Language: C++ - Date: $Date: 2005/06/22 13:06:45 $ - Version: $Revision: 1.41 $ + Date: $Date: 2006/03/15 16:38:47 $ + Version: $Revision: 1.44 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -23,22 +23,23 @@ { if(this != info) { - m_DependencySet.insert(info); + this->DependencySet.insert(info); } } cmMakeDepend::cmMakeDepend() { - m_Verbose = false; - m_IncludeFileRegularExpression.compile("^.*$"); - m_ComplainFileRegularExpression.compile("^$"); + this->Verbose = false; + this->IncludeFileRegularExpression.compile("^.*$"); + this->ComplainFileRegularExpression.compile("^$"); } cmMakeDepend::~cmMakeDepend() { - for(DependInformationMap::iterator i = m_DependInformationMap.begin(); - i != m_DependInformationMap.end(); ++i) + for(DependInformationMapType::iterator i = + this->DependInformationMap.begin(); + i != this->DependInformationMap.end(); ++i) { delete i->second; } @@ -51,22 +52,22 @@ void cmMakeDepend::SetMakefile(cmMakefile* makefile) { - m_Makefile = makefile; + this->Makefile = makefile; // Now extract the include file regular expression from the makefile. - m_IncludeFileRegularExpression.compile( - m_Makefile->m_IncludeFileRegularExpression.c_str()); - m_ComplainFileRegularExpression.compile( - m_Makefile->m_ComplainFileRegularExpression.c_str()); + this->IncludeFileRegularExpression.compile( + this->Makefile->IncludeFileRegularExpression.c_str()); + this->ComplainFileRegularExpression.compile( + this->Makefile->ComplainFileRegularExpression.c_str()); // Now extract any include paths from the makefile flags const std::vector& includes = - m_Makefile->GetIncludeDirectories(); + this->Makefile->GetIncludeDirectories(); for(std::vector::const_iterator j = includes.begin(); j != includes.end(); ++j) { std::string path = *j; - m_Makefile->ExpandVariablesInString(path); + this->Makefile->ExpandVariablesInString(path); this->AddSearchPath(path.c_str()); } } @@ -82,19 +83,20 @@ void cmMakeDepend::GenerateDependInformation(cmDependInformation* info) { // If dependencies are already done, stop now. - if(info->m_DependDone) + if(info->DependDone) { return; } else { // Make sure we don't visit the same file more than once. - info->m_DependDone = true; + info->DependDone = true; } - const char* path = info->m_FullPath.c_str(); + const char* path = info->FullPath.c_str(); if(!path) { - cmSystemTools::Error("Attempt to find dependencies for file without path!"); + cmSystemTools::Error( + "Attempt to find dependencies for file without path!"); return; } @@ -108,14 +110,14 @@ found = true; } - + // See if the cmSourceFile for it has any files specified as // dependency hints. - if(info->m_cmSourceFile != 0) + if(info->SourceFile != 0) { // Get the cmSourceFile corresponding to this. - const cmSourceFile& cFile = *(info->m_cmSourceFile); + const cmSourceFile& cFile = *(info->SourceFile); // See if there are any hints for finding dependencies for the missing // file. if(!cFile.GetDepends().empty()) @@ -123,12 +125,12 @@ // Dependency hints have been given. Use them to begin the // recursion. for(std::vector::const_iterator file = - cFile.GetDepends().begin(); file != cFile.GetDepends().end(); + cFile.GetDepends().begin(); file != cFile.GetDepends().end(); ++file) { this->AddDependency(info, file->c_str()); } - + // Found dependency information. We are done. found = true; } @@ -137,8 +139,8 @@ if(!found) { // Try to find the file amongst the sources - cmSourceFile *srcFile = - m_Makefile->GetSource(cmSystemTools::GetFilenameWithoutExtension(path).c_str()); + cmSourceFile *srcFile = this->Makefile->GetSource + (cmSystemTools::GetFilenameWithoutExtension(path).c_str()); if (srcFile) { if (srcFile->GetFullPath() == path) @@ -149,8 +151,8 @@ { //try to guess which include path to use for(std::vector::iterator t = - m_IncludeDirectories.begin(); - t != m_IncludeDirectories.end(); ++t) + this->IncludeDirectories.begin(); + t != this->IncludeDirectories.end(); ++t) { std::string incpath = *t; if (incpath.size() && incpath[incpath.size() - 1] != '/') @@ -161,18 +163,18 @@ if (srcFile->GetFullPath() == incpath) { // set the path to the guessed path - info->m_FullPath = incpath; + info->FullPath = incpath; found=true; } } } } } - + if(!found) { // Couldn't find any dependency information. - if(m_ComplainFileRegularExpression.find(info->m_IncludeName.c_str())) + if(this->ComplainFileRegularExpression.find(info->IncludeName.c_str())) { cmSystemTools::Error("error cannot find dependencies for ", path); } @@ -180,7 +182,7 @@ { // Destroy the name of the file so that it won't be output as a // dependency. - info->m_FullPath = ""; + info->FullPath = ""; } } } @@ -189,11 +191,12 @@ // #include directives void cmMakeDepend::DependWalk(cmDependInformation* info) { - cmsys::RegularExpression includeLine("^[ \t]*#[ \t]*include[ \t]*[<\"]([^\">]+)[\">]"); - std::ifstream fin(info->m_FullPath.c_str()); + cmsys::RegularExpression includeLine + ("^[ \t]*#[ \t]*include[ \t]*[<\"]([^\">]+)[\">]"); + std::ifstream fin(info->FullPath.c_str()); if(!fin) { - cmSystemTools::Error("Cannot open ", info->m_FullPath.c_str()); + cmSystemTools::Error("Cannot open ", info->FullPath.c_str()); return; } @@ -206,19 +209,19 @@ // extract the file being included std::string includeFile = includeLine.match(1); // see if the include matches the regular expression - if(!m_IncludeFileRegularExpression.find(includeFile)) + if(!this->IncludeFileRegularExpression.find(includeFile)) { - if(m_Verbose) + if(this->Verbose) { std::string message = "Skipping "; message += includeFile; message += " for file "; - message += info->m_FullPath.c_str(); + message += info->FullPath.c_str(); cmSystemTools::Error(message.c_str(), 0); } continue; } - + // Add this file and all its dependencies. this->AddDependency(info, includeFile.c_str()); } @@ -229,7 +232,7 @@ void cmMakeDepend::AddDependency(cmDependInformation* info, const char* file) { cmDependInformation* dependInfo = - this->GetDependInformation(file, info->m_PathOnly.c_str()); + this->GetDependInformation(file, info->PathOnly.c_str()); this->GenerateDependInformation(dependInfo); info->AddDependencies(dependInfo); } @@ -239,11 +242,11 @@ { // Get the full path for the file so that lookup is unambiguous. std::string fullPath = this->FullPath(file, extraPath); - + // Try to find the file's instance of cmDependInformation. - DependInformationMap::const_iterator result = - m_DependInformationMap.find(fullPath); - if(result != m_DependInformationMap.end()) + DependInformationMapType::const_iterator result = + this->DependInformationMap.find(fullPath); + if(result != this->DependInformationMap.end()) { // Found an instance, return it. return result->second; @@ -252,10 +255,10 @@ { // Didn't find an instance. Create a new one and save it. cmDependInformation* info = new cmDependInformation; - info->m_FullPath = fullPath; - info->m_PathOnly = cmSystemTools::GetFilenamePath(fullPath.c_str()); - info->m_IncludeName = file; - m_DependInformationMap[fullPath] = info; + info->FullPath = fullPath; + info->PathOnly = cmSystemTools::GetFilenamePath(fullPath.c_str()); + info->IncludeName = file; + this->DependInformationMap[fullPath] = info; return info; } } @@ -264,20 +267,20 @@ void cmMakeDepend::GenerateMakefileDependencies() { // Now create cmDependInformation objects for files in the directory - cmTargets &tgts = m_Makefile->GetTargets(); + cmTargets &tgts = this->Makefile->GetTargets(); for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { const std::vector &classes = l->second.GetSourceFiles(); - for(std::vector::const_iterator i = classes.begin(); + for(std::vector::const_iterator i = classes.begin(); i != classes.end(); ++i) { if(!(*i)->GetPropertyAsBool("HEADER_FILE_ONLY")) { cmDependInformation* info = this->GetDependInformation((*i)->GetFullPath().c_str(),0); - this->AddFileToSearchPath(info->m_FullPath.c_str()); - info->m_cmSourceFile = *i; + this->AddFileToSearchPath(info->FullPath.c_str()); + info->SourceFile = *i; this->GenerateDependInformation(info); } } @@ -285,23 +288,23 @@ } -// find the full path to fname by searching the m_IncludeDirectories array +// find the full path to fname by searching the this->IncludeDirectories array std::string cmMakeDepend::FullPath(const char* fname, const char *extraPath) { - DirectoryToFileToPathMap::iterator m; + DirectoryToFileToPathMapType::iterator m; if(extraPath) { - m = m_DirectoryToFileToPathMap.find(extraPath); + m = this->DirectoryToFileToPathMap.find(extraPath); } else { - m = m_DirectoryToFileToPathMap.find(""); + m = this->DirectoryToFileToPathMap.find(""); } - if(m != m_DirectoryToFileToPathMap.end()) + if(m != this->DirectoryToFileToPathMap.end()) { - FileToPathMap& map = m->second; - FileToPathMap::iterator p = map.find(fname); + FileToPathMapType& map = m->second; + FileToPathMapType::iterator p = map.find(fname); if(p != map.end()) { return p->second; @@ -311,12 +314,12 @@ if(cmSystemTools::FileExists(fname)) { std::string fp = cmSystemTools::CollapseFullPath(fname); - m_DirectoryToFileToPathMap[extraPath? extraPath: ""][fname] = fp; + this->DirectoryToFileToPathMap[extraPath? extraPath: ""][fname] = fp; return fp; } - for(std::vector::iterator i = m_IncludeDirectories.begin(); - i != m_IncludeDirectories.end(); ++i) + for(std::vector::iterator i = this->IncludeDirectories.begin(); + i != this->IncludeDirectories.end(); ++i) { std::string path = *i; if (path.size() && path[path.size() - 1] != '/') @@ -328,7 +331,7 @@ && !cmSystemTools::FileIsDirectory(path.c_str())) { std::string fp = cmSystemTools::CollapseFullPath(path.c_str()); - m_DirectoryToFileToPathMap[extraPath? extraPath: ""][fname] = fp; + this->DirectoryToFileToPathMap[extraPath? extraPath: ""][fname] = fp; return fp; } } @@ -345,11 +348,11 @@ && !cmSystemTools::FileIsDirectory(path.c_str())) { std::string fp = cmSystemTools::CollapseFullPath(path.c_str()); - m_DirectoryToFileToPathMap[extraPath][fname] = fp; + this->DirectoryToFileToPathMap[extraPath][fname] = fp; return fp; } } - + // Couldn't find the file. return std::string(fname); } @@ -357,7 +360,7 @@ // Add a directory to the search path void cmMakeDepend::AddSearchPath(const char* path) { - m_IncludeDirectories.push_back(path); + this->IncludeDirectories.push_back(path); } // Add a directory to the search path @@ -368,11 +371,11 @@ if(pos != std::string::npos) { std::string path = filepath.substr(0, pos); - if(std::find(m_IncludeDirectories.begin(), - m_IncludeDirectories.end(), path) - == m_IncludeDirectories.end()) + if(std::find(this->IncludeDirectories.begin(), + this->IncludeDirectories.end(), path) + == this->IncludeDirectories.end()) { - m_IncludeDirectories.push_back(path); + this->IncludeDirectories.push_back(path); return; } } @@ -381,11 +384,12 @@ const cmDependInformation* cmMakeDepend::GetDependInformationForSourceFile(const cmSourceFile &sf) const { - for(DependInformationMap::const_iterator i = m_DependInformationMap.begin(); - i != m_DependInformationMap.end(); ++i) + for(DependInformationMapType::const_iterator i = + this->DependInformationMap.begin(); + i != this->DependInformationMap.end(); ++i) { const cmDependInformation* info = i->second; - if(info->m_cmSourceFile == &sf) + if(info->SourceFile == &sf) { return info; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMakeDepend.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMakeDepend.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMakeDepend.h 2005-06-22 21:06:45.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMakeDepend.h 2006-03-16 00:38:47.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmMakeDepend.h,v $ Language: C++ - Date: $Date: 2005/06/22 13:06:45 $ - Version: $Revision: 1.20 $ + Date: $Date: 2006/03/15 16:38:47 $ + Version: $Revision: 1.23 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -34,40 +34,40 @@ * Construct with dependency generation marked not done; instance * not placed in cmMakefile's list. */ - cmDependInformation(): m_DependDone(false), m_cmSourceFile(0) {} + cmDependInformation(): DependDone(false), SourceFile(0) {} /** * The set of files on which this one depends. */ - typedef std::set DependencySet; - DependencySet m_DependencySet; + typedef std::set DependencySetType; + DependencySetType DependencySet; /** * This flag indicates whether dependency checking has been * performed for this file. */ - bool m_DependDone; + bool DependDone; /** * If this object corresponds to a cmSourceFile instance, this points * to it. */ - const cmSourceFile *m_cmSourceFile; + const cmSourceFile *SourceFile; /** * Full path to this file. */ - std::string m_FullPath; + std::string FullPath; /** * Full path not including file name. */ - std::string m_PathOnly; + std::string PathOnly; /** * Name used to #include this file. */ - std::string m_IncludeName; + std::string IncludeName; /** * This method adds the dependencies of another file to this one. @@ -99,7 +99,8 @@ /** * Get the depend info struct for a source file */ - const cmDependInformation *GetDependInformationForSourceFile(const cmSourceFile &sf) const; + const cmDependInformation + *GetDependInformationForSourceFile(const cmSourceFile &sf) const; /** * Add a directory to the search path for include files. @@ -144,7 +145,8 @@ * Get an instance of cmDependInformation corresponding to the given file * name. */ - cmDependInformation* GetDependInformation(const char* file, const char *extraPath); + cmDependInformation* GetDependInformation(const char* file, + const char *extraPath); /** * Find the full path name for the given file name. @@ -153,16 +155,17 @@ */ std::string FullPath(const char *filename, const char *extraPath); - cmMakefile* m_Makefile; - bool m_Verbose; - cmsys::RegularExpression m_IncludeFileRegularExpression; - cmsys::RegularExpression m_ComplainFileRegularExpression; - std::vector m_IncludeDirectories; - typedef std::map FileToPathMap; - typedef std::map DirectoryToFileToPathMap; - typedef std::map DependInformationMap; - DependInformationMap m_DependInformationMap; - DirectoryToFileToPathMap m_DirectoryToFileToPathMap; + cmMakefile* Makefile; + bool Verbose; + cmsys::RegularExpression IncludeFileRegularExpression; + cmsys::RegularExpression ComplainFileRegularExpression; + std::vector IncludeDirectories; + typedef std::map FileToPathMapType; + typedef std::map + DirectoryToFileToPathMapType; + typedef std::map DependInformationMapType; + DependInformationMapType DependInformationMap; + DirectoryToFileToPathMapType DirectoryToFileToPathMap; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMakefile.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMakefile.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMakefile.cxx 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMakefile.cxx 2006-03-16 00:02:05.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmMakefile.cxx,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.301.2.4 $ + Date: $Date: 2006/03/15 16:02:05 $ + Version: $Revision: 1.327 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -15,6 +15,7 @@ =========================================================================*/ #include "cmMakefile.h" + #include "cmCommand.h" #include "cmSourceFile.h" #include "cmSystemTools.h" @@ -29,6 +30,7 @@ #ifdef CMAKE_BUILD_WITH_CMAKE # include "cmVariableWatch.h" #endif +#include "cmInstallGenerator.h" #include "cmake.h" #include // required for atoi @@ -38,43 +40,45 @@ cmMakefile::cmMakefile() { // Setup the default include file regular expression (match everything). - m_IncludeFileRegularExpression = "^.*$"; + this->IncludeFileRegularExpression = "^.*$"; // Setup the default include complaint regular expression (match nothing). - m_ComplainFileRegularExpression = "^$"; + this->ComplainFileRegularExpression = "^$"; // Source and header file extensions that we can handle // Set up a list of source and header extensions // these are used to find files when the extension // is not given // The "c" extension MUST precede the "C" extension. - m_SourceFileExtensions.push_back( "c" ); - m_SourceFileExtensions.push_back( "C" ); + this->SourceFileExtensions.push_back( "c" ); + this->SourceFileExtensions.push_back( "C" ); - m_SourceFileExtensions.push_back( "c++" ); - m_SourceFileExtensions.push_back( "cc" ); - m_SourceFileExtensions.push_back( "cpp" ); - m_SourceFileExtensions.push_back( "cxx" ); - m_SourceFileExtensions.push_back( "m" ); - m_SourceFileExtensions.push_back( "M" ); - m_SourceFileExtensions.push_back( "mm" ); - - m_HeaderFileExtensions.push_back( "h" ); - m_HeaderFileExtensions.push_back( "h++" ); - m_HeaderFileExtensions.push_back( "hm" ); - m_HeaderFileExtensions.push_back( "hpp" ); - m_HeaderFileExtensions.push_back( "hxx" ); - m_HeaderFileExtensions.push_back( "in" ); - m_HeaderFileExtensions.push_back( "txx" ); + this->SourceFileExtensions.push_back( "c++" ); + this->SourceFileExtensions.push_back( "cc" ); + this->SourceFileExtensions.push_back( "cpp" ); + this->SourceFileExtensions.push_back( "cxx" ); + this->SourceFileExtensions.push_back( "m" ); + this->SourceFileExtensions.push_back( "M" ); + this->SourceFileExtensions.push_back( "mm" ); + + this->HeaderFileExtensions.push_back( "h" ); + this->HeaderFileExtensions.push_back( "h++" ); + this->HeaderFileExtensions.push_back( "hm" ); + this->HeaderFileExtensions.push_back( "hpp" ); + this->HeaderFileExtensions.push_back( "hxx" ); + this->HeaderFileExtensions.push_back( "in" ); + this->HeaderFileExtensions.push_back( "txx" ); - m_DefineFlags = " "; - m_LocalGenerator = 0; + this->DefineFlags = " "; + this->LocalGenerator = 0; this->AddSourceGroup("", "^.*$"); this->AddSourceGroup("Source Files", "\\.(C|M|c|c\\+\\+|cc|cpp|cxx|m|mm|rc|def|r|odl|idl|hpj|bat)$"); this->AddSourceGroup("Header Files", "\\.(h|h\\+\\+|hm|hpp|hxx|in|txx|inl)$"); this->AddSourceGroup("CMake Rules", "\\.rule$"); + this->AddSourceGroup("Resources", "\\.plist$"); this->AddDefaultDefinitions(); - m_cmDefineRegex.compile("#cmakedefine[ \t]*([A-Za-z_0-9]*)"); + this->cmDefineRegex.compile("#cmakedefine[ \t]+([A-Za-z_0-9]*)"); + this->cmDefine01Regex.compile("#cmakedefine01[ \t]+([A-Za-z_0-9]*)"); this->PreOrder = false; } @@ -84,8 +88,8 @@ #if CMake_VERSION_MINOR & 1 return "development"; #else -# if CMake_VERSION_PATCH == 1 - return "1-beta"; +# if CMake_VERSION_PATCH == 0 + return "beta"; # else return "patch " CMAKE_TO_STRING(CMake_VERSION_PATCH); # endif @@ -123,22 +127,28 @@ cmMakefile::~cmMakefile() { - for(std::vector::iterator i = m_SourceFiles.begin(); - i != m_SourceFiles.end(); ++i) + for(std::vector::iterator + i = this->InstallGenerators.begin(); + i != this->InstallGenerators.end(); ++i) { delete *i; } - for(std::vector::iterator i = m_Tests.begin(); - i != m_Tests.end(); ++i) + for(std::vector::iterator i = this->SourceFiles.begin(); + i != this->SourceFiles.end(); ++i) { delete *i; } - for(unsigned int i=0; i < m_UsedCommands.size(); i++) + for(std::vector::iterator i = this->Tests.begin(); + i != this->Tests.end(); ++i) { - delete m_UsedCommands[i]; + delete *i; } - for(DataMap::const_iterator d = m_DataMap.begin(); - d != m_DataMap.end(); ++d) + for(unsigned int i=0; i < this->UsedCommands.size(); i++) + { + delete this->UsedCommands[i]; + } + for(DataMapType::const_iterator d = this->DataMap.begin(); + d != this->DataMap.end(); ++d) { if(d->second) { @@ -146,13 +156,13 @@ } } std::list::iterator pos; - for (pos = m_FunctionBlockers.begin(); - pos != m_FunctionBlockers.end(); ++pos) + for (pos = this->FunctionBlockers.begin(); + pos != this->FunctionBlockers.end(); ++pos) { cmFunctionBlocker* b = *pos; delete b; } - m_FunctionBlockers.clear(); + this->FunctionBlockers.clear(); } void cmMakefile::PrintStringVector(const char* s, const std::vector& v) const @@ -184,26 +194,26 @@ // print the class lists std::cout << "classes:\n"; - std::cout << " m_Targets: "; - for (cmTargets::iterator l = m_Targets.begin(); - l != m_Targets.end(); l++) + std::cout << " this->Targets: "; + for (cmTargets::iterator l = this->Targets.begin(); + l != this->Targets.end(); l++) { std::cout << l->first << std::endl; } - std::cout << " m_StartOutputDirectory; " << - m_StartOutputDirectory.c_str() << std::endl; - std::cout << " m_HomeOutputDirectory; " << - m_HomeOutputDirectory.c_str() << std::endl; - std::cout << " m_cmStartDirectory; " << - m_cmStartDirectory.c_str() << std::endl; - std::cout << " m_cmHomeDirectory; " << - m_cmHomeDirectory.c_str() << std::endl; - std::cout << " m_ProjectName; " << m_ProjectName.c_str() << std::endl; - this->PrintStringVector("m_IncludeDirectories;", m_IncludeDirectories); - this->PrintStringVector("m_LinkDirectories", m_LinkDirectories); - for( std::vector::const_iterator i = m_SourceGroups.begin(); - i != m_SourceGroups.end(); ++i) + std::cout << " this->StartOutputDirectory; " << + this->StartOutputDirectory.c_str() << std::endl; + std::cout << " this->HomeOutputDirectory; " << + this->HomeOutputDirectory.c_str() << std::endl; + std::cout << " this->cmStartDirectory; " << + this->cmStartDirectory.c_str() << std::endl; + std::cout << " this->cmHomeDirectory; " << + this->cmHomeDirectory.c_str() << std::endl; + std::cout << " this->ProjectName; " << this->ProjectName.c_str() << std::endl; + this->PrintStringVector("this->IncludeDirectories;", this->IncludeDirectories); + this->PrintStringVector("this->LinkDirectories", this->LinkDirectories); + for( std::vector::const_iterator i = this->SourceGroups.begin(); + i != this->SourceGroups.end(); ++i) { std::cout << "Source Group: " << i->GetName() << std::endl; } @@ -223,7 +233,7 @@ // No error. return result; } - std::string name = lff.m_Name; + std::string name = lff.Name; // execute the command cmCommand *rm = this->GetCMakeInstance()->GetCommand(name.c_str()); @@ -241,7 +251,7 @@ { cmOStringStream error; error << "Error in cmake code at\n" - << lff.m_FilePath << ":" << lff.m_Line << ":\n" + << lff.FilePath << ":" << lff.Line << ":\n" << rm->GetError(); cmSystemTools::Error(error.str().c_str()); return false; @@ -253,11 +263,11 @@ (!this->GetCMakeInstance()->GetScriptMode() || usedCommand->IsScriptable())) { - if(!usedCommand->InvokeInitialPass(lff.m_Arguments)) + if(!usedCommand->InvokeInitialPass(lff.Arguments)) { cmOStringStream error; error << "Error in cmake code at\n" - << lff.m_FilePath << ":" << lff.m_Line << ":\n" + << lff.FilePath << ":" << lff.Line << ":\n" << usedCommand->GetError(); cmSystemTools::Error(error.str().c_str()); result = false; @@ -270,14 +280,14 @@ { // use the command keepCommand = true; - m_UsedCommands.push_back(usedCommand); + this->UsedCommands.push_back(usedCommand); } } else if ( this->GetCMakeInstance()->GetScriptMode() && !usedCommand->IsScriptable() ) { cmOStringStream error; error << "Error in cmake code at\n" - << lff.m_FilePath << ":" << lff.m_Line << ":\n" + << lff.FilePath << ":" << lff.Line << ":\n" << "Command " << usedCommand->GetName() << " not scriptable" << std::endl; cmSystemTools::Error(error.str().c_str()); result = false; @@ -296,8 +306,8 @@ { cmOStringStream error; error << "Error in cmake code at\n" - << lff.m_FilePath << ":" << lff.m_Line << ":\n" - << "Unknown CMake command \"" << lff.m_Name.c_str() << "\"."; + << lff.FilePath << ":" << lff.Line << ":\n" + << "Unknown CMake command \"" << lff.Name.c_str() << "\"."; cmSystemTools::Error(error.str().c_str()); result = false; } @@ -310,6 +320,9 @@ // bool cmMakefile::ReadListFile(const char* filename_in, const char *external_in) { + std::string currentFile = this->GetSafeDefinition("CMAKE_PARENT_LIST_FILE"); + this->AddDefinition("CMAKE_PARENT_LIST_FILE", filename_in); + // used to watch for blockers going out of scope // e.g. mismatched IF statement std::set originalBlockers; @@ -324,13 +337,13 @@ { external_abs = cmSystemTools::CollapseFullPath(external_in, - m_cmStartDirectory.c_str()); + this->cmStartDirectory.c_str()); external = external_abs.c_str(); if (filename_in) { filename_abs = cmSystemTools::CollapseFullPath(filename_in, - m_cmStartDirectory.c_str()); + this->cmStartDirectory.c_str()); filename = filename_abs.c_str(); } } @@ -338,14 +351,14 @@ // keep track of the current file being read if (filename) { - if(m_cmCurrentListFile != filename) + if(this->cmCurrentListFile != filename) { - m_cmCurrentListFile = filename; + this->cmCurrentListFile = filename; } // loop over current function blockers and record them std::list::iterator pos; - for (pos = m_FunctionBlockers.begin(); - pos != m_FunctionBlockers.end(); ++pos) + for (pos = this->FunctionBlockers.begin(); + pos != this->FunctionBlockers.end(); ++pos) { originalBlockers.insert(*pos); } @@ -364,7 +377,7 @@ // one, then cmake will provide one via the // cmListFileCache class. bool requireProjectCommand = false; - if(!external && m_cmStartDirectory == m_cmHomeDirectory) + if(!external && this->cmStartDirectory == this->cmHomeDirectory) { if(cmSystemTools::LowerCase( cmSystemTools::GetFilenameName(filename)) == "cmakelists.txt") @@ -373,21 +386,21 @@ } } - cmListFile* lf = - cmListFileCache::GetInstance()->GetFileCache(filenametoread, - requireProjectCommand); - if(!lf) + cmListFile cacheFile; + if( !cacheFile.ParseFile(filenametoread, requireProjectCommand) ) { + this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentFile.c_str()); return false; } // add this list file to the list of dependencies - m_ListFiles.push_back( filenametoread); - const size_t numberFunctions = lf->m_Functions.size(); + this->ListFiles.push_back( filenametoread); + const size_t numberFunctions = cacheFile.Functions.size(); for(size_t i =0; i < numberFunctions; ++i) { - this->ExecuteCommand(lf->m_Functions[i]); + this->ExecuteCommand(cacheFile.Functions[i]); if ( cmSystemTools::GetFatalErrorOccured() ) { + this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentFile.c_str()); return true; } } @@ -397,8 +410,8 @@ { // loop over all function blockers to see if any block this command std::list::iterator pos; - for (pos = m_FunctionBlockers.begin(); - pos != m_FunctionBlockers.end(); ++pos) + for (pos = this->FunctionBlockers.begin(); + pos != this->FunctionBlockers.end(); ++pos) { // if this blocker was not in the original then send a // scope ended message @@ -409,6 +422,7 @@ } } + this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentFile.c_str()); return true; } @@ -421,7 +435,7 @@ // Set the make file void cmMakefile::SetLocalGenerator(cmLocalGenerator* lg) { - m_LocalGenerator = lg; + this->LocalGenerator = lg; } void cmMakefile::FinalPass() @@ -431,8 +445,8 @@ // give all the commands a chance to do something // after the file has been parsed before generation - for(std::vector::iterator i = m_UsedCommands.begin(); - i != m_UsedCommands.end(); ++i) + for(std::vector::iterator i = this->UsedCommands.begin(); + i != this->UsedCommands.end(); ++i) { (*i)->FinalPass(); } @@ -449,9 +463,8 @@ { cmSystemTools::Error("You have requested backwards compatibility with CMake version 1.2 or earlier. This version of CMake only supports backwards compatibility with CMake 1.4 or later. For compatibility with 1.2 or earlier please use CMake 2.0"); } - - for (cmTargets::iterator l = m_Targets.begin(); - l != m_Targets.end(); l++) + for (cmTargets::iterator l = this->Targets.begin(); + l != this->Targets.end(); l++) { l->second.GenerateSourceFilesFromSourceLists(*this); l->second.AnalyzeLibDependencies(*this); @@ -464,15 +477,16 @@ const std::vector& depends, const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type, - const char* comment) + const char* comment, + const char* workingDir) { // Find the target to which to add the custom command. - cmTargets::iterator ti = m_Targets.find(target); - if(ti != m_Targets.end()) + cmTargets::iterator ti = this->Targets.find(target); + if(ti != this->Targets.end()) { // Add the command to the appropriate build step for the target. const char* no_output = 0; - cmCustomCommand cc(no_output, depends, commandLines, comment); + cmCustomCommand cc(no_output, depends, commandLines, comment, workingDir); switch(type) { case cmTarget::PRE_BUILD: @@ -507,6 +521,7 @@ const char* main_dependency, const cmCustomCommandLines& commandLines, const char* comment, + const char* workingDir, bool replace) { // Choose a source file on which to store the custom command. @@ -581,7 +596,7 @@ if(file) { cmCustomCommand* cc = - new cmCustomCommand(output, depends2, commandLines, comment); + new cmCustomCommand(output, depends2, commandLines, comment, workingDir); file->SetCustomCommand(cc); } } @@ -603,7 +618,7 @@ // same then it added a post-build rule to the target. Preserve // this behavior. this->AddCustomCommandToTarget(target, depends, commandLines, - cmTarget::POST_BUILD, comment); + cmTarget::POST_BUILD, comment, 0); return; } @@ -622,7 +637,7 @@ { // The source looks like a real file. Use it as the main dependency. this->AddCustomCommandToOutput(output, depends, source, - commandLines, comment); + commandLines, comment, 0); } else { @@ -631,7 +646,7 @@ std::vector depends2 = depends; depends2.push_back(source); this->AddCustomCommandToOutput(output, depends2, no_main_dependency, - commandLines, comment); + commandLines, comment, 0); } // If the rule was added to the source (and not a .rule file), @@ -641,9 +656,9 @@ sname += ".rule"; if(!this->GetSource(sname.c_str())) { - if (m_Targets.find(target) != m_Targets.end()) + if (this->Targets.find(target) != this->Targets.end()) { - m_Targets[target].GetSourceLists().push_back(source); + this->Targets[target].GetSourceLists().push_back(source); } else { @@ -659,6 +674,7 @@ void cmMakefile::AddUtilityCommand(const char* utilityName, bool all, const char* output, const std::vector& depends, + const char* workingDirectory, const char* command, const char* arg1, const char* arg2, @@ -688,12 +704,14 @@ commandLines.push_back(commandLine); // Call the real signature of this method. - this->AddUtilityCommand(utilityName, all, output, depends, commandLines); + this->AddUtilityCommand(utilityName, all, output, workingDirectory, + depends, commandLines); } //---------------------------------------------------------------------------- void cmMakefile::AddUtilityCommand(const char* utilityName, bool all, const char* output, + const char* workingDirectory, const std::vector& depends, const cmCustomCommandLines& commandLines) { @@ -702,30 +720,29 @@ target.SetType(cmTarget::UTILITY, utilityName); target.SetInAll(all); target.SetMakefile(this); - // Store the custom command in the target. - cmCustomCommand cc(output, depends, commandLines, 0); + cmCustomCommand cc(output, depends, commandLines, 0, workingDirectory); target.GetPostBuildCommands().push_back(cc); // Add the target to the set of targets. - m_Targets.insert(cmTargets::value_type(utilityName, target)); + this->Targets.insert(cmTargets::value_type(utilityName, target)); } void cmMakefile::AddDefineFlag(const char* flag) { - m_DefineFlags += " "; - m_DefineFlags += flag; + this->DefineFlags += " "; + this->DefineFlags += flag; } void cmMakefile::RemoveDefineFlag(const char* flag) { - cmSystemTools::ReplaceString(m_DefineFlags, flag, " "); + cmSystemTools::ReplaceString(this->DefineFlags, flag, " "); } void cmMakefile::AddLinkLibrary(const char* lib, cmTarget::LinkLibraryType llt) { - m_LinkLibraries.push_back( + this->LinkLibraries.push_back( std::pair(lib,llt)); } @@ -733,22 +750,26 @@ const char* lib, cmTarget::LinkLibraryType llt) { - cmTargets::iterator i = m_Targets.find(target); - if ( i != m_Targets.end()) + cmTargets::iterator i = this->Targets.find(target); + if ( i != this->Targets.end()) { i->second.AddLinkLibrary( *this, target, lib, llt ); } else { - cmSystemTools::Error("Attempt to add link libraries to non-existant target: ", target, " for lib ", lib); + cmOStringStream e; + e << "Attempt to add link library \"" + << lib << "\" to target \"" + << target << "\" which is not built by this project."; + cmSystemTools::Error(e.str().c_str()); } } void cmMakefile::AddLinkDirectoryForTarget(const char *target, const char* d) { - cmTargets::iterator i = m_Targets.find(target); - if ( i != m_Targets.end()) + cmTargets::iterator i = this->Targets.find(target); + if ( i != this->Targets.end()) { i->second.AddLinkDirectory( d ); } @@ -776,47 +797,47 @@ { std::string newdir = dir; newdir = newdir.substr(0, newdir.size()-1); - if(std::find(m_LinkDirectories.begin(), - m_LinkDirectories.end(), newdir.c_str()) == m_LinkDirectories.end()) + if(std::find(this->LinkDirectories.begin(), + this->LinkDirectories.end(), newdir.c_str()) == this->LinkDirectories.end()) { - m_LinkDirectories.push_back(newdir); + this->LinkDirectories.push_back(newdir); } } else { - if(std::find(m_LinkDirectories.begin(), - m_LinkDirectories.end(), dir) == m_LinkDirectories.end()) + if(std::find(this->LinkDirectories.begin(), + this->LinkDirectories.end(), dir) == this->LinkDirectories.end()) { - m_LinkDirectories.push_back(dir); + this->LinkDirectories.push_back(dir); } } } void cmMakefile::InitializeFromParent() { - cmMakefile *parent = m_LocalGenerator->GetParent()->GetMakefile(); + cmMakefile *parent = this->LocalGenerator->GetParent()->GetMakefile(); // copy the definitions - this->m_Definitions = parent->m_Definitions; + this->Definitions = parent->Definitions; // copy include paths - this->m_IncludeDirectories = parent->m_IncludeDirectories; + this->IncludeDirectories = parent->IncludeDirectories; // define flags - this->m_DefineFlags = parent->m_DefineFlags; + this->DefineFlags = parent->DefineFlags; // link libraries - this->m_LinkLibraries = parent->m_LinkLibraries; + this->LinkLibraries = parent->LinkLibraries; // link directories - this->m_LinkDirectories = parent->m_LinkDirectories; + this->LinkDirectories = parent->LinkDirectories; // the initial project name - this->m_ProjectName = parent->m_ProjectName; + this->ProjectName = parent->ProjectName; // Copy include regular expressions. - this->m_IncludeFileRegularExpression = parent->m_IncludeFileRegularExpression; - this->m_ComplainFileRegularExpression = parent->m_ComplainFileRegularExpression; + this->IncludeFileRegularExpression = parent->IncludeFileRegularExpression; + this->ComplainFileRegularExpression = parent->ComplainFileRegularExpression; } void cmMakefile::ConfigureSubDirectory(cmLocalGenerator *lg2) @@ -859,7 +880,7 @@ bool topLevel, bool preorder, bool immediate) { - std::vector& children = m_LocalGenerator->GetChildren(); + std::vector& children = this->LocalGenerator->GetChildren(); // has this directory already been added? If so error unsigned int i; for (i = 0; i < children.size(); ++i) @@ -873,9 +894,9 @@ // create a new local generator and set its parent cmLocalGenerator *lg2 = - m_LocalGenerator->GetGlobalGenerator()->CreateLocalGenerator(); - lg2->SetParent(m_LocalGenerator); - m_LocalGenerator->GetGlobalGenerator()->AddLocalGenerator(lg2); + this->LocalGenerator->GetGlobalGenerator()->CreateLocalGenerator(); + lg2->SetParent(this->LocalGenerator); + this->LocalGenerator->GetGlobalGenerator()->AddLocalGenerator(lg2); // set the subdirs start dirs lg2->GetMakefile()->SetStartDirectory(srcPath); @@ -896,18 +917,18 @@ // getting much bigger than 20. We cannot use a set because of // order dependency of the include path. std::vector::iterator i = - std::find(m_IncludeDirectories.begin(), - m_IncludeDirectories.end(), inc); - if(i == m_IncludeDirectories.end()) + std::find(this->IncludeDirectories.begin(), + this->IncludeDirectories.end(), inc); + if(i == this->IncludeDirectories.end()) { if (before) { // WARNING: this *is* expensive (linear time) since it's a vector - m_IncludeDirectories.insert(m_IncludeDirectories.begin(), inc); + this->IncludeDirectories.insert(this->IncludeDirectories.begin(), inc); } else { - m_IncludeDirectories.push_back(inc); + this->IncludeDirectories.push_back(inc); } } else @@ -915,9 +936,9 @@ if(before) { // if this before and already in the path then remove it - m_IncludeDirectories.erase(i); + this->IncludeDirectories.erase(i); // WARNING: this *is* expensive (linear time) since it's a vector - m_IncludeDirectories.insert(m_IncludeDirectories.begin(), inc); + this->IncludeDirectories.insert(this->IncludeDirectories.begin(), inc); } } } @@ -928,14 +949,14 @@ { return; } - m_TemporaryDefinitionKey = name; - m_Definitions[m_TemporaryDefinitionKey] = value; + this->TemporaryDefinitionKey = name; + this->Definitions[this->TemporaryDefinitionKey] = value; #ifdef CMAKE_BUILD_WITH_CMAKE cmVariableWatch* vv = this->GetVariableWatch(); if ( vv ) { - vv->VariableAccessed(m_TemporaryDefinitionKey, + vv->VariableAccessed(this->TemporaryDefinitionKey, cmVariableWatch::VARIABLE_MODIFIED_ACCESS); } #endif @@ -983,13 +1004,13 @@ { if(value) { - m_Definitions.erase( DefinitionMap::key_type(name)); - m_Definitions.insert(DefinitionMap::value_type(name, "ON")); + this->Definitions.erase( DefinitionMap::key_type(name)); + this->Definitions.insert(DefinitionMap::value_type(name, "ON")); } else { - m_Definitions.erase( DefinitionMap::key_type(name)); - m_Definitions.insert(DefinitionMap::value_type(name, "OFF")); + this->Definitions.erase( DefinitionMap::key_type(name)); + this->Definitions.insert(DefinitionMap::value_type(name, "OFF")); } #ifdef CMAKE_BUILD_WITH_CMAKE cmVariableWatch* vv = this->GetVariableWatch(); @@ -1017,7 +1038,7 @@ void cmMakefile::RemoveDefinition(const char* name) { - m_Definitions.erase(DefinitionMap::key_type(name)); + this->Definitions.erase(DefinitionMap::key_type(name)); #ifdef CMAKE_BUILD_WITH_CMAKE cmVariableWatch* vv = this->GetVariableWatch(); if ( vv ) @@ -1029,7 +1050,7 @@ void cmMakefile::SetProjectName(const char* p) { - m_ProjectName = p; + this->ProjectName = p; } @@ -1039,18 +1060,19 @@ switch(target.GetType()) { case cmTarget::UTILITY: + case cmTarget::GLOBAL_TARGET: case cmTarget::INSTALL_FILES: case cmTarget::INSTALL_PROGRAMS: return; default:; } std::vector::iterator j; - for(j = m_LinkDirectories.begin(); - j != m_LinkDirectories.end(); ++j) + for(j = this->LinkDirectories.begin(); + j != this->LinkDirectories.end(); ++j) { target.AddLinkDirectory(j->c_str()); } - target.MergeLinkLibraries( *this, name, m_LinkLibraries ); + target.MergeLinkLibraries( *this, name, this->LinkLibraries ); } @@ -1081,47 +1103,7 @@ target.GetSourceLists() = srcs; target.SetMakefile(this); this->AddGlobalLinkInformation(lname, target); - m_Targets.insert(cmTargets::value_type(lname,target)); - - // Add an entry into the cache - std::string libPath = lname; - libPath += "_CMAKE_PATH"; - this->GetCacheManager()-> - AddCacheEntry(libPath.c_str(), - this->GetCurrentOutputDirectory(), - "Path to a library", cmCacheManager::INTERNAL); - - // Add an entry into the cache - std::string ltname = lname; - ltname += "_LIBRARY_TYPE"; - switch (shared) - { - case 0: - this->GetCacheManager()->AddCacheEntry(ltname.c_str(),"STATIC", - "Whether a library is static, shared or module.", - cmCacheManager::INTERNAL); - break; - case 1: - this->GetCacheManager()-> - AddCacheEntry(ltname.c_str(), - "SHARED", - "Whether a library is static, shared or module.", - cmCacheManager::INTERNAL); - break; - case 2: - this->GetCacheManager()-> - AddCacheEntry(ltname.c_str(), - "MODULE", - "Whether a library is static, shared or module.", - cmCacheManager::INTERNAL); - break; - default: - this->GetCacheManager()-> - AddCacheEntry(ltname.c_str(), - "STATIC", - "Whether a library is static, shared or module.", - cmCacheManager::INTERNAL); - } + this->Targets.insert(cmTargets::value_type(lname,target)); } cmTarget* cmMakefile::AddExecutable(const char *exeName, @@ -1134,15 +1116,7 @@ target.SetMakefile(this); this->AddGlobalLinkInformation(exeName, target); cmTargets::iterator it = - m_Targets.insert(cmTargets::value_type(exeName,target)).first; - - // Add an entry into the cache - std::string exePath = exeName; - exePath += "_CMAKE_PATH"; - this->GetCacheManager()-> - AddCacheEntry(exePath.c_str(), - this->GetCurrentOutputDirectory(), - "Path to an executable", cmCacheManager::INTERNAL); + this->Targets.insert(cmTargets::value_type(exeName,target)).first; return &it->second; } @@ -1154,8 +1128,8 @@ // look through all the source files that have custom commands // and see if the custom command has the passed source file as an output // keep in mind the possible .rule extension that may be tacked on - for(std::vector::const_iterator i = m_SourceFiles.begin(); - i != m_SourceFiles.end(); ++i) + for(std::vector::const_iterator i = this->SourceFiles.begin(); + i != this->SourceFiles.end(); ++i) { // does this source file have a custom command? if ((*i)->GetCustomCommand()) @@ -1181,8 +1155,8 @@ cmSourceGroup* cmMakefile::GetSourceGroup(const char* name) { // First see if the group exists. If so, replace its regular expression. - for(std::vector::iterator sg = m_SourceGroups.begin(); - sg != m_SourceGroups.end(); ++sg) + for(std::vector::iterator sg = this->SourceGroups.begin(); + sg != this->SourceGroups.end(); ++sg) { std::string sgName = sg->GetName(); if(sgName == name) @@ -1205,9 +1179,9 @@ void cmMakefile::AddSourceGroup(const char* name, const char* regex, const char *parent) { // First see if the group exists. If so, replace its regular expression. - for(unsigned int i=0;iSourceGroups.size();++i) { - cmSourceGroup *sg = &m_SourceGroups[i]; + cmSourceGroup *sg = &this->SourceGroups[i]; std::string sgName = sg->GetName(); if(!parent) @@ -1271,12 +1245,12 @@ } // The group doesn't exist. Add it. - m_SourceGroups.push_back(cmSourceGroup(name, regex)); + this->SourceGroups.push_back(cmSourceGroup(name, regex)); } void cmMakefile::AddExtraDirectory(const char* dir) { - m_AuxSourceDirectories.push_back(dir); + this->AuxSourceDirectories.push_back(dir); } @@ -1286,18 +1260,19 @@ void cmMakefile::ExpandVariables() { // Now expand variables in the include and link strings - for(std::vector::iterator d = m_IncludeDirectories.begin(); - d != m_IncludeDirectories.end(); ++d) + for(std::vector::iterator d = this->IncludeDirectories.begin(); + d != this->IncludeDirectories.end(); ++d) { this->ExpandVariablesInString(*d, true, true); } - for(std::vector::iterator d = m_LinkDirectories.begin(); - d != m_LinkDirectories.end(); ++d) + for(std::vector::iterator d = this->LinkDirectories.begin(); + d != this->LinkDirectories.end(); ++d) { this->ExpandVariablesInString(*d, true, true); } - for(cmTarget::LinkLibraries::iterator l = m_LinkLibraries.begin(); - l != m_LinkLibraries.end(); ++l) + for(cmTarget::LinkLibraryVectorType::iterator l = + this->LinkLibraries.begin(); + l != this->LinkLibraries.end(); ++l) { this->ExpandVariablesInString(l->first, true, true); } @@ -1346,8 +1321,8 @@ const char* cmMakefile::GetDefinition(const char* name) const { const char* def = 0; - DefinitionMap::const_iterator pos = m_Definitions.find(name); - if(pos != m_Definitions.end()) + DefinitionMap::const_iterator pos = this->Definitions.find(name); + if(pos != this->Definitions.end()) { def = (*pos).second.c_str(); } @@ -1367,8 +1342,8 @@ { // are unknown access allowed DefinitionMap::const_iterator pos2 = - m_Definitions.find("CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS"); - if (pos2 != m_Definitions.end() && + this->Definitions.find("CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS"); + if (pos2 != this->Definitions.end() && cmSystemTools::IsOn((*pos2).second.c_str())) { vv->VariableAccessed(name, @@ -1401,7 +1376,7 @@ if ( !cacheonly ) { DefinitionMap::const_iterator it; - for ( it = m_Definitions.begin(); it != m_Definitions.end(); it ++ ) + for ( it = this->Definitions.begin(); it != this->Definitions.end(); it ++ ) { definitions[it->first] = 1; } @@ -1485,7 +1460,6 @@ { cmSystemTools::Message(error.str().c_str()); } - //std::cerr << "[" << source.c_str() << "] results in: [" << parser.GetResult() << "]" << std::endl; } } @@ -1743,7 +1717,7 @@ bool cmMakefile::IsFunctionBlocked(const cmListFileFunction& lff) { // if there are no blockers get out of here - if (m_FunctionBlockers.begin() == m_FunctionBlockers.end()) + if (this->FunctionBlockers.begin() == this->FunctionBlockers.end()) { return false; } @@ -1751,8 +1725,8 @@ // loop over all function blockers to see if any block this command // evaluate in reverse, this is critical for balanced IF statements etc std::list::reverse_iterator pos; - for (pos = m_FunctionBlockers.rbegin(); - pos != m_FunctionBlockers.rend(); ++pos) + for (pos = this->FunctionBlockers.rbegin(); + pos != this->FunctionBlockers.rend(); ++pos) { if((*pos)->IsFunctionBlocked(lff, *this)) { @@ -1793,13 +1767,13 @@ { // loop over all function blockers to see if any block this command std::list::reverse_iterator pos; - for (pos = m_FunctionBlockers.rbegin(); - pos != m_FunctionBlockers.rend(); ++pos) + for (pos = this->FunctionBlockers.rbegin(); + pos != this->FunctionBlockers.rend(); ++pos) { if ((*pos)->ShouldRemove(lff, *this)) { cmFunctionBlocker* b = *pos; - m_FunctionBlockers.remove(b); + this->FunctionBlockers.remove(b); delete b; break; } @@ -1810,8 +1784,8 @@ void cmMakefile::SetHomeDirectory(const char* dir) { - m_cmHomeDirectory = dir; - cmSystemTools::ConvertToUnixSlashes(m_cmHomeDirectory); + this->cmHomeDirectory = dir; + cmSystemTools::ConvertToUnixSlashes(this->cmHomeDirectory); this->AddDefinition("CMAKE_SOURCE_DIR", this->GetHomeDirectory()); if ( !this->GetDefinition("CMAKE_CURRENT_SOURCE_DIR") ) { @@ -1821,8 +1795,8 @@ void cmMakefile::SetHomeOutputDirectory(const char* lib) { - m_HomeOutputDirectory = lib; - cmSystemTools::ConvertToUnixSlashes(m_HomeOutputDirectory); + this->HomeOutputDirectory = lib; + cmSystemTools::ConvertToUnixSlashes(this->HomeOutputDirectory); this->AddDefinition("CMAKE_BINARY_DIR", this->GetHomeOutputDirectory()); if ( !this->GetDefinition("CMAKE_CURRENT_BINARY_DIR") ) { @@ -1837,12 +1811,12 @@ void cmMakefile::RegisterData(cmData* data) { std::string name = data->GetName(); - DataMap::const_iterator d = m_DataMap.find(name); - if((d != m_DataMap.end()) && (d->second != 0) && (d->second != data)) + DataMapType::const_iterator d = this->DataMap.find(name); + if((d != this->DataMap.end()) && (d->second != 0) && (d->second != data)) { delete d->second; } - m_DataMap[name] = data; + this->DataMap[name] = data; } @@ -1852,12 +1826,12 @@ */ void cmMakefile::RegisterData(const char* name, cmData* data) { - DataMap::const_iterator d = m_DataMap.find(name); - if((d != m_DataMap.end()) && (d->second != 0) && (d->second != data)) + DataMapType::const_iterator d = this->DataMap.find(name); + if((d != this->DataMap.end()) && (d->second != 0) && (d->second != data)) { delete d->second; } - m_DataMap[name] = data; + this->DataMap[name] = data; } @@ -1867,8 +1841,8 @@ */ cmData* cmMakefile::LookupData(const char* name) const { - DataMap::const_iterator d = m_DataMap.find(name); - if(d != m_DataMap.end()) + DataMapType::const_iterator d = this->DataMap.find(name); + if(d != this->DataMap.end()) { return d->second; } @@ -1899,8 +1873,8 @@ ext = ext.substr(1); } - for(std::vector::const_iterator i = m_SourceFiles.begin(); - i != m_SourceFiles.end(); ++i) + for(std::vector::const_iterator i = this->SourceFiles.begin(); + i != this->SourceFiles.end(); ++i) { if ((*i)->GetSourceNameWithoutLastExtension() == sname && cmSystemTools::GetFilenamePath((*i)->GetFullPath()) == path && @@ -1917,8 +1891,8 @@ } path = this->GetCurrentOutputDirectory(); - for(std::vector::const_iterator i = m_SourceFiles.begin(); - i != m_SourceFiles.end(); ++i) + for(std::vector::const_iterator i = this->SourceFiles.begin(); + i != this->SourceFiles.end(); ++i) { if ((*i)->GetSourceName() == sname && cmSystemTools::GetFilenamePath((*i)->GetFullPath()) == path && @@ -2012,8 +1986,8 @@ { ext = ext.substr(1); } - bool headerFile = !(std::find( m_HeaderFileExtensions.begin(), m_HeaderFileExtensions.end(), ext ) == - m_HeaderFileExtensions.end()); + bool headerFile = !(std::find( this->HeaderFileExtensions.begin(), this->HeaderFileExtensions.end(), ext ) == + this->HeaderFileExtensions.end()); file.SetName(name_no_ext.c_str(), path.c_str(), ext.c_str(), headerFile); } else @@ -2064,14 +2038,16 @@ return ret; } ret = new cmSourceFile(sf); - m_SourceFiles.push_back(ret); + this->SourceFiles.push_back(ret); return ret; } void cmMakefile::EnableLanguage(std::vector const & lang) { - m_LocalGenerator->GetGlobalGenerator()->EnableLanguage(lang, this); + this->AddDefinition("CMAKE_CFG_INTDIR", + this->LocalGenerator->GetGlobalGenerator()->GetCMakeCFGInitDirectory()); + this->LocalGenerator->GetGlobalGenerator()->EnableLanguage(lang, this); } void cmMakefile::ExpandSourceListArguments( @@ -2110,7 +2086,7 @@ cmake cm; cm.SetIsInTryCompile(true); cmGlobalGenerator *gg = - cm.CreateGlobalGenerator(m_LocalGenerator->GetGlobalGenerator()->GetName()); + cm.CreateGlobalGenerator(this->LocalGenerator->GetGlobalGenerator()->GetName()); if (!gg) { cmSystemTools::Error( @@ -2134,7 +2110,7 @@ cm.SetCacheArgs(*cmakeArgs); } // to save time we pass the EnableLanguage info directly - gg->EnableLanguagesFromGenerator(m_LocalGenerator->GetGlobalGenerator()); + gg->EnableLanguagesFromGenerator(this->LocalGenerator->GetGlobalGenerator()); if (cm.Configure() != 0) { @@ -2156,7 +2132,7 @@ // finally call the generator to actually build the resulting project int ret = - m_LocalGenerator->GetGlobalGenerator()->TryCompile(srcdir,bindir, + this->LocalGenerator->GetGlobalGenerator()->TryCompile(srcdir,bindir, projectName, targetName, output, @@ -2168,9 +2144,9 @@ cmake *cmMakefile::GetCMakeInstance() const { - if ( m_LocalGenerator && m_LocalGenerator->GetGlobalGenerator() ) + if ( this->LocalGenerator && this->LocalGenerator->GetGlobalGenerator() ) { - return m_LocalGenerator->GetGlobalGenerator()->GetCMakeInstance(); + return this->LocalGenerator->GetGlobalGenerator()->GetCMakeInstance(); } return 0; } @@ -2193,7 +2169,7 @@ { return; } - m_MacrosMap[name] = signature; + this->MacrosMap[name] = signature; } void cmMakefile::GetListOfMacros(std::string& macros) @@ -2201,7 +2177,7 @@ StringStringMap::iterator it; macros = ""; int cc = 0; - for ( it = m_MacrosMap.begin(); it != m_MacrosMap.end(); ++it ) + for ( it = this->MacrosMap.begin(); it != this->MacrosMap.end(); ++it ) { if ( cc > 0 ) { @@ -2223,121 +2199,6 @@ ->GetCMakeInstance()->UpdateProgress(message, s); } -/** - * Find the library with the given name. Searches the given path and then - * the system search path. Returns the full path to the library if it is - * found. Otherwise, the empty string is returned. - */ -std::string cmMakefile::FindLibrary(const char* name, - const std::vector& userPaths) -{ - // See if the executable exists as written. - if(cmSystemTools::FileExists(name)) - { - return cmSystemTools::CollapseFullPath(name); - } - // Add the system search path to our path. - std::vector path; - cmSystemTools::GetPath(path, "CMAKE_LIBRARY_PATH"); - cmSystemTools::GetPath(path, "LIB"); - cmSystemTools::GetPath(path); - // now add the path - path.insert(path.end(), userPaths.begin(), userPaths.end()); - // Add some lib directories specific to compilers, depending on the - // current generator, so that library that might have been stored here - // can be found too. - // i.e. Microsoft Visual Studio or .Net: path to compiler/../Lib - // Borland: path to compiler/../Lib - const char* genName = this->GetDefinition("CMAKE_GENERATOR"); - if (genName) - { - if (!strcmp(genName, "NMake Makefiles") || - !strcmp(genName, "Visual Studio 6")) - { - const char* compiler = this->GetDefinition("CMAKE_CXX_COMPILER"); - if (compiler) - { - std::string compiler_path = cmSystemTools::FindProgram(compiler); - if (compiler_path.size()) - { - std::string lib_path = - cmSystemTools::GetFilenamePath( - cmSystemTools::GetFilenamePath(compiler_path)) + "/Lib"; - path.push_back(lib_path); - } - } - } - else if (!strcmp(genName, "Visual Studio 7")) - { - // It is likely that the compiler won't be in the path for .Net, but - // we know where devenv is. - const char* devenv = this->GetDefinition("MICROSOFT_DEVENV"); - if (devenv) - { - std::string devenv_path = cmSystemTools::FindProgram(devenv); - if (devenv_path.size()) - { - std::string vc7_path = - cmSystemTools::GetFilenamePath( - cmSystemTools::GetFilenamePath( - cmSystemTools::GetFilenamePath(devenv_path))) + "/Vc7"; - path.push_back(vc7_path + "/lib"); - path.push_back(vc7_path + "/PlatformSDK/lib"); - } - } - } - else if (!strcmp(genName, "Borland Makefiles")) - { - const char* bcb_bin_path = this->GetDefinition("BCB_BIN_PATH"); - if (bcb_bin_path) - { - std::string lib_path = - cmSystemTools::GetFilenamePath(bcb_bin_path) + "/Lib"; - path.push_back(lib_path); - } - } - } - if(m_LocalGenerator->GetGlobalGenerator()->GetLanguageEnabled("C")) - { - std::string voidsize = this->GetRequiredDefinition("CMAKE_SIZEOF_VOID_P"); - int size = atoi(voidsize.c_str()); - std::vector path64; - if(size == 8) - { - // Convert each search path to possible 32- and 64-bit versions - // of the names. Check for the existence of each one here to - // avoid repeating the check for every file search. - for(std::vector::iterator i = path.begin(); - i != path.end(); ++i) - { - std::string s = *i; - std::string s2 = *i; - cmSystemTools::ReplaceString(s, "lib/", "lib64/"); - if((s != *i) && cmSystemTools::FileIsDirectory(s.c_str())) - { - path64.push_back(s); - } - s2 += "64"; - if(cmSystemTools::FileIsDirectory(s2.c_str())) - { - path64.push_back(s2); - } - if(cmSystemTools::FileIsDirectory(i->c_str())) - { - path64.push_back(*i); - } - } - // now look for the library in the 64 bit path - std::string tmp = cmSystemTools::FindLibrary(name, path64); - cmSystemTools::ConvertToUnixSlashes(tmp); - return tmp; - } - } - std::string tmp = cmSystemTools::FindLibrary(name, path); - cmSystemTools::ConvertToUnixSlashes(tmp); - return tmp; -} - std::string cmMakefile::GetModulesFile(const char* filename) { std::vector modulePath; @@ -2397,9 +2258,9 @@ } // Replace #cmakedefine instances. - if(m_cmDefineRegex.find(line)) + if(this->cmDefineRegex.find(line)) { - const char* def = this->GetDefinition(m_cmDefineRegex.match(1).c_str()); + const char* def = this->GetDefinition(this->cmDefineRegex.match(1).c_str()); if(!cmSystemTools::IsOff(def)) { cmSystemTools::ReplaceString(line, "#cmakedefine", "#define"); @@ -2413,6 +2274,20 @@ output += " */"; } } + else if(this->cmDefine01Regex.find(line)) + { + const char* def = this->GetDefinition(this->cmDefine01Regex.match(1).c_str()); + cmSystemTools::ReplaceString(line, "#cmakedefine01", "#define"); + output += line; + if(!cmSystemTools::IsOff(def)) + { + output += " 1"; + } + else + { + output += " 0"; + } + } else { output += line; @@ -2519,8 +2394,8 @@ bool cmMakefile::CheckInfiniteLoops() { std::vector::iterator it; - for ( it = m_ListFiles.begin(); - it != m_ListFiles.end(); + for ( it = this->ListFiles.begin(); + it != this->ListFiles.end(); ++ it ) { if ( this->HasWrittenFile(it->c_str()) ) @@ -2544,14 +2419,14 @@ { value = "NOTFOUND"; } - m_Properties[prop] = value; + this->Properties[prop] = value; } const char *cmMakefile::GetProperty(const char* prop) const { std::map::const_iterator i = - m_Properties.find(prop); - if (i != m_Properties.end()) + this->Properties.find(prop); + if (i != this->Properties.end()) { return i->second.c_str(); } @@ -2561,8 +2436,8 @@ bool cmMakefile::GetPropertyAsBool(const char* prop) const { std::map::const_iterator i = - m_Properties.find(prop); - if (i != m_Properties.end()) + this->Properties.find(prop); + if (i != this->Properties.end()) { return cmSystemTools::IsOn(i->second.c_str()); } @@ -2596,7 +2471,7 @@ } test = new cmTest; test->SetName(testName); - m_Tests.push_back(test); + this->Tests.push_back(test); return test; } @@ -2607,7 +2482,7 @@ return 0; } std::vector::const_iterator it; - for ( it = m_Tests.begin(); it != m_Tests.end(); ++ it ) + for ( it = this->Tests.begin(); it != this->Tests.end(); ++ it ) { if ( strcmp((*it)->GetName(), testName) == 0 ) { @@ -2619,11 +2494,11 @@ const std::vector *cmMakefile::GetTests() const { - return &m_Tests; + return &this->Tests; } std::vector *cmMakefile::GetTests() { - return &m_Tests; + return &this->Tests; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMakefileExecutableTargetGenerator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMakefileExecutableTargetGenerator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMakefileExecutableTargetGenerator.cxx 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMakefileExecutableTargetGenerator.cxx 2006-03-16 00:02:06.000000000 +0800 @@ -0,0 +1,360 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmMakefileExecutableTargetGenerator.cxx,v $ + Language: C++ + Date: $Date: 2006/03/15 16:02:06 $ + Version: $Revision: 1.9 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "cmMakefileExecutableTargetGenerator.h" + +#include "cmGeneratedFileStream.h" +#include "cmGlobalGenerator.h" +#include "cmLocalUnixMakefileGenerator3.h" +#include "cmMakefile.h" +#include "cmSourceFile.h" +#include "cmTarget.h" + +//---------------------------------------------------------------------------- +void cmMakefileExecutableTargetGenerator::WriteRuleFiles() +{ + // create the build.make file and directory, put in the common blocks + this->CreateRuleFile(); + + // Add in any rules for custom commands + this->WriteCustomCommandsForTarget(); + + // write in rules for object files + this->WriteCommonCodeRules(); + + // Write the dependency generation rule. + this->WriteTargetDependRules(); + + // write the link rules + this->WriteExecutableRule(false); + if(this->Target->NeedRelinkBeforeInstall()) + { + // Write rules to link an installable version of the target. + this->WriteExecutableRule(true); + } + + // Write the requires target. + this->WriteTargetRequiresRules(); + + // Write clean target + this->WriteTargetCleanRules(); + + // close the streams + this->CloseFileStreams(); +} + + + +//---------------------------------------------------------------------------- +void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) +{ + std::vector commands; + + std::string relPath = this->LocalGenerator->GetHomeRelativeOutputPath(); + std::string objTarget; + + // Build list of dependencies. + std::vector depends; + for(std::vector::const_iterator obj = this->Objects.begin(); + obj != this->Objects.end(); ++obj) + { + objTarget = relPath; + objTarget += *obj; + depends.push_back(objTarget); + } + + // Add dependencies on targets that must be built first. + this->AppendTargetDepends(depends); + + // Add a dependency on the rule file itself. + this->LocalGenerator->AppendRuleDepend(depends, + this->BuildFileNameFull.c_str()); + + for(std::vector::const_iterator obj = + this->ExternalObjects.begin(); + obj != this->ExternalObjects.end(); ++obj) + { + depends.push_back(*obj); + } + + // from here up is the same for exe or lib + + // Get the name of the executable to generate. + std::string targetName; + std::string targetNameReal; + this->Target->GetExecutableNames(targetName, targetNameReal, + this->LocalGenerator->ConfigurationName.c_str()); + + // Construct the full path version of the names. + std::string outpath = this->LocalGenerator->ExecutableOutputPath; + if(outpath.length() == 0) + { + outpath = this->Makefile->GetStartOutputDirectory(); + outpath += "/"; + } +#ifdef __APPLE__ + if(this->Target->GetPropertyAsBool("MACOSX_BUNDLE")) + { + // Make bundle directories + outpath += targetName; + outpath += ".app/Contents/MacOS/"; + std::string f1 = + this->Makefile->GetModulesFile("MacOSXBundleInfo.plist.in"); + if ( f1.size() == 0 ) + { + cmSystemTools::Error("could not find Mac OSX bundle template file."); + } + std::string macdir = + this->Makefile->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH"); + if ( macdir.size() == 0 ) + { + macdir = this->Makefile->GetCurrentOutputDirectory(); + } + if(macdir.size() && macdir[macdir.size()-1] != '/') + { + macdir += "/"; + } + macdir += targetName; + macdir += ".app/Contents/"; + + // Configure the Info.plist file. Note that it needs the executable name + // to be set. + std::string f2 = macdir + "Info.plist"; + macdir += "MacOS"; + cmSystemTools::MakeDirectory(macdir.c_str()); + this->Makefile->AddDefinition("MACOSX_BUNDLE_EXECUTABLE_NAME", + targetName.c_str()); + this->Makefile->ConfigureFile(f1.c_str(), f2.c_str(), false, false, false); + } +#endif + if(relink) + { + outpath = this->Makefile->GetStartOutputDirectory(); + outpath += "/CMakeFiles/CMakeRelink.dir"; + cmSystemTools::MakeDirectory(outpath.c_str()); + outpath += "/"; + } + std::string targetFullPath = outpath + targetName; + std::string targetFullPathReal = outpath + targetNameReal; + + // Convert to the output path to use in constructing commands. + std::string targetOutPath = + this->Convert(targetFullPath.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::MAKEFILE); + std::string targetOutPathReal = + this->Convert(targetFullPathReal.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::MAKEFILE); + + // Get the language to use for linking this executable. + const char* linkLanguage = + this->Target->GetLinkerLanguage(this->GlobalGenerator); + + // Make sure we have a link language. + if(!linkLanguage) + { + cmSystemTools::Error("Cannot determine link language for target \"", + this->Target->GetName(), "\"."); + return; + } + + // Add the link message. + std::string buildEcho = "Linking "; + buildEcho += linkLanguage; + buildEcho += " executable "; + buildEcho += targetOutPath; + this->LocalGenerator->AppendEcho(commands, buildEcho.c_str()); + + // Build a list of compiler flags and linker flags. + std::string flags; + std::string linkFlags; + + // Add flags to deal with shared libraries. Any library being + // linked in might be shared, so always use shared flags for an + // executable. + this->LocalGenerator->AddSharedFlags(linkFlags, linkLanguage, true); + + // Add flags to create an executable. + this->LocalGenerator-> + AddConfigVariableFlags(linkFlags, "CMAKE_EXE_LINKER_FLAGS", + this->LocalGenerator->ConfigurationName.c_str()); + + + if(this->Target->GetPropertyAsBool("WIN32_EXECUTABLE")) + { + this->LocalGenerator->AppendFlags(linkFlags, + this->Makefile->GetDefinition("CMAKE_CREATE_WIN32_EXE")); + } + else + { + this->LocalGenerator->AppendFlags(linkFlags, + this->Makefile->GetDefinition("CMAKE_CREATE_CONSOLE_EXE")); + } + + // Add language-specific flags. + this->LocalGenerator + ->AddLanguageFlags(flags, linkLanguage, + this->LocalGenerator->ConfigurationName.c_str()); + + // Add target-specific linker flags. + this->LocalGenerator->AppendFlags(linkFlags, this->Target->GetProperty("LINK_FLAGS")); + + // Construct a list of files associated with this executable that + // may need to be cleaned. + std::vector exeCleanFiles; + { + std::string cleanName; + std::string cleanRealName; + this->Target->GetExecutableCleanNames(cleanName, cleanRealName, + this->LocalGenerator->ConfigurationName.c_str()); + std::string cleanFullName = outpath + cleanName; + std::string cleanFullRealName = outpath + cleanRealName; + exeCleanFiles.push_back(this->Convert(cleanFullName.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::UNCHANGED)); + if(cleanRealName != cleanName) + { + exeCleanFiles.push_back(this->Convert(cleanFullRealName.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::UNCHANGED)); + } + } + + // Add a command to remove any existing files for this executable. + std::vector commands1; + this->LocalGenerator->AppendCleanCommand(commands1, exeCleanFiles, + *this->Target, "target"); + this->LocalGenerator->CreateCDCommand(commands1, + this->Makefile->GetStartOutputDirectory(), + this->Makefile->GetHomeOutputDirectory()); + commands.insert(commands.end(), commands1.begin(), commands1.end()); + commands1.clear(); + + // Add the pre-build and pre-link rules building but not when relinking. + if(!relink) + { + this->LocalGenerator + ->AppendCustomCommands(commands, this->Target->GetPreBuildCommands()); + this->LocalGenerator + ->AppendCustomCommands(commands, this->Target->GetPreLinkCommands()); + } + + // Construct the main link rule. + std::string linkRuleVar = "CMAKE_"; + linkRuleVar += linkLanguage; + linkRuleVar += "_LINK_EXECUTABLE"; + std::string linkRule = + this->Makefile->GetRequiredDefinition(linkRuleVar.c_str()); + cmSystemTools::ExpandListArgument(linkRule, commands1); + this->LocalGenerator->CreateCDCommand + (commands1, + this->Makefile->GetStartOutputDirectory(), + this->Makefile->GetHomeOutputDirectory()); + commands.insert(commands.end(), commands1.begin(), commands1.end()); + + // Add a rule to create necessary symlinks for the library. + if(targetOutPath != targetOutPathReal) + { + std::string symlink = "$(CMAKE_COMMAND) -E cmake_symlink_executable "; + symlink += targetOutPathReal; + symlink += " "; + symlink += targetOutPath; + commands.push_back(symlink); + } + + // Add the post-build rules when building but not when relinking. + if(!relink) + { + this->LocalGenerator-> + AppendCustomCommands(commands, this->Target->GetPostBuildCommands()); + } + + // Collect up flags to link in needed libraries. + cmOStringStream linklibs; + this->LocalGenerator->OutputLinkLibraries(linklibs, *this->Target, relink); + + // Construct object file lists that may be needed to expand the + // rule. + std::string variableName; + std::string variableNameExternal; + this->WriteObjectsVariable(variableName, variableNameExternal); + std::string buildObjs = "$("; + buildObjs += variableName; + buildObjs += ") $("; + buildObjs += variableNameExternal; + buildObjs += ")"; + std::string cleanObjs = "$("; + cleanObjs += variableName; + cleanObjs += ")"; + + cmLocalGenerator::RuleVariables vars; + vars.Language = linkLanguage; + vars.Objects = buildObjs.c_str(); + vars.Target = targetOutPathReal.c_str(); + std::string linkString = linklibs.str(); + vars.LinkLibraries = linkString.c_str(); + vars.Flags = flags.c_str(); + vars.LinkFlags = linkFlags.c_str(); + // Expand placeholders in the commands. + for(std::vector::iterator i = commands.begin(); + i != commands.end(); ++i) + { + this->LocalGenerator->ExpandRuleVariables(*i, vars); + } + + // Write the build rule. + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, + 0, + targetFullPathReal.c_str(), + depends, commands, false); + + // The symlink name for the target should depend on the real target + // so if the target version changes it rebuilds and recreates the + // symlink. + if(targetFullPath != targetFullPathReal) + { + depends.clear(); + commands.clear(); + depends.push_back(targetFullPathReal.c_str()); + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, + targetFullPath.c_str(), + depends, commands, false); + } + + // Write convenience targets. + std::string dir = this->Makefile->GetStartOutputDirectory(); + dir += "/"; + dir += this->LocalGenerator->GetTargetDirectory(*this->Target); + std::string buildTargetRuleName = dir; + buildTargetRuleName += relink?"/preinstall":"/build"; + buildTargetRuleName = + this->Convert(buildTargetRuleName.c_str(), + cmLocalGenerator::HOME_OUTPUT, + cmLocalGenerator::MAKEFILE); + this->LocalGenerator->WriteConvenienceRule(*this->BuildFileStream, + targetFullPath.c_str(), + buildTargetRuleName.c_str()); + + // Clean all the possible executable names and symlinks and object files. + this->CleanFiles.insert(this->CleanFiles.end(), + exeCleanFiles.begin(), + exeCleanFiles.end()); + this->CleanFiles.insert(this->CleanFiles.end(), + this->Objects.begin(), + this->Objects.end()); +} + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMakefileExecutableTargetGenerator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMakefileExecutableTargetGenerator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMakefileExecutableTargetGenerator.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMakefileExecutableTargetGenerator.h 2006-02-17 04:19:00.000000000 +0800 @@ -0,0 +1,34 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmMakefileExecutableTargetGenerator.h,v $ + Language: C++ + Date: $Date: 2006/02/16 20:19:00 $ + Version: $Revision: 1.2 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef cmMakefileExecutableTargetGenerator_h +#define cmMakefileExecutableTargetGenerator_h + +#include "cmMakefileTargetGenerator.h" + +class cmMakefileExecutableTargetGenerator: public cmMakefileTargetGenerator +{ +public: + /* the main entry point for this class. Writes the Makefiles associated + with this target */ + virtual void WriteRuleFiles(); + +protected: + virtual void WriteExecutableRule(bool relink); + +}; + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMakefile.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMakefile.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMakefile.h 2005-08-12 02:02:20.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMakefile.h 2006-03-16 23:53:14.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmMakefile.h,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:20 $ - Version: $Revision: 1.168.2.1 $ + Date: $Date: 2006/03/16 15:53:14 $ + Version: $Revision: 1.179 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -28,6 +28,7 @@ class cmFunctionBlocker; class cmCommand; +class cmInstallGenerator; class cmLocalGenerator; class cmMakeDepend; class cmSourceFile; @@ -80,9 +81,9 @@ * Add a function blocker to this makefile */ void AddFunctionBlocker(cmFunctionBlocker *fb) - { m_FunctionBlockers.push_back(fb);} + { this->FunctionBlockers.push_back(fb);} void RemoveFunctionBlocker(cmFunctionBlocker *fb) - { m_FunctionBlockers.remove(fb);} + { this->FunctionBlockers.remove(fb);} void RemoveFunctionBlocker(const cmListFileFunction& lff); /** @@ -115,7 +116,7 @@ ///! Get the current makefile generator. cmLocalGenerator* GetLocalGenerator() - { return m_LocalGenerator;} + { return this->LocalGenerator;} /** * Perform FinalPass, Library dependency analysis etc before output of the @@ -138,12 +139,12 @@ const std::vector& depends, const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type, - const char* comment); + const char* comment, const char* workingDir); void AddCustomCommandToOutput(const char* output, const std::vector& depends, const char* main_dependency, const cmCustomCommandLines& commandLines, - const char* comment, + const char* comment, const char* workingDir, bool replace = false); void AddCustomCommandOldStyle(const char* target, const std::vector& outputs, @@ -171,6 +172,7 @@ void AddUtilityCommand(const char* utilityName, bool all, const char* output, const std::vector& depends, + const char* workingDirectory, const char* command, const char* arg1=0, const char* arg2=0, @@ -178,6 +180,7 @@ const char* arg4=0); void AddUtilityCommand(const char* utilityName, bool all, const char* output, + const char* workingDirectory, const std::vector& depends, const cmCustomCommandLines& commandLines); @@ -200,21 +203,22 @@ */ std::vector& GetLinkDirectories() { - return m_LinkDirectories; + return this->LinkDirectories; } const std::vector& GetLinkDirectories() const { - return m_LinkDirectories; + return this->LinkDirectories; } void SetLinkDirectories(const std::vector& vec) { - m_LinkDirectories = vec; + this->LinkDirectories = vec; } /** * Add a subdirectory to the build. */ - void AddSubDirectory(const char*, bool includeTopLevel=true, bool preorder = false); + void AddSubDirectory(const char*, bool includeTopLevel=true, + bool preorder = false); void AddSubDirectory(const char* fullSrcDir,const char *fullBinDir, bool includeTopLevel, bool preorder, bool immediate); @@ -230,12 +234,6 @@ void AddIncludeDirectory(const char*, bool before = false); /** - * Find a library (as in cmSystemTools) but add in compiler specific paths - */ - std::string FindLibrary(const char* name, - const std::vector& path); - - /** * Add a variable definition to the build. This variable * can be used in CMake to refer to lists, directories, etc. */ @@ -268,7 +266,7 @@ */ const char* GetProjectName() { - return m_ProjectName.c_str(); + return this->ProjectName.c_str(); } /** @@ -280,7 +278,8 @@ /** * Add a source group for consideration when adding a new source. */ - void AddSourceGroup(const char* name, const char* regex=0, const char* parent=0); + void AddSourceGroup(const char* name, const char* regex=0, + const char* parent=0); /** * Add an auxiliary directory to the build. @@ -294,9 +293,9 @@ void MakeStartDirectoriesCurrent() { this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", - m_cmStartDirectory.c_str()); + this->cmStartDirectory.c_str()); this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", - m_StartOutputDirectory.c_str()); + this->StartOutputDirectory.c_str()); } //@{ @@ -310,12 +309,12 @@ void SetHomeDirectory(const char* dir); const char* GetHomeDirectory() const { - return m_cmHomeDirectory.c_str(); + return this->cmHomeDirectory.c_str(); } void SetHomeOutputDirectory(const char* lib); const char* GetHomeOutputDirectory() const { - return m_HomeOutputDirectory.c_str(); + return this->HomeOutputDirectory.c_str(); } //@} @@ -329,36 +328,36 @@ */ void SetStartDirectory(const char* dir) { - m_cmStartDirectory = dir; - cmSystemTools::ConvertToUnixSlashes(m_cmStartDirectory); + this->cmStartDirectory = dir; + cmSystemTools::ConvertToUnixSlashes(this->cmStartDirectory); this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", - m_cmStartDirectory.c_str()); + this->cmStartDirectory.c_str()); } const char* GetStartDirectory() const { - return m_cmStartDirectory.c_str(); + return this->cmStartDirectory.c_str(); } void SetStartOutputDirectory(const char* lib) { - m_StartOutputDirectory = lib; - cmSystemTools::ConvertToUnixSlashes(m_StartOutputDirectory); - cmSystemTools::MakeDirectory(m_StartOutputDirectory.c_str()); + this->StartOutputDirectory = lib; + cmSystemTools::ConvertToUnixSlashes(this->StartOutputDirectory); + cmSystemTools::MakeDirectory(this->StartOutputDirectory.c_str()); this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", - m_StartOutputDirectory.c_str()); + this->StartOutputDirectory.c_str()); } const char* GetStartOutputDirectory() const { - return m_StartOutputDirectory.c_str(); + return this->StartOutputDirectory.c_str(); } //@} const char* GetCurrentDirectory() const { - return m_cmStartDirectory.c_str(); + return this->cmStartDirectory.c_str(); } const char* GetCurrentOutputDirectory() const { - return m_StartOutputDirectory.c_str(); + return this->StartOutputDirectory.c_str(); } /* Get the current CMakeLists.txt file that is being processed. This @@ -366,7 +365,7 @@ * transparently */ const char* GetCurrentListFile() const { - return m_cmCurrentListFile.c_str(); + return this->cmCurrentListFile.c_str(); } //@} @@ -377,11 +376,11 @@ */ void SetIncludeRegularExpression(const char* regex) { - m_IncludeFileRegularExpression = regex; + this->IncludeFileRegularExpression = regex; } const char* GetIncludeRegularExpression() { - return m_IncludeFileRegularExpression.c_str(); + return this->IncludeFileRegularExpression.c_str(); } /** @@ -390,17 +389,17 @@ */ void SetComplainRegularExpression(const char* regex) { - m_ComplainFileRegularExpression = regex; + this->ComplainFileRegularExpression = regex; } const char* GetComplainRegularExpression() { - return m_ComplainFileRegularExpression.c_str(); + return this->ComplainFileRegularExpression.c_str(); } /** * Get the list of targets */ - cmTargets &GetTargets() { return m_Targets; } + cmTargets &GetTargets() { return this->Targets; } cmTarget* FindTarget(const char* name); @@ -409,15 +408,15 @@ */ std::vector& GetIncludeDirectories() { - return m_IncludeDirectories; + return this->IncludeDirectories; } const std::vector& GetIncludeDirectories() const { - return m_IncludeDirectories; + return this->IncludeDirectories; } void SetIncludeDirectories(const std::vector& vec) { - m_IncludeDirectories = vec; + this->IncludeDirectories = vec; } /** Expand out any arguements in the vector that have ; separated @@ -450,7 +449,7 @@ * Obtain a list of auxiliary source directories. */ std::vector& GetAuxSourceDirectories() - {return m_AuxSourceDirectories;} + {return this->AuxSourceDirectories;} //@{ /** @@ -458,9 +457,9 @@ * files */ const std::vector& GetSourceExtensions() const - {return m_SourceFileExtensions;} + {return this->SourceFileExtensions;} const std::vector& GetHeaderExtensions() const - {return m_HeaderFileExtensions;} + {return this->HeaderFileExtensions;} //@} /** @@ -488,19 +487,19 @@ * Get a list of preprocessor define flags. */ const char* GetDefineFlags() - {return m_DefineFlags.c_str();} + {return this->DefineFlags.c_str();} /** * Get the vector of used command instances. */ const std::vector& GetUsedCommands() const - {return m_UsedCommands;} + {return this->UsedCommands;} /** * Get the vector source groups. */ const std::vector& GetSourceGroups() const - { return m_SourceGroups; } + { return this->SourceGroups; } /** * Get the source group @@ -511,17 +510,17 @@ * Get the vector of list files on which this makefile depends */ const std::vector& GetListFiles() const - { return m_ListFiles; } + { return this->ListFiles; } ///! When the file changes cmake will be re-run from the build system. void AddCMakeDependFile(const char* file) - { m_ListFiles.push_back(file);} + { this->ListFiles.push_back(file);} /** * Expand all defined variables in the string. - * Defined variables come from the m_Definitions map. + * Defined variables come from the this->Definitions map. * They are expanded with ${var} where var is the - * entry in the m_Definitions map. Also @var@ is + * entry in the this->Definitions map. Also @var@ is * expanded to match autoconf style expansions. */ const char *ExpandVariablesInString(std::string& source) const; @@ -579,7 +578,7 @@ */ void AddCommand(cmCommand* ); - ///! Enable support for the named language, if null then all languages are enabled. + ///! Enable support for named language, if nil then all languages are enabled. void EnableLanguage(std::vectorconst& languages); /** @@ -614,8 +613,8 @@ * Get all the source files this makefile knows about */ const std::vector &GetSourceFiles() const - {return m_SourceFiles;} - std::vector &GetSourceFiles() {return m_SourceFiles;} + {return this->SourceFiles;} + std::vector &GetSourceFiles() {return this->SourceFiles;} /** * Is there a source file that has the provided source file as an output? @@ -661,73 +660,83 @@ ///! Set/Get the preorder flag void SetPreOrder(bool p) { this->PreOrder = p; } bool GetPreOrder() { return this->PreOrder; } - + + void AddInstallGenerator(cmInstallGenerator* g) + { this->InstallGenerators.push_back(g); } + std::vector& GetInstallGenerators() + { return this->InstallGenerators; } protected: // add link libraries and directories to the target void AddGlobalLinkInformation(const char* name, cmTarget& target); - std::string m_Prefix; - std::vector m_AuxSourceDirectories; // + std::string Prefix; + std::vector AuxSourceDirectories; // - std::string m_cmStartDirectory; - std::string m_StartOutputDirectory; - std::string m_cmHomeDirectory; - std::string m_HomeOutputDirectory; - std::string m_cmCurrentListFile; + std::string cmStartDirectory; + std::string StartOutputDirectory; + std::string cmHomeDirectory; + std::string HomeOutputDirectory; + std::string cmCurrentListFile; - std::string m_ProjectName; // project name + std::string ProjectName; // project name // libraries, classes, and executables - cmTargets m_Targets; - std::vector m_SourceFiles; + cmTargets Targets; + std::vector SourceFiles; // Tests - std::vector m_Tests; + std::vector Tests; // The include and link-library paths. These may have order // dependency, so they must be vectors (not set). - std::vector m_IncludeDirectories; - std::vector m_LinkDirectories; + std::vector IncludeDirectories; + std::vector LinkDirectories; - std::vector m_ListFiles; // list of command files loaded + std::vector ListFiles; // list of command files loaded - cmTarget::LinkLibraries m_LinkLibraries; + cmTarget::LinkLibraryVectorType LinkLibraries; - std::string m_IncludeFileRegularExpression; - std::string m_ComplainFileRegularExpression; - std::vector m_SourceFileExtensions; - std::vector m_HeaderFileExtensions; - std::string m_DefineFlags; - std::vector m_SourceGroups; - DefinitionMap m_Definitions; - std::vector m_UsedCommands; - cmLocalGenerator* m_LocalGenerator; + std::vector InstallGenerators; + + std::string IncludeFileRegularExpression; + std::string ComplainFileRegularExpression; + std::vector SourceFileExtensions; + std::vector HeaderFileExtensions; + std::string DefineFlags; + std::vector SourceGroups; + DefinitionMap Definitions; + std::vector UsedCommands; + cmLocalGenerator* LocalGenerator; bool IsFunctionBlocked(const cmListFileFunction& lff); private: void ReadSources(std::ifstream& fin, bool t); - friend class cmMakeDepend; // make depend needs direct access - // to the m_Sources array - void PrintStringVector(const char* s, const std::vector >& v) const; - void PrintStringVector(const char* s, const std::vector& v) const; + friend class cmMakeDepend; // make depend needs direct access + // to the Sources array + void PrintStringVector(const char* s, const + std::vector >& v) const; + void PrintStringVector(const char* s, + const std::vector& v) const; + void AddDefaultDefinitions(); - std::list m_FunctionBlockers; + std::list FunctionBlockers; - typedef std::map DataMap; - DataMap m_DataMap; + typedef std::map DataMapType; + DataMapType DataMap; typedef std::map StringStringMap; - StringStringMap m_MacrosMap; + StringStringMap MacrosMap; - std::map m_SubDirectoryOrder; + std::map SubDirectoryOrder; // used in AddDefinition for performance improvement - DefinitionMap::key_type m_TemporaryDefinitionKey; + DefinitionMap::key_type TemporaryDefinitionKey; - cmsys::RegularExpression m_cmDefineRegex; + cmsys::RegularExpression cmDefineRegex; + cmsys::RegularExpression cmDefine01Regex; - std::map m_Properties; + std::map Properties; // should this makefile be processed before or after processing the parent bool PreOrder; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMakefileLibraryTargetGenerator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMakefileLibraryTargetGenerator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMakefileLibraryTargetGenerator.cxx 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMakefileLibraryTargetGenerator.cxx 2006-03-16 00:02:06.000000000 +0800 @@ -0,0 +1,510 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmMakefileLibraryTargetGenerator.cxx,v $ + Language: C++ + Date: $Date: 2006/03/15 16:02:06 $ + Version: $Revision: 1.11 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "cmMakefileLibraryTargetGenerator.h" + +#include "cmGeneratedFileStream.h" +#include "cmGlobalGenerator.h" +#include "cmLocalUnixMakefileGenerator3.h" +#include "cmMakefile.h" +#include "cmSourceFile.h" +#include "cmTarget.h" + +//---------------------------------------------------------------------------- +void cmMakefileLibraryTargetGenerator::WriteRuleFiles() +{ + // create the build.make file and directory, put in the common blocks + this->CreateRuleFile(); + + // Add in any rules for custom commands + this->WriteCustomCommandsForTarget(); + + // write in rules for object files + this->WriteCommonCodeRules(); + + // Write the dependency generation rule. + this->WriteTargetDependRules(); + + // write the link rules + // Write the rule for this target type. + switch(this->Target->GetType()) + { + case cmTarget::STATIC_LIBRARY: + this->WriteStaticLibraryRules(); + break; + case cmTarget::SHARED_LIBRARY: + this->WriteSharedLibraryRules(false); + if(this->Target->NeedRelinkBeforeInstall()) + { + // Write rules to link an installable version of the target. + this->WriteSharedLibraryRules(true); + } + break; + case cmTarget::MODULE_LIBRARY: + this->WriteModuleLibraryRules(false); + if(this->Target->NeedRelinkBeforeInstall()) + { + // Write rules to link an installable version of the target. + this->WriteModuleLibraryRules(true); + } + break; + default: + // If language is not known, this is an error. + cmSystemTools::Error("Unknown Library Type"); + break; + } + + // Write the requires target. + this->WriteTargetRequiresRules(); + + // Write clean target + this->WriteTargetCleanRules(); + + // close the streams + this->CloseFileStreams(); +} + + +//---------------------------------------------------------------------------- +void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules() +{ + const char* linkLanguage = + this->Target->GetLinkerLanguage(this->GlobalGenerator); + std::string linkRuleVar = "CMAKE_"; + if (linkLanguage) + { + linkRuleVar += linkLanguage; + } + linkRuleVar += "_CREATE_STATIC_LIBRARY"; + + std::string extraFlags; + this->LocalGenerator->AppendFlags(extraFlags, this->Target->GetProperty("STATIC_LIBRARY_FLAGS")); + this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), false); +} + +//---------------------------------------------------------------------------- +void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) +{ + const char* linkLanguage = + this->Target->GetLinkerLanguage(this->GlobalGenerator); + std::string linkRuleVar = "CMAKE_"; + if (linkLanguage) + { + linkRuleVar += linkLanguage; + } + linkRuleVar += "_CREATE_SHARED_LIBRARY"; + + std::string extraFlags; + this->LocalGenerator->AppendFlags(extraFlags, this->Target->GetProperty("LINK_FLAGS")); + this->LocalGenerator->AddConfigVariableFlags(extraFlags, "CMAKE_SHARED_LINKER_FLAGS", + this->LocalGenerator->ConfigurationName.c_str()); + if(this->Makefile->IsOn("WIN32") && !(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW"))) + { + const std::vector& sources = this->Target->GetSourceFiles(); + for(std::vector::const_iterator i = sources.begin(); + i != sources.end(); ++i) + { + if((*i)->GetSourceExtension() == "def") + { + extraFlags += " "; + extraFlags += this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG"); + extraFlags += + this->Convert((*i)->GetFullPath().c_str(),cmLocalGenerator::START_OUTPUT,cmLocalGenerator::MAKEFILE); + } + } + } + this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink); +} + +//---------------------------------------------------------------------------- +void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) +{ + const char* linkLanguage = + this->Target->GetLinkerLanguage(this->GlobalGenerator); + std::string linkRuleVar = "CMAKE_"; + if (linkLanguage) + { + linkRuleVar += linkLanguage; + } + linkRuleVar += "_CREATE_SHARED_MODULE"; + + std::string extraFlags; + this->LocalGenerator->AppendFlags(extraFlags, this->Target->GetProperty("LINK_FLAGS")); + this->LocalGenerator->AddConfigVariableFlags(extraFlags, "CMAKE_MODULE_LINKER_FLAGS", + this->LocalGenerator->ConfigurationName.c_str()); + // TODO: .def files should be supported here also. + this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink); +} + +//---------------------------------------------------------------------------- +void cmMakefileLibraryTargetGenerator::WriteLibraryRules +(const char* linkRuleVar, const char* extraFlags, bool relink) +{ + // TODO: Merge the methods that call this method to avoid + // code duplication. + std::vector commands; + + std::string relPath = this->LocalGenerator->GetHomeRelativeOutputPath(); + std::string objTarget; + + // Build list of dependencies. + std::vector depends; + for(std::vector::const_iterator obj = this->Objects.begin(); + obj != this->Objects.end(); ++obj) + { + objTarget = relPath; + objTarget += *obj; + depends.push_back(objTarget); + } + + // Add dependencies on targets that must be built first. + this->AppendTargetDepends(depends); + + // Add a dependency on the rule file itself. + this->LocalGenerator->AppendRuleDepend(depends, + this->BuildFileNameFull.c_str()); + + for(std::vector::const_iterator obj + = this->ExternalObjects.begin(); + obj != this->ExternalObjects.end(); ++obj) + { + depends.push_back(*obj); + } + + // Get the language to use for linking this library. + const char* linkLanguage = + this->Target->GetLinkerLanguage(this->GlobalGenerator); + + // Make sure we have a link language. + if(!linkLanguage) + { + cmSystemTools::Error("Cannot determine link language for target \"", + this->Target->GetName(), "\"."); + return; + } + + // Create set of linking flags. + std::string linkFlags; + this->LocalGenerator->AppendFlags(linkFlags, extraFlags); + + // Construct the name of the library. + std::string targetName; + std::string targetNameSO; + std::string targetNameReal; + std::string targetNameImport; + this->Target->GetLibraryNames( + targetName, targetNameSO, targetNameReal, targetNameImport, + this->LocalGenerator->ConfigurationName.c_str()); + + // Construct the full path version of the names. + std::string outpath = this->LocalGenerator->LibraryOutputPath; + if(outpath.length() == 0) + { + outpath = this->Makefile->GetStartOutputDirectory(); + outpath += "/"; + } + if(relink) + { + outpath = this->Makefile->GetStartOutputDirectory(); + outpath += "/CMakeFiles/CMakeRelink.dir"; + cmSystemTools::MakeDirectory(outpath.c_str()); + outpath += "/"; + } + std::string targetFullPath = outpath + targetName; + std::string targetFullPathSO = outpath + targetNameSO; + std::string targetFullPathReal = outpath + targetNameReal; + std::string targetFullPathImport = outpath + targetNameImport; + + // Construct the output path version of the names for use in command + // arguments. + std::string targetOutPath = + this->Convert(targetFullPath.c_str(),cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::MAKEFILE); + std::string targetOutPathSO = + this->Convert(targetFullPathSO.c_str(),cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::MAKEFILE); + std::string targetOutPathReal = + this->Convert(targetFullPathReal.c_str(),cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::MAKEFILE); + std::string targetOutPathImport = + this->Convert(targetFullPathImport.c_str(),cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::MAKEFILE); + + // Add the link message. + std::string buildEcho = "Linking "; + buildEcho += linkLanguage; + const char* forbiddenFlagVar = 0; + switch(this->Target->GetType()) + { + case cmTarget::STATIC_LIBRARY: + buildEcho += " static library "; + break; + case cmTarget::SHARED_LIBRARY: + forbiddenFlagVar = "_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS"; + buildEcho += " shared library "; + break; + case cmTarget::MODULE_LIBRARY: + forbiddenFlagVar = "_CREATE_SHARED_MODULE_FORBIDDEN_FLAGS"; + buildEcho += " shared module "; + break; + default: + buildEcho += " library "; + break; + } + buildEcho += targetOutPath.c_str(); + this->LocalGenerator->AppendEcho(commands, buildEcho.c_str()); + + // Construct a list of files associated with this library that may + // need to be cleaned. + std::vector libCleanFiles; + { + std::string cleanStaticName; + std::string cleanSharedName; + std::string cleanSharedSOName; + std::string cleanSharedRealName; + std::string cleanImportName; + this->Target->GetLibraryCleanNames( + cleanStaticName, + cleanSharedName, + cleanSharedSOName, + cleanSharedRealName, + cleanImportName, + this->LocalGenerator->ConfigurationName.c_str()); + std::string cleanFullStaticName = outpath + cleanStaticName; + std::string cleanFullSharedName = outpath + cleanSharedName; + std::string cleanFullSharedSOName = outpath + cleanSharedSOName; + std::string cleanFullSharedRealName = outpath + cleanSharedRealName; + std::string cleanFullImportName = outpath + cleanImportName; + libCleanFiles.push_back + (this->Convert(cleanFullStaticName.c_str(),cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::UNCHANGED)); + if(cleanSharedRealName != cleanStaticName) + { + libCleanFiles.push_back(this->Convert(cleanFullSharedRealName.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::UNCHANGED)); + } + if(cleanSharedSOName != cleanStaticName && + cleanSharedSOName != cleanSharedRealName) + { + libCleanFiles.push_back(this->Convert(cleanFullSharedSOName.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::UNCHANGED)); + } + if(cleanSharedName != cleanStaticName && + cleanSharedName != cleanSharedSOName && + cleanSharedName != cleanSharedRealName) + { + libCleanFiles.push_back(this->Convert(cleanFullSharedName.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::UNCHANGED)); + } + if(!cleanImportName.empty() && + cleanImportName != cleanStaticName && + cleanImportName != cleanSharedSOName && + cleanImportName != cleanSharedRealName && + cleanImportName != cleanSharedName) + { + libCleanFiles.push_back(this->Convert(cleanFullImportName.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::UNCHANGED)); + } + } + // Add a command to remove any existing files for this library. + std::vector commands1; + this->LocalGenerator->AppendCleanCommand(commands1, libCleanFiles, + *this->Target, "target"); + this->LocalGenerator->CreateCDCommand(commands1, + this->Makefile->GetStartOutputDirectory(), + this->Makefile->GetHomeOutputDirectory()); + commands.insert(commands.end(), commands1.begin(), commands1.end()); + commands1.clear(); + + // Add the pre-build and pre-link rules building but not when relinking. + if(!relink) + { + this->LocalGenerator + ->AppendCustomCommands(commands, this->Target->GetPreBuildCommands()); + this->LocalGenerator + ->AppendCustomCommands(commands, this->Target->GetPreLinkCommands()); + } + + // Construct the main link rule. + std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar); + cmSystemTools::ExpandListArgument(linkRule, commands1); + this->LocalGenerator->CreateCDCommand(commands1, + this->Makefile->GetStartOutputDirectory(), + this->Makefile->GetHomeOutputDirectory()); + commands.insert(commands.end(), commands1.begin(), commands1.end()); + + // Add a rule to create necessary symlinks for the library. + if(targetOutPath != targetOutPathReal) + { + std::string symlink = "$(CMAKE_COMMAND) -E cmake_symlink_library "; + symlink += targetOutPathReal; + symlink += " "; + symlink += targetOutPathSO; + symlink += " "; + symlink += targetOutPath; + commands1.clear(); + commands1.push_back(symlink); + this->LocalGenerator->CreateCDCommand(commands1, + this->Makefile->GetStartOutputDirectory(), + this->Makefile->GetHomeOutputDirectory()); + commands.insert(commands.end(), commands1.begin(), commands1.end()); + } + + // Add the post-build rules when building but not when relinking. + if(!relink) + { + this->LocalGenerator-> + AppendCustomCommands(commands, this->Target->GetPostBuildCommands()); + } + + // Collect up flags to link in needed libraries. + cmOStringStream linklibs; + this->LocalGenerator->OutputLinkLibraries(linklibs, *this->Target, relink); + + // Construct object file lists that may be needed to expand the + // rule. + std::string variableName; + std::string variableNameExternal; + this->WriteObjectsVariable(variableName, variableNameExternal); + std::string buildObjs = "$("; + buildObjs += variableName; + buildObjs += ") $("; + buildObjs += variableNameExternal; + buildObjs += ")"; + std::string cleanObjs = "$("; + cleanObjs += variableName; + cleanObjs += ")"; + cmLocalGenerator::RuleVariables vars; + vars.Language = linkLanguage; + vars.Objects = buildObjs.c_str(); + vars.Target = targetOutPathReal.c_str(); + std::string linkString = linklibs.str(); + vars.LinkLibraries = linkString.c_str(); + vars.ObjectsQuoted = buildObjs.c_str(); + vars.TargetSOName= targetNameSO.c_str(); + vars.LinkFlags = linkFlags.c_str(); + + // Compute the directory portion of the install_name setting. + std::string install_name_dir; + if(this->Target->GetType() == cmTarget::SHARED_LIBRARY) + { + // Select whether to generate an install_name directory for the + // install tree or the build tree. + const char* config = this->LocalGenerator->ConfigurationName.c_str(); + if(this->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + install_name_dir = + this->Target->GetInstallNameDirForInstallTree(config); + } + else + { + install_name_dir = + this->Target->GetInstallNameDirForBuildTree(config); + } + + // Set the rule variable replacement value. + if(install_name_dir.empty()) + { + vars.TargetInstallNameDir = ""; + } + else + { + // Convert to a path for the native build tool. + install_name_dir = + this->LocalGenerator->Convert(install_name_dir.c_str(), + cmLocalGenerator::FULL, + cmLocalGenerator::SHELL, false); + + // The Convert method seems to strip trailing slashes, which should + // probably be fixed. Since the only platform supporting install_name + // right now uses forward slashes just add one. + install_name_dir += "/"; + vars.TargetInstallNameDir = install_name_dir.c_str(); + } + } + std::string langFlags; + this->LocalGenerator + ->AddLanguageFlags(langFlags, linkLanguage, + this->LocalGenerator->ConfigurationName.c_str()); + // remove any language flags that might not work with the + // particular os + if(forbiddenFlagVar) + { + this->RemoveForbiddenFlags(forbiddenFlagVar, + linkLanguage, langFlags); + } + vars.LanguageCompileFlags = langFlags.c_str(); + // Expand placeholders in the commands. + this->LocalGenerator->TargetImplib = targetOutPathImport; + for(std::vector::iterator i = commands.begin(); + i != commands.end(); ++i) + { + this->LocalGenerator->ExpandRuleVariables(*i, vars); + } + this->LocalGenerator->TargetImplib = ""; + + // Write the build rule. + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, + targetFullPathReal.c_str(), + depends, commands, false); + + // The symlink names for the target should depend on the real target + // so if the target version changes it rebuilds and recreates the + // symlinks. + if(targetFullPathSO != targetFullPathReal) + { + depends.clear(); + commands.clear(); + depends.push_back(targetFullPathReal.c_str()); + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, + targetFullPathSO.c_str(), + depends, commands, false); + } + if(targetFullPath != targetFullPathSO) + { + depends.clear(); + commands.clear(); + depends.push_back(targetFullPathSO.c_str()); + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, + targetFullPath.c_str(), + depends, commands, false); + } + + // Write convenience targets. + std::string dir = this->Makefile->GetStartOutputDirectory(); + dir += "/"; + dir += this->LocalGenerator->GetTargetDirectory(*this->Target); + std::string buildTargetRuleName = dir; + buildTargetRuleName += relink?"/preinstall":"/build"; + buildTargetRuleName = + this->Convert(buildTargetRuleName.c_str(), + cmLocalGenerator::HOME_OUTPUT,cmLocalGenerator::MAKEFILE); + this->LocalGenerator->WriteConvenienceRule(*this->BuildFileStream, + targetFullPath.c_str(), + buildTargetRuleName.c_str()); + + // Clean all the possible library names and symlinks and object files. + this->CleanFiles.insert(this->CleanFiles.end(), + libCleanFiles.begin(),libCleanFiles.end()); + this->CleanFiles.insert(this->CleanFiles.end(), + this->Objects.begin(), + this->Objects.end()); +} + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMakefileLibraryTargetGenerator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMakefileLibraryTargetGenerator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMakefileLibraryTargetGenerator.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMakefileLibraryTargetGenerator.h 2006-02-17 04:19:00.000000000 +0800 @@ -0,0 +1,38 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmMakefileLibraryTargetGenerator.h,v $ + Language: C++ + Date: $Date: 2006/02/16 20:19:00 $ + Version: $Revision: 1.2 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef cmMakefileLibraryTargetGenerator_h +#define cmMakefileLibraryTargetGenerator_h + +#include "cmMakefileTargetGenerator.h" + +class cmMakefileLibraryTargetGenerator: + public cmMakefileTargetGenerator +{ +public: + /* the main entry point for this class. Writes the Makefiles associated + with this target */ + virtual void WriteRuleFiles(); + +protected: + void WriteStaticLibraryRules(); + void WriteSharedLibraryRules(bool relink); + void WriteModuleLibraryRules(bool relink); + void WriteLibraryRules(const char *linkRule, const char *extraFlags, + bool relink); +}; + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMakefileTargetGenerator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMakefileTargetGenerator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMakefileTargetGenerator.cxx 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMakefileTargetGenerator.cxx 2006-03-16 00:02:06.000000000 +0800 @@ -0,0 +1,824 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmMakefileTargetGenerator.cxx,v $ + Language: C++ + Date: $Date: 2006/03/15 16:02:06 $ + Version: $Revision: 1.11 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "cmMakefileTargetGenerator.h" + +#include "cmGeneratedFileStream.h" +#include "cmGlobalGenerator.h" +#include "cmLocalUnixMakefileGenerator3.h" +#include "cmMakefile.h" +#include "cmSourceFile.h" +#include "cmTarget.h" + +#include "cmMakefileExecutableTargetGenerator.h" +#include "cmMakefileLibraryTargetGenerator.h" +#include "cmMakefileUtilityTargetGenerator.h" + + +cmMakefileTargetGenerator::cmMakefileTargetGenerator() +{ + this->BuildFileStream = 0; + this->InfoFileStream = 0; + this->FlagFileStream = 0; +} + +cmMakefileTargetGenerator * +cmMakefileTargetGenerator::New(cmLocalUnixMakefileGenerator3 *lg, + cmStdString tgtName, cmTarget *tgt) +{ + cmMakefileTargetGenerator *result = 0; + + switch (tgt->GetType()) + { + case cmTarget::EXECUTABLE: + result = new cmMakefileExecutableTargetGenerator; + break; + case cmTarget::STATIC_LIBRARY: + case cmTarget::SHARED_LIBRARY: + case cmTarget::MODULE_LIBRARY: + result = new cmMakefileLibraryTargetGenerator; + break; + case cmTarget::UTILITY: + result = new cmMakefileUtilityTargetGenerator; + break; + default: + return result; + break; + } + + result->TargetName = tgtName; + result->Target = tgt; + result->LocalGenerator = lg; + result->GlobalGenerator = lg->GetGlobalGenerator(); + result->Makefile = lg->GetMakefile(); + return result; +} + +//---------------------------------------------------------------------------- +void cmMakefileTargetGenerator::CreateRuleFile() +{ + // Create a directory for this target. + this->TargetBuildDirectory = + this->LocalGenerator->GetTargetDirectory(*this->Target); + this->TargetBuildDirectoryFull = + this->LocalGenerator->ConvertToFullPath(this->TargetBuildDirectory); + cmSystemTools::MakeDirectory(this->TargetBuildDirectoryFull.c_str()); + + // Construct the rule file name. + this->BuildFileName = this->TargetBuildDirectory; + this->BuildFileName += "/build.make"; + this->BuildFileNameFull = this->TargetBuildDirectoryFull; + this->BuildFileNameFull += "/build.make"; + + // Open the rule file. This should be copy-if-different because the + // rules may depend on this file itself. + this->BuildFileStream = + new cmGeneratedFileStream(this->BuildFileNameFull.c_str()); + this->BuildFileStream->SetCopyIfDifferent(true); + if(!this->BuildFileStream) + { + return; + } + this->LocalGenerator->WriteDisclaimer(*this->BuildFileStream); + this->LocalGenerator->WriteSpecialTargetsTop(*this->BuildFileStream); + this->LocalGenerator->WriteMakeVariables(*this->BuildFileStream); +} + +//---------------------------------------------------------------------------- +void cmMakefileTargetGenerator::WriteCustomCommandsForTarget() +{ + // write the custom commands for this target + // Look for files registered for cleaning in this directory. + if(const char* additional_clean_files = + this->Makefile->GetProperty + ("ADDITIONAL_MAKE_CLEAN_FILES")) + { + cmSystemTools::ExpandListArgument(additional_clean_files, + this->CleanFiles); + } + this->WriteCustomCommands(); +} + + +//---------------------------------------------------------------------------- +void cmMakefileTargetGenerator::WriteCommonCodeRules() +{ + // Include the dependencies for the target. + std::string dependFileNameFull = this->TargetBuildDirectoryFull; + dependFileNameFull += "/depend.make"; + *this->BuildFileStream + << "# Include any dependencies generated for this target.\n" + << this->LocalGenerator->IncludeDirective << " " + << this->Convert(dependFileNameFull.c_str(), + cmLocalGenerator::HOME_OUTPUT, + cmLocalGenerator::MAKEFILE) + << "\n\n"; + + // make sure the depend file exists + if (!cmSystemTools::FileExists(dependFileNameFull.c_str())) + { + // Write an empty dependency file. + cmGeneratedFileStream depFileStream(dependFileNameFull.c_str()); + depFileStream + << "# Empty dependencies file for " << this->Target->GetName() << ".\n" + << "# This may be replaced when dependencies are built." << std::endl; + } + + // Open the flags file. This should be copy-if-different because the + // rules may depend on this file itself. + this->FlagFileNameFull = this->TargetBuildDirectoryFull; + this->FlagFileNameFull += "/flags.make"; + this->FlagFileStream = + new cmGeneratedFileStream(this->FlagFileNameFull.c_str()); + this->FlagFileStream->SetCopyIfDifferent(true); + if(!this->FlagFileStream) + { + return; + } + this->LocalGenerator->WriteDisclaimer(*this->FlagFileStream); + + // Include the flags for the target. + *this->BuildFileStream + << "# Include the compile flags for this target's objects.\n" + << this->LocalGenerator->IncludeDirective << " " + << this->Convert(this->FlagFileNameFull.c_str(), + cmLocalGenerator::HOME_OUTPUT, + cmLocalGenerator::MAKEFILE) + << "\n\n"; + + // First generate the object rule files. Save a list of all object + // files for this target. + const std::vector& sources = this->Target->GetSourceFiles(); + for(std::vector::const_iterator source = sources.begin(); + source != sources.end(); ++source) + { + if(!(*source)->GetPropertyAsBool("HEADER_FILE_ONLY") && + !(*source)->GetCustomCommand()) + { + if(!this->GlobalGenerator->IgnoreFile + ((*source)->GetSourceExtension().c_str())) + { + // Generate this object file's rule file. + this->WriteObjectRuleFiles(*(*source)); + } + else if((*source)->GetPropertyAsBool("EXTERNAL_OBJECT")) + { + // This is an external object file. Just add it. + this->ExternalObjects.push_back((*source)->GetFullPath()); + } + else + { + // We only get here if a source file is not an external object + // and has an extension that is listed as an ignored file type + // for this language. No message or diagnosis should be + // given. + } + } + } + + // write language flags for target + std::map& + checkSet = + this->LocalGenerator->GetIntegrityCheckSet()[this->Target->GetName()]; + for(std::map::const_iterator + l = checkSet.begin(); l != checkSet.end(); ++l) + { + const char *lang = l->first.c_str(); + std::string flags; + // Add the export symbol definition for shared library objects. + bool shared = ((this->Target->GetType() == cmTarget::SHARED_LIBRARY) || + (this->Target->GetType() == cmTarget::MODULE_LIBRARY)); + if(shared) + { + flags += "-D"; + if(const char* custom_export_name = + this->Target->GetProperty("DEFINE_SYMBOL")) + { + flags += custom_export_name; + } + else + { + std::string in = this->Target->GetName(); + in += "_EXPORTS"; + flags += cmSystemTools::MakeCindentifier(in.c_str()); + } + } + + // Add language-specific flags. + this->LocalGenerator + ->AddLanguageFlags(flags, lang, + this->LocalGenerator->ConfigurationName.c_str()); + + // Add shared-library flags if needed. + this->LocalGenerator->AddSharedFlags(flags, lang, shared); + + // Add include directory flags. + this->LocalGenerator-> + AppendFlags(flags, this->LocalGenerator->GetIncludeFlags(lang)); + // Add include directory flags. + this->LocalGenerator-> + AppendFlags(flags,this->GetFrameworkFlags().c_str()); + + *this->FlagFileStream << lang << "_FLAGS = " << flags << "\n\n"; + } +} + + + +//---------------------------------------------------------------------------- +void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source) +{ + // Identify the language of the source file. + const char* lang = this->LocalGenerator->GetSourceFileLanguage(source); + if(!lang) + { + // If language is not known, this is an error. + cmSystemTools::Error("Source file \"", source.GetFullPath().c_str(), + "\" has unknown type."); + return; + } + + // Get the full path name of the object file. + std::string objNoTargetDir; + std::string obj = + this->LocalGenerator->GetObjectFileName(*this->Target, source, &objNoTargetDir); + + // Avoid generating duplicate rules. + if(this->ObjectFiles.find(obj) == this->ObjectFiles.end()) + { + this->ObjectFiles.insert(obj); + } + else + { + cmOStringStream err; + err << "Warning: Source file \"" + << source.GetSourceName().c_str() << "." + << source.GetSourceExtension().c_str() + << "\" is listed multiple times for target \"" + << this->Target->GetName() + << "\"."; + cmSystemTools::Message(err.str().c_str(), "Warning"); + return; + } + + // Create the directory containing the object file. This may be a + // subdirectory under the target's directory. + std::string dir = cmSystemTools::GetFilenamePath(obj.c_str()); + cmSystemTools::MakeDirectory + (this->LocalGenerator->ConvertToFullPath(dir).c_str()); + + // Save this in the target's list of object files. + this->Objects.push_back(obj); + std::string relativeObj = this->LocalGenerator->GetHomeRelativeOutputPath(); + relativeObj += obj; + // we compute some depends when writing the depend.make that we will also + // use in the build.make, same with depMakeFile + std::vector depends; + std::string depMakeFile; + + // generate the build rule file + this->WriteObjectBuildFile(obj, lang, source, depends); + + // The object file should be checked for dependency integrity. + this->LocalGenerator->CheckDependFiles[this->Target->GetName()][lang].insert(&source); + // add this to the list of objects for this local generator + if(cmSystemTools::FileIsFullPath(objNoTargetDir.c_str())) + { + objNoTargetDir = cmSystemTools::GetFilenameName(objNoTargetDir); + } + this->LocalGenerator->LocalObjectFiles[objNoTargetDir].push_back(this->Target); +} + +//---------------------------------------------------------------------------- +void +cmMakefileTargetGenerator +::WriteObjectBuildFile(std::string &obj, + const char *lang, + cmSourceFile& source, + std::vector& depends) +{ + this->LocalGenerator->AppendRuleDepend(depends, this->FlagFileNameFull.c_str()); + + // generate the depend scanning rule + this->WriteObjectDependRules(source, depends); + + std::string relativeObj = this->LocalGenerator->GetHomeRelativeOutputPath(); + relativeObj += obj; + if(this->Makefile->GetDefinition("CMAKE_WINDOWS_OBJECT_PATH")) + { + relativeObj = cmSystemTools::ConvertToOutputPath(relativeObj.c_str()); + } + // Write the build rule. + + // Build the set of compiler flags. + std::string flags; + + // Add language-specific flags. + std::string langFlags = "$("; + langFlags += lang; + langFlags += "_FLAGS)"; + this->LocalGenerator->AppendFlags(flags, langFlags.c_str()); + + // Add target-specific flags. + if(this->Target->GetProperty("COMPILE_FLAGS")) + { + this->LocalGenerator->AppendFlags(flags, this->Target->GetProperty("COMPILE_FLAGS")); + } + + // Add flags from source file properties. + if (source.GetProperty("COMPILE_FLAGS")) + { + this->LocalGenerator->AppendFlags(flags, source.GetProperty("COMPILE_FLAGS")); + *this->FlagFileStream << "# Custom flags: " + << relativeObj << "_FLAGS = " + << source.GetProperty("COMPILE_FLAGS") + << "\n" + << "\n"; + } + + // Get the output paths for source and object files. + std::string sourceFile = source.GetFullPath(); + if(this->LocalGenerator->UseRelativePaths) + { + sourceFile = this->Convert(sourceFile.c_str(), + cmLocalGenerator::HOME_OUTPUT); + } + sourceFile = this->Convert(sourceFile.c_str(), + cmLocalGenerator::NONE, + cmLocalGenerator::SHELL); + std::string objectFile = + this->Convert(obj.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::SHELL); + + // Construct the build message. + std::vector no_commands; + std::vector commands; + std::string buildEcho = "Building "; + buildEcho += lang; + buildEcho += " object "; + buildEcho += relativeObj; + this->LocalGenerator->AppendEcho(commands, buildEcho.c_str()); + + // Construct the compile rules. + std::string compileRuleVar = "CMAKE_"; + compileRuleVar += lang; + compileRuleVar += "_COMPILE_OBJECT"; + std::string compileRule = + this->Makefile->GetRequiredDefinition(compileRuleVar.c_str()); + cmSystemTools::ExpandListArgument(compileRule, commands); + cmLocalGenerator::RuleVariables vars; + vars.Language = lang; + vars.Source = sourceFile.c_str(); + vars.Object = relativeObj.c_str(); + vars.Flags = flags.c_str(); + + // Expand placeholders in the commands. + for(std::vector::iterator i = commands.begin(); + i != commands.end(); ++i) + { + this->LocalGenerator->ExpandRuleVariables(*i, vars); + } + + // Make the target dependency scanning rule include cmake-time-known + // dependencies. The others are handled by the check-build-system + // path. + std::string depMark = + this->LocalGenerator->GetRelativeTargetDirectory(*this->Target); + depMark += "/depend.make.mark"; + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, + depMark.c_str(), + depends, no_commands, false); + + // Write the rule. + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, + relativeObj.c_str(), + depends, commands, false); + + // If the language needs provides-requires mode, create the + // corresponding targets. + std::string objectRequires = relativeObj; + objectRequires += ".requires"; + std::vector p_depends; + // always provide an empty requires target + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, + objectRequires.c_str(), p_depends, + no_commands, true); + + // write a build rule to recursively build what this obj provides + std::string objectProvides = relativeObj; + objectProvides += ".provides"; + std::string temp = relativeObj; + temp += ".provides.build"; + std::vector r_commands; + std::string tgtMakefileName = + this->LocalGenerator->GetRelativeTargetDirectory(*this->Target); + tgtMakefileName += "/build.make"; + r_commands.push_back + (this->LocalGenerator->GetRecursiveMakeCall(tgtMakefileName.c_str(),temp.c_str())); + p_depends.clear(); + p_depends.push_back(objectRequires); + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, + objectProvides.c_str(), p_depends, + r_commands, true); + + // write the provides.build rule dependency on the obj file + p_depends.clear(); + p_depends.push_back(relativeObj); + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, + temp.c_str(), p_depends, no_commands, + true); +} + +//---------------------------------------------------------------------------- +void cmMakefileTargetGenerator::WriteTargetRequiresRules() +{ + std::vector depends; + std::vector no_commands; + + // Construct the name of the dependency generation target. + std::string depTarget = + this->LocalGenerator->GetRelativeTargetDirectory(*this->Target); + depTarget += "/requires"; + + // This target drives dependency generation for all object files. + std::string relPath = this->LocalGenerator->GetHomeRelativeOutputPath(); + std::string objTarget; + for(std::vector::const_iterator obj = this->Objects.begin(); + obj != this->Objects.end(); ++obj) + { + objTarget = relPath; + objTarget += *obj; + objTarget += ".requires"; + depends.push_back(objTarget); + } + + // Write the rule. + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, + depTarget.c_str(), + depends, no_commands, true); +} + +//---------------------------------------------------------------------------- +void cmMakefileTargetGenerator::WriteTargetCleanRules() +{ + std::vector depends; + std::vector commands; + + // Construct the clean target name. + std::string cleanTarget = + this->LocalGenerator->GetRelativeTargetDirectory(*this->Target); + cleanTarget += "/clean"; + + // Construct the clean command. + this->LocalGenerator->AppendCleanCommand(commands, this->CleanFiles, + *this->Target); + this->LocalGenerator->CreateCDCommand(commands, + this->Makefile->GetStartOutputDirectory(), + this->Makefile->GetHomeOutputDirectory()); + + // Write the rule. + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, + cleanTarget.c_str(), + depends, commands, true); +} + + +//---------------------------------------------------------------------------- +void cmMakefileTargetGenerator::WriteTargetDependRules() +{ + // must write the targets depend info file + std::string dir = this->LocalGenerator->GetTargetDirectory(*this->Target); + this->InfoFileNameFull = dir; + this->InfoFileNameFull += "/DependInfo.cmake"; + this->InfoFileNameFull = + this->LocalGenerator->ConvertToFullPath(this->InfoFileNameFull); + this->InfoFileStream = + new cmGeneratedFileStream(this->InfoFileNameFull.c_str()); + this->InfoFileStream->SetCopyIfDifferent(true); + if(!*this->InfoFileStream) + { + return; + } + this->LocalGenerator-> + WriteDependLanguageInfo(*this->InfoFileStream,*this->Target); + + // and now write the rule to use it + std::vector depends; + std::vector commands; + + // Construct the name of the dependency generation target. + std::string depTarget = + this->LocalGenerator->GetRelativeTargetDirectory(*this->Target); + depTarget += "/depend"; + + std::string depMark = depTarget; + depMark += ".make.mark"; + depends.push_back(depMark); + + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, + depTarget.c_str(), + depends, commands, true); + depends.clear(); + + // Write the dependency generation rule. + std::string depEcho = "Scanning dependencies of target "; + depEcho += this->Target->GetName(); + this->LocalGenerator->AppendEcho(commands, depEcho.c_str()); + + // Add a command to call CMake to scan dependencies. CMake will + // touch the corresponding depends file after scanning dependencies. + cmOStringStream depCmd; + // TODO: Account for source file properties and directory-level + // definitions when scanning for dependencies. + depCmd << "$(CMAKE_COMMAND) -E cmake_depends " + << " \"" + << this->GlobalGenerator->GetName() << "\" " + << this->LocalGenerator->Convert + (this->Makefile->GetHomeOutputDirectory(), + cmLocalGenerator::FULL,cmLocalGenerator::SHELL) + << " " + << this->LocalGenerator->Convert + (this->Makefile->GetStartOutputDirectory(), + cmLocalGenerator::FULL,cmLocalGenerator::SHELL) + << " " + << this->Convert(this->InfoFileNameFull.c_str(), + cmLocalGenerator::FULL, + cmLocalGenerator::SHELL); + commands.push_back(depCmd.str()); + + // Write the rule. + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, + depMark.c_str(), + depends, commands, false); +} + +//---------------------------------------------------------------------------- +void cmMakefileTargetGenerator +::WriteObjectDependRules(cmSourceFile& source, + std::vector& depends) +{ + // Create the list of dependencies known at cmake time. These are + // shared between the object file and dependency scanning rule. + depends.push_back(source.GetFullPath()); + if(const char* objectDeps = source.GetProperty("OBJECT_DEPENDS")) + { + std::vector deps; + cmSystemTools::ExpandListArgument(objectDeps, deps); + for(std::vector::iterator i = deps.begin(); + i != deps.end(); ++i) + { + depends.push_back(i->c_str()); + } + } +} + +void cmMakefileTargetGenerator::WriteCustomCommands() +{ + // add custom commands to the clean rules? + const char* clean_no_custom = this->Makefile->GetProperty("CLEAN_NO_CUSTOM"); + bool clean = cmSystemTools::IsOff(clean_no_custom); + + // Generate the rule files for each custom command. + const std::vector &classes = this->Makefile->GetSourceFiles(); + for(std::vector::const_iterator i = classes.begin(); + i != classes.end(); i++) + { + if(cmCustomCommand* cc = (*i)->GetCustomCommand()) + { + this->GenerateCustomRuleFile(*cc); + if (clean) + { + this->CleanFiles.push_back + (this->Convert(cc->GetOutput(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::UNCHANGED)); + } + } + } +} + +//---------------------------------------------------------------------------- +void cmMakefileTargetGenerator +::GenerateCustomRuleFile(const cmCustomCommand& cc) +{ + // Convert the output name to a relative path if possible. + std::string output = this->Convert(cc.GetOutput(), + cmLocalGenerator::START_OUTPUT); + + // Collect the commands. + std::vector commands; + std::string preEcho = "Generating "; + preEcho += output; + this->LocalGenerator->AppendEcho(commands, preEcho.c_str()); + this->LocalGenerator->AppendCustomCommand(commands, cc); + + // Collect the dependencies. + std::vector depends; + this->LocalGenerator->AppendCustomDepend(depends, cc); + + // Write the rule. + const char* comment = 0; + if(cc.GetComment() && *cc.GetComment()) + { + comment = cc.GetComment(); + } + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, comment, + cc.GetOutput(), depends, commands, + false); +} + +//---------------------------------------------------------------------------- +void +cmMakefileTargetGenerator +::WriteObjectsVariable(std::string& variableName, + std::string& variableNameExternal) +{ + // Write a make variable assignment that lists all objects for the + // target. + variableName = + this->LocalGenerator->CreateMakeVariable(this->Target->GetName(), "_OBJECTS"); + *this->BuildFileStream + << "# Object files for target " << this->Target->GetName() << "\n" + << variableName.c_str() << " ="; + std::string object; + const char* objName = + this->Makefile->GetDefinition("CMAKE_NO_QUOTED_OBJECTS"); + const char* lineContinue = + this->Makefile->GetDefinition("CMAKE_MAKE_LINE_CONTINUE"); + if(!lineContinue) + { + lineContinue = "\\"; + } + for(std::vector::const_iterator i = this->Objects.begin(); + i != this->Objects.end(); ++i) + { + *this->BuildFileStream << " " << lineContinue << "\n"; + if(objName) + { + *this->BuildFileStream << + this->Convert(i->c_str(), cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::MAKEFILE); + } + else + { + *this->BuildFileStream << + this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str()); + } + } + *this->BuildFileStream << "\n"; + + // Write a make variable assignment that lists all external objects + // for the target. + variableNameExternal = + this->LocalGenerator->CreateMakeVariable(this->Target->GetName(),"_EXTERNAL_OBJECTS"); + *this->BuildFileStream + << "\n" + << "# External object files for target " << this->Target->GetName() << "\n" + << variableNameExternal.c_str() << " ="; + for(std::vector::const_iterator i = + this->ExternalObjects.begin(); + i != this->ExternalObjects.end(); ++i) + { + object = this->Convert(i->c_str(),cmLocalGenerator::START_OUTPUT); + *this->BuildFileStream + << " " << lineContinue << "\n" + << this->Makefile->GetSafeDefinition("CMAKE_OBJECT_NAME"); + if(objName) + { + *this->BuildFileStream << this->Convert(i->c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::MAKEFILE); + } + else + { + *this->BuildFileStream << + this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str()); + } + } + *this->BuildFileStream << "\n" << "\n"; +} + + +//---------------------------------------------------------------------------- +std::string cmMakefileTargetGenerator::GetFrameworkFlags() +{ +#ifndef __APPLE__ + return std::string(); +#else + std::set emitted; + std::vector includes; + this->LocalGenerator->GetIncludeDirectories(includes); + std::vector::iterator i; + // check all include directories for frameworks as this + // will already have added a -F for the framework + for(i = includes.begin(); i != includes.end(); ++i) + { + if(cmSystemTools::IsPathToFramework(i->c_str())) + { + std::string frameworkDir = *i; + frameworkDir += "/../"; + frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str()); + emitted.insert(frameworkDir); + } + } + + std::string flags; + std::vector& frameworks = this->Target->GetFrameworks(); + for(i = frameworks.begin(); + i != frameworks.end(); ++i) + { + if(emitted.insert(*i).second) + { + flags += "-F"; + flags += this->LocalGenerator->ConvertToOutputForExisting(i->c_str()); + flags += " "; + } + } + return flags; +#endif +} + +//---------------------------------------------------------------------------- +void cmMakefileTargetGenerator +::AppendTargetDepends(std::vector& depends) +{ + // Static libraries never depend on anything for linking. + if(this->Target->GetType() == cmTarget::STATIC_LIBRARY) + { + return; + } + + // Keep track of dependencies already listed. + std::set emitted; + + // A target should not depend on itself. + emitted.insert(this->Target->GetName()); + + // Loop over all library dependencies. + const cmTarget::LinkLibraryVectorType& tlibs = + this->Target->GetLinkLibraries(); + for(cmTarget::LinkLibraryVectorType::const_iterator lib = tlibs.begin(); + lib != tlibs.end(); ++lib) + { + // Don't emit the same library twice for this target. + if(emitted.insert(lib->first).second) + { + // Depend only on other CMake targets. + if(cmTarget* tgt = + this->GlobalGenerator->FindTarget(0, lib->first.c_str())) + { + if(const char* location = + tgt->GetLocation(this->LocalGenerator->ConfigurationName.c_str())) + { + depends.push_back(location); + } + } + } + } +} + +//---------------------------------------------------------------------------- +void cmMakefileTargetGenerator +::CloseFileStreams() +{ + delete this->BuildFileStream; + delete this->InfoFileStream; + delete this->FlagFileStream; +} + +void cmMakefileTargetGenerator::RemoveForbiddenFlags(const char* flagVar, + const char* linkLang, + std::string& linkFlags) +{ + // check for language flags that are not allowed at link time, and + // remove them, -w on darwin for gcc -w -dynamiclib sends -w to libtool + // which fails, there may be more] + + std::string removeFlags = "CMAKE_"; + removeFlags += linkLang; + removeFlags += flagVar; + std::string removeflags = + this->Makefile->GetSafeDefinition(removeFlags.c_str()); + std::vector removeList; + cmSystemTools::ExpandListArgument(removeflags, removeList); + for(std::vector::iterator i = removeList.begin(); + i != removeList.end(); ++i) + { + cmSystemTools::ReplaceString(linkFlags, i->c_str(), ""); + } +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMakefileTargetGenerator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMakefileTargetGenerator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMakefileTargetGenerator.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMakefileTargetGenerator.h 2006-03-16 00:02:06.000000000 +0800 @@ -0,0 +1,154 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmMakefileTargetGenerator.h,v $ + Language: C++ + Date: $Date: 2006/03/15 16:02:06 $ + Version: $Revision: 1.5 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef cmMakefileTargetGenerator_h +#define cmMakefileTargetGenerator_h + +#include "cmLocalUnixMakefileGenerator3.h" + +class cmCustomCommand; +class cmDependInformation; +class cmDepends; +class cmGeneratedFileStream; +class cmGlobalGenerator; +class cmLocalUnixMakefileGenerator3; +class cmMakeDepend; +class cmMakefile; +class cmTarget; +class cmSourceFile; + +/** \class cmMakefileTargetGenerator + * \brief Support Routines for writing makefiles + * + */ +class cmMakefileTargetGenerator +{ +public: + // constructor to set the ivars + cmMakefileTargetGenerator(); + virtual ~cmMakefileTargetGenerator() {}; + + // construct using this factory call + static cmMakefileTargetGenerator *New(cmLocalUnixMakefileGenerator3 *lg, + cmStdString tgtName, + cmTarget *tgt); + + /* the main entry point for this class. Writes the Makefiles associated + with this target */ + virtual void WriteRuleFiles() = 0; + +protected: + + // create the file and directory etc + void CreateRuleFile(); + + // outputs the rules for any custom commands used by this target + void WriteCustomCommandsForTarget(); + + // write some common code at the top of build.make + void WriteCommonCodeRules(); + + // write the provide require rules for this target + void WriteTargetRequiresRules(); + + // write the clean rules for this target + void WriteTargetCleanRules(); + + // write the depend rules for this target + void WriteTargetDependRules(); + + // write the rules for an object + void WriteObjectRuleFiles(cmSourceFile& source); + + // write the build rule for an object + void WriteObjectBuildFile(std::string &obj, + const char *lang, + cmSourceFile& source, + std::vector& depends); + + // write the depend.make file for an object + void WriteObjectDependRules(cmSourceFile& source, + std::vector& depends); + + // this is responsible for writing all of the rules for all this + // directories custom commands (but not utility targets) + void WriteCustomCommands(); + void GenerateCustomRuleFile(const cmCustomCommand& cc); + + // write out the variable that lists the objects for this target + void WriteObjectsVariable(std::string& variableName, + std::string& variableNameExternal); + + // Return the a string with -F flags on apple + std::string GetFrameworkFlags(); + + // append intertarget dependencies + void AppendTargetDepends(std::vector& depends); + + virtual void CloseFileStreams(); + void RemoveForbiddenFlags(const char* flagVar, const char* linkLang, + std::string& linkFlags); + cmStdString TargetName; + cmTarget *Target; + cmLocalUnixMakefileGenerator3 *LocalGenerator; + cmGlobalGenerator *GlobalGenerator; + cmMakefile *Makefile; + + // the full path to the build file + std::string BuildFileName; + std::string BuildFileNameFull; + + // the path to the directory the build file is in + std::string TargetBuildDirectory; + std::string TargetBuildDirectoryFull; + + // the stream for the build file + cmGeneratedFileStream *BuildFileStream; + + // the stream for the flag file + std::string FlagFileNameFull; + cmGeneratedFileStream *FlagFileStream; + + // the stream for the info file + std::string InfoFileNameFull; + cmGeneratedFileStream *InfoFileStream; + + // files to clean + std::vector CleanFiles; + + // objects used by this target + std::vector Objects; + std::vector ExternalObjects; + + // Set of object file names that will be built in this directory. + std::set ObjectFiles; + + + //================================================================== + // Convenience routines that do nothing more than forward to + // implementaitons + std::string Convert(const char* source, + cmLocalGenerator::RelativeRoot relative, + cmLocalGenerator::OutputFormat output = + cmLocalGenerator::UNCHANGED, + bool optional = false) + { + return this->LocalGenerator->Convert(source, relative, output, optional); + } + +}; + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMakefileUtilityTargetGenerator.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMakefileUtilityTargetGenerator.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMakefileUtilityTargetGenerator.cxx 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMakefileUtilityTargetGenerator.cxx 2006-02-16 05:35:16.000000000 +0800 @@ -0,0 +1,86 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmMakefileUtilityTargetGenerator.cxx,v $ + Language: C++ + Date: $Date: 2006/02/15 21:35:16 $ + Version: $Revision: 1.2 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "cmMakefileUtilityTargetGenerator.h" + +#include "cmGeneratedFileStream.h" +#include "cmGlobalGenerator.h" +#include "cmLocalUnixMakefileGenerator3.h" +#include "cmMakefile.h" +#include "cmSourceFile.h" +#include "cmTarget.h" + + +//---------------------------------------------------------------------------- +void cmMakefileUtilityTargetGenerator::WriteRuleFiles() +{ + this->CreateRuleFile(); + + *this->BuildFileStream + << "# Utility rule file for " << this->Target->GetName() << ".\n\n"; + + // write the custom commands for this target + this->WriteCustomCommandsForTarget(); + + // Collect the commands and dependencies. + std::vector commands; + std::vector depends; + + // Utility targets store their rules in pre- and post-build commands. + this->LocalGenerator->AppendCustomDepends + (depends, this->Target->GetPreBuildCommands()); + this->LocalGenerator->AppendCustomDepends + (depends, this->Target->GetPostBuildCommands()); + this->LocalGenerator->AppendCustomCommands + (commands, this->Target->GetPreBuildCommands()); + this->LocalGenerator->AppendCustomCommands + (commands, this->Target->GetPostBuildCommands()); + + // Add dependencies on targets that must be built first. + this->AppendTargetDepends(depends); + + // Add a dependency on the rule file itself. + std::string relPath = this->LocalGenerator->GetHomeRelativeOutputPath(); + std::string objTarget = relPath; + objTarget += this->BuildFileName; + this->LocalGenerator->AppendRuleDepend(depends, objTarget.c_str()); + + // Write the rule. + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, + this->Target->GetName(), + depends, commands, true); + + // Write convenience targets. + std::string dir = this->Makefile->GetStartOutputDirectory(); + dir += "/"; + dir += this->LocalGenerator->GetTargetDirectory(*this->Target); + std::string buildTargetRuleName = dir; + buildTargetRuleName += "/build"; + buildTargetRuleName = + this->LocalGenerator->Convert(buildTargetRuleName.c_str(), + cmLocalGenerator::HOME_OUTPUT, + cmLocalGenerator::MAKEFILE); + this->LocalGenerator->WriteConvenienceRule(*this->BuildFileStream, + this->Target->GetName(), + buildTargetRuleName.c_str()); + + // Write clean target + this->WriteTargetCleanRules(); + + // close the streams + this->CloseFileStreams(); +} + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMakefileUtilityTargetGenerator.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMakefileUtilityTargetGenerator.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMakefileUtilityTargetGenerator.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMakefileUtilityTargetGenerator.h 2006-02-14 23:35:59.000000000 +0800 @@ -0,0 +1,34 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmMakefileUtilityTargetGenerator.h,v $ + Language: C++ + Date: $Date: 2006/02/14 15:35:59 $ + Version: $Revision: 1.1 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef cmMakefileUtilityTargetGenerator_h +#define cmMakefileUtilityTargetGenerator_h + +#include "cmMakefileTargetGenerator.h" + +class cmMakefileUtilityTargetGenerator: + public cmMakefileTargetGenerator +{ +public: + /* the main entry point for this class. Writes the Makefiles associated + with this target */ + virtual void WriteRuleFiles(); + +protected: + +}; + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMarkAsAdvancedCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMarkAsAdvancedCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMarkAsAdvancedCommand.cxx 2002-12-12 07:13:33.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMarkAsAdvancedCommand.cxx 2006-03-16 00:02:06.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmMarkAsAdvancedCommand.cxx,v $ Language: C++ - Date: $Date: 2002/12/11 23:13:33 $ - Version: $Revision: 1.10 $ + Date: $Date: 2006/03/15 16:02:06 $ + Version: $Revision: 1.11 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -40,11 +40,11 @@ for(; i < args.size(); ++i) { std::string variable = args[i]; - cmCacheManager* manager = m_Makefile->GetCacheManager(); + cmCacheManager* manager = this->Makefile->GetCacheManager(); cmCacheManager::CacheIterator it = manager->GetCacheIterator(variable.c_str()); if ( it.IsAtEnd() ) { - m_Makefile->AddCacheDefinition(variable.c_str(), 0, 0, + this->Makefile->AddCacheDefinition(variable.c_str(), 0, 0, cmCacheManager::UNINITIALIZED); overwrite = true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMarkAsAdvancedCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMarkAsAdvancedCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMarkAsAdvancedCommand.h 2005-11-24 01:33:38.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMarkAsAdvancedCommand.h 2005-11-17 22:31:43.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmMarkAsAdvancedCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:38 $ - Version: $Revision: 1.8.2.1 $ + Date: $Date: 2005/11/17 14:31:43 $ + Version: $Revision: 1.9 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMathCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMathCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMathCommand.cxx 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMathCommand.cxx 2006-03-16 00:02:06.000000000 +0800 @@ -0,0 +1,65 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmMathCommand.cxx,v $ + Language: C++ + Date: $Date: 2006/03/15 16:02:06 $ + Version: $Revision: 1.2 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "cmMathCommand.h" + +#include "cmExprParserHelper.h" + +//---------------------------------------------------------------------------- +bool cmMathCommand::InitialPass(std::vector const& args) +{ + if ( args.size() < 1 ) + { + this->SetError("must be called with at least one argument."); + return false; + } + const std::string &subCommand = args[0]; + if(subCommand == "EXPR") + { + return this->HandleExprCommand(args); + } + std::string e = "does not recognize sub-command "+subCommand; + this->SetError(e.c_str()); + return false; +} + +//---------------------------------------------------------------------------- +bool cmMathCommand::HandleExprCommand(std::vector const& args) +{ + if ( args.size() != 3 ) + { + this->SetError("EXPR called with incorrect arguments."); + return false; + } + + const std::string& outputVariable = args[1]; + const std::string& expression = args[2]; + + cmExprParserHelper helper; + if ( !helper.ParseString(expression.c_str(), 0) ) + { + std::string e = "cannot parse the expression: \""+expression+"\": "; + e += helper.GetError(); + this->SetError(e.c_str()); + return false; + } + + char buffer[1024]; + sprintf(buffer, "%d", helper.GetResult()); + + this->Makefile->AddDefinition(outputVariable.c_str(), buffer); + return true; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMathCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMathCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMathCommand.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMathCommand.h 2005-10-18 04:42:47.000000000 +0800 @@ -0,0 +1,80 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmMathCommand.h,v $ + Language: C++ + Date: $Date: 2005/10/17 20:42:47 $ + Version: $Revision: 1.1 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef cmMathCommand_h +#define cmMathCommand_h + +#include "cmCommand.h" + +/** \class cmMathCommand + * \brief Common string operations + * + */ +class cmMathCommand : public cmCommand +{ +public: + /** + * This is a virtual constructor for the command. + */ + virtual cmCommand* Clone() + { + return new cmMathCommand; + } + + /** + * This is called when the command is first encountered in + * the CMakeLists.txt file. + */ + virtual bool InitialPass(std::vector const& args); + + /** + * This determines if the command is invoked when in script mode. + */ + virtual bool IsScriptable() { return true; } + + /** + * The name of the command as specified in CMakeList.txt. + */ + virtual const char* GetName() { return "MATH";} + + /** + * Succinct documentation. + */ + virtual const char* GetTerseDocumentation() + { + return "Mathematical expressions."; + } + + /** + * More documentation. + */ + virtual const char* GetFullDocumentation() + { + return + " MATH(EXPR )\n" + "EXPR evaluates mathematical expression and return result in the " + "output variable. Example mathematical expression is '5 * ( 10 + 13 )'."; + } + + cmTypeMacro(cmMathCommand, cmCommand); +protected: + + bool HandleExprCommand(std::vector const& args); +}; + + +#endif + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMessageCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMessageCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMessageCommand.cxx 2003-01-22 01:50:48.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMessageCommand.cxx 2006-03-16 00:02:06.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmMessageCommand.cxx,v $ Language: C++ - Date: $Date: 2003/01/21 17:50:48 $ - Version: $Revision: 1.15 $ + Date: $Date: 2006/03/15 16:02:06 $ + Version: $Revision: 1.18 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -65,14 +65,14 @@ { if (status) { - m_Makefile->DisplayStatus(message.c_str(), -1); + this->Makefile->DisplayStatus(message.c_str(), -1); } else { cmSystemTools::Message(message.c_str()); } } - if(fatal_error) + if(fatal_error ) { cmSystemTools::SetFatalErrorOccured(); } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMessageCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMessageCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmMessageCommand.h 2005-11-24 01:33:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmMessageCommand.h 2006-01-28 01:58:34.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmMessageCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:39 $ - Version: $Revision: 1.11.4.1 $ + Date: $Date: 2006/01/27 17:58:34 $ + Version: $Revision: 1.14 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -66,9 +66,14 @@ return " MESSAGE([SEND_ERROR | STATUS | FATAL_ERROR]\n" " \"message to display\" ...)\n" - "The arguments are messages to display. If the first argument is " - "SEND_ERROR then an error is raised. If the first argument is " - "STATUS then the message is displayed in the progress line for the GUI."; + "By default the message is displayed in a pop up window (CMakeSetup), " + "or in the stdout of cmake, or the error section of ccmake. " + "If the first argument is " + "SEND_ERROR then an error is raised, and the generate phase will " + "be skipped. If the first argument is FATAL_ERROR, all processing " + "is halted. If the first argument is STATUS then the message is " + "displayed in the progress line for the GUI, or with a -- in the " + "command line cmake."; } cmTypeMacro(cmMessageCommand, cmCommand); diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmOptionCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmOptionCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmOptionCommand.cxx 2004-04-16 01:15:28.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmOptionCommand.cxx 2006-03-16 00:02:06.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmOptionCommand.cxx,v $ Language: C++ - Date: $Date: 2004/04/15 17:15:28 $ - Version: $Revision: 1.20 $ + Date: $Date: 2006/03/15 16:02:06 $ + Version: $Revision: 1.21 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -27,7 +27,7 @@ // for VTK 4.0 we have to support the option command with more than 3 arguments // if CMAKE_MINIMUM_REQUIRED_VERSION is not defined, if CMAKE_MINIMUM_REQUIRED_VERSION // is defined, then we can have stricter checking. - if(m_Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION")) + if(this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION")) { if(args.size() > 3) { @@ -50,7 +50,7 @@ // Now check and see if the value has been stored in the cache // already, if so use that value and don't look for the program cmCacheManager::CacheIterator it = - m_Makefile->GetCacheManager()->GetCacheIterator(args[0].c_str()); + this->Makefile->GetCacheManager()->GetCacheIterator(args[0].c_str()); if(!it.IsAtEnd()) { if ( it.GetType() != cmCacheManager::UNINITIALIZED ) @@ -67,7 +67,7 @@ { initialValue = args[2]; } - m_Makefile->AddCacheDefinition(args[0].c_str(), + this->Makefile->AddCacheDefinition(args[0].c_str(), cmSystemTools::IsOn(initialValue.c_str()), args[1].c_str()); diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmOptionCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmOptionCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmOptionCommand.h 2005-03-18 23:41:41.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmOptionCommand.h 2006-01-28 01:58:53.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmOptionCommand.h,v $ Language: C++ - Date: $Date: 2005/03/18 15:41:41 $ - Version: $Revision: 1.11 $ + Date: $Date: 2006/01/27 17:58:53 $ + Version: $Revision: 1.12 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -60,7 +60,7 @@ virtual const char* GetFullDocumentation() { return - " OPTION(OPTION_VAR \"help string decribing option\"\n" + " OPTION(OPTION_VAR \"help string describing option\"\n" " [initial value])\n" "Provide an option for the user to select as ON or OFF. If no " "initial value is provided, OFF is used."; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmOrderLinkDirectories.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmOrderLinkDirectories.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmOrderLinkDirectories.cxx 2005-11-24 01:33:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmOrderLinkDirectories.cxx 2006-03-17 00:27:56.000000000 +0800 @@ -7,7 +7,7 @@ //------------------------------------------------------------------- cmOrderLinkDirectories::cmOrderLinkDirectories() { - m_Debug = false; + this->Debug = false; } //------------------------------------------------------------------- @@ -24,12 +24,12 @@ } // next remove the extension (.a, .so ) and look for the library // under a different name as the linker can do either - if(m_RemoveLibraryExtension.find(libIn)) + if(this->RemoveLibraryExtension.find(libIn)) { - cmStdString lib = m_RemoveLibraryExtension.match(1); - cmStdString ext = m_RemoveLibraryExtension.match(2); - for(std::vector::iterator i = m_LinkExtensions.begin(); - i != m_LinkExtensions.end(); ++i) + cmStdString lib = this->RemoveLibraryExtension.match(1); + cmStdString ext = this->RemoveLibraryExtension.match(2); + for(std::vector::iterator i = this->LinkExtensions.begin(); + i != this->LinkExtensions.end(); ++i) { if(ext != *i) { @@ -49,18 +49,18 @@ //------------------------------------------------------------------- void cmOrderLinkDirectories::FindLibrariesInSeachPaths() { - for(std::set::iterator dir = m_LinkPathSet.begin(); - dir != m_LinkPathSet.end(); ++dir) + for(std::set::iterator dir = this->LinkPathSet.begin(); + dir != this->LinkPathSet.end(); ++dir) { for(std::map::iterator lib - = m_FullPathLibraries.begin(); - lib != m_FullPathLibraries.end(); ++lib) + = this->FullPathLibraries.begin(); + lib != this->FullPathLibraries.end(); ++lib) { if(lib->second.Path != *dir) { if(this->LibraryInDirectory(dir->c_str(), lib->second.File.c_str())) { - m_LibraryToDirectories[lib->second.FullPath].push_back(*dir); + this->LibraryToDirectories[lib->second.FullPath].push_back(*dir); } } } @@ -70,11 +70,11 @@ //------------------------------------------------------------------- void cmOrderLinkDirectories::FindIndividualLibraryOrders() { - for(std::vector::iterator lib = m_MultiDirectoryLibraries.begin(); - lib != m_MultiDirectoryLibraries.end(); ++lib) + for(std::vector::iterator lib = this->MultiDirectoryLibraries.begin(); + lib != this->MultiDirectoryLibraries.end(); ++lib) { - std::vector& dirs = m_LibraryToDirectories[lib->FullPath]; - m_DirectoryToAfterList[lib->Path] = dirs; + std::vector& dirs = this->LibraryToDirectories[lib->FullPath]; + this->DirectoryToAfterList[lib->Path] = dirs; } } @@ -104,10 +104,11 @@ //------------------------------------------------------------------- void cmOrderLinkDirectories::CreateRegularExpressions() { + this->SplitFramework.compile("(.*)/(.*)\\.framework$"); cmStdString libext = "("; bool first = true; - for(std::vector::iterator i = m_LinkExtensions.begin(); - i != m_LinkExtensions.end(); ++i) + for(std::vector::iterator i = this->LinkExtensions.begin(); + i != this->LinkExtensions.end(); ++i) { if(!first) { @@ -124,36 +125,36 @@ libext += ").*"; cmStdString reg("(.*)"); reg += libext; - m_RemoveLibraryExtension.compile(reg.c_str()); + this->RemoveLibraryExtension.compile(reg.c_str()); reg = ""; - if(m_LinkPrefix.size()) + if(this->LinkPrefix.size()) { reg = "^"; - reg += m_LinkPrefix; + reg += this->LinkPrefix; } reg += "([^/]*)"; reg += libext; - m_ExtractBaseLibraryName.compile(reg.c_str()); + this->ExtractBaseLibraryName.compile(reg.c_str()); reg = "([^/]*)"; reg += libext; - m_ExtractBaseLibraryNameNoPrefix.compile(reg.c_str()); + this->ExtractBaseLibraryNameNoPrefix.compile(reg.c_str()); } //------------------------------------------------------------------- void cmOrderLinkDirectories::PrepareLinkTargets() { - for(std::vector::iterator i = m_LinkItems.begin(); - i != m_LinkItems.end(); ++i) + for(std::vector::iterator i = this->LinkItems.begin(); + i != this->LinkItems.end(); ++i) { // separate the library name from libfoo.a or foo.a - if(m_ExtractBaseLibraryName.find(*i)) + if(this->ExtractBaseLibraryName.find(*i)) { - *i = m_ExtractBaseLibraryName.match(1); + *i = this->ExtractBaseLibraryName.match(1); } - else if(m_ExtractBaseLibraryNameNoPrefix.find(*i)) + else if(this->ExtractBaseLibraryNameNoPrefix.find(*i)) { - *i = m_ExtractBaseLibraryNameNoPrefix.match(1); + *i = this->ExtractBaseLibraryNameNoPrefix.match(1); } } } @@ -163,13 +164,13 @@ cmStdString& path) { for(std::map >::iterator i - = m_DirectoryToAfterList.begin(); - i != m_DirectoryToAfterList.end(); ++i) + = this->DirectoryToAfterList.begin(); + i != this->DirectoryToAfterList.end(); ++i) { const cmStdString& p = i->first; bool found = false; for(std::map >::iterator j - = m_DirectoryToAfterList.begin(); j != m_DirectoryToAfterList.end() + = this->DirectoryToAfterList.begin(); j != this->DirectoryToAfterList.end() && !found; ++j) { if(j != i) @@ -180,7 +181,7 @@ if(!found) { path = p; - m_DirectoryToAfterList.erase(i); + this->DirectoryToAfterList.erase(i); return true; } } @@ -198,20 +199,20 @@ // One at a time find paths that are not in any other paths after list // and put them into the orderedPaths vector in that order // FindPathNotInDirectoryToAfterList removes the path from the - // m_DirectoryToAfterList once it is found + // this->DirectoryToAfterList once it is found while(this->FindPathNotInDirectoryToAfterList(path)) { orderedPaths.push_back(path); } - // at this point if there are still paths in m_DirectoryToAfterList + // at this point if there are still paths in this->DirectoryToAfterList // then there is a cycle and we are stuck - if(m_DirectoryToAfterList.size()) + if(this->DirectoryToAfterList.size()) { for(std::map >::iterator i - = m_DirectoryToAfterList.begin(); - i != m_DirectoryToAfterList.end(); ++i) + = this->DirectoryToAfterList.begin(); + i != this->DirectoryToAfterList.end(); ++i) { - m_ImposibleDirectories.insert(i->first); + this->ImpossibleDirectories.insert(i->first); // still put it in the path list in the order we find them orderedPaths.push_back(i->first); } @@ -220,50 +221,29 @@ } //------------------------------------------------------------------- -void cmOrderLinkDirectories::SetLinkInformation(cmTarget& target, - cmTarget::LinkLibraryType - linktype, - const char* targetLibrary) -{ - m_TargetName = target.GetName(); - // collect the search paths from the target into paths set - const std::vector& searchPaths = target.GetLinkDirectories(); +void cmOrderLinkDirectories::SetLinkInformation( + const char* targetName, + const std::vector& linkLibraries, + const std::vector& linkDirectories + ) +{ + // Save the target name. + this->TargetName = targetName; + + // Merge the link directory search path given into our path set. std::vector empty; - for(std::vector::const_iterator p = searchPaths.begin(); - p != searchPaths.end(); ++p) + for(std::vector::const_iterator p = linkDirectories.begin(); + p != linkDirectories.end(); ++p) { - m_DirectoryToAfterList[*p] = empty; - m_LinkPathSet.insert(*p); + this->DirectoryToAfterList[*p] = empty; + this->LinkPathSet.insert(*p); } - // collect the link items from the target and put it into libs - const cmTarget::LinkLibraries& tlibs = target.GetLinkLibraries(); - std::vector libs; - for(cmTarget::LinkLibraries::const_iterator lib = tlibs.begin(); - lib != tlibs.end(); ++lib) + + // Append the link library list into our raw list. + for(std::vector::const_iterator l = linkLibraries.begin(); + l != linkLibraries.end(); ++l) { - // skip zero size library entries, this may happen - // if a variable expands to nothing. - if (lib->first.size() == 0) - { - continue; - } - // Don't link the library against itself! - if(targetLibrary && (lib->first == targetLibrary) && - target.GetType() != cmTarget::EXECUTABLE) - { - continue; - } - // use the correct lib for the current configuration - if (lib->second == cmTarget::DEBUG && linktype != cmTarget::DEBUG) - { - continue; - } - if (lib->second == cmTarget::OPTIMIZED && - (linktype != cmTarget::OPTIMIZED && linktype != cmTarget::GENERAL)) - { - continue; - } - m_RawLinkItems.push_back(lib->first); + this->RawLinkItems.push_back(*l); } } @@ -278,61 +258,98 @@ cmStdString dir; cmStdString file; std::vector empty; - for(unsigned int i=0; i < m_RawLinkItems.size(); ++i) + bool framework = false; + // do not add a -F for the system frameworks + this->EmittedFrameworkPaths.insert("/System/Library/Frameworks"); + for(unsigned int i=0; i < this->RawLinkItems.size(); ++i) { - if(cmSystemTools::FileIsFullPath(m_RawLinkItems[i].c_str())) + if(cmSystemTools::FileIsFullPath(this->RawLinkItems[i].c_str())) { - if(cmSystemTools::FileIsDirectory(m_RawLinkItems[i].c_str())) + if(cmSystemTools::FileIsDirectory(this->RawLinkItems[i].c_str())) { - std::string message = "Warning: Ignoring path found in link libraries for target: "; - message += m_TargetName; - message += ", path is: "; - message += m_RawLinkItems[i]; - message += ". Expected a library name or a full path to a library name."; - cmSystemTools::Message(message.c_str()); - continue; + if(cmSystemTools::IsPathToFramework(this->RawLinkItems[i].c_str())) + { + this->SplitFramework.find(this->RawLinkItems[i]); + cmStdString path = this->SplitFramework.match(1); + // Add the -F path if we have not yet done so + if(this->EmittedFrameworkPaths.insert(path).second) + { + std::string fpath = "-F"; + fpath += cmSystemTools::ConvertToOutputPath(path.c_str()); + this->LinkItems.push_back(fpath); + } + // now add the -framework option + std::string frame = "-framework "; + frame += this->SplitFramework.match(2); + this->LinkItems.push_back(frame); + framework = true; + } + else + { + std::string message = "Warning: Ignoring path found in link libraries for target: "; + message += this->TargetName; + message += ", path is: "; + message += this->RawLinkItems[i]; + message += ". Expected a library name or a full path to a library name."; + cmSystemTools::Message(message.c_str()); + continue; + } + } + if(!framework) + { + cmSystemTools::SplitProgramPath(this->RawLinkItems[i].c_str(), + dir, file); +#ifdef _WIN32 + // Avoid case problems for windows paths. + if(dir.size() > 2 && dir[1] == ':') + { + if(dir[0] >= 'A' && dir[0] <= 'Z') + { + dir[0] += 'a' - 'A'; + } + } + dir = cmSystemTools::GetActualCaseForPath(dir.c_str()); +#endif + this->DirectoryToAfterList[dir] = empty; + this->LinkPathSet.insert(dir); + aLib.FullPath = this->RawLinkItems[i]; + aLib.File = file; + aLib.Path = dir; + this->FullPathLibraries[aLib.FullPath] = aLib; + this->LinkItems.push_back(file); } - cmSystemTools::SplitProgramPath(m_RawLinkItems[i].c_str(), - dir, file); - m_DirectoryToAfterList[dir] = empty; - m_LinkPathSet.insert(dir); - aLib.FullPath = m_RawLinkItems[i]; - aLib.File = file; - aLib.Path = dir; - m_FullPathLibraries[aLib.FullPath] = aLib; - m_LinkItems.push_back(file); } else { - m_LinkItems.push_back(m_RawLinkItems[i]); + this->LinkItems.push_back(this->RawLinkItems[i]); } } this->FindLibrariesInSeachPaths(); for(std::map >::iterator lib = - m_LibraryToDirectories.begin(); lib!= m_LibraryToDirectories.end(); + this->LibraryToDirectories.begin(); lib!= this->LibraryToDirectories.end(); ++lib) { if(lib->second.size() > 0) { - m_MultiDirectoryLibraries.push_back(m_FullPathLibraries[lib->first]); + this->MultiDirectoryLibraries.push_back(this->FullPathLibraries[lib->first]); } else { - m_SingleDirectoryLibraries.push_back(m_FullPathLibraries[lib->first]); + this->SingleDirectoryLibraries.push_back(this->FullPathLibraries[lib->first]); } } this->FindIndividualLibraryOrders(); - m_SortedSearchPaths.clear(); - if(m_Debug) + this->SortedSearchPaths.clear(); + if(this->Debug) { - this->PrintMap("m_LibraryToDirectories", m_LibraryToDirectories); - this->PrintMap("m_DirectoryToAfterList", m_DirectoryToAfterList); + this->PrintMap("this->LibraryToDirectories", this->LibraryToDirectories); + this->PrintMap("this->DirectoryToAfterList", this->DirectoryToAfterList); } - this->OrderPaths(m_SortedSearchPaths); + this->OrderPaths(this->SortedSearchPaths); // now turn libfoo.a into foo and foo.a into foo // This will prepare the link items for -litem this->PrepareLinkTargets(); - if(m_ImposibleDirectories.size()) + if(this->ImpossibleDirectories.size()) { cmSystemTools::Message(this->GetWarnings().c_str()); return false; @@ -343,15 +360,15 @@ std::string cmOrderLinkDirectories::GetWarnings() { std::string warning = "It is impossible to order the linker search path in such a way that libraries specified as full paths will be picked by the linker.\nDirectories and libraries involved are:\n"; - for(std::set::iterator i = m_ImposibleDirectories.begin(); - i != m_ImposibleDirectories.end(); ++i) + for(std::set::iterator i = this->ImpossibleDirectories.begin(); + i != this->ImpossibleDirectories.end(); ++i) { warning += "Directory: "; warning += *i; warning += " contains:\n"; std::map >::iterator j; - for(j = m_LibraryToDirectories.begin(); - j != m_LibraryToDirectories.end(); ++j) + for(j = this->LibraryToDirectories.begin(); + j != this->LibraryToDirectories.end(); ++j) { if(std::find(j->second.begin(), j->second.end(), *i) != j->second.end()) @@ -390,8 +407,8 @@ void cmOrderLinkDirectories::GetFullPathLibraries(std::vector& libs) { - for(std::map::iterator i = m_FullPathLibraries.begin(); - i != m_FullPathLibraries.end(); ++i) + for(std::map::iterator i = this->FullPathLibraries.begin(); + i != this->FullPathLibraries.end(); ++i) { libs.push_back(i->first); } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmOrderLinkDirectories.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmOrderLinkDirectories.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmOrderLinkDirectories.h 2005-11-24 01:33:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmOrderLinkDirectories.h 2006-03-16 00:02:06.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmOrderLinkDirectories.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:39 $ - Version: $Revision: 1.8.2.2 $ + Date: $Date: 2006/03/15 16:02:06 $ + Version: $Revision: 1.14 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -49,28 +49,35 @@ public: cmOrderLinkDirectories(); ///! set link information from the target - void SetLinkInformation(cmTarget&, cmTarget::LinkLibraryType, - const char* targetLibrary); + void SetLinkInformation(const char* targetName, + const std::vector& linkLibraries, + const std::vector& linkDirectories); ///! Compute the best order for -L paths from GetLinkLibraries bool DetermineLibraryPathOrder(); ///! Get the results from DetermineLibraryPathOrder void GetLinkerInformation(std::vector& searchPaths, std::vector& linkItems) { - linkItems = m_LinkItems; - searchPaths = m_SortedSearchPaths; + linkItems = this->LinkItems; + searchPaths = this->SortedSearchPaths; } // should be set from CMAKE_STATIC_LIBRARY_SUFFIX, // CMAKE_SHARED_LIBRARY_SUFFIX // CMAKE_LINK_LIBRARY_SUFFIX void AddLinkExtension(const char* e) { - m_LinkExtensions.push_back(e); + if(e && *e) + { + this->LinkExtensions.push_back(e); + } } // should be set from CMAKE_STATIC_LIBRARY_PREFIX void SetLinkPrefix(const char* s) { - m_LinkPrefix = s; + if(s) + { + this->LinkPrefix = s; + } } // Return any warnings if the exist std::string GetWarnings(); @@ -87,7 +94,7 @@ friend struct cmOrderLinkDirectoriesCompare; void DebugOn() { - m_Debug = true; + this->Debug = true; } private: @@ -106,36 +113,39 @@ std::string NoCaseExpression(const char* str); private: // map from library to directories that it is in other than its full path - std::map > m_LibraryToDirectories; + std::map > LibraryToDirectories; // map from directory to vector of directories that must be after it - std::map > m_DirectoryToAfterList; + std::map > DirectoryToAfterList; // map from full path to a Library struct - std::map m_FullPathLibraries; + std::map FullPathLibraries; // libraries that are found in multiple directories - std::vector m_MultiDirectoryLibraries; + std::vector MultiDirectoryLibraries; // libraries that are only found in one directory - std::vector m_SingleDirectoryLibraries; + std::vector SingleDirectoryLibraries; // This is a vector of all the link objects -lm or m - std::vector m_LinkItems; + std::vector LinkItems; // Unprocessed link items - std::vector m_RawLinkItems; + std::vector RawLinkItems; // This vector holds the sorted -L paths - std::vector m_SortedSearchPaths; + std::vector SortedSearchPaths; + // This vector holds the -F paths + std::set EmittedFrameworkPaths; // This is the set of -L paths unsorted, but unique - std::set m_LinkPathSet; + std::set LinkPathSet; // the names of link extensions - std::vector m_LinkExtensions; + std::vector LinkExtensions; // the names of link prefixes - cmStdString m_LinkPrefix; + cmStdString LinkPrefix; // set of directories that can not be put in the correct order - std::set m_ImposibleDirectories; + std::set ImpossibleDirectories; // Name of target - cmStdString m_TargetName; + cmStdString TargetName; // library regular expressions - cmsys::RegularExpression m_RemoveLibraryExtension; - cmsys::RegularExpression m_ExtractBaseLibraryName; - cmsys::RegularExpression m_ExtractBaseLibraryNameNoPrefix; - bool m_Debug; + cmsys::RegularExpression RemoveLibraryExtension; + cmsys::RegularExpression ExtractBaseLibraryName; + cmsys::RegularExpression ExtractBaseLibraryNameNoPrefix; + cmsys::RegularExpression SplitFramework; + bool Debug; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmOutputRequiredFilesCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmOutputRequiredFilesCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmOutputRequiredFilesCommand.cxx 2005-10-25 03:43:52.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmOutputRequiredFilesCommand.cxx 2006-03-16 00:02:06.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmOutputRequiredFilesCommand.cxx,v $ Language: C++ - Date: $Date: 2005/10/24 19:43:52 $ - Version: $Revision: 1.10.8.1 $ + Date: $Date: 2006/03/15 16:02:06 $ + Version: $Revision: 1.13 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -27,10 +27,10 @@ void cmLBDepend::DependWalk(cmDependInformation* info) { - std::ifstream fin(info->m_FullPath.c_str()); + std::ifstream fin(info->FullPath.c_str()); if(!fin) { - cmSystemTools::Error("error can not open ", info->m_FullPath.c_str()); + cmSystemTools::Error("error can not open ", info->FullPath.c_str()); return; } @@ -66,14 +66,14 @@ // extract the file being included std::string includeFile = currentline.substr(qstart+1, qend - qstart-1); // see if the include matches the regular expression - if(!m_IncludeFileRegularExpression.find(includeFile)) + if(!this->IncludeFileRegularExpression.find(includeFile)) { - if(m_Verbose) + if(this->Verbose) { std::string message = "Skipping "; message += includeFile; message += " for file "; - message += info->m_FullPath.c_str(); + message += info->FullPath.c_str(); cmSystemTools::Error(message.c_str(), 0); } continue; @@ -95,8 +95,8 @@ found = true; } for(std::vector::iterator i = - m_IncludeDirectories.begin(); - i != m_IncludeDirectories.end(); ++i) + this->IncludeDirectories.begin(); + i != this->IncludeDirectories.end(); ++i) { std::string path = *i; path = path + "/"; @@ -114,8 +114,8 @@ found = true; } for(std::vector::iterator i = - m_IncludeDirectories.begin(); - i != m_IncludeDirectories.end(); ++i) + this->IncludeDirectories.begin(); + i != this->IncludeDirectories.end(); ++i) { std::string path = *i; path = path + "/"; @@ -134,8 +134,8 @@ found = true; } for(std::vector::iterator i = - m_IncludeDirectories.begin(); - i != m_IncludeDirectories.end(); ++i) + this->IncludeDirectories.begin(); + i != this->IncludeDirectories.end(); ++i) { std::string path = *i; path = path + "/"; @@ -154,8 +154,8 @@ found = true; } for(std::vector::iterator i = - m_IncludeDirectories.begin(); - i != m_IncludeDirectories.end(); ++i) + this->IncludeDirectories.begin(); + i != this->IncludeDirectories.end(); ++i) { std::string path = *i; path = path + "/"; @@ -185,8 +185,8 @@ } // store the arg for final pass - m_File = args[0]; - m_OutputFile = args[1]; + this->File = args[0]; + this->OutputFile = args[1]; return true; } @@ -199,20 +199,20 @@ // add info to the visited set visited->insert(info); // now recurse with info's dependencies - for(cmDependInformation::DependencySet::const_iterator d = - info->m_DependencySet.begin(); - d != info->m_DependencySet.end(); ++d) + for(cmDependInformation::DependencySetType::const_iterator d = + info->DependencySet.begin(); + d != info->DependencySet.end(); ++d) { if (visited->find(*d) == visited->end()) { - if(info->m_FullPath != "") + if(info->FullPath != "") { - std::string tmp = (*d)->m_FullPath; + std::string tmp = (*d)->FullPath; std::string::size_type pos = tmp.rfind('.'); if(pos != std::string::npos && (tmp.substr(pos) != ".h")) { tmp = tmp.substr(0, pos); - fprintf(fout,"%s\n",(*d)->m_FullPath.c_str()); + fprintf(fout,"%s\n",(*d)->FullPath.c_str()); } } this->ListDependencies(*d,fout,visited); @@ -223,22 +223,22 @@ void cmOutputRequiredFilesCommand::FinalPass() { - cmTargets &tgts = m_Makefile->GetTargets(); + cmTargets &tgts = this->Makefile->GetTargets(); for (cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { - l->second.GenerateSourceFilesFromSourceLists(*m_Makefile); + l->second.GenerateSourceFilesFromSourceLists(*this->Makefile); } // compute the list of files cmLBDepend md; - md.SetMakefile(m_Makefile); - md.AddSearchPath(m_Makefile->GetStartDirectory()); + md.SetMakefile(this->Makefile); + md.AddSearchPath(this->Makefile->GetStartDirectory()); // find the depends for a file - const cmDependInformation *info = md.FindDependencies(m_File.c_str()); + const cmDependInformation *info = md.FindDependencies(this->File.c_str()); if (info) { // write them out - FILE *fout = fopen(m_OutputFile.c_str(),"w"); + FILE *fout = fopen(this->OutputFile.c_str(),"w"); std::set visited; this->ListDependencies(info,fout, &visited); fclose(fout); diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmOutputRequiredFilesCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmOutputRequiredFilesCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmOutputRequiredFilesCommand.h 2004-02-23 02:14:59.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmOutputRequiredFilesCommand.h 2006-03-16 00:02:06.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmOutputRequiredFilesCommand.h,v $ Language: C++ - Date: $Date: 2004/02/22 18:14:59 $ - Version: $Revision: 1.8 $ + Date: $Date: 2006/03/15 16:02:06 $ + Version: $Revision: 1.10 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -64,7 +64,10 @@ { return " OUTPUT_REQUIRED_FILES(srcfile outputfile)\n" - "Outputs a list of all the source files that are required by the specified srcfile. This list is written into outputfile. This is similar to writing out the dependencies for srcfile except that it jumps from .h files into .cxx, .c and .cpp files if possible."; + "Outputs a list of all the source files that are required by the " + "specified srcfile. This list is written into outputfile. This is " + "similar to writing out the dependencies for srcfile except that it " + "jumps from .h files into .cxx, .c and .cpp files if possible."; } cmTypeMacro(cmOutputRequiredFilesCommand, cmCommand); @@ -73,8 +76,8 @@ std::set *visited); private: - std::string m_File; - std::string m_OutputFile; + std::string File; + std::string OutputFile; }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmProjectCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmProjectCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmProjectCommand.cxx 2005-02-23 04:31:02.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmProjectCommand.cxx 2006-03-16 00:02:06.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmProjectCommand.cxx,v $ Language: C++ - Date: $Date: 2005/02/22 20:31:02 $ - Version: $Revision: 1.21 $ + Date: $Date: 2006/03/15 16:02:06 $ + Version: $Revision: 1.22 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -24,36 +24,36 @@ this->SetError("PROJECT called with incorrect number of arguments"); return false; } - m_Makefile->SetProjectName(args[0].c_str()); + this->Makefile->SetProjectName(args[0].c_str()); std::string bindir = args[0]; bindir += "_BINARY_DIR"; std::string srcdir = args[0]; srcdir += "_SOURCE_DIR"; - m_Makefile->AddCacheDefinition(bindir.c_str(), - m_Makefile->GetCurrentOutputDirectory(), + this->Makefile->AddCacheDefinition(bindir.c_str(), + this->Makefile->GetCurrentOutputDirectory(), "Value Computed by CMake", cmCacheManager::STATIC); - m_Makefile->AddCacheDefinition(srcdir.c_str(), - m_Makefile->GetCurrentDirectory(), + this->Makefile->AddCacheDefinition(srcdir.c_str(), + this->Makefile->GetCurrentDirectory(), "Value Computed by CMake", cmCacheManager::STATIC); bindir = "PROJECT_BINARY_DIR"; srcdir = "PROJECT_SOURCE_DIR"; - m_Makefile->AddDefinition(bindir.c_str(), - m_Makefile->GetCurrentOutputDirectory()); - m_Makefile->AddDefinition(srcdir.c_str(), - m_Makefile->GetCurrentDirectory()); + this->Makefile->AddDefinition(bindir.c_str(), + this->Makefile->GetCurrentOutputDirectory()); + this->Makefile->AddDefinition(srcdir.c_str(), + this->Makefile->GetCurrentDirectory()); - m_Makefile->AddDefinition("PROJECT_NAME", args[0].c_str()); + this->Makefile->AddDefinition("PROJECT_NAME", args[0].c_str()); // Set the CMAKE_PROJECT_NAME variable to be the highest-level // project name in the tree. This is always the first PROJECT // command encountered. - if(!m_Makefile->GetDefinition("CMAKE_PROJECT_NAME")) + if(!this->Makefile->GetDefinition("CMAKE_PROJECT_NAME")) { - m_Makefile->AddDefinition("CMAKE_PROJECT_NAME", args[0].c_str()); + this->Makefile->AddDefinition("CMAKE_PROJECT_NAME", args[0].c_str()); } std::vector languages; @@ -70,7 +70,7 @@ languages.push_back("C"); languages.push_back("CXX"); } - m_Makefile->EnableLanguage(languages); + this->Makefile->EnableLanguage(languages); return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmProjectCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmProjectCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmProjectCommand.h 2005-03-18 23:41:41.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmProjectCommand.h 2006-03-11 00:13:14.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmProjectCommand.h,v $ Language: C++ - Date: $Date: 2005/03/18 15:41:41 $ - Version: $Revision: 1.13 $ + Date: $Date: 2006/03/10 16:13:14 $ + Version: $Revision: 1.14 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -65,9 +65,11 @@ return " PROJECT(projectname [CXX] [C] [Java])\n" "Sets the name of the project. " - "This creates the variables projectname_BINARY_DIR and projectname_SOURCE_DIR. " + "This creates the variables projectname_BINARY_DIR and " + "projectname_SOURCE_DIR. " "Optionally you can specify which languages your project supports. " - "By default all languages are supported. If you do not have a C++ compiler, but want" + "By default all languages are supported. If you do not have a " + "C++ compiler, but want" " to build a c program with cmake, then use this option."; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmQTWrapCPPCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmQTWrapCPPCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmQTWrapCPPCommand.cxx 2005-08-12 02:02:20.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmQTWrapCPPCommand.cxx 2006-03-16 00:02:06.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmQTWrapCPPCommand.cxx,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:20 $ - Version: $Revision: 1.19.2.1 $ + Date: $Date: 2006/03/15 16:02:06 $ + Version: $Revision: 1.22 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -25,19 +25,19 @@ return false; } std::vector args; - m_Makefile->ExpandSourceListArguments(argsIn, args, 2); + this->Makefile->ExpandSourceListArguments(argsIn, args, 2); // what is the current source dir - std::string cdir = m_Makefile->GetCurrentDirectory(); + std::string cdir = this->Makefile->GetCurrentDirectory(); // keep the library name - m_LibraryName = args[0]; - m_SourceList = args[1]; + this->LibraryName = args[0]; + this->SourceList = args[1]; std::string sourceListValue; // was the list already populated - const char *def = m_Makefile->GetDefinition(m_SourceList.c_str()); + const char *def = this->Makefile->GetDefinition(this->SourceList.c_str()); if (def) { sourceListValue = def; @@ -47,7 +47,7 @@ for(std::vector::iterator j = (args.begin() + 2); j != args.end(); ++j) { - cmSourceFile *curr = m_Makefile->GetSource(j->c_str()); + cmSourceFile *curr = this->Makefile->GetSource(j->c_str()); // if we should wrap the class if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE")) @@ -59,7 +59,7 @@ } std::string srcName = cmSystemTools::GetFilenameWithoutLastExtension(*j); std::string newName = "moc_" + srcName; - file.SetName(newName.c_str(), m_Makefile->GetCurrentOutputDirectory(), + file.SetName(newName.c_str(), this->Makefile->GetCurrentOutputDirectory(), "cxx",false); std::string hname; if ( (*j)[0] == '/' || (*j)[1] == ':' ) @@ -70,17 +70,17 @@ { if ( curr && curr->GetPropertyAsBool("GENERATED") ) { - hname = std::string( m_Makefile->GetCurrentOutputDirectory() ) + "/" + *j; + hname = std::string( this->Makefile->GetCurrentOutputDirectory() ) + "/" + *j; } else { hname = cdir + "/" + *j; } } - m_WrapHeaders.push_back(hname); + this->WrapHeaders.push_back(hname); // add starting depends file.GetDepends().push_back(hname); - m_WrapClasses.push_back(file); + this->WrapClasses.push_back(file); if (sourceListValue.size() > 0) { sourceListValue += ";"; @@ -89,7 +89,7 @@ } } - m_Makefile->AddDefinition(m_SourceList.c_str(), sourceListValue.c_str()); + this->Makefile->AddDefinition(this->SourceList.c_str(), sourceListValue.c_str()); return true; } @@ -97,9 +97,9 @@ { // first we add the rules for all the .h to Moc files - size_t lastClass = m_WrapClasses.size(); + size_t lastClass = this->WrapClasses.size(); std::vector depends; - const char* moc_exe = m_Makefile->GetRequiredDefinition("QT_MOC_EXECUTABLE"); + const char* moc_exe = this->Makefile->GetRequiredDefinition("QT_MOC_EXECUTABLE"); // wrap all the .h files depends.push_back(moc_exe); @@ -107,30 +107,32 @@ for(size_t classNum = 0; classNum < lastClass; classNum++) { // Add output to build list - m_Makefile->AddSource(m_WrapClasses[classNum]); + this->Makefile->AddSource(this->WrapClasses[classNum]); // set up moc command - std::string res = m_Makefile->GetCurrentOutputDirectory(); + std::string res = this->Makefile->GetCurrentOutputDirectory(); res += "/"; - res += m_WrapClasses[classNum].GetSourceName() + ".cxx"; + res += this->WrapClasses[classNum].GetSourceName() + ".cxx"; cmCustomCommandLine commandLine; commandLine.push_back(moc_exe); commandLine.push_back("-o"); commandLine.push_back(res); - commandLine.push_back(m_WrapHeaders[classNum]); + commandLine.push_back(this->WrapHeaders[classNum]); cmCustomCommandLines commandLines; commandLines.push_back(commandLine); std::vector realdepends = depends; - realdepends.push_back(m_WrapHeaders[classNum]); + realdepends.push_back(this->WrapHeaders[classNum]); const char* no_main_dependency = 0; - m_Makefile->AddCustomCommandToOutput(res.c_str(), + const char* no_working_dir = 0; + this->Makefile->AddCustomCommandToOutput(res.c_str(), realdepends, no_main_dependency, commandLines, - "QT Wrapped File"); + "QT Wrapped File", + no_working_dir); } } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmQTWrapCPPCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmQTWrapCPPCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmQTWrapCPPCommand.h 2005-11-24 01:33:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmQTWrapCPPCommand.h 2006-03-16 00:02:07.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmQTWrapCPPCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:39 $ - Version: $Revision: 1.8.2.1 $ + Date: $Date: 2006/03/15 16:02:07 $ + Version: $Revision: 1.10 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -83,13 +83,13 @@ /** * List of produced files. */ - std::vector m_WrapClasses; + std::vector WrapClasses; /** - * List of header files that pprovide the source for m_WrapClasses. + * List of header files that pprovide the source for WrapClasses. */ - std::vector m_WrapHeaders; - std::string m_LibraryName; - std::string m_SourceList; + std::vector WrapHeaders; + std::string LibraryName; + std::string SourceList; }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmQTWrapUICommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmQTWrapUICommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmQTWrapUICommand.cxx 2005-06-01 20:50:12.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmQTWrapUICommand.cxx 2006-03-16 00:02:07.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmQTWrapUICommand.cxx,v $ Language: C++ - Date: $Date: 2005/06/01 12:50:12 $ - Version: $Revision: 1.20 $ + Date: $Date: 2006/03/15 16:02:07 $ + Version: $Revision: 1.22 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -25,18 +25,18 @@ return false; } std::vector args; - m_Makefile->ExpandSourceListArguments(argsIn, args, 3); + this->Makefile->ExpandSourceListArguments(argsIn, args, 3); // what is the current source dir - std::string cdir = m_Makefile->GetCurrentDirectory(); + std::string cdir = this->Makefile->GetCurrentDirectory(); // keep the library name - m_LibraryName = args[0]; - m_HeaderList = args[1]; - m_SourceList = args[2]; + this->LibraryName = args[0]; + this->HeaderList = args[1]; + this->SourceList = args[2]; std::string sourceListValue; std::string headerListValue; - const char *def = m_Makefile->GetDefinition(m_SourceList.c_str()); + const char *def = this->Makefile->GetDefinition(this->SourceList.c_str()); if (def) { sourceListValue = def; @@ -46,7 +46,7 @@ for(std::vector::iterator j = (args.begin() + 3); j != args.end(); ++j) { - cmSourceFile *curr = m_Makefile->GetSource(j->c_str()); + cmSourceFile *curr = this->Makefile->GetSource(j->c_str()); // if we should wrap the class if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE")) @@ -56,15 +56,15 @@ cmSourceFile moc_file; std::string srcName = cmSystemTools::GetFilenameWithoutExtension(*j); header_file.SetName(srcName.c_str(), - m_Makefile->GetCurrentOutputDirectory(), + this->Makefile->GetCurrentOutputDirectory(), "h",false); source_file.SetName(srcName.c_str(), - m_Makefile->GetCurrentOutputDirectory(), + this->Makefile->GetCurrentOutputDirectory(), "cxx",false); std::string moc_source_name("moc_"); moc_source_name = moc_source_name + srcName; moc_file.SetName(moc_source_name.c_str(), - m_Makefile->GetCurrentOutputDirectory(), + this->Makefile->GetCurrentOutputDirectory(), "cxx",false); std::string origname; if ( (*j)[0] == '/' || (*j)[1] == ':' ) @@ -75,7 +75,7 @@ { if ( curr && curr->GetPropertyAsBool("GENERATED") ) { - origname = std::string( m_Makefile->GetCurrentOutputDirectory() ) + "/" + *j; + origname = std::string( this->Makefile->GetCurrentOutputDirectory() ) + "/" + *j; } else { @@ -83,18 +83,18 @@ } } std::string hname = header_file.GetFullPath(); - m_WrapUserInterface.push_back(origname); + this->WrapUserInterface.push_back(origname); // add starting depends moc_file.GetDepends().push_back(hname); source_file.GetDepends().push_back(hname); source_file.GetDepends().push_back(origname); header_file.GetDepends().push_back(origname); - m_WrapHeadersClasses.push_back(header_file); - m_WrapSourcesClasses.push_back(source_file); - m_WrapMocClasses.push_back(moc_file); - m_Makefile->AddSource(header_file); - m_Makefile->AddSource(source_file); - m_Makefile->AddSource(moc_file); + this->WrapHeadersClasses.push_back(header_file); + this->WrapSourcesClasses.push_back(source_file); + this->WrapMocClasses.push_back(moc_file); + this->Makefile->AddSource(header_file); + this->Makefile->AddSource(source_file); + this->Makefile->AddSource(moc_file); // create the list of headers if (headerListValue.size() > 0) @@ -114,8 +114,8 @@ } } - m_Makefile->AddDefinition(m_SourceList.c_str(), sourceListValue.c_str()); - m_Makefile->AddDefinition(m_HeaderList.c_str(), headerListValue.c_str()); + this->Makefile->AddDefinition(this->SourceList.c_str(), sourceListValue.c_str()); + this->Makefile->AddDefinition(this->HeaderList.c_str(), headerListValue.c_str()); return true; } @@ -123,10 +123,10 @@ { // first we add the rules for all the .ui to .h and .cxx files - size_t lastHeadersClass = m_WrapHeadersClasses.size(); + size_t lastHeadersClass = this->WrapHeadersClasses.size(); std::vector depends; - const char* uic_exe = m_Makefile->GetRequiredDefinition("QT_UIC_EXECUTABLE"); - const char* moc_exe = m_Makefile->GetRequiredDefinition("QT_MOC_EXECUTABLE"); + const char* uic_exe = this->Makefile->GetRequiredDefinition("QT_UIC_EXECUTABLE"); + const char* moc_exe = this->Makefile->GetRequiredDefinition("QT_MOC_EXECUTABLE"); // wrap all the .h files depends.push_back(uic_exe); @@ -134,26 +134,26 @@ for(size_t classNum = 0; classNum < lastHeadersClass; classNum++) { // set up .ui to .h and .cxx command - std::string hres = m_Makefile->GetCurrentOutputDirectory(); + std::string hres = this->Makefile->GetCurrentOutputDirectory(); hres += "/"; - hres += m_WrapHeadersClasses[classNum].GetSourceName() + "." + - m_WrapHeadersClasses[classNum].GetSourceExtension(); + hres += this->WrapHeadersClasses[classNum].GetSourceName() + "." + + this->WrapHeadersClasses[classNum].GetSourceExtension(); - std::string cxxres = m_Makefile->GetCurrentOutputDirectory(); + std::string cxxres = this->Makefile->GetCurrentOutputDirectory(); cxxres += "/"; - cxxres += m_WrapSourcesClasses[classNum].GetSourceName() + "." + - m_WrapSourcesClasses[classNum].GetSourceExtension(); + cxxres += this->WrapSourcesClasses[classNum].GetSourceName() + "." + + this->WrapSourcesClasses[classNum].GetSourceExtension(); - std::string mocres = m_Makefile->GetCurrentOutputDirectory(); + std::string mocres = this->Makefile->GetCurrentOutputDirectory(); mocres += "/"; - mocres += m_WrapMocClasses[classNum].GetSourceName() + "." + - m_WrapMocClasses[classNum].GetSourceExtension(); + mocres += this->WrapMocClasses[classNum].GetSourceName() + "." + + this->WrapMocClasses[classNum].GetSourceExtension(); cmCustomCommandLine hCommand; hCommand.push_back(uic_exe); hCommand.push_back("-o"); hCommand.push_back(hres); - hCommand.push_back(m_WrapUserInterface[classNum]); + hCommand.push_back(this->WrapUserInterface[classNum]); cmCustomCommandLines hCommandLines; hCommandLines.push_back(hCommand); @@ -163,7 +163,7 @@ cxxCommand.push_back(hres); cxxCommand.push_back("-o"); cxxCommand.push_back(cxxres); - cxxCommand.push_back(m_WrapUserInterface[classNum]); + cxxCommand.push_back(this->WrapUserInterface[classNum]); cmCustomCommandLines cxxCommandLines; cxxCommandLines.push_back(cxxCommand); @@ -176,30 +176,34 @@ mocCommandLines.push_back(mocCommand); depends.clear(); - depends.push_back(m_WrapUserInterface[classNum]); + depends.push_back(this->WrapUserInterface[classNum]); const char* no_main_dependency = 0; const char* no_comment = 0; - m_Makefile->AddCustomCommandToOutput(hres.c_str(), + const char* no_working_dir = 0; + this->Makefile->AddCustomCommandToOutput(hres.c_str(), depends, no_main_dependency, hCommandLines, - no_comment); + no_comment, + no_working_dir); depends.push_back(hres); - m_Makefile->AddCustomCommandToOutput(cxxres.c_str(), + this->Makefile->AddCustomCommandToOutput(cxxres.c_str(), depends, no_main_dependency, cxxCommandLines, - no_comment); + no_comment, + no_working_dir); depends.clear(); depends.push_back(hres); - m_Makefile->AddCustomCommandToOutput(mocres.c_str(), + this->Makefile->AddCustomCommandToOutput(mocres.c_str(), depends, no_main_dependency, mocCommandLines, - no_comment); + no_comment, + no_working_dir); } } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmQTWrapUICommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmQTWrapUICommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmQTWrapUICommand.h 2005-11-24 01:33:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmQTWrapUICommand.h 2006-03-16 00:02:07.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmQTWrapUICommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:39 $ - Version: $Revision: 1.8.2.1 $ + Date: $Date: 2006/03/15 16:02:07 $ + Version: $Revision: 1.10 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -85,16 +85,16 @@ /** * List of produced files. */ - std::vector m_WrapSourcesClasses; - std::vector m_WrapHeadersClasses; - std::vector m_WrapMocClasses; - /** - * List of header files that pprovide the source for m_WrapClasses. - */ - std::vector m_WrapUserInterface; - std::string m_LibraryName; - std::string m_HeaderList; - std::string m_SourceList; + std::vector WrapSourcesClasses; + std::vector WrapHeadersClasses; + std::vector WrapMocClasses; + /** + * List of header files that pprovide the source for WrapClasses. + */ + std::vector WrapUserInterface; + std::string LibraryName; + std::string HeaderList; + std::string SourceList; }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmRemoveCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmRemoveCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmRemoveCommand.cxx 2003-03-22 00:24:09.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmRemoveCommand.cxx 2006-03-16 00:02:07.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmRemoveCommand.cxx,v $ Language: C++ - Date: $Date: 2003/03/21 16:24:09 $ - Version: $Revision: 1.5 $ + Date: $Date: 2006/03/15 16:02:07 $ + Version: $Revision: 1.6 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -27,7 +27,7 @@ const char* variable = args[0].c_str(); // VAR is always first // get the old value const char* cacheValue - = m_Makefile->GetDefinition(variable); + = this->Makefile->GetDefinition(variable); // if there is no old value then return if (!cacheValue) @@ -73,7 +73,7 @@ } // add the definition - m_Makefile->AddDefinition(variable, value.c_str()); + this->Makefile->AddDefinition(variable, value.c_str()); return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmRemoveDefinitionsCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmRemoveDefinitionsCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmRemoveDefinitionsCommand.cxx 2004-04-16 01:58:10.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmRemoveDefinitionsCommand.cxx 2006-03-16 00:02:07.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmRemoveDefinitionsCommand.cxx,v $ Language: C++ - Date: $Date: 2004/04/15 17:58:10 $ - Version: $Revision: 1.1 $ + Date: $Date: 2006/03/15 16:02:07 $ + Version: $Revision: 1.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -28,7 +28,7 @@ for(std::vector::const_iterator i = args.begin(); i != args.end(); ++i) { - m_Makefile->RemoveDefineFlag(i->c_str()); + this->Makefile->RemoveDefineFlag(i->c_str()); } return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmRemoveDefinitionsCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmRemoveDefinitionsCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmRemoveDefinitionsCommand.h 2005-03-18 23:41:41.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmRemoveDefinitionsCommand.h 2006-03-11 00:13:14.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmRemoveDefinitionsCommand.h,v $ Language: C++ - Date: $Date: 2005/03/18 15:41:41 $ - Version: $Revision: 1.2 $ + Date: $Date: 2006/03/10 16:13:14 $ + Version: $Revision: 1.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -22,7 +22,8 @@ /** \class cmRemoveDefinitionsCommand * \brief Specify a list of compiler defines * - * cmRemoveDefinitionsCommand specifies a list of compiler defines. These defines will + * cmRemoveDefinitionsCommand specifies a list of compiler defines. + * These defines will * be removed from the compile command. */ class cmRemoveDefinitionsCommand : public cmCommand @@ -52,7 +53,8 @@ */ virtual const char* GetTerseDocumentation() { - return "Removes -D define flags to the command line of C and C++ compilers."; + return + "Removes -D define flags to the command line of C and C++ compilers."; } /** diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSeparateArgumentsCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSeparateArgumentsCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSeparateArgumentsCommand.cxx 2002-10-24 06:03:26.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSeparateArgumentsCommand.cxx 2006-03-16 00:02:07.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSeparateArgumentsCommand.cxx,v $ Language: C++ - Date: $Date: 2002/10/23 22:03:26 $ - Version: $Revision: 1.2 $ + Date: $Date: 2006/03/15 16:02:07 $ + Version: $Revision: 1.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -24,7 +24,7 @@ this->SetError("called with incorrect number of arguments"); return false; } - const char* cacheValue = m_Makefile->GetDefinition(args[0].c_str()); + const char* cacheValue = this->Makefile->GetDefinition(args[0].c_str()); if(!cacheValue) { return true; @@ -32,7 +32,7 @@ std::string value = cacheValue; cmSystemTools::ReplaceString(value, " ", ";"); - m_Makefile->AddDefinition(args[0].c_str(), value.c_str()); + this->Makefile->AddDefinition(args[0].c_str(), value.c_str()); return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSetCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSetCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSetCommand.cxx 2005-06-04 02:17:59.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSetCommand.cxx 2006-03-16 00:02:07.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSetCommand.cxx,v $ Language: C++ - Date: $Date: 2005/06/03 18:17:59 $ - Version: $Revision: 1.28 $ + Date: $Date: 2006/03/15 16:02:07 $ + Version: $Revision: 1.29 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -63,7 +63,7 @@ // SET (VAR) // Removes the definition of VAR. if (args.size() == 1) { - m_Makefile->RemoveDefinition(args[0].c_str()); + this->Makefile->RemoveDefinition(args[0].c_str()); return true; } @@ -134,7 +134,7 @@ // see if this is already in the cache cmCacheManager::CacheIterator it = - m_Makefile->GetCacheManager()->GetCacheIterator(variable); + this->Makefile->GetCacheManager()->GetCacheIterator(variable); if(!it.IsAtEnd() && (it.GetType() != cmCacheManager::UNINITIALIZED)) { // if the set is trying to CACHE the value but the value @@ -150,7 +150,7 @@ // if it is meant to be in the cache then define it in the cache if(cache) { - m_Makefile->AddCacheDefinition(variable, + this->Makefile->AddCacheDefinition(variable, value.c_str(), docstring, type); @@ -158,7 +158,7 @@ else { // add the definition - m_Makefile->AddDefinition(variable, value.c_str()); + this->Makefile->AddDefinition(variable, value.c_str()); } return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSetCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSetCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSetCommand.h 2005-11-24 01:33:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSetCommand.h 2005-11-17 23:28:35.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSetCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:39 $ - Version: $Revision: 1.15.2.1 $ + Date: $Date: 2005/11/17 15:28:35 $ + Version: $Revision: 1.16 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSetDirectoryPropertiesCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSetDirectoryPropertiesCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSetDirectoryPropertiesCommand.cxx 2004-05-21 04:56:34.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSetDirectoryPropertiesCommand.cxx 2006-03-16 00:02:07.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSetDirectoryPropertiesCommand.cxx,v $ Language: C++ - Date: $Date: 2004/05/20 20:56:34 $ - Version: $Revision: 1.2 $ + Date: $Date: 2006/03/15 16:02:07 $ + Version: $Revision: 1.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -54,29 +54,29 @@ { std::vector varArgsExpanded; cmSystemTools::ExpandListArgument(value, varArgsExpanded); - m_Makefile->SetIncludeDirectories(varArgsExpanded); + this->Makefile->SetIncludeDirectories(varArgsExpanded); } else if ( prop == "LINK_DIRECTORIES" ) { std::vector varArgsExpanded; cmSystemTools::ExpandListArgument(value, varArgsExpanded); - m_Makefile->SetLinkDirectories(varArgsExpanded); + this->Makefile->SetLinkDirectories(varArgsExpanded); } else if ( prop == "INCLUDE_REGULAR_EXPRESSION" ) { - m_Makefile->SetIncludeRegularExpression(value.c_str()); + this->Makefile->SetIncludeRegularExpression(value.c_str()); } else { if ( prop == "ADDITIONAL_MAKE_CLEAN_FILES" ) { // This property is not inherrited - if ( strcmp(m_Makefile->GetCurrentDirectory(), m_Makefile->GetStartDirectory()) != 0 ) + if ( strcmp(this->Makefile->GetCurrentDirectory(), this->Makefile->GetStartDirectory()) != 0 ) { continue; } } - m_Makefile->SetProperty(prop.c_str(), value.c_str()); + this->Makefile->SetProperty(prop.c_str(), value.c_str()); } } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSetDirectoryPropertiesCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSetDirectoryPropertiesCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSetDirectoryPropertiesCommand.h 2005-03-18 23:41:41.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSetDirectoryPropertiesCommand.h 2005-12-08 00:39:08.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSetDirectoryPropertiesCommand.h,v $ Language: C++ - Date: $Date: 2005/03/18 15:41:41 $ - Version: $Revision: 1.3 $ + Date: $Date: 2005/12/07 16:39:08 $ + Version: $Revision: 1.4 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -34,6 +34,11 @@ virtual bool InitialPass(std::vector const& args); /** + * This determines if the command is invoked when in script mode. + */ + virtual bool IsScriptable() { return true; } + + /** * The name of the command as specified in CMakeList.txt. */ virtual const char* GetName() { return "SET_DIRECTORY_PROPERTIES";} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSetSourceFilesPropertiesCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSetSourceFilesPropertiesCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSetSourceFilesPropertiesCommand.cxx 2004-02-23 02:14:59.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSetSourceFilesPropertiesCommand.cxx 2006-03-16 00:02:07.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSetSourceFilesPropertiesCommand.cxx,v $ Language: C++ - Date: $Date: 2004/02/22 18:14:59 $ - Version: $Revision: 1.12 $ + Date: $Date: 2006/03/15 16:02:07 $ + Version: $Revision: 1.13 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -129,7 +129,7 @@ { // get the source file cmSourceFile* sf = - m_Makefile->GetOrCreateSource(args[i].c_str(), generated); + this->Makefile->GetOrCreateSource(args[i].c_str(), generated); if(sf) { // now loop through all the props and set them diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSetSourceFilesPropertiesCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSetSourceFilesPropertiesCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSetSourceFilesPropertiesCommand.h 2005-11-24 01:33:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSetSourceFilesPropertiesCommand.h 2005-11-17 23:36:55.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSetSourceFilesPropertiesCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:39 $ - Version: $Revision: 1.8.8.1 $ + Date: $Date: 2005/11/17 15:36:55 $ + Version: $Revision: 1.9 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSetTargetPropertiesCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSetTargetPropertiesCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSetTargetPropertiesCommand.cxx 2002-12-22 00:14:47.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSetTargetPropertiesCommand.cxx 2006-03-16 00:02:07.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSetTargetPropertiesCommand.cxx,v $ Language: C++ - Date: $Date: 2002/12/21 16:14:47 $ - Version: $Revision: 1.1 $ + Date: $Date: 2006/03/15 16:02:07 $ + Version: $Revision: 1.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -69,7 +69,7 @@ return false; } - cmTargets& targets = m_Makefile->GetTargets(); + cmTargets& targets = this->Makefile->GetTargets(); // now loop over all the targets int i; unsigned int k; @@ -92,6 +92,7 @@ std::string message = "Can not find target to add properties to: "; message += args[i]; this->SetError(message.c_str()); + return false; } } return true; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSetTargetPropertiesCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSetTargetPropertiesCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSetTargetPropertiesCommand.h 2005-11-24 01:33:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSetTargetPropertiesCommand.h 2006-03-02 11:45:13.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSetTargetPropertiesCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:39 $ - Version: $Revision: 1.9.2.2 $ + Date: $Date: 2006/03/02 03:45:13 $ + Version: $Revision: 1.18 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -58,17 +58,33 @@ "Set properties on a target. The syntax for the command is to " "list all the files you want " "to change, and then provide the values you want to set next. " - "Properties that cmake knows about are PREFIX and SUFFIX for UNIX " - "systems and libraries. CMake also knows about LINK_FLAGS, which " - "can be used to add extra flags to the link step of a target. " - "DEFINE_SYMBOL is a symbol that is defined when compiling C or C++ " - "sources. " + "You can use any prop value pair you want and " + "extract it later with the GET_TARGET_PROPERTY command.\n" + "Properties that affect the name of a target's output file are " + "as follows. " + "The PREFIX and SUFFIX properties override the default target name " + "prefix (such as \"lib\") and suffix (such as \".so\"). " + "IMPORT_PREFIX and IMPORT_SUFFIX are the equivalent properties for " + "the import library corresponding to a DLL " + "(for SHARED library targets). " + "OUTPUT_NAME sets the real name of a target when it is built and " + "can be used to help create two targets of the same name even though " + "CMake requires unique logical target names. " + "_POSTFIX sets a postfix for the real name of the target " + "when it is built under the configuration named by " + "(in upper-case, such as \"DEBUG_POSTFIX\"). The value of " + "this property is initialized when the target is created to the " + "value of the variable CMAKE__POSTFIX (except for executable " + "targets because earlier CMake versions which did not use this " + "variable for executables)." + "\n" + "The LINK_FLAGS property can be used to add extra flags to the " + "link step of a target. " + "DEFINE_SYMBOL sets the name of the preprocessor symbol defined when " + "compiling sources in a shared library. " "If not set here then it is set to target_EXPORTS by default " "(with some substitutions if the target is not a valid C " - "identifier). " - "PRE_INSTALL_SCRIPT specifies a CMake script that is run " - "prior to installing the target. POST_INSTALL_SCRIPT specifies " - "a CMake script that is run after target is installed. " + "identifier).\n" "For shared libraries VERSION and SOVERSION can be used to specify " "the build version and api version respectively. When building or " "installing appropriate symlinks are created if the platform " @@ -77,15 +93,33 @@ "the same version number. " "For executables VERSION can be used to specify the build version. " "When building or installing appropriate symlinks are created if " - "the platform supports symlinks. " - "The OUTPUT_NAME can be used to set an output name that is " - "used in place of the target name when creating executables. " + "the platform supports symlinks.\n" + "There are a few properties used to specify RPATH rules. " + "INSTALL_RPATH is a semicolon-separated list specifying the rpath " + "to use in installed targets (for platforms that support it). " + "SKIP_BUILD_RPATH is a boolean specifying whether to skip automatic " + "generation of an rpath allowing the target to run from the " + "build tree. " + "BUILD_WITH_INSTALL_RPATH is a boolean specifying whether to link " + "the target in the build tree with the INSTALL_RPATH. This takes " + "precedence over SKIP_BUILD_RPATH and avoids the need for relinking " + "before installation. INSTALL_NAME_DIR is a string specifying the " + "directory portion of the \"install_name\" field of shared libraries " + "on Mac OSX to use in the installed targets. " + "When the target is created the values of " + "the variables CMAKE_INSTALL_RPATH, CMAKE_SKIP_BUILD_RPATH, " + "CMAKE_BUILD_WITH_INSTALL_RPATH, and CMAKE_INSTALL_NAME_DIR " + "are used to initialize these properties.\n" "PROJECT_LABEL can be used to change the name of " "the target in an IDE like visual studio. VS_KEYWORD can be set " "to change the visual studio keyword, for example QT integration " - "works better if this is set to Qt4VSv1.0. " - "You can use any prop value pair you want and " - "extract it later with the GET_TARGET_PROPERTY command."; + "works better if this is set to Qt4VSv1.0.\n" + "The PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT properties are the " + "old way to specify CMake scripts to run before and after " + "installing a target. They are used only when the old " + "INSTALL_TARGETS command is used to install the target. Use the " + "INSTALL command instead." + ; } cmTypeMacro(cmSetTargetPropertiesCommand, cmCommand); diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSetTestsPropertiesCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSetTestsPropertiesCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSetTestsPropertiesCommand.cxx 2005-08-12 02:02:20.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSetTestsPropertiesCommand.cxx 2006-03-16 00:02:07.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSetTestsPropertiesCommand.cxx,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:20 $ - Version: $Revision: 1.1.2.1 $ + Date: $Date: 2006/03/15 16:02:07 $ + Version: $Revision: 1.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -72,7 +72,7 @@ return false; } - std::vector &tests = *m_Makefile->GetTests(); + std::vector &tests = *this->Makefile->GetTests(); // now loop over all the targets int i; unsigned int k; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSetTestsPropertiesCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSetTestsPropertiesCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSetTestsPropertiesCommand.h 2005-11-24 01:33:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSetTestsPropertiesCommand.h 2006-03-11 00:13:14.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSetTestsPropertiesCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:39 $ - Version: $Revision: 1.1.2.2 $ + Date: $Date: 2006/03/10 16:13:14 $ + Version: $Revision: 1.4 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -52,12 +52,15 @@ virtual const char* GetFullDocumentation() { return - " SET_TESTS_PROPERTIES(test1 [test2...] PROPERTIES prop1 value1 prop2 value2)\n" + " SET_TESTS_PROPERTIES(test1 [test2...] PROPERTIES prop1 value1 prop2" + " value2)\n" "Set a property for the tests. If the property is not found, CMake will " "report an error. The properties include:\n" - "WILL_FAIL: If set to true, this will invert the pass/fail flag of the test.\n" + "WILL_FAIL: If set to true, this will invert the pass/fail flag of the" + " test.\n" "PASS_REGULAR_EXPRESSION: If set, the test output will be checked " - "against the specified regular expressions and at least one of the regular " + "against the specified regular expressions and at least one of the" + " regular " "expressions has to match, otherwise the test will fail.\n" " Example: PASS_REGULAR_EXPRESSION \"TestPassed;All ok\"\n" "FAIL_REGULAR_EXPRESSION: If set, if the output will match to one of " diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSiteNameCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSiteNameCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSiteNameCommand.cxx 2004-04-15 23:38:35.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSiteNameCommand.cxx 2006-03-16 00:02:07.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSiteNameCommand.cxx,v $ Language: C++ - Date: $Date: 2004/04/15 15:38:35 $ - Version: $Revision: 1.21 $ + Date: $Date: 2006/03/15 16:02:07 $ + Version: $Revision: 1.22 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -35,13 +35,13 @@ paths.push_back("/usr/local/bin"); const char* cacheValue - = m_Makefile->GetDefinition(args[0].c_str()); + = this->Makefile->GetDefinition(args[0].c_str()); if(cacheValue) { return true; } - const char *temp = m_Makefile->GetDefinition("HOSTNAME"); + const char *temp = this->Makefile->GetDefinition("HOSTNAME"); std::string hostname_cmd; if(temp) { @@ -88,7 +88,7 @@ } } #endif - m_Makefile-> + this->Makefile-> AddCacheDefinition(args[0].c_str(), siteName.c_str(), "Name of the computer/site where compile is being run", diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSiteNameCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSiteNameCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSiteNameCommand.h 2005-03-18 23:41:41.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSiteNameCommand.h 2005-12-08 00:39:08.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSiteNameCommand.h,v $ Language: C++ - Date: $Date: 2005/03/18 15:41:41 $ - Version: $Revision: 1.8 $ + Date: $Date: 2005/12/07 16:39:08 $ + Version: $Revision: 1.9 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -42,6 +42,11 @@ virtual bool InitialPass(std::vector const& args); /** + * This determines if the command is invoked when in script mode. + */ + virtual bool IsScriptable() { return true; } + + /** * The name of the command as specified in CMakeList.txt. */ virtual const char* GetName() {return "SITE_NAME";} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSourceFile.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSourceFile.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSourceFile.cxx 2005-11-24 01:33:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSourceFile.cxx 2006-03-16 00:02:07.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSourceFile.cxx,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:39 $ - Version: $Revision: 1.27.2.1 $ + Date: $Date: 2006/03/15 16:02:07 $ + Version: $Revision: 1.30 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -29,10 +29,10 @@ { this->SetProperty("HEADER_FILE_ONLY","1"); - m_SourceNameWithoutLastExtension = ""; + this->SourceNameWithoutLastExtension = ""; // Save the original name given. - m_SourceName = name; + this->SourceName = name; // Convert the name to a full path in case the given name is a // relative path. @@ -43,39 +43,39 @@ std::string hname = pathname; if(cmSystemTools::FileExists(hname.c_str())) { - m_SourceName = cmSystemTools::GetFilenamePath(name); - if ( m_SourceName.size() > 0 ) + this->SourceName = cmSystemTools::GetFilenamePath(name); + if ( this->SourceName.size() > 0 ) { - m_SourceName += "/"; + this->SourceName += "/"; } - m_SourceName += cmSystemTools::GetFilenameWithoutLastExtension(name); + this->SourceName += cmSystemTools::GetFilenameWithoutLastExtension(name); std::string::size_type pos = hname.rfind('.'); if(pos != std::string::npos) { - m_SourceExtension = hname.substr(pos+1, hname.size()-pos); + this->SourceExtension = hname.substr(pos+1, hname.size()-pos); if ( cmSystemTools::FileIsFullPath(name) ) { std::string::size_type pos2 = hname.rfind('/'); if(pos2 != std::string::npos) { - m_SourceName = hname.substr(pos2+1, pos - pos2-1); + this->SourceName = hname.substr(pos2+1, pos - pos2-1); } } } // See if the file is a header file - if(std::find( headerExts.begin(), headerExts.end(), m_SourceExtension ) == + if(std::find( headerExts.begin(), headerExts.end(), this->SourceExtension ) == headerExts.end()) { this->SetProperty("HEADER_FILE_ONLY","0"); } - m_FullPath = hname; + this->FullPath = hname; // Mark this as an external object file if it has the proper // extension. THIS CODE IS DUPLICATED IN THE OTHER SetName METHOD. // THESE METHODS SHOULD BE MERGED. - if ( m_SourceExtension == "obj" || m_SourceExtension == "o" || - m_SourceExtension == "lo" ) + if ( this->SourceExtension == "obj" || this->SourceExtension == "o" || + this->SourceExtension == "lo" ) { this->SetProperty("EXTERNAL_OBJECT", "1"); } @@ -91,9 +91,9 @@ hname += *ext; if(cmSystemTools::FileExists(hname.c_str())) { - m_SourceExtension = *ext; + this->SourceExtension = *ext; this->SetProperty("HEADER_FILE_ONLY","0"); - m_FullPath = hname; + this->FullPath = hname; return; } } @@ -107,8 +107,8 @@ hname += *ext; if(cmSystemTools::FileExists(hname.c_str())) { - m_SourceExtension = *ext; - m_FullPath = hname; + this->SourceExtension = *ext; + this->FullPath = hname; return; } } @@ -134,23 +134,23 @@ bool hfo) { this->SetProperty("HEADER_FILE_ONLY",(hfo ? "1" : "0")); - m_SourceNameWithoutLastExtension = ""; - m_SourceName = name; - std::string fname = m_SourceName; + this->SourceNameWithoutLastExtension = ""; + this->SourceName = name; + std::string fname = this->SourceName; if(ext && strlen(ext)) { fname += "."; fname += ext; } - m_FullPath = cmSystemTools::CollapseFullPath(fname.c_str(), dir); - cmSystemTools::ConvertToUnixSlashes(m_FullPath); - m_SourceExtension = ext; + this->FullPath = cmSystemTools::CollapseFullPath(fname.c_str(), dir); + cmSystemTools::ConvertToUnixSlashes(this->FullPath); + this->SourceExtension = ext; // Mark this as an external object file if it has the proper // extension. THIS CODE IS DUPLICATED IN THE OTHER SetName METHOD. // THESE METHODS SHOULD BE MERGED. - if ( m_SourceExtension == "obj" || m_SourceExtension == "o" || - m_SourceExtension == "lo" ) + if ( this->SourceExtension == "obj" || this->SourceExtension == "o" || + this->SourceExtension == "lo" ) { this->SetProperty("EXTERNAL_OBJECT", "1"); } @@ -159,9 +159,9 @@ void cmSourceFile::Print() const { - std::cerr << "m_FullPath: " << m_FullPath << "\n"; - std::cerr << "m_SourceName: " << m_SourceName << std::endl; - std::cerr << "m_SourceExtension: " << m_SourceExtension << "\n"; + std::cerr << "this->FullPath: " << this->FullPath << "\n"; + std::cerr << "this->SourceName: " << this->SourceName << std::endl; + std::cerr << "this->SourceExtension: " << this->SourceExtension << "\n"; } void cmSourceFile::SetProperty(const char* prop, const char* value) @@ -174,14 +174,14 @@ { value = "NOTFOUND"; } - m_Properties[prop] = value; + this->Properties[prop] = value; } const char *cmSourceFile::GetProperty(const char* prop) const { std::map::const_iterator i = - m_Properties.find(prop); - if (i != m_Properties.end()) + this->Properties.find(prop); + if (i != this->Properties.end()) { return i->second.c_str(); } @@ -191,8 +191,8 @@ bool cmSourceFile::GetPropertyAsBool(const char* prop) const { std::map::const_iterator i = - m_Properties.find(prop); - if (i != m_Properties.end()) + this->Properties.find(prop); + if (i != this->Properties.end()) { return cmSystemTools::IsOn(i->second.c_str()); } @@ -201,18 +201,19 @@ void cmSourceFile::SetCustomCommand(cmCustomCommand* cc) { - if(m_CustomCommand) + if(this->CustomCommand) { - delete m_CustomCommand; + delete this->CustomCommand; } - m_CustomCommand = cc; + this->CustomCommand = cc; } const std::string& cmSourceFile::GetSourceNameWithoutLastExtension() { - if ( m_SourceNameWithoutLastExtension.empty() ) + if ( this->SourceNameWithoutLastExtension.empty() ) { - m_SourceNameWithoutLastExtension = cmSystemTools::GetFilenameWithoutLastExtension(m_FullPath); + this->SourceNameWithoutLastExtension = + cmSystemTools::GetFilenameWithoutLastExtension(this->FullPath); } - return m_SourceNameWithoutLastExtension; + return this->SourceNameWithoutLastExtension; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSourceFile.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSourceFile.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSourceFile.h 2005-04-14 04:35:26.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSourceFile.h 2006-03-16 00:02:07.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSourceFile.h,v $ Language: C++ - Date: $Date: 2005/04/13 20:35:26 $ - Version: $Revision: 1.14 $ + Date: $Date: 2006/03/15 16:02:07 $ + Version: $Revision: 1.15 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -34,7 +34,7 @@ */ cmSourceFile() { - m_CustomCommand = 0; + this->CustomCommand = 0; } ~cmSourceFile() { @@ -54,8 +54,8 @@ * Get the list of the custom commands for this source file */ const cmCustomCommand *GetCustomCommand() const - {return m_CustomCommand;} - cmCustomCommand *GetCustomCommand() {return m_CustomCommand;} + {return this->CustomCommand;} + cmCustomCommand *GetCustomCommand() {return this->CustomCommand;} void SetCustomCommand(cmCustomCommand *cc); /** @@ -79,27 +79,27 @@ /** * The full path to the file. */ - const std::string &GetFullPath() const {return m_FullPath;} - void SetFullPath(const char *name) {m_FullPath = name;} + const std::string &GetFullPath() const {return this->FullPath;} + void SetFullPath(const char *name) {this->FullPath = name;} /** * The file name associated with stripped off directory and extension. * (In most cases this is the name of the class.) */ - const std::string &GetSourceName() const {return m_SourceName;} - void SetSourceName(const char *name) {m_SourceName = name;} + const std::string &GetSourceName() const {return this->SourceName;} + void SetSourceName(const char *name) {this->SourceName = name;} /** * The file extension associated with source file */ - const std::string &GetSourceExtension() const {return m_SourceExtension;} - void SetSourceExtension(const char *name) {m_SourceExtension = name;} + const std::string &GetSourceExtension() const {return this->SourceExtension;} + void SetSourceExtension(const char *name) {this->SourceExtension = name;} /** * Return the vector that holds the list of dependencies */ - const std::vector &GetDepends() const {return m_Depends;} - std::vector &GetDepends() {return m_Depends;} + const std::vector &GetDepends() const {return this->Depends;} + std::vector &GetDepends() {return this->Depends;} /** * Get the source name without last extension @@ -107,13 +107,13 @@ const std::string& GetSourceNameWithoutLastExtension(); private: - std::map m_Properties; - cmCustomCommand *m_CustomCommand; - std::string m_FullPath; - std::string m_SourceName; - std::string m_SourceExtension; - std::vector m_Depends; - std::string m_SourceNameWithoutLastExtension; + std::map Properties; + cmCustomCommand *CustomCommand; + std::string FullPath; + std::string SourceName; + std::string SourceExtension; + std::vector Depends; + std::string SourceNameWithoutLastExtension; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSourceGroupCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSourceGroupCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSourceGroupCommand.cxx 2005-08-12 02:02:20.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSourceGroupCommand.cxx 2006-03-16 00:02:07.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSourceGroupCommand.cxx,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:20 $ - Version: $Revision: 1.11.8.1 $ + Date: $Date: 2006/03/15 16:02:07 $ + Version: $Revision: 1.16 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -17,31 +17,20 @@ #include "cmSourceGroupCommand.h" inline std::vector tokenize(const std::string& str, - const std::string& sep, - bool skipEmptyTokens) + const std::string& sep) { std::vector tokens; - std::string::size_type tokstart,tokend; - - if (skipEmptyTokens) - { - tokend=0; - } - else + if(str.size() == 0) { - tokend=std::string::npos; + tokens.push_back(""); + return tokens; } - + std::string::size_type tokstart,tokend; + + tokend=0; do { - if (skipEmptyTokens) - { - tokstart=str.find_first_not_of(sep,tokend); - } - else - { - tokstart=tokend+1; - } + tokstart=str.find_first_not_of(sep,tokend); if (tokstart==std::string::npos) { break; // no more tokens @@ -56,7 +45,6 @@ tokens.push_back(str.substr(tokstart,tokend-tokstart)); } } while (tokend!=std::string::npos); - return tokens; } @@ -68,32 +56,35 @@ this->SetError("called with incorrect number of arguments"); return false; } - - std::string delimiter = "\\"; - if(m_Makefile->GetDefinition("SOURCE_GROUP_DELIMITER")) - delimiter = m_Makefile->GetDefinition("SOURCE_GROUP_DELIMITER"); + std::string delimiter = "\\"; + if(this->Makefile->GetDefinition("SOURCE_GROUP_DELIMITER")) + { + delimiter = this->Makefile->GetDefinition("SOURCE_GROUP_DELIMITER"); + } - std::vector folders = tokenize(args[0], delimiter, true); + std::vector folders = tokenize(args[0], delimiter); const char *parent = NULL; - cmSourceGroup* sg = NULL; - for(unsigned int i=0;iGetSourceGroup(folders[i].c_str()); - if(!sg) - { - m_Makefile->AddSourceGroup(folders[i].c_str(), 0, parent); + sg = this->Makefile->GetSourceGroup(folders[i].c_str()); + if(!sg) + { + this->Makefile->AddSourceGroup(folders[i].c_str(), 0, parent); } - sg = m_Makefile->GetSourceGroup(folders[i].c_str()); + sg = this->Makefile->GetSourceGroup(folders[i].c_str()); parent = folders[i].c_str(); } - + if(!sg) + { + this->SetError("Could not create or find source group"); + return false; + } // If only two arguments are given, the pre-1.8 version of the // command is being invoked. - if(args.size() == 2 && args[1] != "FILES") + if(args.size() == 2 && args[1] != "FILES") { sg->SetGroupRegex(args[1].c_str()); return true; @@ -129,10 +120,11 @@ std::string src = args[i].c_str(); if(!cmSystemTools::FileIsFullPath(src.c_str())) { - src = m_Makefile->GetCurrentDirectory(); + src = this->Makefile->GetCurrentDirectory(); src += "/"; src += args[i]; } + src = cmSystemTools::CollapseFullPath(src.c_str()); sg->AddGroupFile(src.c_str()); } else diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSourceGroupCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSourceGroupCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSourceGroupCommand.h 2005-11-24 01:33:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSourceGroupCommand.h 2005-11-18 00:04:11.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSourceGroupCommand.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:39 $ - Version: $Revision: 1.11.2.1 $ + Date: $Date: 2005/11/17 16:04:11 $ + Version: $Revision: 1.12 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSourceGroup.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSourceGroup.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSourceGroup.cxx 2005-08-12 02:02:20.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSourceGroup.cxx 2006-03-16 00:02:07.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSourceGroup.cxx,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:20 $ - Version: $Revision: 1.16.8.1 $ + Date: $Date: 2006/03/15 16:02:07 $ + Version: $Revision: 1.18 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -17,7 +17,7 @@ #include "cmSourceGroup.h" //---------------------------------------------------------------------------- -cmSourceGroup::cmSourceGroup(const char* name, const char* regex): m_Name(name) +cmSourceGroup::cmSourceGroup(const char* name, const char* regex): Name(name) { this->SetGroupRegex(regex); } @@ -27,37 +27,37 @@ { if(regex) { - m_GroupRegex.compile(regex); + this->GroupRegex.compile(regex); } else { - m_GroupRegex.compile("^$"); + this->GroupRegex.compile("^$"); } } //---------------------------------------------------------------------------- void cmSourceGroup::AddGroupFile(const char* name) { - m_GroupFiles.insert(name); + this->GroupFiles.insert(name); } //---------------------------------------------------------------------------- const char* cmSourceGroup::GetName() const { - return m_Name.c_str(); + return this->Name.c_str(); } //---------------------------------------------------------------------------- bool cmSourceGroup::MatchesRegex(const char* name) { - return m_GroupRegex.find(name); + return this->GroupRegex.find(name); } //---------------------------------------------------------------------------- bool cmSourceGroup::MatchesFiles(const char* name) { - std::set::const_iterator i = m_GroupFiles.find(name); - if(i != m_GroupFiles.end()) + std::set::const_iterator i = this->GroupFiles.find(name); + if(i != this->GroupFiles.end()) { return true; } @@ -67,33 +67,33 @@ //---------------------------------------------------------------------------- void cmSourceGroup::AssignSource(const cmSourceFile* sf) { - m_SourceFiles.push_back(sf); + this->SourceFiles.push_back(sf); } //---------------------------------------------------------------------------- const std::vector& cmSourceGroup::GetSourceFiles() const { - return m_SourceFiles; + return this->SourceFiles; } //---------------------------------------------------------------------------- std::vector& cmSourceGroup::GetSourceFiles() { - return m_SourceFiles; + return this->SourceFiles; } //---------------------------------------------------------------------------- void cmSourceGroup::AddChild(cmSourceGroup child) { - m_GroupChildren.push_back(child); + this->GroupChildren.push_back(child); } //---------------------------------------------------------------------------- cmSourceGroup *cmSourceGroup::lookupChild(const char* name) { // initializing iterators - std::vector::iterator iter = m_GroupChildren.begin(); - std::vector::iterator end = m_GroupChildren.end(); + std::vector::iterator iter = this->GroupChildren.begin(); + std::vector::iterator end = this->GroupChildren.end(); // st for(;iter!=end; ++iter) @@ -122,8 +122,8 @@ cmSourceGroup *cmSourceGroup::MatchChildrenFiles(const char *name) { // initializing iterators - std::vector::iterator iter = m_GroupChildren.begin(); - std::vector::iterator end = m_GroupChildren.end(); + std::vector::iterator iter = this->GroupChildren.begin(); + std::vector::iterator end = this->GroupChildren.end(); if(this->MatchesFiles(name)) { @@ -144,8 +144,8 @@ cmSourceGroup *cmSourceGroup::MatchChildrenRegex(const char *name) { // initializing iterators - std::vector::iterator iter = m_GroupChildren.begin(); - std::vector::iterator end = m_GroupChildren.end(); + std::vector::iterator iter = this->GroupChildren.begin(); + std::vector::iterator end = this->GroupChildren.end(); if(this->MatchesRegex(name)) { @@ -164,5 +164,5 @@ std::vector cmSourceGroup::GetGroupChildren() const { - return m_GroupChildren; + return this->GroupChildren; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSourceGroup.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSourceGroup.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmSourceGroup.h 2005-08-12 02:02:20.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmSourceGroup.h 2006-03-16 00:02:07.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSourceGroup.h,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:20 $ - Version: $Revision: 1.16.8.1 $ + Date: $Date: 2006/03/15 16:02:07 $ + Version: $Revision: 1.19 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -47,7 +47,7 @@ * Add a file name to the explicit list of files for this group. */ void AddGroupFile(const char* name); - + /** * Add child to this sourcegroup */ @@ -72,9 +72,10 @@ * Check if the given name matches this group's explicit file list. */ bool MatchesFiles(const char* name); - - /** - * Check if the given name matches this group's explicit file list in children. + + /** + * Check if the given name matches this group's explicit file list + * in children. */ cmSourceGroup *MatchChildrenFiles(const char *name); @@ -101,25 +102,25 @@ /** * The name of the source group. */ - std::string m_Name; + std::string Name; /** * The regular expression matching the files in the group. */ - cmsys::RegularExpression m_GroupRegex; + cmsys::RegularExpression GroupRegex; /** * Set of file names explicitly added to this group. */ - std::set m_GroupFiles; + std::set GroupFiles; /** * Vector of all source files that have been assigned to * this group. */ - std::vector m_SourceFiles; + std::vector SourceFiles; - std::vector m_GroupChildren; + std::vector GroupChildren; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmStandardIncludes.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmStandardIncludes.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmStandardIncludes.h 2005-06-18 01:04:55.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmStandardIncludes.h 2006-03-16 22:33:23.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmStandardIncludes.h,v $ Language: C++ - Date: $Date: 2005/06/17 17:04:55 $ - Version: $Revision: 1.58 $ + Date: $Date: 2006/03/16 14:33:23 $ + Version: $Revision: 1.62 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -102,6 +102,21 @@ #include #include +// Borland C++ defines several of the stdlib.h and string.h symbols in +// sub-headers search.h and mem.h. These sub-headers have using +// declarations to pull functions from the std namespace to the global +// namespace, but they are defined only if the header was not included +// through the C++-style cstdlib or cstring header. These outer +// headers are included by the streams library in C++-style and +// include blockers are put in place that prevent including the +// C-style versions from ever including the sub-headers. Therefore we +// have to include the sub-headers here to get the using declarations. +#if defined(__BORLANDC__) +# include /* mem... functions from string.h */ +# include /* search functions from stdlib.h */ +#endif + + #if !defined(_WIN32) && defined(__COMO__) // Hack for como strict mode to avoid defining _SVID_SOURCE or _BSD_SOURCE. extern "C" @@ -197,26 +212,8 @@ // use this class to shrink the size of symbols in .o files // std::string is really basic_string<....lots of stuff....> // when combined with a map or set, the symbols can be > 2000 chars! -struct cmStdString : public std::string -{ - typedef std::string StdString; - typedef StdString::value_type value_type; - typedef StdString::pointer pointer; - typedef StdString::reference reference; - typedef StdString::const_reference const_reference; - typedef StdString::size_type size_type; - typedef StdString::difference_type difference_type; - typedef StdString::iterator iterator; - typedef StdString::const_iterator const_iterator; - typedef StdString::reverse_iterator reverse_iterator; - typedef StdString::const_reverse_iterator const_reverse_iterator; - - cmStdString(): StdString() {} - cmStdString(const value_type* s): StdString(s) {} - cmStdString(const value_type* s, size_type n): StdString(s, n) {} - cmStdString(const StdString& s, size_type pos=0, size_type n=npos): - StdString(s, pos, n) {} -}; +#include +typedef cmsys::String cmStdString; // Define cmOStringStream and cmIStringStream wrappers to hide // differences between std::stringstream and the old strstream. @@ -243,11 +240,11 @@ class cmOStrStreamCleanup { public: - cmOStrStreamCleanup(std::ostrstream& ostr): m_OStrStream(ostr) {} - ~cmOStrStreamCleanup() { m_OStrStream.rdbuf()->freeze(0); } + cmOStrStreamCleanup(std::ostrstream& ostr): OStrStream(ostr) {} + ~cmOStrStreamCleanup() { this->OStrStream.rdbuf()->freeze(0); } static void IgnoreUnusedVariable(const cmOStrStreamCleanup&) {} protected: - std::ostrstream& m_OStrStream; + std::ostrstream& OStrStream; }; class cmOStringStream: public std::ostrstream @@ -323,7 +320,8 @@ # pragma reset woff 1375 /* base class destructor not virtual */ #endif -// All subclasses of cmCommand or cmCTestGenericHandler should invoke this macro. +// All subclasses of cmCommand or cmCTestGenericHandler should +// invoke this macro. #define cmTypeMacro(thisClass,superclass) \ virtual const char* GetNameOfClass() { return #thisClass; } \ typedef superclass Superclass; \ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/cmStringCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmStringCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/cmStringCommand.cxx 2005-10-25 03:43:52.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/cmStringCommand.cxx 2006-03-16 00:02:07.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmStringCommand.cxx,v $ Language: C++ - Date: $Date: 2005/10/24 19:43:52 $ - Version: $Revision: 1.12.4.1 $ + Date: $Date: 2006/03/15 16:02:07 $ + Version: $Revision: 1.19 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -95,7 +95,7 @@ } // Store the output in the provided variable. - m_Makefile->AddDefinition(outvar.c_str(), output.c_str()); + this->Makefile->AddDefinition(outvar.c_str(), output.c_str()); return true; } @@ -127,7 +127,7 @@ } } // Store the output in the provided variable. - m_Makefile->AddDefinition(outvar.c_str(), output.c_str()); + this->Makefile->AddDefinition(outvar.c_str(), output.c_str()); return true; } @@ -170,10 +170,10 @@ // Configure the string. std::string output; - m_Makefile->ConfigureString(args[1], output, atOnly, escapeQuotes); + this->Makefile->ConfigureString(args[1], output, atOnly, escapeQuotes); // Store the output in the provided variable. - m_Makefile->AddDefinition(args[2].c_str(), output.c_str()); + this->Makefile->AddDefinition(args[2].c_str(), output.c_str()); return true; } @@ -226,7 +226,8 @@ //---------------------------------------------------------------------------- bool cmStringCommand::RegexMatch(std::vector const& args) { - //"STRING(REGEX MATCH =", "Set a CPack variable.", \ + "Set a variable that can be used by the generator."}, \ + {"--patch ", "Specify the patch of the project.", + "This option specifies the patch of the project that will be " + "used by installer." }, + {"--vendor ", "Specify the vendor of the project.", + "This option specifies the vendor of the project that will be " + "used by installer." }, + {0,0,0} +}; + +//---------------------------------------------------------------------------- +static const cmDocumentationEntry cmDocumentationSeeAlso[] = +{ + {0, "cmake", 0}, + {0, "ccmake", 0}, + {0, 0, 0} +}; + +//---------------------------------------------------------------------------- +int cpackUnknownArgument(const char*, void*) +{ + return 1; +} + +//---------------------------------------------------------------------------- +struct cpackDefinitions +{ + typedef std::map MapType; + MapType Map; + cmCPackLog *Log; +}; + +//---------------------------------------------------------------------------- +int cpackDefinitionArgument(const char* argument, const char* cValue, + void* call_data) +{ + (void)argument; + cpackDefinitions* def = static_cast(call_data); + std::string value = cValue; + size_t pos = value.find_first_of("="); + if ( pos == std::string::npos ) + { + cmCPack_Log(def->Log, cmCPackLog::LOG_ERROR, + "Please specify CPack definitions as: KEY=VALUE" << std::endl); + return 0; + } + std::string key = value.substr(0, pos); + value = value.c_str() + pos + 1; + def->Map[key] = value; + cmCPack_Log(def->Log, cmCPackLog::LOG_DEBUG, "Set CPack variable: " + << key.c_str() << " to \"" << value.c_str() << "\"" << std::endl); + return 1; +} + +//---------------------------------------------------------------------------- +// this is CPack. +int main (int argc, char *argv[]) +{ + cmCPackLog log; + log.SetErrorPrefix("CPack Error: "); + log.SetWarningPrefix("CPack Warning: "); + log.SetOutputPrefix("CPack: "); + log.SetVerbosePrefix("CPack Verbose: "); + + cmSystemTools::EnableMSVCDebugHook(); + + if ( cmSystemTools::GetCurrentWorkingDirectory().size() == 0 ) + { + cmCPack_Log(&log, cmCPackLog::LOG_ERROR, + "Current working directory cannot be established." << std::endl); + } + + std::string generator; + bool help = false; + bool helpVersion = false; + bool verbose = false; + bool debug = false; + std::string helpFull; + std::string helpMAN; + std::string helpHTML; + + std::string cpackProjectName; + std::string cpackProjectDirectory + = cmsys::SystemTools::GetCurrentWorkingDirectory(); + std::string cpackBuildConfig; + std::string cpackProjectVersion; + std::string cpackProjectPatch; + std::string cpackProjectVendor; + std::string cpackConfigFile; + + cpackDefinitions definitions; + definitions.Log = &log; + + cpackConfigFile = ""; + + cmDocumentation doc; + cmsys::CommandLineArguments arg; + arg.Initialize(argc, argv); + typedef cmsys::CommandLineArguments argT; + // Help arguments + arg.AddArgument("--help", argT::NO_ARGUMENT, &help, "CPack help"); + arg.AddArgument("--help-full", argT::SPACE_ARGUMENT, &helpFull, + "CPack help"); + arg.AddArgument("--help-html", argT::SPACE_ARGUMENT, &helpHTML, + "CPack help"); + arg.AddArgument("--help-man", argT::SPACE_ARGUMENT, &helpMAN, "CPack help"); + arg.AddArgument("--version", argT::NO_ARGUMENT, &helpVersion, "CPack help"); + + arg.AddArgument("-V", argT::NO_ARGUMENT, &verbose, "CPack verbose"); + arg.AddArgument("--verbose", argT::NO_ARGUMENT, &verbose, "-V"); + arg.AddArgument("--debug", argT::NO_ARGUMENT, &debug, "-V"); + arg.AddArgument("--config", argT::SPACE_ARGUMENT, &cpackConfigFile, + "CPack configuration file"); + arg.AddArgument("-C", argT::SPACE_ARGUMENT, &cpackBuildConfig, + "CPack build configuration"); + arg.AddArgument("-G", argT::SPACE_ARGUMENT, + &generator, "CPack generator"); + arg.AddArgument("-P", argT::SPACE_ARGUMENT, + &cpackProjectName, "CPack project name"); + arg.AddArgument("-R", argT::SPACE_ARGUMENT, + &cpackProjectVersion, "CPack project version"); + arg.AddArgument("-B", argT::SPACE_ARGUMENT, + &cpackProjectDirectory, "CPack project directory"); + arg.AddArgument("--patch", argT::SPACE_ARGUMENT, + &cpackProjectPatch, "CPack project patch"); + arg.AddArgument("--vendor", argT::SPACE_ARGUMENT, + &cpackProjectVendor, "CPack project vendor"); + arg.AddCallback("-D", argT::SPACE_ARGUMENT, + cpackDefinitionArgument, &definitions, "CPack Definitions"); + arg.SetUnknownArgumentCallback(cpackUnknownArgument); + + // Parse command line + int parsed = arg.Parse(); + + // Setup logging + if ( verbose ) + { + log.SetVerbose(verbose); + cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Verbse" << std::endl); + } + if ( debug ) + { + log.SetDebug(debug); + cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Debug" << std::endl); + } + + cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, + "Read CPack config file: " << cpackConfigFile.c_str() << std::endl); + + cmake cminst; + cmGlobalGenerator cmgg; + cmgg.SetCMakeInstance(&cminst); + cmLocalGenerator* cmlg = cmgg.CreateLocalGenerator(); + cmMakefile* mf = cmlg->GetMakefile(); + + bool cpackConfigFileSpecified = true; + if ( cpackConfigFile.empty() ) + { + cpackConfigFile = cmSystemTools::GetCurrentWorkingDirectory(); + cpackConfigFile += "/CPackConfig.cmake"; + cpackConfigFileSpecified = false; + } + + cmCPackGenerators generators; + generators.SetLogger(&log); + cmCPackGenericGenerator* cpackGenerator = 0; + + if ( !helpFull.empty() || !helpMAN.empty() || + !helpHTML.empty() || helpVersion ) + { + help = true; + } + + if ( parsed && !help ) + { + if ( cmSystemTools::FileExists(cpackConfigFile.c_str()) ) + { + if ( !mf->ReadListFile(0, cpackConfigFile.c_str()) ) + { + cmCPack_Log(&log, cmCPackLog::LOG_ERROR, + "Problem reding CPack config file: \"" + << cpackConfigFile.c_str() << "\"" << std::endl); + return 1; + } + } + else if ( cpackConfigFileSpecified ) + { + cmCPack_Log(&log, cmCPackLog::LOG_ERROR, + "Cannot find CPack config file: \"" << cpackConfigFile.c_str() + << "\"" << std::endl); + return 1; + } + + if ( !generator.empty() ) + { + mf->AddDefinition("CPACK_GENERATOR", generator.c_str()); + } + if ( !cpackProjectName.empty() ) + { + mf->AddDefinition("CPACK_PACKAGE_NAME", cpackProjectName.c_str()); + } + if ( !cpackProjectVersion.empty() ) + { + mf->AddDefinition("CPACK_PACKAGE_VERSION", cpackProjectVersion.c_str()); + } + if ( !cpackProjectVendor.empty() ) + { + mf->AddDefinition("CPACK_PACKAGE_VENDOR", cpackProjectVendor.c_str()); + } + if ( !cpackProjectDirectory.empty() ) + { + mf->AddDefinition("CPACK_PACKAGE_DIRECTORY", + cpackProjectDirectory.c_str()); + } + if ( !cpackBuildConfig.empty() ) + { + mf->AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str()); + } + cpackDefinitions::MapType::iterator cdit; + for ( cdit = definitions.Map.begin(); + cdit != definitions.Map.end(); + ++cdit ) + { + mf->AddDefinition(cdit->first.c_str(), cdit->second.c_str()); + } + + const char* gen = mf->GetDefinition("CPACK_GENERATOR"); + if ( !gen ) + { + cmCPack_Log(&log, cmCPackLog::LOG_ERROR, + "CPack generator not specified" << std::endl); + parsed = 0; + } + if ( parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME") ) + { + cmCPack_Log(&log, cmCPackLog::LOG_ERROR, + "CPack project name not specified" << std::endl); + parsed = 0; + } + if ( parsed && !(mf->GetDefinition("CPACK_PACKAGE_VERSION") + || mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR") && + mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR") + && mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH")) ) + { + cmCPack_Log(&log, cmCPackLog::LOG_ERROR, + "CPack project version not specified" << std::endl + << "Specify CPACK_PACKAGE_VERSION, or CPACK_PACKAGE_VERSION_MAJOR, " + "CPACK_PACKAGE_VERSION_MINOR, and CPACK_PACKAGE_VERSION_PATCH." + << std::endl); + parsed = 0; + } + if ( parsed ) + { + cpackGenerator = generators.NewGenerator(gen); + if ( !cpackGenerator ) + { + cmCPack_Log(&log, cmCPackLog::LOG_ERROR, + "Cannot initialize CPack generator: " + << generator.c_str() << std::endl); + parsed = 0; + } + if ( !cpackGenerator->Initialize(gen, mf) ) + { + parsed = 0; + } + if ( parsed && !cpackGenerator->FindRunningCMake(argv[0]) ) + { + cmCPack_Log(&log, cmCPackLog::LOG_ERROR, + "Cannot initialize the generator" << std::endl); + parsed = 0; + } + + if ( !mf->GetDefinition("CPACK_INSTALL_COMMANDS") && + !mf->GetDefinition("CPACK_INSTALLED_DIRECTORIES") ) + { + cmsys::SystemTools::ConvertToUnixSlashes(cpackProjectDirectory); + std::string makeInstallFile + = cpackProjectDirectory + "/cmake_install.cmake"; + if ( !cmsys::SystemTools::FileExists(makeInstallFile.c_str()) ) + { + cmCPack_Log(&log, cmCPackLog::LOG_ERROR, + "Cannot find installation file: " << makeInstallFile.c_str() + << std::endl); + cmCPack_Log(&log, cmCPackLog::LOG_ERROR, + "Please specify build tree of the project that uses CMake, " + "specify CPACK_INSTALL_COMMANDS, or specify " + "CPACK_INSTALLED_DIRECTORIES." + << std::endl); + parsed = 0; + } + } + } + } + + if ( !parsed || help ) + { + doc.CheckOptions(argc, argv); + // Construct and print requested documentation. + doc.SetName("cpack"); + doc.SetNameSection(cmDocumentationName); + doc.SetUsageSection(cmDocumentationUsage); + doc.SetDescriptionSection(cmDocumentationDescription); + doc.SetOptionsSection(cmDocumentationOptions); + doc.SetSeeAlsoList(cmDocumentationSeeAlso); +#undef cout + return doc.PrintRequestedDocumentation(std::cout)? 0:1; +#define cout no_cout_use_cmCPack_Log + } + +#ifdef _WIN32 + std::string comspec = "cmw9xcom.exe"; + cmSystemTools::SetWindows9xComspecSubstitute(comspec.c_str()); +#endif + + const char* projName = mf->GetDefinition("CPACK_PACKAGE_NAME"); + cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Use generator: " + << cpackGenerator->GetNameOfClass() << std::endl); + cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "For project: " + << projName << std::endl); + + const char* projVersion = mf->GetDefinition("CPACK_PACKAGE_VERSION"); + if ( !projVersion ) + { + const char* projVersionMajor + = mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR"); + const char* projVersionMinor + = mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR"); + const char* projVersionPatch + = mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH"); + cmOStringStream ostr; + ostr << projVersionMajor << "." << projVersionMinor << "." + << projVersionPatch; + mf->AddDefinition("CPACK_PACKAGE_VERSION", ostr.str().c_str()); + } + + int res = cpackGenerator->ProcessGenerator(); + if ( !res ) + { + cmCPack_Log(&log, cmCPackLog::LOG_ERROR, + "Error when generating package: " << projName << std::endl); + return 1; + } + + return 0; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestBuildAndTestHandler.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestBuildAndTestHandler.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestBuildAndTestHandler.cxx 2005-06-24 01:04:16.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestBuildAndTestHandler.cxx 2006-03-11 04:03:08.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestBuildAndTestHandler.cxx,v $ Language: C++ - Date: $Date: 2005/06/23 17:04:16 $ - Version: $Revision: 1.3 $ + Date: $Date: 2006/03/10 20:03:08 $ + Version: $Revision: 1.10 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -26,59 +26,60 @@ //---------------------------------------------------------------------- cmCTestBuildAndTestHandler::cmCTestBuildAndTestHandler() { - m_BuildTwoConfig = false; - m_BuildNoClean = false; - m_BuildNoCMake = false; + this->BuildTwoConfig = false; + this->BuildNoClean = false; + this->BuildNoCMake = false; } //---------------------------------------------------------------------- void cmCTestBuildAndTestHandler::Initialize() { + this->BuildTargets.erase( + this->BuildTargets.begin(), this->BuildTargets.end()); this->Superclass::Initialize(); } //---------------------------------------------------------------------- const char* cmCTestBuildAndTestHandler::GetOutput() { - return m_Output.c_str(); + return this->Output.c_str(); } //---------------------------------------------------------------------- int cmCTestBuildAndTestHandler::ProcessHandler() { - m_Output = ""; + this->Output = ""; std::string output; cmSystemTools::ResetErrorOccuredFlag(); - cmListFileCache::ClearCache(); - int retv = this->RunCMakeAndTest(&m_Output); + int retv = this->RunCMakeAndTest(&this->Output); cmSystemTools::ResetErrorOccuredFlag(); - cmListFileCache::ClearCache(); return retv; } //---------------------------------------------------------------------- -int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, cmOStringStream &out, - std::string &cmakeOutString, std::string &cwd, - cmake *cm) +int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, + cmOStringStream &out, std::string &cmakeOutString, std::string &cwd, + cmake *cm) { unsigned int k; std::vector args; - args.push_back(m_CTest->GetCMakeExecutable()); - args.push_back(m_SourceDir); - if(m_BuildGenerator.size()) + args.push_back(this->CTest->GetCMakeExecutable()); + args.push_back(this->SourceDir); + if(this->BuildGenerator.size()) { std::string generator = "-G"; - generator += m_BuildGenerator; + generator += this->BuildGenerator; args.push_back(generator); } - if ( m_CTest->GetConfigType().size() > 0 ) + if ( this->CTest->GetConfigType().size() > 0 ) { - std::string btype = "-DBUILD_TYPE:STRING=" + m_CTest->GetConfigType(); + std::string btype + = "-DCMAKE_BUILD_TYPE:STRING=" + this->CTest->GetConfigType(); args.push_back(btype); } - for(k=0; k < m_BuildOptions.size(); ++k) + for(k=0; k < this->BuildOptions.size(); ++k) { - args.push_back(m_BuildOptions[k]); + args.push_back(this->BuildOptions[k]); } if (cm->Run(args) != 0) { @@ -92,12 +93,12 @@ } else { - cmCTestLog(m_CTest, ERROR_MESSAGE, out.str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, out.str() << std::endl); } return 1; } // do another config? - if(m_BuildTwoConfig) + if(this->BuildTwoConfig) { if (cm->Run(args) != 0) { @@ -111,11 +112,11 @@ } else { - cmCTestLog(m_CTest, ERROR_MESSAGE, out.str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, out.str() << std::endl); } return 1; } - } + } return 0; } @@ -136,42 +137,44 @@ //---------------------------------------------------------------------- int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) -{ +{ unsigned int k; std::string cmakeOutString; cmSystemTools::SetErrorCallback(CMakeMessageCallback, &cmakeOutString); cmSystemTools::SetStdoutCallback(CMakeStdoutCallback, &cmakeOutString); cmOStringStream out; - // What is this? double timeout = m_CTest->GetTimeOut(); + // What is this? double timeout = this->CTest->GetTimeOut(); int retVal = 0; - + // if the generator and make program are not specified then it is an error - if (!m_BuildGenerator.size() || !m_BuildMakeProgram.size()) + if (!this->BuildGenerator.size() || !this->BuildMakeProgram.size()) { if(outstring) { - *outstring = + *outstring = "--build-and-test requires that both the generator and makeprogram " "be provided using the --build-generator and --build-makeprogram " "command line options. "; } return 1; } - + // make sure the binary dir is there std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - out << "Internal cmake changing into directory: " << m_BinaryDir << "\n"; - if (!cmSystemTools::FileIsDirectory(m_BinaryDir.c_str())) + out << "Internal cmake changing into directory: " + << this->BinaryDir << std::endl; + if (!cmSystemTools::FileIsDirectory(this->BinaryDir.c_str())) { - cmSystemTools::MakeDirectory(m_BinaryDir.c_str()); + cmSystemTools::MakeDirectory(this->BinaryDir.c_str()); } - cmSystemTools::ChangeDirectory(m_BinaryDir.c_str()); + cmSystemTools::ChangeDirectory(this->BinaryDir.c_str()); // should we cmake? cmake cm; - cm.SetGlobalGenerator(cm.CreateGlobalGenerator(m_BuildGenerator.c_str())); - - if(!m_BuildNoCMake) + cm.SetGlobalGenerator(cm.CreateGlobalGenerator( + this->BuildGenerator.c_str())); + + if(!this->BuildNoCMake) { // do the cmake step if (this->RunCMake(outstring,out,cmakeOutString,cwd,&cm)) @@ -181,39 +184,51 @@ } // do the build - std::string output; - retVal = cm.GetGlobalGenerator()->Build( - m_SourceDir.c_str(), m_BinaryDir.c_str(), - m_BuildProject.c_str(), m_BuildTarget.c_str(), - &output, m_BuildMakeProgram.c_str(), - m_CTest->GetConfigType().c_str(),!m_BuildNoClean); - - out << output; - if(outstring) + std::vector::iterator tarIt; + if ( this->BuildTargets.size() == 0 ) { - *outstring = out.str(); + this->BuildTargets.push_back(""); } - - // if the build failed then return - if (retVal) + for ( tarIt = this->BuildTargets.begin(); tarIt != this->BuildTargets.end(); + ++ tarIt ) { - return 1; + std::string output; + retVal = cm.GetGlobalGenerator()->Build( + this->SourceDir.c_str(), this->BinaryDir.c_str(), + this->BuildProject.c_str(), tarIt->c_str(), + &output, this->BuildMakeProgram.c_str(), + this->CTest->GetConfigType().c_str(),!this->BuildNoClean); + + out << output; + // if the build failed then return + if (retVal) + { + if(outstring) + { + *outstring = out.str(); + } + return 1; + } } - + if(outstring) + { + *outstring = out.str(); + } + // if not test was specified then we are done - if (!m_TestCommand.size()) + if (!this->TestCommand.size()) { return 0; } - + // now run the compiled test if we can find it std::vector attempted; std::vector failed; std::string tempPath; - std::string filepath = - cmSystemTools::GetFilenamePath(m_TestCommand); - std::string filename = - cmSystemTools::GetFilenameName(m_TestCommand); + std::string filepath = + cmSystemTools::GetFilenamePath(this->TestCommand); + std::string filename = + cmSystemTools::GetFilenameName(this->TestCommand); // if full path specified then search that first if (filepath.size()) { @@ -221,11 +236,19 @@ tempPath += "/"; tempPath += filename; attempted.push_back(tempPath); - if(m_CTest->GetConfigType().size()) + if(this->CTest->GetConfigType().size()) { tempPath = filepath; tempPath += "/"; - tempPath += m_CTest->GetConfigType(); + tempPath += this->CTest->GetConfigType(); + tempPath += "/"; + tempPath += filename; + attempted.push_back(tempPath); + // If the file is an OSX bundle then the configtyp + // will be at the start of the path + tempPath = this->CTest->GetConfigType(); + tempPath += "/"; + tempPath += filepath; tempPath += "/"; tempPath += filename; attempted.push_back(tempPath); @@ -235,26 +258,26 @@ else { attempted.push_back(filename); - if(m_CTest->GetConfigType().size()) + if(this->CTest->GetConfigType().size()) { - tempPath = m_CTest->GetConfigType(); + tempPath = this->CTest->GetConfigType(); tempPath += "/"; tempPath += filename; attempted.push_back(tempPath); } } - // if m_ExecutableDirectory is set try that as well - if (m_ExecutableDirectory.size()) + // if this->ExecutableDirectory is set try that as well + if (this->ExecutableDirectory.size()) { - tempPath = m_ExecutableDirectory; + tempPath = this->ExecutableDirectory; tempPath += "/"; - tempPath += m_TestCommand; + tempPath += this->TestCommand; attempted.push_back(tempPath); - if(m_CTest->GetConfigType().size()) + if(this->CTest->GetConfigType().size()) { - tempPath = m_ExecutableDirectory; + tempPath = this->ExecutableDirectory; tempPath += "/"; - tempPath += m_CTest->GetConfigType(); + tempPath += this->CTest->GetConfigType(); tempPath += "/"; tempPath += filename; attempted.push_back(tempPath); @@ -263,9 +286,9 @@ // store the final location in fullPath std::string fullPath; - + // now look in the paths we specified above - for(unsigned int ai=0; + for(unsigned int ai=0; ai < attempted.size() && fullPath.size() == 0; ++ai) { // first check without exe extension @@ -294,8 +317,8 @@ if(!cmSystemTools::FileExists(fullPath.c_str())) { - out << "Could not find path to executable, perhaps it was not built: " << - m_TestCommand << "\n"; + out << "Could not find path to executable, perhaps it was not built: " + << this->TestCommand << "\n"; out << "tried to find it in these places:\n"; out << fullPath.c_str() << "\n"; for(unsigned int i=0; i < failed.size(); ++i) @@ -308,7 +331,7 @@ } else { - cmCTestLog(m_CTest, ERROR_MESSAGE, out.str()); + cmCTestLog(this->CTest, ERROR_MESSAGE, out.str()); } // return to the original directory cmSystemTools::ChangeDirectory(cwd.c_str()); @@ -317,27 +340,27 @@ std::vector testCommand; testCommand.push_back(fullPath.c_str()); - for(k=0; k < m_TestCommandArgs.size(); ++k) + for(k=0; k < this->TestCommandArgs.size(); ++k) { - testCommand.push_back(m_TestCommandArgs[k].c_str()); + testCommand.push_back(this->TestCommandArgs[k].c_str()); } testCommand.push_back(0); std::string outs; int retval = 0; - // run the test from the m_BuildRunDir if set - if(m_BuildRunDir.size()) + // run the test from the this->BuildRunDir if set + if(this->BuildRunDir.size()) { - out << "Run test in directory: " << m_BuildRunDir << "\n"; - cmSystemTools::ChangeDirectory(m_BuildRunDir.c_str()); + out << "Run test in directory: " << this->BuildRunDir << "\n"; + cmSystemTools::ChangeDirectory(this->BuildRunDir.c_str()); } out << "Running test executable: " << fullPath << " "; - for(k=0; k < m_TestCommandArgs.size(); ++k) + for(k=0; k < this->TestCommandArgs.size(); ++k) { - out << m_TestCommandArgs[k] << " "; + out << this->TestCommandArgs[k] << " "; } out << "\n"; - // What is this? m_TimeOut = timeout; - int runTestRes = m_CTest->RunTest(testCommand, &outs, &retval, 0); + // What is this? this->TimeOut = timeout; + int runTestRes = this->CTest->RunTest(testCommand, &outs, &retval, 0); if(runTestRes != cmsysProcess_State_Exited || retval != 0) { out << "Failed to run test command: " << testCommand[0] << "\n"; @@ -351,7 +374,7 @@ } else { - cmCTestLog(m_CTest, OUTPUT, out.str() << std::endl); + cmCTestLog(this->CTest, OUTPUT, out.str() << std::endl); } return retval; } @@ -367,61 +390,65 @@ if(idx+2 < allArgs.size()) { idx++; - m_SourceDir = allArgs[idx]; + this->SourceDir = allArgs[idx]; idx++; - m_BinaryDir = allArgs[idx]; + this->BinaryDir = allArgs[idx]; // dir must exist before CollapseFullPath is called - cmSystemTools::MakeDirectory(m_BinaryDir.c_str()); - m_BinaryDir = cmSystemTools::CollapseFullPath(m_BinaryDir.c_str()); - m_SourceDir = cmSystemTools::CollapseFullPath(m_SourceDir.c_str()); + cmSystemTools::MakeDirectory(this->BinaryDir.c_str()); + this->BinaryDir + = cmSystemTools::CollapseFullPath(this->BinaryDir.c_str()); + this->SourceDir + = cmSystemTools::CollapseFullPath(this->SourceDir.c_str()); } else { - cmCTestLog(m_CTest, ERROR_MESSAGE, "--build-and-test must have source and binary dir" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "--build-and-test must have source and binary dir" << std::endl); return 0; } } if(currentArg.find("--build-target",0) == 0 && idx < allArgs.size() - 1) { idx++; - m_BuildTarget = allArgs[idx]; + this->BuildTargets.push_back(allArgs[idx]); } if(currentArg.find("--build-nocmake",0) == 0) { - m_BuildNoCMake = true; + this->BuildNoCMake = true; } if(currentArg.find("--build-run-dir",0) == 0 && idx < allArgs.size() - 1) { idx++; - m_BuildRunDir = allArgs[idx]; + this->BuildRunDir = allArgs[idx]; } if(currentArg.find("--build-two-config",0) == 0) { - m_BuildTwoConfig = true; + this->BuildTwoConfig = true; } if(currentArg.find("--build-exe-dir",0) == 0 && idx < allArgs.size() - 1) { idx++; - m_ExecutableDirectory = allArgs[idx]; + this->ExecutableDirectory = allArgs[idx]; } if(currentArg.find("--build-generator",0) == 0 && idx < allArgs.size() - 1) { idx++; - m_BuildGenerator = allArgs[idx]; + this->BuildGenerator = allArgs[idx]; } if(currentArg.find("--build-project",0) == 0 && idx < allArgs.size() - 1) { idx++; - m_BuildProject = allArgs[idx]; + this->BuildProject = allArgs[idx]; } - if(currentArg.find("--build-makeprogram",0) == 0 && idx < allArgs.size() - 1) + if(currentArg.find("--build-makeprogram",0) == 0 && + idx < allArgs.size() - 1) { idx++; - m_BuildMakeProgram = allArgs[idx]; + this->BuildMakeProgram = allArgs[idx]; } if(currentArg.find("--build-noclean",0) == 0) { - m_BuildNoClean = true; + this->BuildNoClean = true; } if(currentArg.find("--build-options",0) == 0 && idx < allArgs.size() - 1) { @@ -429,9 +456,10 @@ bool done = false; while(idx < allArgs.size() && !done) { - m_BuildOptions.push_back(allArgs[idx]); - if(idx+1 < allArgs.size() - && (allArgs[idx+1] == "--build-target" || allArgs[idx+1] == "--test-command")) + this->BuildOptions.push_back(allArgs[idx]); + if(idx+1 < allArgs.size() + && (allArgs[idx+1] == "--build-target" || + allArgs[idx+1] == "--test-command")) { done = true; } @@ -444,11 +472,11 @@ if(currentArg.find("--test-command",0) == 0 && idx < allArgs.size() - 1) { ++idx; - m_TestCommand = allArgs[idx]; + this->TestCommand = allArgs[idx]; while(idx+1 < allArgs.size()) { ++idx; - m_TestCommandArgs.push_back(allArgs[idx]); + this->TestCommandArgs.push_back(allArgs[idx]); } } return 1; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestBuildAndTestHandler.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestBuildAndTestHandler.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestBuildAndTestHandler.h 2005-06-18 01:04:55.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestBuildAndTestHandler.h 2006-03-11 04:03:08.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestBuildAndTestHandler.h,v $ Language: C++ - Date: $Date: 2005/06/17 17:04:55 $ - Version: $Revision: 1.2 $ + Date: $Date: 2006/03/10 20:03:08 $ + Version: $Revision: 1.4 $ Copyright (c) 2002 Kitware, Inc. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -59,22 +59,22 @@ std::string &cmakeOutString, std::string &cwd, cmake *cm); - cmStdString m_Output; + cmStdString Output; - std::string m_BuildGenerator; - std::vector m_BuildOptions; - bool m_BuildTwoConfig; - std::string m_BuildMakeProgram; - std::string m_SourceDir; - std::string m_BinaryDir; - std::string m_BuildProject; - std::string m_TestCommand; - bool m_BuildNoClean; - std::string m_BuildRunDir; - std::string m_ExecutableDirectory; - std::vector m_TestCommandArgs; - std::string m_BuildTarget; - bool m_BuildNoCMake; + std::string BuildGenerator; + std::vector BuildOptions; + bool BuildTwoConfig; + std::string BuildMakeProgram; + std::string SourceDir; + std::string BinaryDir; + std::string BuildProject; + std::string TestCommand; + bool BuildNoClean; + std::string BuildRunDir; + std::string ExecutableDirectory; + std::vector TestCommandArgs; + std::vector BuildTargets; + bool BuildNoCMake; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestBuildCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestBuildCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestBuildCommand.cxx 2005-06-24 01:04:17.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestBuildCommand.cxx 2006-03-16 00:02:08.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestBuildCommand.cxx,v $ Language: C++ - Date: $Date: 2005/06/23 17:04:17 $ - Version: $Revision: 1.7 $ + Date: $Date: 2006/03/15 16:02:08 $ + Version: $Revision: 1.11 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -25,16 +25,16 @@ //---------------------------------------------------------------------------- cmCTestBuildCommand::cmCTestBuildCommand() { - m_GlobalGenerator = 0; + this->GlobalGenerator = 0; } //---------------------------------------------------------------------------- cmCTestBuildCommand::~cmCTestBuildCommand() { - if ( m_GlobalGenerator ) + if ( this->GlobalGenerator ) { - delete m_GlobalGenerator; - m_GlobalGenerator = 0; + delete this->GlobalGenerator; + this->GlobalGenerator = 0; } } @@ -63,16 +63,18 @@ { if ( res_var ) { - this->SetError("called with incorrect number of arguments. RETURN_VALUE specified twice."); + this->SetError("called with incorrect number of arguments. " + "RETURN_VALUE specified twice."); return false; } havereturn_variable = true; - } + } else if(args[i] == "BUILD") { if ( build_dir ) { - this->SetError("called with incorrect number of arguments. BUILD specified twice."); + this->SetError("called with incorrect number of arguments. " + "BUILD specified twice."); return false; } havesource = true; @@ -80,7 +82,8 @@ else { cmOStringStream str; - str << "called with incorrect number of arguments. Extra argument is: " << args[i].c_str() << "."; + str << "called with incorrect number of arguments. Extra argument is: " + << args[i].c_str() << "."; this->SetError(str.str().c_str()); return false; } @@ -88,26 +91,33 @@ if ( build_dir ) { - m_CTest->SetCTestConfiguration("BuildDirectory", build_dir); + this->CTest->SetCTestConfiguration("BuildDirectory", build_dir); } - cmCTestGenericHandler* handler = m_CTest->GetInitializedHandler("build"); + cmCTestGenericHandler* handler + = this->CTest->GetInitializedHandler("build"); if ( !handler ) { this->SetError("internal CTest error. Cannot instantiate build handler"); return false; } - - const char* ctestBuildCommand = m_Makefile->GetDefinition("CTEST_BUILD_COMMAND"); + + const char* ctestBuildCommand + = this->Makefile->GetDefinition("CTEST_BUILD_COMMAND"); if ( ctestBuildCommand && *ctestBuildCommand ) { - m_CTest->SetCTestConfiguration("MakeCommand", ctestBuildCommand); + this->CTest->SetCTestConfiguration("MakeCommand", ctestBuildCommand); } else { - const char* cmakeGeneratorName = m_Makefile->GetDefinition("CTEST_CMAKE_GENERATOR"); - const char* cmakeProjectName = m_Makefile->GetDefinition("CTEST_PROJECT_NAME"); - const char* cmakeBuildConfiguration = m_Makefile->GetDefinition("CTEST_BUILD_CONFIGURATION"); + const char* cmakeGeneratorName + = this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR"); + const char* cmakeProjectName + = this->Makefile->GetDefinition("CTEST_PROJECT_NAME"); + const char* cmakeBuildConfiguration + = this->Makefile->GetDefinition("CTEST_BUILD_CONFIGURATION"); + const char* cmakeBuildAdditionalFlags + = this->Makefile->GetDefinition("CTEST_BUILD_FLAGS"); if ( cmakeGeneratorName && *cmakeGeneratorName && cmakeProjectName && *cmakeProjectName ) { @@ -115,41 +125,48 @@ { cmakeBuildConfiguration = "Release"; } - if ( m_GlobalGenerator ) + if ( this->GlobalGenerator ) { - if ( strcmp(m_GlobalGenerator->GetName(), cmakeGeneratorName) != 0 ) + if ( strcmp(this->GlobalGenerator->GetName(), + cmakeGeneratorName) != 0 ) { - delete m_GlobalGenerator; - m_GlobalGenerator = 0; + delete this->GlobalGenerator; + this->GlobalGenerator = 0; } } - if ( !m_GlobalGenerator ) + if ( !this->GlobalGenerator ) { - m_GlobalGenerator = - m_Makefile->GetCMakeInstance()->CreateGlobalGenerator(cmakeGeneratorName); + this->GlobalGenerator = + this->Makefile->GetCMakeInstance()->CreateGlobalGenerator( + cmakeGeneratorName); } - m_GlobalGenerator->FindMakeProgram(m_Makefile); - const char* cmakeMakeProgram = m_Makefile->GetDefinition("CMAKE_MAKE_PROGRAM"); + this->GlobalGenerator->FindMakeProgram(this->Makefile); + const char* cmakeMakeProgram + = this->Makefile->GetDefinition("CMAKE_MAKE_PROGRAM"); std::string buildCommand - = m_GlobalGenerator->GenerateBuildCommand(cmakeMakeProgram, cmakeProjectName, - 0, cmakeBuildConfiguration, true); - m_CTest->SetCTestConfiguration("MakeCommand", buildCommand.c_str()); + = this->GlobalGenerator->GenerateBuildCommand(cmakeMakeProgram, + cmakeProjectName, + cmakeBuildAdditionalFlags, 0, cmakeBuildConfiguration, true); + this->CTest->SetCTestConfiguration("MakeCommand", buildCommand.c_str()); } else { cmOStringStream ostr; - ostr << "CTEST_BUILD_COMMAND or CTEST_CMAKE_GENERATOR not specified. Please specify the CTEST_CMAKE_GENERATOR and CTEST_PROJECT_NAME if this is a CMake project, or specify the CTEST_BUILD_COMMAND for cmake or any other project."; + ostr << "CTEST_BUILD_COMMAND or CTEST_CMAKE_GENERATOR not specified. " + "Please specify the CTEST_CMAKE_GENERATOR and CTEST_PROJECT_NAME if " + "this is a CMake project, or specify the CTEST_BUILD_COMMAND for " + "cmake or any other project."; this->SetError(ostr.str().c_str()); return false; } } - + int res = handler->ProcessHandler(); if ( res_var ) { cmOStringStream str; str << res; - m_Makefile->AddDefinition(res_var, str.str().c_str()); + this->Makefile->AddDefinition(res_var, str.str().c_str()); } return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestBuildCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestBuildCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestBuildCommand.h 2005-05-09 01:48:09.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestBuildCommand.h 2006-03-11 04:03:08.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestBuildCommand.h,v $ Language: C++ - Date: $Date: 2005/05/08 17:48:09 $ - Version: $Revision: 1.3 $ + Date: $Date: 2006/03/10 20:03:08 $ + Version: $Revision: 1.4 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -32,15 +32,15 @@ cmCTestBuildCommand(); ~cmCTestBuildCommand(); - + /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { cmCTestBuildCommand* ni = new cmCTestBuildCommand; - ni->m_CTest = this->m_CTest; - ni->m_CTestScriptHandler = this->m_CTestScriptHandler; + ni->CTest = this->CTest; + ni->CTestScriptHandler = this->CTestScriptHandler; return ni; } @@ -58,11 +58,11 @@ /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { return "Builds the repository."; } - + /** * More documentation. */ @@ -75,7 +75,7 @@ cmTypeMacro(cmCTestBuildCommand, cmCTestCommand); - cmGlobalGenerator* m_GlobalGenerator; + cmGlobalGenerator* GlobalGenerator; }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestBuildHandler.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestBuildHandler.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestBuildHandler.cxx 2005-11-24 01:33:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestBuildHandler.cxx 2006-03-11 04:03:08.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestBuildHandler.cxx,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:39 $ - Version: $Revision: 1.30.2.4 $ + Date: $Date: 2006/03/10 20:03:08 $ + Version: $Revision: 1.39 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -32,7 +32,7 @@ #include "windows.h" #endif -#include +#include #include #include #include @@ -107,17 +107,17 @@ "^cc[^C]*CC: WARNING File = ([^,]+), Line = ([0-9]+)", "^ld([^:])*:([ \\t])*WARNING([^:])*:", "([^:]+): warning ([0-9]+):", - "^\"[^\"]+\", line [0-9]+: [Ww]arning", + "^\"[^\"]+\", line [0-9]+: [Ww](arning|arnung)", "([^:]+): warning[ \\t]*[0-9]+[ \\t]*:", - "^Warning ([0-9]+):", - "^Warning ", + "^(Warning|Warnung) ([0-9]+):", + "^(Warning|Warnung) ", "WARNING: ", "([^ :]+) : warning", "([^:]+): warning", "\", line [0-9]+\\.[0-9]+: [0-9]+-[0-9]+ \\(W\\)", "^cxx: Warning:", ".*file: .* has no symbols", - "([^ :]+):([0-9]+): Warning", + "([^ :]+):([0-9]+): (Warning|Warnung)", "\\([0-9]*\\): remark #[0-9]*", "\".*\", line [0-9]+: remark\\([0-9]*\\):", "cc-[0-9]* CC: REMARK File = .*, Line = [0-9]*", @@ -125,9 +125,9 @@ }; static const char* cmCTestWarningExceptions[] = { - "/usr/openwin/include/X11/Xlib\\.h:[0-9]+: warning: ANSI C\\+\\+ forbids declaration", - "/usr/openwin/include/X11/Xutil\\.h:[0-9]+: warning: ANSI C\\+\\+ forbids declaration", - "/usr/openwin/include/X11/XResource\\.h:[0-9]+: warning: ANSI C\\+\\+ forbids declaration", + "/usr/.*/X11/Xlib\\.h:[0-9]+: war.*: ANSI C\\+\\+ forbids declaration", + "/usr/.*/X11/Xutil\\.h:[0-9]+: war.*: ANSI C\\+\\+ forbids declaration", + "/usr/.*/X11/XResource\\.h:[0-9]+: war.*: ANSI C\\+\\+ forbids declaration", "WARNING 84 :", "WARNING 47 :", "makefile:", @@ -146,9 +146,9 @@ struct cmCTestBuildCompileErrorWarningRex { - const char* m_RegularExpressionString; - int m_FileIndex; - int m_LineIndex; + const char* RegularExpressionString; + int FileIndex; + int LineIndex; }; static cmCTestBuildCompileErrorWarningRex @@ -165,13 +165,13 @@ //---------------------------------------------------------------------- cmCTestBuildHandler::cmCTestBuildHandler() { - m_MaxPreContext = 6; - m_MaxPostContext = 6; + this->MaxPreContext = 6; + this->MaxPostContext = 6; - m_MaxErrors = 50; - m_MaxWarnings = 50; + this->MaxErrors = 50; + this->MaxWarnings = 50; - m_LastErrorOrWarning = m_ErrorsAndWarnings.end(); + this->LastErrorOrWarning = this->ErrorsAndWarnings.end(); } @@ -179,61 +179,61 @@ void cmCTestBuildHandler::Initialize() { this->Superclass::Initialize(); - m_StartBuild = ""; - m_EndBuild = ""; - m_CustomErrorMatches.clear(); - m_CustomErrorExceptions.clear(); - m_CustomWarningMatches.clear(); - m_CustomWarningExceptions.clear(); - m_ErrorWarningFileLineRegex.clear(); - - m_ErrorMatchRegex.clear(); - m_ErrorExceptionRegex.clear(); - m_WarningMatchRegex.clear(); - m_WarningExceptionRegex.clear(); - m_BuildProcessingQueue.clear(); - m_BuildProcessingQueueLocation = m_BuildProcessingQueue.end(); - m_BuildOutputLogSize = 0; - m_CurrentProcessingLine.clear(); - - m_SimplifySourceDir = ""; - m_SimplifyBuildDir = ""; - m_OutputLineCounter = 0; - m_ErrorsAndWarnings.clear(); - m_LastErrorOrWarning = m_ErrorsAndWarnings.end(); - m_PostContextCount = 0; - m_MaxPreContext = 6; - m_MaxPostContext = 6; - m_PreContext.clear(); - - m_TotalErrors = 0; - m_TotalWarnings = 0; - m_LastTickChar = 0; + this->StartBuild = ""; + this->EndBuild = ""; + this->CustomErrorMatches.clear(); + this->CustomErrorExceptions.clear(); + this->CustomWarningMatches.clear(); + this->CustomWarningExceptions.clear(); + this->ErrorWarningFileLineRegex.clear(); + + this->ErrorMatchRegex.clear(); + this->ErrorExceptionRegex.clear(); + this->WarningMatchRegex.clear(); + this->WarningExceptionRegex.clear(); + this->BuildProcessingQueue.clear(); + this->BuildProcessingErrorQueue.clear(); + this->BuildOutputLogSize = 0; + this->CurrentProcessingLine.clear(); + + this->SimplifySourceDir = ""; + this->SimplifyBuildDir = ""; + this->OutputLineCounter = 0; + this->ErrorsAndWarnings.clear(); + this->LastErrorOrWarning = this->ErrorsAndWarnings.end(); + this->PostContextCount = 0; + this->MaxPreContext = 6; + this->MaxPostContext = 6; + this->PreContext.clear(); + + this->TotalErrors = 0; + this->TotalWarnings = 0; + this->LastTickChar = 0; - m_ErrorQuotaReached = false; - m_WarningQuotaReached = false; + this->ErrorQuotaReached = false; + this->WarningQuotaReached = false; - m_MaxErrors = 50; - m_MaxWarnings = 50; + this->MaxErrors = 50; + this->MaxWarnings = 50; } //---------------------------------------------------------------------- void cmCTestBuildHandler::PopulateCustomVectors(cmMakefile *mf) { - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_MATCH", - m_CustomErrorMatches); - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_EXCEPTION", - m_CustomErrorExceptions); - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_MATCH", - m_CustomWarningMatches); - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_EXCEPTION", - m_CustomWarningExceptions); - cmCTest::PopulateCustomInteger(mf, - "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS", - m_MaxErrors); - cmCTest::PopulateCustomInteger(mf, - "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS", - m_MaxWarnings); + cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_MATCH", + this->CustomErrorMatches); + cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_EXCEPTION", + this->CustomErrorExceptions); + cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_MATCH", + this->CustomWarningMatches); + cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_EXCEPTION", + this->CustomWarningExceptions); + cmCTest::PopulateCustomInteger(mf, + "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS", + this->MaxErrors); + cmCTest::PopulateCustomInteger(mf, + "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS", + this->MaxWarnings); } //---------------------------------------------------------------------- @@ -241,37 +241,47 @@ //functions and commented... int cmCTestBuildHandler::ProcessHandler() { - cmCTestLog(m_CTest, HANDLER_OUTPUT, "Build project" << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, "Build project" << std::endl); int entry; - for ( entry = 0; cmCTestWarningErrorFileLine[entry].m_RegularExpressionString; ++ entry ) + for ( entry = 0; + cmCTestWarningErrorFileLine[entry].RegularExpressionString; + ++ entry ) { cmCTestBuildHandler::cmCTestCompileErrorWarningRex r; - if ( r.m_RegularExpression.compile( - cmCTestWarningErrorFileLine[entry].m_RegularExpressionString) ) + if ( r.RegularExpression.compile( + cmCTestWarningErrorFileLine[entry].RegularExpressionString) ) { - r.m_FileIndex = cmCTestWarningErrorFileLine[entry].m_FileIndex; - r.m_LineIndex = cmCTestWarningErrorFileLine[entry].m_LineIndex; - m_ErrorWarningFileLineRegex.push_back(r); + r.FileIndex = cmCTestWarningErrorFileLine[entry].FileIndex; + r.LineIndex = cmCTestWarningErrorFileLine[entry].LineIndex; + this->ErrorWarningFileLineRegex.push_back(r); } else { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem Compiling regular expression: " - << cmCTestWarningErrorFileLine[entry].m_RegularExpressionString << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Problem Compiling regular expression: " + << cmCTestWarningErrorFileLine[entry].RegularExpressionString + << std::endl); } } // Determine build command and build directory - const std::string &makeCommand = m_CTest->GetCTestConfiguration("MakeCommand"); + const std::string &makeCommand + = this->CTest->GetCTestConfiguration("MakeCommand"); if ( makeCommand.size() == 0 ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot find MakeCommand key in the DartConfiguration.tcl" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Cannot find MakeCommand key in the DartConfiguration.tcl" + << std::endl); return -1; } - const std::string &buildDirectory = m_CTest->GetCTestConfiguration("BuildDirectory"); + const std::string &buildDirectory + = this->CTest->GetCTestConfiguration("BuildDirectory"); if ( buildDirectory.size() == 0 ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot find BuildDirectory key in the DartConfiguration.tcl" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Cannot find BuildDirectory key in the DartConfiguration.tcl" + << std::endl); return -1; } @@ -280,7 +290,8 @@ double elapsed_time_start = cmSystemTools::GetTime(); if ( !this->StartLogFile("Build", ofs) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create build log file" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create build log file" + << std::endl); } // Create lists of regular expression strings for errors, error exceptions, @@ -288,19 +299,19 @@ std::vector::size_type cc; for ( cc = 0; cmCTestErrorMatches[cc]; cc ++ ) { - m_CustomErrorMatches.push_back(cmCTestErrorMatches[cc]); + this->CustomErrorMatches.push_back(cmCTestErrorMatches[cc]); } for ( cc = 0; cmCTestErrorExceptions[cc]; cc ++ ) { - m_CustomErrorExceptions.push_back(cmCTestErrorExceptions[cc]); + this->CustomErrorExceptions.push_back(cmCTestErrorExceptions[cc]); } for ( cc = 0; cmCTestWarningMatches[cc]; cc ++ ) { - m_CustomWarningMatches.push_back(cmCTestWarningMatches[cc]); + this->CustomWarningMatches.push_back(cmCTestWarningMatches[cc]); } for ( cc = 0; cmCTestWarningExceptions[cc]; cc ++ ) { - m_CustomWarningExceptions.push_back(cmCTestWarningExceptions[cc]); + this->CustomWarningExceptions.push_back(cmCTestWarningExceptions[cc]); } // Pre-compile regular expressions objects for all regular expressions @@ -312,18 +323,23 @@ { \ regexes.push_back(it->c_str()); \ } - cmCTestBuildHandlerPopulateRegexVector(m_CustomErrorMatches, m_ErrorMatchRegex); - cmCTestBuildHandlerPopulateRegexVector(m_CustomErrorExceptions, m_ErrorExceptionRegex); - cmCTestBuildHandlerPopulateRegexVector(m_CustomWarningMatches, m_WarningMatchRegex); - cmCTestBuildHandlerPopulateRegexVector(m_CustomWarningExceptions, m_WarningExceptionRegex); + cmCTestBuildHandlerPopulateRegexVector( + this->CustomErrorMatches, this->ErrorMatchRegex); + cmCTestBuildHandlerPopulateRegexVector( + this->CustomErrorExceptions, this->ErrorExceptionRegex); + cmCTestBuildHandlerPopulateRegexVector( + this->CustomWarningMatches, this->WarningMatchRegex); + cmCTestBuildHandlerPopulateRegexVector( + this->CustomWarningExceptions, this->WarningExceptionRegex); // Determine source and binary tree substitutions to simplify the output. - m_SimplifySourceDir = ""; - m_SimplifyBuildDir = ""; - if ( m_CTest->GetCTestConfiguration("SourceDirectory").size() > 20 ) + this->SimplifySourceDir = ""; + this->SimplifyBuildDir = ""; + if ( this->CTest->GetCTestConfiguration("SourceDirectory").size() > 20 ) { - std::string srcdir = m_CTest->GetCTestConfiguration("SourceDirectory") + "/"; + std::string srcdir + = this->CTest->GetCTestConfiguration("SourceDirectory") + "/"; std::string srcdirrep; for ( cc = srcdir.size()-2; cc > 0; cc -- ) { @@ -335,11 +351,12 @@ break; } } - m_SimplifySourceDir = srcdir; + this->SimplifySourceDir = srcdir; } - if ( m_CTest->GetCTestConfiguration("BuildDirectory").size() > 20 ) + if ( this->CTest->GetCTestConfiguration("BuildDirectory").size() > 20 ) { - std::string bindir = m_CTest->GetCTestConfiguration("BuildDirectory") + "/"; + std::string bindir + = this->CTest->GetCTestConfiguration("BuildDirectory") + "/"; std::string bindirrep; for ( cc = bindir.size()-2; cc > 0; cc -- ) { @@ -351,105 +368,121 @@ break; } } - m_SimplifyBuildDir = bindir; + this->SimplifyBuildDir = bindir; } // Ok, let's do the build - + // Remember start build time - m_StartBuild = m_CTest->CurrentTime(); + this->StartBuild = this->CTest->CurrentTime(); int retVal = 0; int res = cmsysProcess_State_Exited; - if ( !m_CTest->GetShowOnly() ) + if ( !this->CTest->GetShowOnly() ) { - res = this->RunMakeCommand(makeCommand.c_str(), &retVal, buildDirectory.c_str(), 0, ofs); + res = this->RunMakeCommand(makeCommand.c_str(), &retVal, + buildDirectory.c_str(), 0, ofs); } else { - cmCTestLog(m_CTest, DEBUG, "Build with command: " << makeCommand << std::endl); + cmCTestLog(this->CTest, DEBUG, "Build with command: " << makeCommand + << std::endl); } // Remember end build time and calculate elapsed time - m_EndBuild = m_CTest->CurrentTime(); + this->EndBuild = this->CTest->CurrentTime(); double elapsed_build_time = cmSystemTools::GetTime() - elapsed_time_start; if (res != cmsysProcess_State_Exited || retVal ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Error(s) when building project" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, "Error(s) when building project" + << std::endl); } // Cleanups strings in the errors and warnings list. t_ErrorsAndWarningsVector::iterator evit; - if ( !m_SimplifySourceDir.empty() ) + if ( !this->SimplifySourceDir.empty() ) { - for ( evit = m_ErrorsAndWarnings.begin(); evit != m_ErrorsAndWarnings.end(); ++ evit ) + for ( evit = this->ErrorsAndWarnings.begin(); + evit != this->ErrorsAndWarnings.end(); + ++ evit ) { - cmSystemTools::ReplaceString(evit->m_Text, m_SimplifySourceDir.c_str(), "/.../"); - cmSystemTools::ReplaceString(evit->m_PreContext, m_SimplifySourceDir.c_str(), "/.../"); - cmSystemTools::ReplaceString(evit->m_PostContext, m_SimplifySourceDir.c_str(), "/.../"); + cmSystemTools::ReplaceString( + evit->Text, this->SimplifySourceDir.c_str(), "/.../"); + cmSystemTools::ReplaceString( + evit->PreContext, this->SimplifySourceDir.c_str(), "/.../"); + cmSystemTools::ReplaceString( + evit->PostContext, this->SimplifySourceDir.c_str(), "/.../"); } } - if ( !m_SimplifyBuildDir.empty() ) + if ( !this->SimplifyBuildDir.empty() ) { - for ( evit = m_ErrorsAndWarnings.begin(); evit != m_ErrorsAndWarnings.end(); ++ evit ) + for ( evit = this->ErrorsAndWarnings.begin(); + evit != this->ErrorsAndWarnings.end(); + ++ evit ) { - cmSystemTools::ReplaceString(evit->m_Text, m_SimplifyBuildDir.c_str(), "/.../"); - cmSystemTools::ReplaceString(evit->m_PreContext, m_SimplifyBuildDir.c_str(), "/.../"); - cmSystemTools::ReplaceString(evit->m_PostContext, m_SimplifyBuildDir.c_str(), "/.../"); + cmSystemTools::ReplaceString( + evit->Text, this->SimplifyBuildDir.c_str(), "/.../"); + cmSystemTools::ReplaceString( + evit->PreContext, this->SimplifyBuildDir.c_str(), "/.../"); + cmSystemTools::ReplaceString( + evit->PostContext, this->SimplifyBuildDir.c_str(), "/.../"); } } // Display message about number of errors and warnings - cmCTestLog(m_CTest, HANDLER_OUTPUT, " " << m_TotalErrors - << (m_TotalErrors >= m_MaxErrors ? " or more" : "") + cmCTestLog(this->CTest, HANDLER_OUTPUT, " " << this->TotalErrors + << (this->TotalErrors >= this->MaxErrors ? " or more" : "") << " Compiler errors" << std::endl); - cmCTestLog(m_CTest, HANDLER_OUTPUT, " " << m_TotalWarnings - << (m_TotalWarnings >= m_MaxWarnings ? " or more" : "") + cmCTestLog(this->CTest, HANDLER_OUTPUT, " " << this->TotalWarnings + << (this->TotalWarnings >= this->MaxWarnings ? " or more" : "") << " Compiler warnings" << std::endl); // Generate XML output cmGeneratedFileStream xofs; if( !this->StartResultingXML("Build", xofs)) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create build XML file" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create build XML file" + << std::endl); return -1; } - this->GenerateDartBuildOutput(xofs, m_ErrorsAndWarnings, elapsed_build_time); + this->GenerateDartBuildOutput( + xofs, this->ErrorsAndWarnings, elapsed_build_time); return 0; } //---------------------------------------------------------------------- void cmCTestBuildHandler::GenerateDartBuildOutput( - std::ostream& os, + std::ostream& os, std::vector ew, double elapsed_build_time) { - m_CTest->StartXML(os); + this->CTest->StartXML(os); os << "\n" - << "\t" << m_StartBuild << "\n" - << "" - << m_CTest->MakeXMLSafe(m_CTest->GetCTestConfiguration("MakeCommand")) + << "\t" << this->StartBuild << "\n" + << "" + << this->CTest->MakeXMLSafe( + this->CTest->GetCTestConfiguration("MakeCommand")) << "" << std::endl; - + std::vector::iterator it; - + // only report the first 50 warnings and first 50 errors - unsigned short numErrorsAllowed = m_MaxErrors; - unsigned short numWarningsAllowed = m_MaxWarnings; - std::string srcdir = m_CTest->GetCTestConfiguration("SourceDirectory"); + unsigned short numErrorsAllowed = this->MaxErrors; + unsigned short numWarningsAllowed = this->MaxWarnings; + std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory"); // make sure the source dir is in the correct case on windows // via a call to collapse full path. srcdir = cmSystemTools::CollapseFullPath(srcdir.c_str()); srcdir += "/"; - for ( it = ew.begin(); + for ( it = ew.begin(); it != ew.end() && (numErrorsAllowed || numWarningsAllowed); it++ ) { cmCTestBuildErrorWarning *cm = &(*it); - if (cm->m_Error && numErrorsAllowed || - !cm->m_Error && numWarningsAllowed) + if (cm->Error && numErrorsAllowed || + !cm->Error && numWarningsAllowed) { - if (cm->m_Error) + if (cm->Error) { numErrorsAllowed--; } @@ -457,76 +490,80 @@ { numWarningsAllowed--; } - os << "\t<" << (cm->m_Error ? "Error" : "Warning") << ">\n" - << "\t\t" << cm->m_LogLine << "\n" - << "\t\t" << m_CTest->MakeXMLSafe(cm->m_Text) + os << "\t<" << (cm->Error ? "Error" : "Warning") << ">\n" + << "\t\t" << cm->LogLine << "\n" + << "\t\t" << this->CTest->MakeXMLSafe(cm->Text) << "\n" << std::endl; std::vector::iterator rit; - for ( rit = m_ErrorWarningFileLineRegex.begin(); - rit != m_ErrorWarningFileLineRegex.end(); ++ rit ) + for ( rit = this->ErrorWarningFileLineRegex.begin(); + rit != this->ErrorWarningFileLineRegex.end(); ++ rit ) { - cmsys::RegularExpression* re = &rit->m_RegularExpression; - if ( re->find(cm->m_Text.c_str() ) ) + cmsys::RegularExpression* re = &rit->RegularExpression; + if ( re->find(cm->Text.c_str() ) ) { - cm->m_SourceFile = re->match(rit->m_FileIndex); - // At this point we need to make m_SourceFile relative to + cm->SourceFile = re->match(rit->FileIndex); + // At this point we need to make this->SourceFile relative to // the source root of the project, so cvs links will work - cmSystemTools::ConvertToUnixSlashes(cm->m_SourceFile); - if(cm->m_SourceFile.find("/.../") != cm->m_SourceFile.npos) + cmSystemTools::ConvertToUnixSlashes(cm->SourceFile); + if(cm->SourceFile.find("/.../") != cm->SourceFile.npos) { - cmSystemTools::ReplaceString(cm->m_SourceFile, "/.../", ""); - std::string::size_type p = cm->m_SourceFile.find("/"); - if(p != cm->m_SourceFile.npos) + cmSystemTools::ReplaceString(cm->SourceFile, "/.../", ""); + std::string::size_type p = cm->SourceFile.find("/"); + if(p != cm->SourceFile.npos) { - cm->m_SourceFile = cm->m_SourceFile.substr(p+1, cm->m_SourceFile.size()-p); + cm->SourceFile = cm->SourceFile.substr( + p+1, cm->SourceFile.size()-p); } } else { // make sure it is a full path with the correct case - cm->m_SourceFile = cmSystemTools::CollapseFullPath(cm->m_SourceFile.c_str()); - cmSystemTools::ReplaceString(cm->m_SourceFile, srcdir.c_str(), ""); + cm->SourceFile = cmSystemTools::CollapseFullPath( + cm->SourceFile.c_str()); + cmSystemTools::ReplaceString( + cm->SourceFile, srcdir.c_str(), ""); } - cm->m_LineNumber = atoi(re->match(rit->m_LineIndex).c_str()); + cm->LineNumber = atoi(re->match(rit->LineIndex).c_str()); break; } } - if ( cm->m_SourceFile.size() > 0 ) + if ( cm->SourceFile.size() > 0 ) { - os << "\t\t" << cm->m_SourceFile << "" + os << "\t\t" << cm->SourceFile << "" << std::endl; } - if ( cm->m_SourceFileTail.size() > 0 ) + if ( cm->SourceFileTail.size() > 0 ) { - os << "\t\t" << cm->m_SourceFileTail + os << "\t\t" << cm->SourceFileTail << "" << std::endl; } - if ( cm->m_LineNumber >= 0 ) + if ( cm->LineNumber >= 0 ) { - os << "\t\t" << cm->m_LineNumber + os << "\t\t" << cm->LineNumber << "" << std::endl; } - os << "\t\t" << m_CTest->MakeXMLSafe(cm->m_PreContext) + os << "\t\t" << this->CTest->MakeXMLSafe(cm->PreContext) << "\n" - << "\t\t" << m_CTest->MakeXMLSafe(cm->m_PostContext); + << "\t\t" << this->CTest->MakeXMLSafe(cm->PostContext); // is this the last warning or error, if so notify - if (cm->m_Error && !numErrorsAllowed || - !cm->m_Error && !numWarningsAllowed) + if (cm->Error && !numErrorsAllowed || + !cm->Error && !numWarningsAllowed) { - os << "\nThe maximum number of reported warnings or errors has been reached!!!\n"; + os << "\nThe maximum number of reported warnings or errors has been " + "reached!!!\n"; } os << "\n" << "\t\t0\n" - << "m_Error ? "Error" : "Warning") << ">\n\n" + << "Error ? "Error" : "Warning") << ">\n\n" << std::endl; } } os << "\t\n\t\n" - << "\t" << m_EndBuild << "\n" + << "\t" << this->EndBuild << "\n" << "" << static_cast(elapsed_build_time/6)/10.0 << "" << "" << std::endl; - m_CTest->EndXML(os); + this->CTest->EndXML(os); } //###################################################################### @@ -554,14 +591,14 @@ } argv.push_back(0); - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run command:"); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command:"); std::vector::iterator ait; for ( ait = argv.begin(); ait != argv.end() && *ait; ++ ait ) { - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " \"" << *ait << "\""); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " \"" << *ait << "\""); } - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, std::endl); - + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl); + // Now create process object cmsysProcess* cp = cmsysProcess_New(); cmsysProcess_SetCommand(cp, &*argv.begin()); @@ -576,24 +613,26 @@ char* data; int length; - cmCTestLog(m_CTest, HANDLER_OUTPUT, - " Each symbol represents " << tick_len << " bytes of output." << std::endl + cmCTestLog(this->CTest, HANDLER_OUTPUT, + " Each symbol represents " << tick_len << " bytes of output." + << std::endl << " '!' represents an error and '*' a warning." << std::endl << " " << std::flush); // Initialize building structures - m_BuildProcessingQueue.clear(); - m_OutputLineCounter = 0; - m_ErrorsAndWarnings.clear(); - m_TotalErrors = 0; - m_TotalWarnings = 0; - m_BuildOutputLogSize = 0; - m_LastTickChar = '.'; - m_WarningQuotaReached = false; - m_ErrorQuotaReached = false; + this->BuildProcessingQueue.clear(); + this->OutputLineCounter = 0; + this->ErrorsAndWarnings.clear(); + this->TotalErrors = 0; + this->TotalWarnings = 0; + this->BuildOutputLogSize = 0; + this->LastTickChar = '.'; + this->WarningQuotaReached = false; + this->ErrorQuotaReached = false; // For every chunk of data - while(cmsysProcess_WaitForData(cp, &data, &length, 0)) + int res; + while((res = cmsysProcess_WaitForData(cp, &data, &length, 0))) { // Replace '\0' with '\n', since '\0' does not really make sense. This is // for Visual Studio output @@ -606,12 +645,23 @@ } // Process the chunk of data - this->ProcessBuffer(data, length, tick, tick_len, ofs); + if ( res == cmsysProcess_Pipe_STDERR ) + { + this->ProcessBuffer(data, length, tick, tick_len, ofs, + &this->BuildProcessingErrorQueue); + } + else + { + this->ProcessBuffer(data, length, tick, tick_len, ofs, + &this->BuildProcessingQueue); + } } - this->ProcessBuffer(0, 0, tick, tick_len, ofs); - cmCTestLog(m_CTest, OUTPUT, " Size of output: " - << int(m_BuildOutputLogSize / 1024.0) << "K" << std::endl); + this->ProcessBuffer(0, 0, tick, tick_len, ofs, &this->BuildProcessingQueue); + this->ProcessBuffer(0, 0, tick, tick_len, ofs, + &this->BuildProcessingErrorQueue); + cmCTestLog(this->CTest, OUTPUT, " Size of output: " + << int(this->BuildOutputLogSize / 1024.0) << "K" << std::endl); // Properly handle output of the build command cmsysProcess_WaitForExit(cp, 0); @@ -620,30 +670,33 @@ if(result == cmsysProcess_State_Exited) { *retVal = cmsysProcess_GetExitValue(cp); - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Command exited with the value: " << *retVal << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "Command exited with the value: " << *retVal << std::endl); } else if(result == cmsysProcess_State_Exception) { *retVal = cmsysProcess_GetExitException(cp); - cmCTestLog(m_CTest, WARNING, "There was an exception: " << *retVal << std::endl); + cmCTestLog(this->CTest, WARNING, "There was an exception: " << *retVal + << std::endl); } else if(result == cmsysProcess_State_Expired) { - cmCTestLog(m_CTest, WARNING, "There was a timeout" << std::endl); - } + cmCTestLog(this->CTest, WARNING, "There was a timeout" << std::endl); + } else if(result == cmsysProcess_State_Error) { // If there was an error running command, report that on the dashboard. cmCTestBuildErrorWarning errorwarning; - errorwarning.m_LogLine = 1; - errorwarning.m_Text = "*** ERROR executing: "; - errorwarning.m_Text += cmsysProcess_GetErrorString(cp); - errorwarning.m_PreContext = ""; - errorwarning.m_PostContext = ""; - errorwarning.m_Error = true; - m_ErrorsAndWarnings.push_back(errorwarning); - m_TotalErrors ++; - cmCTestLog(m_CTest, ERROR_MESSAGE, "There was an error: " << cmsysProcess_GetErrorString(cp) << std::endl); + errorwarning.LogLine = 1; + errorwarning.Text = "*** ERROR executing: "; + errorwarning.Text += cmsysProcess_GetErrorString(cp); + errorwarning.PreContext = ""; + errorwarning.PostContext = ""; + errorwarning.Error = true; + this->ErrorsAndWarnings.push_back(errorwarning); + this->TotalErrors ++; + cmCTestLog(this->CTest, ERROR_MESSAGE, "There was an error: " + << cmsysProcess_GetErrorString(cp) << std::endl); } cmsysProcess_Delete(cp); @@ -657,25 +710,26 @@ //###################################################################### //---------------------------------------------------------------------- -void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, size_t& tick, size_t tick_len, - std::ofstream& ofs) +void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, + size_t& tick, size_t tick_len, std::ofstream& ofs, + t_BuildProcessingQueueType* queue) { #undef cerr const std::string::size_type tick_line_len = 50; const char* ptr; for ( ptr = data; ptr < data+length; ptr ++ ) { - m_BuildProcessingQueue.push_back(*ptr); + queue->push_back(*ptr); } - m_BuildOutputLogSize += length; + this->BuildOutputLogSize += length; // until there are any lines left in the buffer while ( 1 ) { // Find the end of line t_BuildProcessingQueueType::iterator it; - for ( it = m_BuildProcessingQueue.begin(); - it != m_BuildProcessingQueue.end(); + for ( it = queue->begin(); + it != queue->end(); ++ it ) { if ( *it == '\n' ) @@ -684,34 +738,35 @@ } } - // Once certain number of errors or warnings reached, ignore future errors or warnings. - if ( m_TotalWarnings >= m_MaxWarnings ) + // Once certain number of errors or warnings reached, ignore future errors + // or warnings. + if ( this->TotalWarnings >= this->MaxWarnings ) { - m_WarningQuotaReached = true; + this->WarningQuotaReached = true; } - if ( m_TotalErrors >= m_MaxErrors ) + if ( this->TotalErrors >= this->MaxErrors ) { - m_ErrorQuotaReached = true; + this->ErrorQuotaReached = true; } // If the end of line was found - if ( it != m_BuildProcessingQueue.end() ) + if ( it != queue->end() ) { // Create a contiguous array for the line - m_CurrentProcessingLine.clear(); + this->CurrentProcessingLine.clear(); t_BuildProcessingQueueType::iterator cit; - for ( cit = m_BuildProcessingQueue.begin(); cit != it; ++cit ) + for ( cit = queue->begin(); cit != it; ++cit ) { - m_CurrentProcessingLine.push_back(*cit); + this->CurrentProcessingLine.push_back(*cit); } - m_CurrentProcessingLine.push_back(0); - const char* line = &*m_CurrentProcessingLine.begin(); + this->CurrentProcessingLine.push_back(0); + const char* line = &*this->CurrentProcessingLine.begin(); // Process the line int lineType = this->ProcessSingleLine(line); // Erase the line from the queue - m_BuildProcessingQueue.erase(m_BuildProcessingQueue.begin(), it+1); + queue->erase(queue->begin(), it+1); // Depending on the line type, produce error or warning, or nothing cmCTestBuildErrorWarning errorwarning; @@ -719,63 +774,67 @@ switch ( lineType ) { case b_WARNING_LINE: - m_LastTickChar = '*'; - errorwarning.m_Error = false; + this->LastTickChar = '*'; + errorwarning.Error = false; found = true; - m_TotalWarnings ++; + this->TotalWarnings ++; break; case b_ERROR_LINE: - m_LastTickChar = '!'; - errorwarning.m_Error = true; + this->LastTickChar = '!'; + errorwarning.Error = true; found = true; - m_TotalErrors ++; + this->TotalErrors ++; break; } if ( found ) { // This is an error or warning, so generate report - errorwarning.m_LogLine = static_cast(m_OutputLineCounter+1); - errorwarning.m_Text = line; - errorwarning.m_PreContext = ""; - errorwarning.m_PostContext = ""; + errorwarning.LogLine = static_cast(this->OutputLineCounter+1); + errorwarning.Text = line; + errorwarning.PreContext = ""; + errorwarning.PostContext = ""; // Copy pre-context to report std::deque::iterator pcit; - for ( pcit = m_PreContext.begin(); pcit != m_PreContext.end(); ++pcit ) + for ( pcit = this->PreContext.begin(); + pcit != this->PreContext.end(); + ++pcit ) { - errorwarning.m_PreContext += *pcit + "\n"; + errorwarning.PreContext += *pcit + "\n"; } - m_PreContext.clear(); + this->PreContext.clear(); // Store report - m_ErrorsAndWarnings.push_back(errorwarning); - m_LastErrorOrWarning = m_ErrorsAndWarnings.end()-1; - m_PostContextCount = 0; + this->ErrorsAndWarnings.push_back(errorwarning); + this->LastErrorOrWarning = this->ErrorsAndWarnings.end()-1; + this->PostContextCount = 0; } else { // This is not an error or warning. // So, figure out if this is a post-context line - if ( m_LastErrorOrWarning != m_ErrorsAndWarnings.end() && m_PostContextCount < m_MaxPostContext ) + if ( this->LastErrorOrWarning != this->ErrorsAndWarnings.end() && + this->PostContextCount < this->MaxPostContext ) { - m_PostContextCount ++; - m_LastErrorOrWarning->m_PostContext += line; - if ( m_PostContextCount < m_MaxPostContext ) + this->PostContextCount ++; + this->LastErrorOrWarning->PostContext += line; + if ( this->PostContextCount < this->MaxPostContext ) { - m_LastErrorOrWarning->m_PostContext += "\n"; + this->LastErrorOrWarning->PostContext += "\n"; } } else { // Otherwise store pre-context for the next error - m_PreContext.push_back(line); - if ( m_PreContext.size() > m_MaxPreContext ) + this->PreContext.push_back(line); + if ( this->PreContext.size() > this->MaxPreContext ) { - m_PreContext.erase(m_PreContext.begin(), m_PreContext.end()-m_MaxPreContext); + this->PreContext.erase(this->PreContext.begin(), + this->PreContext.end()-this->MaxPreContext); } } } - m_OutputLineCounter ++; + this->OutputLineCounter ++; } else { @@ -785,25 +844,26 @@ // Now that the buffer is processed, display missing ticks int tickDisplayed = false; - while ( m_BuildOutputLogSize > (tick * tick_len) ) + while ( this->BuildOutputLogSize > (tick * tick_len) ) { tick ++; - cmCTestLog(m_CTest, HANDLER_OUTPUT, m_LastTickChar); + cmCTestLog(this->CTest, HANDLER_OUTPUT, this->LastTickChar); tickDisplayed = true; if ( tick % tick_line_len == 0 && tick > 0 ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Size: " - << int((m_BuildOutputLogSize / 1024.0) + 1) << "K" << std::endl + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Size: " + << int((this->BuildOutputLogSize / 1024.0) + 1) << "K" << std::endl << " "); } } if ( tickDisplayed ) { - m_LastTickChar = '.'; + this->LastTickChar = '.'; } // And if this is verbose output, display the content of the chunk - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, cmCTestLogWrite(data, length)); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + cmCTestLogWrite(data, length)); // Always store the chunk to the file ofs << cmCTestLogWrite(data, length); @@ -812,7 +872,7 @@ //---------------------------------------------------------------------- int cmCTestBuildHandler::ProcessSingleLine(const char* data) { - cmCTestLog(m_CTest, DEBUG, "Line: [" << data << "]" << std::endl); + cmCTestLog(this->CTest, DEBUG, "Line: [" << data << "]" << std::endl); std::vector::iterator it; @@ -820,52 +880,63 @@ int errorLine = 0; // Check for regular expressions - - if ( !m_ErrorQuotaReached ) + + if ( !this->ErrorQuotaReached ) { - // Errors - for ( it = m_ErrorMatchRegex.begin(); it != m_ErrorMatchRegex.end(); ++ it ) + // Errors + for ( it = this->ErrorMatchRegex.begin(); + it != this->ErrorMatchRegex.end(); + ++ it ) { if ( it->find(data) ) { errorLine = 1; - cmCTestLog(m_CTest, DEBUG, " Error Line: " << data << std::endl); + cmCTestLog(this->CTest, DEBUG, " Error Line: " << data << std::endl); break; } } - // Error exceptions - for ( it = m_ErrorExceptionRegex.begin(); it != m_ErrorExceptionRegex.end(); ++ it ) + // Error exceptions + for ( it = this->ErrorExceptionRegex.begin(); + it != this->ErrorExceptionRegex.end(); + ++ it ) { if ( it->find(data) ) { errorLine = 0; - cmCTestLog(m_CTest, DEBUG, " Not an error Line: " << data << std::endl); + cmCTestLog(this->CTest, DEBUG, " Not an error Line: " << data + << std::endl); break; } } } - if ( !m_WarningQuotaReached ) + if ( !this->WarningQuotaReached ) { // Warnings - for ( it = m_WarningMatchRegex.begin(); it != m_WarningMatchRegex.end(); ++ it ) + for ( it = this->WarningMatchRegex.begin(); + it != this->WarningMatchRegex.end(); + ++ it ) { if ( it->find(data) ) { warningLine = 1; - cmCTestLog(m_CTest, DEBUG, " Warning Line: " << data << std::endl); + cmCTestLog(this->CTest, DEBUG, + " Warning Line: " << data << std::endl); break; - } + } } // Warning exceptions - for ( it = m_WarningExceptionRegex.begin(); it != m_WarningExceptionRegex.end(); ++ it ) + for ( it = this->WarningExceptionRegex.begin(); + it != this->WarningExceptionRegex.end(); + ++ it ) { if ( it->find(data) ) { warningLine = 0; - cmCTestLog(m_CTest, DEBUG, " Not a warning Line: " << data << std::endl); + cmCTestLog(this->CTest, DEBUG, " Not a warning Line: " << data + << std::endl); break; - } + } } } if ( errorLine ) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestBuildHandler.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestBuildHandler.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestBuildHandler.h 2005-06-18 01:04:56.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestBuildHandler.h 2006-03-11 04:03:08.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestBuildHandler.h,v $ Language: C++ - Date: $Date: 2005/06/17 17:04:56 $ - Version: $Revision: 1.9 $ + Date: $Date: 2006/03/10 20:03:08 $ + Version: $Revision: 1.12 $ Copyright (c) 2002 Kitware, Inc. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -39,21 +39,21 @@ * The main entry point for this class */ int ProcessHandler(); - + cmCTestBuildHandler(); - + void PopulateCustomVectors(cmMakefile *mf); /** * Initialize handler */ virtual void Initialize(); - + private: //! Run command specialized for make and configure. Returns process status // and retVal is return value or exception. int RunMakeCommand(const char* command, - int* retVal, const char* dir, int timeout, + int* retVal, const char* dir, int timeout, std::ofstream& ofs); enum { @@ -66,73 +66,74 @@ { public: cmCTestCompileErrorWarningRex() {} - int m_FileIndex; - int m_LineIndex; - cmsys::RegularExpression m_RegularExpression; + int FileIndex; + int LineIndex; + cmsys::RegularExpression RegularExpression; }; struct cmCTestBuildErrorWarning { - bool m_Error; - int m_LogLine; - std::string m_Text; - std::string m_SourceFile; - std::string m_SourceFileTail; - int m_LineNumber; - std::string m_PreContext; - std::string m_PostContext; + bool Error; + int LogLine; + std::string Text; + std::string SourceFile; + std::string SourceFileTail; + int LineNumber; + std::string PreContext; + std::string PostContext; }; // generate the XML output - void GenerateDartBuildOutput(std::ostream& os, + void GenerateDartBuildOutput(std::ostream& os, std::vector, double elapsed_time); - - std::string m_StartBuild; - std::string m_EndBuild; - - std::vector m_CustomErrorMatches; - std::vector m_CustomErrorExceptions; - std::vector m_CustomWarningMatches; - std::vector m_CustomWarningExceptions; - std::vector m_ErrorWarningFileLineRegex; - - std::vector m_ErrorMatchRegex; - std::vector m_ErrorExceptionRegex; - std::vector m_WarningMatchRegex; - std::vector m_WarningExceptionRegex; - void ProcessBuffer(const char* data, int length, size_t& tick, size_t tick_len, - std::ofstream& ofs); - int ProcessSingleLine(const char* data); + std::string StartBuild; + std::string EndBuild; + + std::vector CustomErrorMatches; + std::vector CustomErrorExceptions; + std::vector CustomWarningMatches; + std::vector CustomWarningExceptions; + std::vector ErrorWarningFileLineRegex; + + std::vector ErrorMatchRegex; + std::vector ErrorExceptionRegex; + std::vector WarningMatchRegex; + std::vector WarningExceptionRegex; typedef std::deque t_BuildProcessingQueueType; - t_BuildProcessingQueueType m_BuildProcessingQueue; - t_BuildProcessingQueueType::iterator m_BuildProcessingQueueLocation; - size_t m_BuildOutputLogSize; - std::vector m_CurrentProcessingLine; - - cmStdString m_SimplifySourceDir; - cmStdString m_SimplifyBuildDir; - size_t m_OutputLineCounter; + + void ProcessBuffer(const char* data, int length, size_t& tick, + size_t tick_len, std::ofstream& ofs, t_BuildProcessingQueueType* queue); + int ProcessSingleLine(const char* data); + + t_BuildProcessingQueueType BuildProcessingQueue; + t_BuildProcessingQueueType BuildProcessingErrorQueue; + size_t BuildOutputLogSize; + std::vector CurrentProcessingLine; + + cmStdString SimplifySourceDir; + cmStdString SimplifyBuildDir; + size_t OutputLineCounter; typedef std::vector t_ErrorsAndWarningsVector; - t_ErrorsAndWarningsVector m_ErrorsAndWarnings; - t_ErrorsAndWarningsVector::iterator m_LastErrorOrWarning; - size_t m_PostContextCount; - size_t m_MaxPreContext; - size_t m_MaxPostContext; - std::deque m_PreContext; - - int m_TotalErrors; - int m_TotalWarnings; - char m_LastTickChar; + t_ErrorsAndWarningsVector ErrorsAndWarnings; + t_ErrorsAndWarningsVector::iterator LastErrorOrWarning; + size_t PostContextCount; + size_t MaxPreContext; + size_t MaxPostContext; + std::deque PreContext; + + int TotalErrors; + int TotalWarnings; + char LastTickChar; - bool m_ErrorQuotaReached; - bool m_WarningQuotaReached; + bool ErrorQuotaReached; + bool WarningQuotaReached; - int m_MaxErrors; - int m_MaxWarnings; + int MaxErrors; + int MaxWarnings; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestCommand.h 2005-06-17 01:18:21.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestCommand.h 2006-03-11 04:03:09.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestCommand.h,v $ Language: C++ - Date: $Date: 2005/06/16 17:18:21 $ - Version: $Revision: 1.2 $ + Date: $Date: 2006/03/10 20:03:09 $ + Version: $Revision: 1.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -27,17 +27,17 @@ * * cmCTestCommand is the superclass for all commands that will be added to * the ctest script handlers parser. - * + * */ class cmCTestCommand : public cmCommand { public: - cmCTestCommand() {m_CTest = 0; m_CTestScriptHandler = 0;} - - cmCTest *m_CTest; - cmCTestScriptHandler *m_CTestScriptHandler; - + cmCTestCommand() {this->CTest = 0; this->CTestScriptHandler = 0;} + + cmCTest *CTest; + cmCTestScriptHandler *CTestScriptHandler; + cmTypeMacro(cmCTestCommand, cmCommand); }; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestConfigureCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestConfigureCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestConfigureCommand.cxx 2005-06-24 01:04:17.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestConfigureCommand.cxx 2006-03-16 00:02:08.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestConfigureCommand.cxx,v $ Language: C++ - Date: $Date: 2005/06/23 17:04:17 $ - Version: $Revision: 1.5 $ + Date: $Date: 2006/03/15 16:02:08 $ + Version: $Revision: 1.8 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -50,16 +50,18 @@ { if ( res_var ) { - this->SetError("called with incorrect number of arguments. RETURN_VALUE specified twice."); + this->SetError("called with incorrect number of arguments. " + "RETURN_VALUE specified twice."); return false; } havereturn_variable = true; - } + } else if(args[i] == "SOURCE") { if ( source_dir ) { - this->SetError("called with incorrect number of arguments. SOURCE specified twice."); + this->SetError("called with incorrect number of arguments. " + "SOURCE specified twice."); return false; } havesource = true; @@ -68,7 +70,8 @@ { if ( build_dir ) { - this->SetError("called with incorrect number of arguments. BUILD specified twice."); + this->SetError("called with incorrect number of arguments. " + "BUILD specified twice."); return false; } havebuild = true; @@ -76,7 +79,8 @@ else { cmOStringStream str; - str << "called with incorrect number of arguments. Extra argument is: " << args[i].c_str() << "."; + str << "called with incorrect number of arguments. Extra argument is: " + << args[i].c_str() << "."; this->SetError(str.str().c_str()); return false; } @@ -84,58 +88,68 @@ if ( source_dir ) { - m_CTest->SetCTestConfiguration("SourceDirectory", source_dir); + this->CTest->SetCTestConfiguration("SourceDirectory", source_dir); } else { - source_dir = m_Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY"); + source_dir = this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY"); } if ( build_dir ) { - m_CTest->SetCTestConfiguration("BuildDirectory", build_dir); + this->CTest->SetCTestConfiguration("BuildDirectory", build_dir); } else { - build_dir = m_Makefile->GetDefinition("CTEST_BINARY_DIRECTORY"); + build_dir = this->Makefile->GetDefinition("CTEST_BINARY_DIRECTORY"); if ( !build_dir ) { - this->SetError("Build directory not specified. Either use BUILD argument to CTEST_CONFIGURE command or set CTEST_BINARY_DIRECTORY variable"); + this->SetError("Build directory not specified. Either use BUILD " + "argument to CTEST_CONFIGURE command or set CTEST_BINARY_DIRECTORY " + "variable"); return false; } } - const char* ctestConfigureCommand = m_Makefile->GetDefinition("CTEST_CONFIGURE_COMMAND"); + const char* ctestConfigureCommand + = this->Makefile->GetDefinition("CTEST_CONFIGURE_COMMAND"); if ( ctestConfigureCommand && *ctestConfigureCommand ) { - m_CTest->SetCTestConfiguration("ConfigureCommand", ctestConfigureCommand); + this->CTest->SetCTestConfiguration("ConfigureCommand", + ctestConfigureCommand); } else { - const char* cmakeGeneratorName = m_Makefile->GetDefinition("CTEST_CMAKE_GENERATOR"); + const char* cmakeGeneratorName + = this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR"); if ( cmakeGeneratorName && *cmakeGeneratorName ) { std::string cmakeConfigureCommand = "\""; - cmakeConfigureCommand += m_CTest->GetCMakeExecutable(); + cmakeConfigureCommand += this->CTest->GetCMakeExecutable(); cmakeConfigureCommand += "\" \"-G"; cmakeConfigureCommand += cmakeGeneratorName; cmakeConfigureCommand += "\" \""; cmakeConfigureCommand += source_dir; cmakeConfigureCommand += "\""; - m_CTest->SetCTestConfiguration("ConfigureCommand", cmakeConfigureCommand.c_str()); + this->CTest->SetCTestConfiguration("ConfigureCommand", + cmakeConfigureCommand.c_str()); } else { - this->SetError("Configure command is not specified. If this is a CMake project, specify CTEST_CMAKE_GENERATOR, or if this is not CMake project, specify CTEST_CONFIGURE_COMMAND."); + this->SetError("Configure command is not specified. If this is a CMake " + "project, specify CTEST_CMAKE_GENERATOR, or if this is not CMake " + "project, specify CTEST_CONFIGURE_COMMAND."); return false; } } - cmCTestGenericHandler* handler = m_CTest->GetInitializedHandler("configure"); + cmCTestGenericHandler* handler + = this->CTest->GetInitializedHandler("configure"); if ( !handler ) { - this->SetError("internal CTest error. Cannot instantiate configure handler"); + this->SetError( + "internal CTest error. Cannot instantiate configure handler"); return false; } int res = handler->ProcessHandler(); @@ -143,7 +157,7 @@ { cmOStringStream str; str << res; - m_Makefile->AddDefinition(res_var, str.str().c_str()); + this->Makefile->AddDefinition(res_var, str.str().c_str()); } return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestConfigureCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestConfigureCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestConfigureCommand.h 2005-05-04 23:13:35.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestConfigureCommand.h 2006-03-11 04:03:09.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestConfigureCommand.h,v $ Language: C++ - Date: $Date: 2005/05/04 15:13:35 $ - Version: $Revision: 1.2 $ + Date: $Date: 2006/03/10 20:03:09 $ + Version: $Revision: 1.4 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -29,15 +29,15 @@ public: cmCTestConfigureCommand() {} - + /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { cmCTestConfigureCommand* ni = new cmCTestConfigureCommand; - ni->m_CTest = this->m_CTest; - ni->m_CTestScriptHandler = this->m_CTestScriptHandler; + ni->CTest = this->CTest; + ni->CTestScriptHandler = this->CTestScriptHandler; return ni; } @@ -55,11 +55,11 @@ /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { return "Configures the repository."; } - + /** * More documentation. */ @@ -67,8 +67,9 @@ { return " CTEST_CONFIGURE(BUILD build_dir RETURN_VALUE res)\n" - "Configures the given build directory and stores results in Configure.xml. The " - "second argument is a variable that will hold return value."; + "Configures the given build directory and stores results in " + "Configure.xml. The second argument is a variable that will hold " + "return value."; } cmTypeMacro(cmCTestConfigureCommand, cmCTestCommand); diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestConfigureHandler.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestConfigureHandler.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestConfigureHandler.cxx 2005-06-24 01:04:17.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestConfigureHandler.cxx 2006-03-11 04:03:09.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestConfigureHandler.cxx,v $ Language: C++ - Date: $Date: 2005/06/23 17:04:17 $ - Version: $Revision: 1.11 $ + Date: $Date: 2006/03/10 20:03:09 $ + Version: $Revision: 1.13 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -39,19 +39,24 @@ //functions and commented... int cmCTestConfigureHandler::ProcessHandler() { - cmCTestLog(m_CTest, HANDLER_OUTPUT, "Configure project" << std::endl); - std::string cCommand = m_CTest->GetCTestConfiguration("ConfigureCommand"); + cmCTestLog(this->CTest, HANDLER_OUTPUT, "Configure project" << std::endl); + std::string cCommand + = this->CTest->GetCTestConfiguration("ConfigureCommand"); if ( cCommand.size() == 0 ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot find ConfigureCommand key in the DartConfiguration.tcl" - << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Cannot find ConfigureCommand key in the DartConfiguration.tcl" + << std::endl); return -1; } - std::string buildDirectory = m_CTest->GetCTestConfiguration("BuildDirectory"); + std::string buildDirectory + = this->CTest->GetCTestConfiguration("BuildDirectory"); if ( buildDirectory.size() == 0 ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot find BuildDirectory key in the DartConfiguration.tcl" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Cannot find BuildDirectory key in the DartConfiguration.tcl" + << std::endl); return -1; } @@ -59,20 +64,22 @@ std::string output; int retVal = 0; int res = 0; - if ( !m_CTest->GetShowOnly() ) + if ( !this->CTest->GetShowOnly() ) { - cmGeneratedFileStream os; + cmGeneratedFileStream os; if ( !this->StartResultingXML("Configure", os) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot open configure file" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open configure file" + << std::endl); return 1; } - std::string start_time = m_CTest->CurrentTime(); + std::string start_time = this->CTest->CurrentTime(); cmGeneratedFileStream ofs; this->StartLogFile("Configure", ofs); - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Configure with command: " << cCommand.c_str() << std::endl); - res = m_CTest->RunMakeCommand(cCommand.c_str(), &output, + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Configure with command: " + << cCommand.c_str() << std::endl); + res = this->CTest->RunMakeCommand(cCommand.c_str(), &output, &retVal, buildDirectory.c_str(), 0, ofs); @@ -80,37 +87,41 @@ { ofs.close(); } - + if ( os ) { - m_CTest->StartXML(os); + this->CTest->StartXML(os); os << "\n" - << "\t" << start_time << "" << std::endl; + << "\t" << start_time << "" + << std::endl; if ( res == cmsysProcess_State_Exited && retVal ) { os << retVal; } - os << "" << cCommand.c_str() << "" << std::endl; - cmCTestLog(m_CTest, DEBUG, "End" << std::endl); + os << "" << cCommand.c_str() << "" + << std::endl; + cmCTestLog(this->CTest, DEBUG, "End" << std::endl); os << "" << cmCTest::MakeXMLSafe(output) << "" << std::endl; - std::string end_time = m_CTest->CurrentTime(); + std::string end_time = this->CTest->CurrentTime(); os << "\t" << retVal << "\n" << "\t" << end_time << "\n" - << "" + << "" << static_cast( (cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0 << "" << "" << std::endl; - m_CTest->EndXML(os); - } + this->CTest->EndXML(os); + } } else { - cmCTestLog(m_CTest, DEBUG, "Configure with command: " << cCommand << std::endl); + cmCTestLog(this->CTest, DEBUG, "Configure with command: " << cCommand + << std::endl); } if (! res || retVal ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Error(s) when updating the project" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Error(s) when updating the project" << std::endl); return -1; } return 0; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestConfigureHandler.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestConfigureHandler.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestConfigureHandler.h 2005-06-18 01:04:56.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestConfigureHandler.h 2006-03-10 00:17:10.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestConfigureHandler.h,v $ Language: C++ - Date: $Date: 2005/06/17 17:04:56 $ - Version: $Revision: 1.4 $ + Date: $Date: 2006/03/09 16:17:10 $ + Version: $Revision: 1.5 $ Copyright (c) 2002 Kitware, Inc. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -35,7 +35,7 @@ * The main entry point for this class */ int ProcessHandler(); - + cmCTestConfigureHandler(); void Initialize(); diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestCoverageCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestCoverageCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestCoverageCommand.cxx 2005-06-24 01:04:17.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestCoverageCommand.cxx 2006-03-16 00:02:08.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestCoverageCommand.cxx,v $ Language: C++ - Date: $Date: 2005/06/23 17:04:17 $ - Version: $Revision: 1.3 $ + Date: $Date: 2006/03/15 16:02:08 $ + Version: $Revision: 1.6 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -43,16 +43,18 @@ { if ( res_var ) { - this->SetError("called with incorrect number of arguments. RETURN_VALUE specified twice."); + this->SetError("called with incorrect number of arguments. " + "RETURN_VALUE specified twice."); return false; } havereturn_variable = true; - } + } else if(args[i] == "BUILD") { if ( build_dir ) { - this->SetError("called with incorrect number of arguments. BUILD specified twice."); + this->SetError("called with incorrect number of arguments. " + "BUILD specified twice."); return false; } havesource = true; @@ -60,7 +62,8 @@ else { cmOStringStream str; - str << "called with incorrect number of arguments. Extra argument is: " << args[i].c_str() << "."; + str << "called with incorrect number of arguments. Extra argument is: " + << args[i].c_str() << "."; this->SetError(str.str().c_str()); return false; } @@ -68,26 +71,28 @@ if ( build_dir ) { - m_CTest->SetCTestConfiguration("BuildDirectory", build_dir); + this->CTest->SetCTestConfiguration("BuildDirectory", build_dir); } - m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, "CoverageCommand", "CTEST_COVERAGE_COMMAND"); - cmCTestGenericHandler* handler = m_CTest->GetInitializedHandler("coverage"); + cmCTestGenericHandler* handler + = this->CTest->GetInitializedHandler("coverage"); if ( !handler ) { this->SetError("internal CTest error. Cannot instantiate test handler"); return false; } std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(m_CTest->GetCTestConfiguration("BuildDirectory").c_str()); + cmSystemTools::ChangeDirectory( + this->CTest->GetCTestConfiguration("BuildDirectory").c_str()); int res = handler->ProcessHandler(); if ( res_var ) { cmOStringStream str; str << res; - m_Makefile->AddDefinition(res_var, str.str().c_str()); + this->Makefile->AddDefinition(res_var, str.str().c_str()); } cmSystemTools::ChangeDirectory(current_dir.c_str()); return true; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestCoverageCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestCoverageCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestCoverageCommand.h 2005-06-15 02:00:45.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestCoverageCommand.h 2006-03-11 04:03:09.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestCoverageCommand.h,v $ Language: C++ - Date: $Date: 2005/06/14 18:00:45 $ - Version: $Revision: 1.1 $ + Date: $Date: 2006/03/10 20:03:09 $ + Version: $Revision: 1.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -29,15 +29,15 @@ public: cmCTestCoverageCommand() {} - + /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { cmCTestCoverageCommand* ni = new cmCTestCoverageCommand; - ni->m_CTest = this->m_CTest; - ni->m_CTestScriptHandler = this->m_CTestScriptHandler; + ni->CTest = this->CTest; + ni->CTestScriptHandler = this->CTestScriptHandler; return ni; } @@ -55,11 +55,11 @@ /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { return "Tests the repository."; } - + /** * More documentation. */ @@ -67,8 +67,9 @@ { return " CTEST_COVERAGE([BUILD build_dir] [RETURN_VALUE res])\n" - "Perform the coverage of the given build directory and stores results in " - "Coverage.xml. The second argument is a variable that will hold value."; + "Perform the coverage of the given build directory and stores results " + "in Coverage.xml. The second argument is a variable that will hold " + "value."; } cmTypeMacro(cmCTestCoverageCommand, cmCTestCommand); diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestCoverageHandler.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestCoverageHandler.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestCoverageHandler.cxx 2005-09-16 04:38:36.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestCoverageHandler.cxx 2006-03-11 04:03:09.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestCoverageHandler.cxx,v $ Language: C++ - Date: $Date: 2005/09/15 20:38:36 $ - Version: $Revision: 1.18.2.2 $ + Date: $Date: 2006/03/10 20:03:09 $ + Version: $Revision: 1.29 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include @@ -40,51 +40,58 @@ void cmCTestCoverageHandler::Initialize() { this->Superclass::Initialize(); - m_CustomCoverageExclude.empty(); + this->CustomCoverageExclude.empty(); } //---------------------------------------------------------------------- -bool cmCTestCoverageHandler::StartCoverageLogFile(cmGeneratedFileStream& covLogFile, int logFileCount) +bool cmCTestCoverageHandler::StartCoverageLogFile( + cmGeneratedFileStream& covLogFile, int logFileCount) { char covLogFilename[1024]; sprintf(covLogFilename, "CoverageLog-%d", logFileCount); - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Open file: " << covLogFilename << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Open file: " + << covLogFilename << std::endl); if (!this->StartResultingXML(covLogFilename, covLogFile) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot open log file: " << covLogFilename << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open log file: " + << covLogFilename << std::endl); return false; } - std::string local_start_time = m_CTest->CurrentTime(); - m_CTest->StartXML(covLogFile); + std::string local_start_time = this->CTest->CurrentTime(); + this->CTest->StartXML(covLogFile); covLogFile << "" << std::endl - << "\t" << local_start_time << "" << std::endl; + << "\t" << local_start_time << "" + << std::endl; return true; } //---------------------------------------------------------------------- -void cmCTestCoverageHandler::EndCoverageLogFile(cmGeneratedFileStream& ostr, int logFileCount) +void cmCTestCoverageHandler::EndCoverageLogFile(cmGeneratedFileStream& ostr, + int logFileCount) { - std::string local_end_time = m_CTest->CurrentTime(); + std::string local_end_time = this->CTest->CurrentTime(); ostr << "\t" << local_end_time << "" << std::endl << "" << std::endl; - m_CTest->EndXML(ostr); + this->CTest->EndXML(ostr); char covLogFilename[1024]; sprintf(covLogFilename, "CoverageLog-%d.xml", logFileCount); - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Close file: " << covLogFilename << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Close file: " + << covLogFilename << std::endl); ostr.Close(); } //---------------------------------------------------------------------- -bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, const char* srcDir, +bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, + const char* srcDir, const char* binDir) { std::vector::iterator sit; - for ( sit = m_CustomCoverageExcludeRegex.begin(); - sit != m_CustomCoverageExcludeRegex.end(); ++ sit ) + for ( sit = this->CustomCoverageExcludeRegex.begin(); + sit != this->CustomCoverageExcludeRegex.end(); ++ sit ) { if ( sit->find(file) ) { - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " File " << file + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " File " << file << " is excluded in CTestCustom.ctest" << std::endl;); return false; } @@ -93,8 +100,10 @@ std::string fSrcDir = cmSystemTools::CollapseFullPath(srcDir); std::string fBinDir = cmSystemTools::CollapseFullPath(binDir); std::string fFile = cmSystemTools::CollapseFullPath(file); - bool sourceSubDir = cmSystemTools::IsSubDirectory(fFile.c_str(), fSrcDir.c_str()); - bool buildSubDir = cmSystemTools::IsSubDirectory(fFile.c_str(), fBinDir.c_str()); + bool sourceSubDir = cmSystemTools::IsSubDirectory(fFile.c_str(), + fSrcDir.c_str()); + bool buildSubDir = cmSystemTools::IsSubDirectory(fFile.c_str(), + fBinDir.c_str()); // Always check parent directory of the file. std::string fileDir = cmSystemTools::GetFilenamePath(fFile.c_str()); std::string checkDir; @@ -124,7 +133,8 @@ fFile.c_str(), checkDir.c_str()); if ( ndc.size() ) { - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc.c_str() << " so skip coverage of " << file << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc.c_str() + << " so skip coverage of " << file << std::endl); return false; } @@ -154,7 +164,8 @@ fFile.c_str(), checkDir.c_str()); if ( ndc.size() ) { - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc.c_str() << " so skip coverage of: " << file << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc.c_str() + << " so skip coverage of: " << file << std::endl); return false; } // Ok, nothing in source tree, nothing in binary tree @@ -168,15 +179,19 @@ { int error = 0; - std::string sourceDir = m_CTest->GetCTestConfiguration("SourceDirectory"); - std::string binaryDir = m_CTest->GetCTestConfiguration("BuildDirectory"); - std::string gcovCommand = m_CTest->GetCTestConfiguration("CoverageCommand"); + std::string sourceDir + = this->CTest->GetCTestConfiguration("SourceDirectory"); + std::string binaryDir + = this->CTest->GetCTestConfiguration("BuildDirectory"); + std::string gcovCommand + = this->CTest->GetCTestConfiguration("CoverageCommand"); cmGeneratedFileStream ofs; double elapsed_time_start = cmSystemTools::GetTime(); if ( !this->StartLogFile("Coverage", ofs) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create LastCoverage.log file" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Cannot create LastCoverage.log file" << std::endl); } ofs << "Performing coverage: " << elapsed_time_start << std::endl; @@ -186,39 +201,42 @@ std::string asfGlob = sourceDir + "/*"; std::string abfGlob = binaryDir + "/*"; - - + + // Style 1 - std::string st1gcovOutputRex1 = "[0-9]+\\.[0-9]+% of [0-9]+ (source |)lines executed in file (.*)$"; + std::string st1gcovOutputRex1 + = "[0-9]+\\.[0-9]+% of [0-9]+ (source |)lines executed in file (.*)$"; std::string st1gcovOutputRex2 = "^Creating (.*\\.gcov)\\."; cmsys::RegularExpression st1re1(st1gcovOutputRex1.c_str()); cmsys::RegularExpression st1re2(st1gcovOutputRex2.c_str()); - - + + // Style 2 std::string st2gcovOutputRex1 = "^File *[`'](.*)'$"; - std::string st2gcovOutputRex2 = "Lines executed: *[0-9]+\\.[0-9]+% of [0-9]+$"; + std::string st2gcovOutputRex2 + = "Lines executed: *[0-9]+\\.[0-9]+% of [0-9]+$"; std::string st2gcovOutputRex3 = "^(.*):creating [`'](.*\\.gcov)'"; std::string st2gcovOutputRex4 = "^(.*):unexpected EOF *$"; std::string st2gcovOutputRex5 = "^(.*):cannot open source file*$"; - std::string st2gcovOutputRex6 = "^(.*):source file is newer than graph file `(.*)'$"; + std::string st2gcovOutputRex6 + = "^(.*):source file is newer than graph file `(.*)'$"; cmsys::RegularExpression st2re1(st2gcovOutputRex1.c_str()); cmsys::RegularExpression st2re2(st2gcovOutputRex2.c_str()); cmsys::RegularExpression st2re3(st2gcovOutputRex3.c_str()); cmsys::RegularExpression st2re4(st2gcovOutputRex4.c_str()); cmsys::RegularExpression st2re5(st2gcovOutputRex5.c_str()); cmsys::RegularExpression st2re6(st2gcovOutputRex6.c_str()); - - cmCTestLog(m_CTest, HANDLER_OUTPUT, "Performing coverage" << std::endl); - - std::string coverage_start_time = m_CTest->CurrentTime(); - - std::string testingDir = m_CTest->GetBinaryDir() + "/Testing"; + + cmCTestLog(this->CTest, HANDLER_OUTPUT, "Performing coverage" << std::endl); + + std::string coverage_start_time = this->CTest->CurrentTime(); + + std::string testingDir = this->CTest->GetBinaryDir() + "/Testing"; std::string tempDir = testingDir + "/CoverageInfo"; std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory(); cmSystemTools::MakeDirectory(tempDir.c_str()); cmSystemTools::ChangeDirectory(tempDir.c_str()); - + cmGlob gl; gl.RecurseOn(); std::string daGlob = binaryDir + "/*.da"; @@ -229,79 +247,91 @@ std::vector& moreFiles = gl.GetFiles(); files.insert(files.end(), moreFiles.begin(), moreFiles.end()); std::vector::iterator it; - + if ( files.size() == 0 ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Cannot find any coverage files." << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find any coverage files." + << std::endl); // No coverage files is a valid thing, so the exit code is 0 return 0; } - m_CustomCoverageExcludeRegex.empty(); + this->CustomCoverageExcludeRegex.empty(); std::vector::iterator rexIt; - for ( rexIt = m_CustomCoverageExclude.begin(); - rexIt != m_CustomCoverageExclude.end(); + for ( rexIt = this->CustomCoverageExclude.begin(); + rexIt != this->CustomCoverageExclude.end(); ++ rexIt ) { - m_CustomCoverageExcludeRegex.push_back(cmsys::RegularExpression(rexIt->c_str())); + this->CustomCoverageExcludeRegex.push_back( + cmsys::RegularExpression(rexIt->c_str())); } - + typedef std::vector singleFileCoverageVector; typedef std::map totalCoverageMap; - + totalCoverageMap totalCoverage; - + int gcovStyle = 0; std::set missingFiles; - + std::string actualSourceFile = ""; - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Processing coverage (each . represents one file):" << std::endl); - cmCTestLog(m_CTest, HANDLER_OUTPUT, " "); + cmCTestLog(this->CTest, HANDLER_OUTPUT, + " Processing coverage (each . represents one file):" << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " "); int file_count = 0; for ( it = files.begin(); it != files.end(); ++ it ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, "." << std::flush); + cmCTestLog(this->CTest, HANDLER_OUTPUT, "." << std::flush); std::string fileDir = cmSystemTools::GetFilenamePath(it->c_str()); - std::string command = "\"" + gcovCommand + "\" -l -o \"" + fileDir + "\" \"" + *it + "\""; - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, command.c_str() << std::endl); + std::string command = "\"" + gcovCommand + "\" -l -o \"" + fileDir + + "\" \"" + *it + "\""; + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, command.c_str() + << std::endl); std::string output = ""; std::string errors = ""; int retVal = 0; ofs << "* Run coverage for: " << fileDir.c_str() << std::endl; ofs << " Command: " << command.c_str() << std::endl; - int res = m_CTest->RunCommand(command.c_str(), &output, &errors, - &retVal, tempDir.c_str(), 0 /*m_TimeOut*/); - + int res = this->CTest->RunCommand(command.c_str(), &output, &errors, + &retVal, tempDir.c_str(), 0 /*this->TimeOut*/); + ofs << " Output: " << output.c_str() << std::endl; ofs << " Errors: " << errors.c_str() << std::endl; if ( ! res ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem running coverage on file: " << it->c_str() << std::endl); - cmCTestLog(m_CTest, ERROR_MESSAGE, "Command produced error: " << errors << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Problem running coverage on file: " << it->c_str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Command produced error: " << errors << std::endl); error ++; continue; } if ( retVal != 0 ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Coverage command returned: " << retVal << " while processing: " << it->c_str() << std::endl); - cmCTestLog(m_CTest, ERROR_MESSAGE, "Command produced error: " << error << std::endl); - } - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, - "--------------------------------------------------------------" << std::endl + cmCTestLog(this->CTest, ERROR_MESSAGE, "Coverage command returned: " + << retVal << " while processing: " << it->c_str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Command produced error: " << error << std::endl); + } + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "--------------------------------------------------------------" + << std::endl << output << std::endl - << "--------------------------------------------------------------" << std::endl); + << "--------------------------------------------------------------" + << std::endl); std::vector lines; std::vector::iterator line; - - + + // Globals for storing current source file and current gcov file; cmSystemTools::Split(output.c_str(), lines); for ( line = lines.begin(); line != lines.end(); ++line) { std::string sourceFile; std::string gcovFile; - cmCTestLog(m_CTest, DEBUG, "Line: [" << line->c_str() << "]" << std::endl); + cmCTestLog(this->CTest, DEBUG, "Line: [" << line->c_str() << "]" + << std::endl); if ( line->size() == 0 ) { // Ignore empty line; probably style 2 @@ -312,13 +342,14 @@ { if ( gcovStyle != 1 ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown gcov output style" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style" + << std::endl); error ++; break; } gcovStyle = 1; } - + actualSourceFile = ""; sourceFile = st1re1.match(2); } @@ -328,13 +359,14 @@ { if ( gcovStyle != 1 ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown gcov output style" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style" + << std::endl); error ++; break; } gcovStyle = 1; } - + gcovFile = st1re2.match(1); } else if ( st2re1.find(line->c_str() ) ) @@ -343,13 +375,14 @@ { if ( gcovStyle != 2 ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown gcov output style" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style" + << std::endl); error ++; break; } gcovStyle = 2; } - + actualSourceFile = ""; sourceFile = st2re1.match(1); } @@ -359,7 +392,8 @@ { if ( gcovStyle != 2 ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown gcov output style" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style" + << std::endl); error ++; break; } @@ -372,13 +406,14 @@ { if ( gcovStyle != 2 ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown gcov output style" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style" + << std::endl); error ++; break; } gcovStyle = 2; } - + gcovFile = st2re3.match(2); } else if ( st2re4.find(line->c_str() ) ) @@ -387,14 +422,16 @@ { if ( gcovStyle != 2 ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown gcov output style" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style" + << std::endl); error ++; break; } gcovStyle = 2; } - - cmCTestLog(m_CTest, WARNING, "Warning: " << st2re4.match(1) << " had unexpected EOF" << std::endl); + + cmCTestLog(this->CTest, WARNING, "Warning: " << st2re4.match(1) + << " had unexpected EOF" << std::endl); } else if ( st2re5.find(line->c_str() ) ) { @@ -402,14 +439,16 @@ { if ( gcovStyle != 2 ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown gcov output style" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style" + << std::endl); error ++; break; } gcovStyle = 2; } - - cmCTestLog(m_CTest, WARNING, "Warning: Cannot open file: " << st2re5.match(1) << std::endl); + + cmCTestLog(this->CTest, WARNING, "Warning: Cannot open file: " + << st2re5.match(1) << std::endl); } else if ( st2re6.find(line->c_str() ) ) { @@ -417,30 +456,34 @@ { if ( gcovStyle != 2 ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown gcov output style" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style" + << std::endl); error ++; break; } gcovStyle = 2; } - - cmCTestLog(m_CTest, WARNING, "Warning: File: " << st2re6.match(1) + + cmCTestLog(this->CTest, WARNING, "Warning: File: " << st2re6.match(1) << " is newer than " << st2re6.match(2) << std::endl); } else { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown line: [" << line->c_str() << "]" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Unknown line: [" << line->c_str() << "]" << std::endl); error ++; //abort(); } if ( !gcovFile.empty() && actualSourceFile.size() ) { singleFileCoverageVector* vec = &totalCoverage[actualSourceFile]; - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " in file: " << gcovFile << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " in file: " + << gcovFile << std::endl); std::ifstream ifile(gcovFile.c_str()); if ( ! ifile ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot open file: " << gcovFile << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: " + << gcovFile << std::endl); } else { @@ -449,30 +492,33 @@ while ( cmSystemTools::GetLineFromStream(ifile, nl) ) { cnt ++; - + //TODO: Handle gcov 3.0 non-coverage lines - + // Skip empty lines if ( !nl.size() ) { continue; } - + // Skip unused lines if ( nl.size() < 12 ) { continue; } - // Read the coverage count from the beginning of the gcov output line + // Read the coverage count from the beginning of the gcov output + // line std::string prefix = nl.substr(0, 12); int cov = atoi(prefix.c_str()); - // Read the line number starting at the 10th character of the gcov output line + // Read the line number starting at the 10th character of the gcov + // output line std::string lineNumber = nl.substr(10, 5); int lineIdx = atoi(lineNumber.c_str())-1; if ( lineIdx >= 0 ) { - while ( vec->size() <= static_cast(lineIdx) ) + while ( vec->size() <= + static_cast(lineIdx) ) { vec->push_back(-1); } @@ -499,28 +545,39 @@ sourceFile.substr(0, sourceDir.size()) == sourceDir && sourceFile[sourceDir.size()] == '/' ) { - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " produced s: " << sourceFile.c_str() << std::endl); - ofs << " produced in source dir: " << sourceFile.c_str() << std::endl; - actualSourceFile = cmSystemTools::CollapseFullPath(sourceFile.c_str()); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " produced s: " + << sourceFile.c_str() << std::endl); + ofs << " produced in source dir: " << sourceFile.c_str() + << std::endl; + actualSourceFile + = cmSystemTools::CollapseFullPath(sourceFile.c_str()); } // Binary dir? if ( sourceFile.size() > binaryDir.size() && sourceFile.substr(0, binaryDir.size()) == binaryDir && sourceFile[binaryDir.size()] == '/' ) { - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " produced b: " << sourceFile.c_str() << std::endl); - ofs << " produced in binary dir: " << sourceFile.c_str() << std::endl; - actualSourceFile = cmSystemTools::CollapseFullPath(sourceFile.c_str()); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " produced b: " + << sourceFile.c_str() << std::endl); + ofs << " produced in binary dir: " << sourceFile.c_str() + << std::endl; + actualSourceFile + = cmSystemTools::CollapseFullPath(sourceFile.c_str()); } if ( actualSourceFile.empty() ) { if ( missingFiles.find(actualSourceFile) == missingFiles.end() ) { - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Something went wrong" << std::endl); - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "File: [" << sourceFile.c_str() << "]" << std::endl); - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "s: [" << sourceFile.substr(0, sourceDir.size()) << "]" << std::endl); - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "b: [" << sourceFile.substr(0, binaryDir.size()) << "]" << std::endl); - ofs << " Something went wrong. Cannot find: " << sourceFile.c_str() + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "Something went wrong" << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "File: [" + << sourceFile.c_str() << "]" << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "s: [" + << sourceFile.substr(0, sourceDir.size()) << "]" << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "b: [" + << sourceFile.substr(0, binaryDir.size()) << "]" << std::endl); + ofs << " Something went wrong. Cannot find: " + << sourceFile.c_str() << " in source dir: " << sourceDir.c_str() << " or binary dir: " << binaryDir.c_str() << std::endl; missingFiles.insert(actualSourceFile); @@ -531,26 +588,29 @@ file_count ++; if ( file_count % 50 == 0 ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, " processed: " << file_count << " out of " << files.size() << std::endl); - cmCTestLog(m_CTest, HANDLER_OUTPUT, " "); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " processed: " << file_count + << " out of " << files.size() << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " "); } } - + cmGeneratedFileStream covSumFile; cmGeneratedFileStream covLogFile; if (!this->StartResultingXML("Coverage", covSumFile)) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot open coverage summary file." << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Cannot open coverage summary file." << std::endl); return -1; } - m_CTest->StartXML(covSumFile); + this->CTest->StartXML(covSumFile); // Produce output xml files covSumFile << "" << std::endl - << "\t" << coverage_start_time << "" << std::endl; + << "\t" << coverage_start_time << "" + << std::endl; int logFileCount = 0; if ( !this->StartCoverageLogFile(covLogFile, logFileCount) ) { @@ -562,9 +622,10 @@ long total_untested = 0; //std::string fullSourceDir = sourceDir + "/"; //std::string fullBinaryDir = binaryDir + "/"; - cmCTestLog(m_CTest, HANDLER_OUTPUT, std::endl); - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Acumulating results (each . represents one file):" << std::endl); - cmCTestLog(m_CTest, HANDLER_OUTPUT, " "); + cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, + " Acumulating results (each . represents one file):" << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " "); std::vector errorsWhileAccumulating; @@ -573,13 +634,14 @@ fileIterator != totalCoverage.end(); ++fileIterator ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, "." << std::flush); + cmCTestLog(this->CTest, HANDLER_OUTPUT, "." << std::flush); file_count ++; if ( file_count % 50 == 0 ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, " processed: " << file_count << " out of " + cmCTestLog(this->CTest, HANDLER_OUTPUT, " processed: " << file_count + << " out of " << totalCoverage.size() << std::endl); - cmCTestLog(m_CTest, HANDLER_OUTPUT, " "); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " "); } if ( cnt % 100 == 0 ) { @@ -591,15 +653,19 @@ } } const std::string fullFileName = fileIterator->first; - const std::string fileName = cmSystemTools::GetFilenameName(fullFileName.c_str()); - std::string fullFilePath = cmSystemTools::GetFilenamePath(fullFileName.c_str()); - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Process file: " << fullFileName << std::endl); + const std::string fileName + = cmSystemTools::GetFilenameName(fullFileName.c_str()); + std::string fullFilePath + = cmSystemTools::GetFilenamePath(fullFileName.c_str()); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Process file: " + << fullFileName << std::endl); cmSystemTools::ConvertToUnixSlashes(fullFilePath); if ( !cmSystemTools::FileExists(fullFileName.c_str()) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot find file: " << fullFileName.c_str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find file: " + << fullFileName.c_str() << std::endl); continue; } @@ -608,7 +674,8 @@ sourceDir.c_str(), binaryDir.c_str()); if ( !shouldIDoCoverage ) { - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, ".NoDartCoverage found, so skip coverage check for: " + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + ".NoDartCoverage found, so skip coverage check for: " << fullFileName.c_str() << std::endl); continue; @@ -616,8 +683,9 @@ const singleFileCoverageVector& fcov = fileIterator->second; covLogFile << "\tMakeXMLSafe(fileName.c_str()) - << "\" FullPath=\"" << m_CTest->MakeXMLSafe(m_CTest->GetShortPathToFile( + << this->CTest->MakeXMLSafe(fileName.c_str()) + << "\" FullPath=\"" << this->CTest->MakeXMLSafe( + this->CTest->GetShortPathToFile( fileIterator->first.c_str())) << "\">" << std::endl << "\t\t" << std::endl; @@ -641,13 +709,15 @@ if ( !cmSystemTools::GetLineFromStream(ifs, line) ) { cmOStringStream ostr; - ostr << "Problem reading source file: " << fullFileName.c_str() << " line:" << cc; + ostr << "Problem reading source file: " << fullFileName.c_str() + << " line:" << cc; errorsWhileAccumulating.push_back(ostr.str()); error ++; break; } - covLogFile << "\t\t" - << m_CTest->MakeXMLSafe(line.c_str()) << "" << std::endl; + covLogFile << "\t\t" + << this->CTest->MakeXMLSafe(line.c_str()) << "" << std::endl; if ( fcov[cc] == 0 ) { untested ++; @@ -676,9 +746,9 @@ total_untested += untested; covLogFile << "\t\t" << std::endl << "\t" << std::endl; - covSumFile << "\tMakeXMLSafe(fileName) - << "\" FullPath=\"" << m_CTest->MakeXMLSafe( - m_CTest->GetShortPathToFile(fullFileName.c_str())) + covSumFile << "\tCTest->MakeXMLSafe(fileName) + << "\" FullPath=\"" << this->CTest->MakeXMLSafe( + this->CTest->GetShortPathToFile(fullFileName.c_str())) << "\" Covered=\"" << (cmet>0?"true":"false") << "\">\n" << "\t\t" << tested << "\n" << "\t\t" << untested << "\n" @@ -697,14 +767,16 @@ if ( errorsWhileAccumulating.size() > 0 ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, std::endl); - cmCTestLog(m_CTest, ERROR_MESSAGE, "Error(s) while acumulating results:" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Error(s) while acumulating results:" << std::endl); std::vector::iterator erIt; for ( erIt = errorsWhileAccumulating.begin(); erIt != errorsWhileAccumulating.end(); ++ erIt ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " " << erIt->c_str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + " " << erIt->c_str() << std::endl); } } @@ -716,7 +788,7 @@ percent_coverage = 0; } - std::string end_time = m_CTest->CurrentTime(); + std::string end_time = this->CTest->CurrentTime(); covSumFile << "\t" << total_tested << "\n" << "\t" << total_untested << "\n" @@ -726,16 +798,17 @@ covSumFile.precision(2); covSumFile << (percent_coverage)<< "\n" << "\t" << end_time << "\n"; - covSumFile << "" << + covSumFile << "" << static_cast((cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0 << "" << "" << std::endl; - m_CTest->EndXML(covSumFile); + this->CTest->EndXML(covSumFile); - cmCTestLog(m_CTest, HANDLER_OUTPUT, "\tCovered LOC: " << total_tested << std::endl + cmCTestLog(this->CTest, HANDLER_OUTPUT, "\tCovered LOC: " + << total_tested << std::endl << "\tNot covered LOC: " << total_untested << std::endl << "\tTotal LOC: " << total_lines << std::endl - << "\tPercentage Coverage: " + << "\tPercentage Coverage: " << std::setiosflags(std::ios::fixed) << std::setprecision(2) << (percent_coverage) << "%" << std::endl); @@ -743,7 +816,7 @@ ofs << "\tCovered LOC: " << total_tested << std::endl << "\tNot covered LOC: " << total_untested << std::endl << "\tTotal LOC: " << total_lines << std::endl - << "\tPercentage Coverage: " + << "\tPercentage Coverage: " << std::setiosflags(std::ios::fixed) << std::setprecision(2) << (percent_coverage) << "%" << std::endl; @@ -760,14 +833,16 @@ //---------------------------------------------------------------------- void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile *mf) { - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " Add coverage exclude regular expressions." << std::endl); - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_COVERAGE_EXCLUDE", - m_CustomCoverageExclude); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " Add coverage exclude regular expressions." << std::endl); + cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_COVERAGE_EXCLUDE", + this->CustomCoverageExclude); std::vector::iterator it; - for ( it = m_CustomCoverageExclude.begin(); - it != m_CustomCoverageExclude.end(); + for ( it = this->CustomCoverageExclude.begin(); + it != this->CustomCoverageExclude.end(); ++ it ) { - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " Add coverage exclude: " << it->c_str() << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Add coverage exclude: " + << it->c_str() << std::endl); } } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestCoverageHandler.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestCoverageHandler.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestCoverageHandler.h 2005-08-12 02:02:20.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestCoverageHandler.h 2006-03-11 04:03:09.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestCoverageHandler.h,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:20 $ - Version: $Revision: 1.10.2.1 $ + Date: $Date: 2006/03/10 20:03:09 $ + Version: $Revision: 1.13 $ Copyright (c) 2002 Kitware, Inc. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -39,16 +39,16 @@ * The main entry point for this class */ int ProcessHandler(); - + cmCTestCoverageHandler(); - + virtual void Initialize(); /** * This method is called when reading CTest custom file */ void PopulateCustomVectors(cmMakefile *mf); - + private: bool ShouldIDoCoverage(const char* file, const char* srcDir, const char* binDir); @@ -59,48 +59,48 @@ { cmCTestCoverage() { - m_AbsolutePath = ""; - m_FullPath = ""; - m_Covered = false; - m_Tested = 0; - m_UnTested = 0; - m_Lines.clear(); - m_Show = false; + this->AbsolutePath = ""; + this->FullPath = ""; + this->Covered = false; + this->Tested = 0; + this->UnTested = 0; + this->Lines.clear(); + this->Show = false; } cmCTestCoverage(const cmCTestCoverage& rhs) : - m_AbsolutePath(rhs.m_AbsolutePath), - m_FullPath(rhs.m_FullPath), - m_Covered(rhs.m_Covered), - m_Tested(rhs.m_Tested), - m_UnTested(rhs.m_UnTested), - m_Lines(rhs.m_Lines), - m_Show(rhs.m_Show) + AbsolutePath(rhs.AbsolutePath), + FullPath(rhs.FullPath), + Covered(rhs.Covered), + Tested(rhs.Tested), + UnTested(rhs.UnTested), + Lines(rhs.Lines), + Show(rhs.Show) { } cmCTestCoverage& operator=(const cmCTestCoverage& rhs) { - m_AbsolutePath = rhs.m_AbsolutePath; - m_FullPath = rhs.m_FullPath; - m_Covered = rhs.m_Covered; - m_Tested = rhs.m_Tested; - m_UnTested = rhs.m_UnTested; - m_Lines = rhs.m_Lines; - m_Show = rhs.m_Show; + this->AbsolutePath = rhs.AbsolutePath; + this->FullPath = rhs.FullPath; + this->Covered = rhs.Covered; + this->Tested = rhs.Tested; + this->UnTested = rhs.UnTested; + this->Lines = rhs.Lines; + this->Show = rhs.Show; return *this; } - std::string m_AbsolutePath; - std::string m_FullPath; - bool m_Covered; - int m_Tested; - int m_UnTested; - std::vector m_Lines; - bool m_Show; + std::string AbsolutePath; + std::string FullPath; + bool Covered; + int Tested; + int UnTested; + std::vector Lines; + bool Show; }; - std::vector m_CustomCoverageExclude; - std::vector m_CustomCoverageExcludeRegex; + std::vector CustomCoverageExclude; + std::vector CustomCoverageExcludeRegex; - typedef std::map tm_CoverageMap; + typedef std::map CoverageMap; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx 2005-08-12 02:02:20.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx 2005-07-12 22:40:14.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestEmptyBinaryDirectoryCommand.cxx,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:20 $ - Version: $Revision: 1.2.2.1 $ + Date: $Date: 2005/07/12 14:40:14 $ + Version: $Revision: 1.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h 2005-01-27 23:11:04.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h 2006-03-11 04:03:09.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestEmptyBinaryDirectoryCommand.h,v $ Language: C++ - Date: $Date: 2005/01/27 15:11:04 $ - Version: $Revision: 1.1 $ + Date: $Date: 2006/03/10 20:03:09 $ + Version: $Revision: 1.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -30,15 +30,16 @@ public: cmCTestEmptyBinaryDirectoryCommand() {} - + /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { - cmCTestEmptyBinaryDirectoryCommand* ni = new cmCTestEmptyBinaryDirectoryCommand; - ni->m_CTest = this->m_CTest; - ni->m_CTestScriptHandler = this->m_CTestScriptHandler; + cmCTestEmptyBinaryDirectoryCommand* ni + = new cmCTestEmptyBinaryDirectoryCommand; + ni->CTest = this->CTest; + ni->CTestScriptHandler = this->CTestScriptHandler; return ni; } @@ -56,11 +57,11 @@ /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { return "empties the binary directory"; } - + /** * More documentation. */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestGenericHandler.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestGenericHandler.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestGenericHandler.cxx 2005-08-30 04:19:32.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestGenericHandler.cxx 2006-03-11 04:03:09.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestGenericHandler.cxx,v $ Language: C++ - Date: $Date: 2005/08/29 20:19:32 $ - Version: $Revision: 1.6.2.2 $ + Date: $Date: 2006/03/10 20:03:09 $ + Version: $Revision: 1.11 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -22,9 +22,9 @@ //---------------------------------------------------------------------- cmCTestGenericHandler::cmCTestGenericHandler() { - m_HandlerVerbose = false; - m_CTest = 0; - m_SubmitIndex = 0; + this->HandlerVerbose = false; + this->CTest = 0; + this->SubmitIndex = 0; } //---------------------------------------------------------------------- @@ -41,30 +41,30 @@ } if ( !value ) { - cmCTestGenericHandler::t_StringToString::iterator remit - = m_Options.find(op); - if ( remit != m_Options.end() ) + cmCTestGenericHandler::t_StringToString::iterator remit + = this->Options.find(op); + if ( remit != this->Options.end() ) { - m_Options.erase(remit); + this->Options.erase(remit); } return; } - m_Options[op] = value; + this->Options[op] = value; } //---------------------------------------------------------------------- void cmCTestGenericHandler::Initialize() { - m_Options.clear(); + this->Options.clear(); } //---------------------------------------------------------------------- const char* cmCTestGenericHandler::GetOption(const char* op) { - cmCTestGenericHandler::t_StringToString::iterator remit - = m_Options.find(op); - if ( remit == m_Options.end() ) + cmCTestGenericHandler::t_StringToString::iterator remit + = this->Options.find(op); + if ( remit == this->Options.end() ) { return 0; } @@ -72,51 +72,60 @@ } //---------------------------------------------------------------------- -bool cmCTestGenericHandler::StartResultingXML(const char* name, cmGeneratedFileStream& xofs) +bool cmCTestGenericHandler::StartResultingXML(const char* name, + cmGeneratedFileStream& xofs) { if ( !name ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create resulting XML file without providing the name" << std::endl;); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Cannot create resulting XML file without providing the name" + << std::endl;); return false; } cmOStringStream ostr; ostr << name; - if ( m_SubmitIndex > 0 ) + if ( this->SubmitIndex > 0 ) { - ostr << "_" << m_SubmitIndex; + ostr << "_" << this->SubmitIndex; } ostr << ".xml"; - if( !m_CTest->OpenOutputFile(m_CTest->GetCurrentTag(), ostr.str().c_str(), xofs, true) ) + if( !this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(), + ostr.str().c_str(), xofs, true) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create resulting XML file: " << ostr.str().c_str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Cannot create resulting XML file: " << ostr.str().c_str() + << std::endl); return false; } - m_CTest->AddSubmitFile(ostr.str().c_str()); + this->CTest->AddSubmitFile(ostr.str().c_str()); return true; } //---------------------------------------------------------------------- -bool cmCTestGenericHandler::StartLogFile(const char* name, cmGeneratedFileStream& xofs) +bool cmCTestGenericHandler::StartLogFile(const char* name, + cmGeneratedFileStream& xofs) { if ( !name ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create log file without providing the name" << std::endl;); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Cannot create log file without providing the name" << std::endl;); return false; } cmOStringStream ostr; ostr << "Last" << name; - if ( m_SubmitIndex > 0 ) + if ( this->SubmitIndex > 0 ) { - ostr << "_" << m_SubmitIndex; + ostr << "_" << this->SubmitIndex; } - if ( !m_CTest->GetCurrentTag().empty() ) + if ( !this->CTest->GetCurrentTag().empty() ) { - ostr << "_" << m_CTest->GetCurrentTag(); + ostr << "_" << this->CTest->GetCurrentTag(); } ostr << ".log"; - if( !m_CTest->OpenOutputFile("Temporary", ostr.str().c_str(), xofs) ) + if( !this->CTest->OpenOutputFile("Temporary", ostr.str().c_str(), xofs) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create log file: " << ostr.str().c_str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create log file: " + << ostr.str().c_str() << std::endl); return false; } return true; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestGenericHandler.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestGenericHandler.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestGenericHandler.h 2005-06-24 01:04:17.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestGenericHandler.h 2006-03-11 04:03:09.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestGenericHandler.h,v $ Language: C++ - Date: $Date: 2005/06/23 17:04:17 $ - Version: $Revision: 1.8 $ + Date: $Date: 2006/03/10 20:03:09 $ + Version: $Revision: 1.10 $ Copyright (c) 2002 Kitware, Inc. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -36,7 +36,7 @@ /** * If verbose then more informaiton is printed out */ - void SetVerbose(bool val) { m_HandlerVerbose = val; } + void SetVerbose(bool val) { this->HandlerVerbose = val; } /** * Populate internals from CTest custom scripts @@ -64,8 +64,8 @@ /** * Set the CTest instance */ - void SetCTestInstance(cmCTest* ctest) { m_CTest = ctest; } - cmCTest* GetCTestInstance() { return m_CTest; } + void SetCTestInstance(cmCTest* ctest) { this->CTest = ctest; } + cmCTest* GetCTestInstance() { return this->CTest; } /** * Construct handler @@ -80,22 +80,22 @@ void SetCommand(cmCTestCommand* command) { - m_Command = command; + this->Command = command; } - void SetSubmitIndex(int idx) { m_SubmitIndex = idx; } - int GetSubmitIndex() { return m_SubmitIndex; } + void SetSubmitIndex(int idx) { this->SubmitIndex = idx; } + int GetSubmitIndex() { return this->SubmitIndex; } protected: bool StartResultingXML(const char* name, cmGeneratedFileStream& xofs); bool StartLogFile(const char* name, cmGeneratedFileStream& xofs); - - bool m_HandlerVerbose; - cmCTest *m_CTest; - t_StringToString m_Options; - cmCTestCommand* m_Command; - int m_SubmitIndex; + bool HandlerVerbose; + cmCTest *CTest; + t_StringToString Options; + + cmCTestCommand* Command; + int SubmitIndex; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestHandlerCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestHandlerCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestHandlerCommand.cxx 2005-06-24 01:04:17.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestHandlerCommand.cxx 2006-03-16 00:02:08.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestHandlerCommand.cxx,v $ Language: C++ - Date: $Date: 2005/06/23 17:04:17 $ - Version: $Revision: 1.1 $ + Date: $Date: 2006/03/15 16:02:08 $ + Version: $Revision: 1.5 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -23,22 +23,23 @@ { const size_t INIT_SIZE = 100; size_t cc; - m_Arguments.reserve(INIT_SIZE); + this->Arguments.reserve(INIT_SIZE); for ( cc = 0; cc < INIT_SIZE; ++ cc ) { - m_Arguments[cc] = 0; + this->Arguments.push_back(0); } - m_Arguments[ct_RETURN_VALUE] = "RETURN_VALUE"; - m_Arguments[ct_SOURCE] = "SOURCE"; - m_Arguments[ct_BUILD] = "BUILD"; - m_Arguments[ct_SUBMIT_INDEX] = "SUBMIT_INDEX"; - m_Last = ct_LAST; + this->Arguments[ct_RETURN_VALUE] = "RETURN_VALUE"; + this->Arguments[ct_SOURCE] = "SOURCE"; + this->Arguments[ct_BUILD] = "BUILD"; + this->Arguments[ct_SUBMIT_INDEX] = "SUBMIT_INDEX"; + this->Last = ct_LAST; } bool cmCTestHandlerCommand::InitialPass( std::vector const& args) { - if ( !this->ProcessArguments(args, m_Last, &*m_Arguments.begin(), m_Values) ) + if ( !this->ProcessArguments(args, this->Last, &*this->Arguments.begin(), + this->Values) ) { return false; } @@ -50,39 +51,46 @@ return false; } - if ( m_Values[ct_BUILD] ) + if ( this->Values[ct_BUILD] ) { - m_CTest->SetCTestConfiguration("BuildDirectory", m_Values[ct_BUILD]); + this->CTest->SetCTestConfiguration("BuildDirectory", + this->Values[ct_BUILD]); } - if ( m_Values[ct_SUBMIT_INDEX] ) + if ( this->Values[ct_SUBMIT_INDEX] ) { - if ( m_CTest->GetDartVersion() <= 1 ) + if ( this->CTest->GetDartVersion() <= 1 ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Dart before version 2.0 does not support collecting submissions." << std::endl - << "Please upgrade the server to Dart 2 or higher, or do not use SUBMIT_INDEX." << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Dart before version 2.0 does not support collecting submissions." + << std::endl + << "Please upgrade the server to Dart 2 or higher, or do not use " + "SUBMIT_INDEX." << std::endl); } else { - handler->SetSubmitIndex(atoi(m_Values[ct_SUBMIT_INDEX])); + handler->SetSubmitIndex(atoi(this->Values[ct_SUBMIT_INDEX])); } } std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(m_CTest->GetCTestConfiguration("BuildDirectory").c_str()); + cmSystemTools::ChangeDirectory( + this->CTest->GetCTestConfiguration("BuildDirectory").c_str()); int res = handler->ProcessHandler(); - if ( m_Values[ct_RETURN_VALUE] && *m_Values[ct_RETURN_VALUE]) + if ( this->Values[ct_RETURN_VALUE] && *this->Values[ct_RETURN_VALUE]) { cmOStringStream str; str << res; - m_Makefile->AddDefinition(m_Values[ct_RETURN_VALUE], str.str().c_str()); + this->Makefile->AddDefinition( + this->Values[ct_RETURN_VALUE], str.str().c_str()); } cmSystemTools::ChangeDirectory(current_dir.c_str()); return true; } -bool cmCTestHandlerCommand::ProcessArguments(std::vector const& args, - int last, const char** strings, std::vector& values) +bool cmCTestHandlerCommand::ProcessArguments( + std::vector const& args, int last, const char** strings, + std::vector& values) { int state = 0; int cc; @@ -97,8 +105,8 @@ if ( state > 0 && state < last ) { values[state] = args[i].c_str(); -#undef cerr - cmCTestLog(m_CTest, DEBUG, "Set " << strings[state] << " to " << args[i].c_str() << std::endl); + cmCTestLog(this->CTest, DEBUG, "Set " << strings[state] << " to " + << args[i].c_str() << std::endl); state = 0; } else @@ -112,7 +120,8 @@ if ( values[state] ) { cmOStringStream ostr; - ostr << "called with incorrect number of arguments. " << strings[state] << " specified twice."; + ostr << "called with incorrect number of arguments. " + << strings[state] << " specified twice."; this->SetError(ostr.str().c_str()); return false; } @@ -123,7 +132,9 @@ if ( !found ) { cmOStringStream str; - str << "called with incorrect number of arguments. Extra argument is: " << args[i].c_str() << "."; + str + << "called with incorrect number of arguments. Extra argument is: " + << args[i].c_str() << "."; this->SetError(str.str().c_str()); return false; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestHandlerCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestHandlerCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestHandlerCommand.h 2005-06-24 01:04:17.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestHandlerCommand.h 2006-03-11 04:03:09.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestHandlerCommand.h,v $ Language: C++ - Date: $Date: 2005/06/23 17:04:17 $ - Version: $Revision: 1.1 $ + Date: $Date: 2006/03/10 20:03:09 $ + Version: $Revision: 1.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -54,10 +54,10 @@ bool ProcessArguments(std::vector const& args, int last, const char** strings, std::vector& values); - std::string m_ReturnVariable; - std::vector m_Arguments; - std::vector m_Values; - size_t m_Last; + std::string ReturnVariable; + std::vector Arguments; + std::vector Values; + size_t Last; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestMemCheckCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestMemCheckCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestMemCheckCommand.cxx 2005-06-24 01:04:17.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestMemCheckCommand.cxx 2006-03-16 00:02:08.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestMemCheckCommand.cxx,v $ Language: C++ - Date: $Date: 2005/06/23 17:04:17 $ - Version: $Revision: 1.3 $ + Date: $Date: 2006/03/15 16:02:08 $ + Version: $Revision: 1.5 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -22,13 +22,14 @@ cmCTestGenericHandler* cmCTestMemCheckCommand::InitializeActualHandler() { - cmCTestGenericHandler* handler = m_CTest->GetInitializedHandler("memcheck"); + cmCTestGenericHandler* handler + = this->CTest->GetInitializedHandler("memcheck"); - m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, "MemoryCheckCommand", "CTEST_MEMORYCHECK_COMMAND"); - m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, "MemoryCheckCommandOptions", "CTEST_MEMORYCHECK_COMMAND_OPTIONS"); - m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, "MemoryCheckSuppressionFile", "CTEST_MEMORYCHECK_SUPPRESSIONS_FILE"); return handler; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestMemCheckCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestMemCheckCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestMemCheckCommand.h 2005-06-24 01:04:17.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestMemCheckCommand.h 2006-03-11 04:03:09.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestMemCheckCommand.h,v $ Language: C++ - Date: $Date: 2005/06/23 17:04:17 $ - Version: $Revision: 1.2 $ + Date: $Date: 2006/03/10 20:03:09 $ + Version: $Revision: 1.4 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -31,15 +31,15 @@ public: cmCTestMemCheckCommand() {} - + /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { cmCTestMemCheckCommand* ni = new cmCTestMemCheckCommand; - ni->m_CTest = this->m_CTest; - ni->m_CTestScriptHandler = this->m_CTestScriptHandler; + ni->CTest = this->CTest; + ni->CTestScriptHandler = this->CTestScriptHandler; return ni; } @@ -51,11 +51,11 @@ /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { return "Tests the repository."; } - + /** * More documentation. */ @@ -64,8 +64,8 @@ return " CTEST_MEMCHECK([BUILD build_dir] [RETURN_VALUE res])\n" "Performs a memory checking of tests in the given build directory and " - "stores results in MemCheck.xml. The second argument is a variable that " - "will hold value."; + "stores results in MemCheck.xml. The second argument is a variable " + "that will hold value."; } cmTypeMacro(cmCTestMemCheckCommand, cmCTestTestCommand); diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestMemCheckHandler.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestMemCheckHandler.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestMemCheckHandler.cxx 2005-06-18 01:04:56.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestMemCheckHandler.cxx 2006-03-17 00:29:12.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestMemCheckHandler.cxx,v $ Language: C++ - Date: $Date: 2005/06/17 17:04:56 $ - Version: $Revision: 1.7 $ + Date: $Date: 2006/03/16 16:29:12 $ + Version: $Revision: 1.10 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -25,7 +25,7 @@ #include #include "cmMakefile.h" -#include +#include #include #include @@ -87,22 +87,24 @@ //---------------------------------------------------------------------- cmCTestMemCheckHandler::cmCTestMemCheckHandler() { - m_MemCheck = true; + this->MemCheck = true; + this->CustomMaximumPassedTestOutputSize = 0; + this->CustomMaximumFailedTestOutputSize = 0; } //---------------------------------------------------------------------- void cmCTestMemCheckHandler::Initialize() { this->Superclass::Initialize(); - m_MemoryTester = ""; - m_MemoryTesterOptionsParsed.clear(); - m_MemoryTesterOptions = ""; - m_MemoryTesterStyle = UNKNOWN; - m_MemoryTesterOutputFile = ""; + this->MemoryTester = ""; + this->MemoryTesterOptionsParsed.clear(); + this->MemoryTesterOptions = ""; + this->MemoryTesterStyle = UNKNOWN; + this->MemoryTesterOutputFile = ""; int cc; for ( cc = 0; cc < NO_MEMORY_FAULT; cc ++ ) { - m_MemoryTesterGlobalResults[cc] = 0; + this->MemoryTesterGlobalResults[cc] = 0; } } @@ -115,9 +117,10 @@ return 0; } - if ( !this->ExecuteCommands(m_CustomPreMemCheck) ) + if ( !this->ExecuteCommands(this->CustomPreMemCheck) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem executing pre-memcheck command(s)." << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Problem executing pre-memcheck command(s)." << std::endl); return 0; } return 1; @@ -126,55 +129,59 @@ //---------------------------------------------------------------------- int cmCTestMemCheckHandler::PostProcessHandler() { - if ( !this->ExecuteCommands(m_CustomPostMemCheck) ) + if ( !this->ExecuteCommands(this->CustomPostMemCheck) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem executing post-memcheck command(s)." << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Problem executing post-memcheck command(s)." << std::endl); return 0; } return 1; } //---------------------------------------------------------------------- -void cmCTestMemCheckHandler::GenerateTestCommand(std::vector& args) +void cmCTestMemCheckHandler::GenerateTestCommand( + std::vector& args) { std::vector::size_type pp; - args.push_back(m_MemoryTester.c_str()); + args.push_back(this->MemoryTester.c_str()); std::string memcheckcommand = ""; - memcheckcommand = m_MemoryTester; - for ( pp = 0; pp < m_MemoryTesterOptionsParsed.size(); pp ++ ) + memcheckcommand = this->MemoryTester; + for ( pp = 0; pp < this->MemoryTesterOptionsParsed.size(); pp ++ ) { - args.push_back(m_MemoryTesterOptionsParsed[pp].c_str()); + args.push_back(this->MemoryTesterOptionsParsed[pp].c_str()); memcheckcommand += " "; - memcheckcommand += cmSystemTools::EscapeSpaces(m_MemoryTesterOptionsParsed[pp].c_str()); + memcheckcommand += cmSystemTools::EscapeSpaces( + this->MemoryTesterOptionsParsed[pp].c_str()); } - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Memory check command: " << memcheckcommand << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Memory check command: " + << memcheckcommand << std::endl); } //---------------------------------------------------------------------- void cmCTestMemCheckHandler::PopulateCustomVectors(cmMakefile *mf) { this->cmCTestTestHandler::PopulateCustomVectors(mf); - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_PRE_MEMCHECK", - m_CustomPreMemCheck); - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_POST_MEMCHECK", - m_CustomPostMemCheck); - - cmCTest::PopulateCustomVector(mf, - "CTEST_CUSTOM_MEMCHECK_IGNORE", - m_CustomTestsIgnore); + cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_PRE_MEMCHECK", + this->CustomPreMemCheck); + cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_POST_MEMCHECK", + this->CustomPostMemCheck); + + cmCTest::PopulateCustomVector(mf, + "CTEST_CUSTOM_MEMCHECK_IGNORE", + this->CustomTestsIgnore); } //---------------------------------------------------------------------- void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os) { - if ( !m_CTest->GetProduceXML() ) + if ( !this->CTest->GetProduceXML() ) { return; } - m_CTest->StartXML(os); + this->CTest->StartXML(os); os << "MemoryTesterStyle ) { case cmCTestMemCheckHandler::VALGRIND: os << "Valgrind"; @@ -190,39 +197,43 @@ } os << "\">" << std::endl; - os << "\t" << m_StartTest << "\n" + os << "\t" << this->StartTest << "\n" << "\t\n"; - tm_TestResultsVector::size_type cc; - for ( cc = 0; cc < m_TestResults.size(); cc ++ ) + cmCTestMemCheckHandler::TestResultsVector::size_type cc; + for ( cc = 0; cc < this->TestResults.size(); cc ++ ) { - cmCTestTestResult *result = &m_TestResults[cc]; - std::string testPath = result->m_Path + "/" + result->m_Name; + cmCTestTestResult *result = &this->TestResults[cc]; + std::string testPath = result->Path + "/" + result->Name; os << "\t\t" << cmCTest::MakeXMLSafe( - m_CTest->GetShortPathToFile(testPath.c_str())) + this->CTest->GetShortPathToFile(testPath.c_str())) << "" << std::endl; } os << "\t\n"; - cmCTestLog(m_CTest, HANDLER_OUTPUT, "-- Processing memory checking output: "); - unsigned int total = m_TestResults.size(); + cmCTestLog(this->CTest, HANDLER_OUTPUT, + "-- Processing memory checking output: "); + unsigned int total = this->TestResults.size(); unsigned int step = total / 10; unsigned int current = 0; - for ( cc = 0; cc < m_TestResults.size(); cc ++ ) + for ( cc = 0; cc < this->TestResults.size(); cc ++ ) { - cmCTestTestResult *result = &m_TestResults[cc]; + cmCTestTestResult *result = &this->TestResults[cc]; std::string memcheckstr; int memcheckresults[cmCTestMemCheckHandler::NO_MEMORY_FAULT]; int kk; - bool res = this->ProcessMemCheckOutput(result->m_Output, memcheckstr, memcheckresults); - if ( res && result->m_Status == cmCTestMemCheckHandler::COMPLETED ) + bool res = this->ProcessMemCheckOutput(result->Output, memcheckstr, + memcheckresults); + if ( res && result->Status == cmCTestMemCheckHandler::COMPLETED ) { continue; } + this->CleanTestOutput(memcheckstr, + static_cast(this->CustomMaximumFailedTestOutputSize)); os << "\tm_Status == cmCTestMemCheckHandler::COMPLETED ) + if ( result->Status == cmCTestMemCheckHandler::COMPLETED ) { os << "passed"; } - else if ( result->m_Status == cmCTestMemCheckHandler::NOT_RUN ) + else if ( result->Status == cmCTestMemCheckHandler::NOT_RUN ) { os << "notrun"; } @@ -230,64 +241,68 @@ { os << "failed"; } - std::string testPath = result->m_Path + "/" + result->m_Name; + std::string testPath = result->Path + "/" + result->Name; os << "\">\n" - << "\t\t" << cmCTest::MakeXMLSafe(result->m_Name) << "\n" + << "\t\t" << cmCTest::MakeXMLSafe(result->Name) << "\n" << "\t\t" << cmCTest::MakeXMLSafe( - m_CTest->GetShortPathToFile(result->m_Path.c_str())) << "\n" + this->CTest->GetShortPathToFile(result->Path.c_str())) << "\n" << "\t\t" << cmCTest::MakeXMLSafe( - m_CTest->GetShortPathToFile(testPath.c_str())) << "\n" - << "\t\t" - << cmCTest::MakeXMLSafe(result->m_FullCommandLine) + this->CTest->GetShortPathToFile(testPath.c_str())) << "\n" + << "\t\t" + << cmCTest::MakeXMLSafe(result->FullCommandLine) << "\n" << "\t\t" << std::endl; for ( kk = 0; cmCTestMemCheckResultLongStrings[kk]; kk ++ ) { if ( memcheckresults[kk] ) { - os << "\t\t\t" - << memcheckresults[kk] + os << "\t\t\t" + << memcheckresults[kk] << "" << std::endl; } - m_MemoryTesterGlobalResults[kk] += memcheckresults[kk]; + this->MemoryTesterGlobalResults[kk] += memcheckresults[kk]; } - os + os << "\t\t\n" << "\t\n" << memcheckstr << std::endl << "\t\n" << "\t" << std::endl; if ( current < cc ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, "#" << std::flush); + cmCTestLog(this->CTest, HANDLER_OUTPUT, "#" << std::flush); current += step; } } - cmCTestLog(m_CTest, HANDLER_OUTPUT, std::endl); - cmCTestLog(m_CTest, HANDLER_OUTPUT, "Memory checking results:" << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, "Memory checking results:" + << std::endl); os << "\t" << std::endl; for ( cc = 0; cmCTestMemCheckResultStrings[cc]; cc ++ ) { - if ( m_MemoryTesterGlobalResults[cc] ) + if ( this->MemoryTesterGlobalResults[cc] ) { #ifdef cerr # undef cerr #endif std::cerr.width(35); #define cerr no_cerr - cmCTestLog(m_CTest, HANDLER_OUTPUT, cmCTestMemCheckResultLongStrings[cc] << " - " - << m_MemoryTesterGlobalResults[cc] << std::endl); - os << "\t\t" << std::endl; + cmCTestLog(this->CTest, HANDLER_OUTPUT, + cmCTestMemCheckResultLongStrings[cc] << " - " + << this->MemoryTesterGlobalResults[cc] << std::endl); + os << "\t\t" << std::endl; } } os << "\t" << std::endl; - os << "\t" << m_EndTest << "" << std::endl; - os << "" - << static_cast(m_ElapsedTestingTime/6)/10.0 + os << "\t" << this->EndTest << "" << std::endl; + os << "" + << static_cast(this->ElapsedTestingTime/6)/10.0 << "\n"; - + os << "" << std::endl; - m_CTest->EndXML(os); + this->CTest->EndXML(os); } @@ -296,96 +311,124 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() { // Setup the command - if ( cmSystemTools::FileExists(m_CTest->GetCTestConfiguration("MemoryCheckCommand").c_str()) ) - { - m_MemoryTester - = cmSystemTools::ConvertToOutputPath(m_CTest->GetCTestConfiguration("MemoryCheckCommand").c_str()); - } - else if ( cmSystemTools::FileExists(m_CTest->GetCTestConfiguration("PurifyCommand").c_str()) ) - { - m_MemoryTester - = cmSystemTools::ConvertToOutputPath(m_CTest->GetCTestConfiguration("PurifyCommand").c_str()); - } - else if ( cmSystemTools::FileExists(m_CTest->GetCTestConfiguration("ValgrindCommand").c_str()) ) + if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration( + "MemoryCheckCommand").c_str()) ) { - m_MemoryTester - = cmSystemTools::ConvertToOutputPath(m_CTest->GetCTestConfiguration("ValgrindCommand").c_str()); + this->MemoryTester + = cmSystemTools::ConvertToOutputPath(this->CTest->GetCTestConfiguration( + "MemoryCheckCommand").c_str()); + } + else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration( + "PurifyCommand").c_str()) ) + { + this->MemoryTester + = cmSystemTools::ConvertToOutputPath(this->CTest->GetCTestConfiguration( + "PurifyCommand").c_str()); + } + else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration( + "ValgrindCommand").c_str()) ) + { + this->MemoryTester + = cmSystemTools::ConvertToOutputPath(this->CTest->GetCTestConfiguration( + "ValgrindCommand").c_str()); } else { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Memory checker (MemoryCheckCommand) not set, or cannot find the specified program." + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Memory checker (MemoryCheckCommand) " + "not set, or cannot find the specified program." << std::endl); return false; } - if ( m_MemoryTester[0] == '\"' && m_MemoryTester[m_MemoryTester.size()-1] == '\"' ) + if ( this->MemoryTester[0] == '\"' && + this->MemoryTester[this->MemoryTester.size()-1] == '\"' ) { - m_MemoryTester = m_MemoryTester.substr(1, m_MemoryTester.size()-2); + this->MemoryTester + = this->MemoryTester.substr(1, this->MemoryTester.size()-2); } // Setup the options - if ( m_CTest->GetCTestConfiguration("MemoryCheckCommandOptions").size() ) + if ( this->CTest->GetCTestConfiguration( + "MemoryCheckCommandOptions").size() ) { - m_MemoryTesterOptions = m_CTest->GetCTestConfiguration("MemoryCheckCommandOptions"); + this->MemoryTesterOptions = this->CTest->GetCTestConfiguration( + "MemoryCheckCommandOptions"); } - else if ( m_CTest->GetCTestConfiguration("ValgrindCommandOptions").size() ) + else if ( this->CTest->GetCTestConfiguration( + "ValgrindCommandOptions").size() ) { - m_MemoryTesterOptions = m_CTest->GetCTestConfiguration("ValgrindCommandOptions"); + this->MemoryTesterOptions = this->CTest->GetCTestConfiguration( + "ValgrindCommandOptions"); } - m_MemoryTesterOutputFile = m_CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.log"; - m_MemoryTesterOutputFile = cmSystemTools::EscapeSpaces(m_MemoryTesterOutputFile.c_str()); + this->MemoryTesterOutputFile + = this->CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.log"; + this->MemoryTesterOutputFile + = cmSystemTools::EscapeSpaces(this->MemoryTesterOutputFile.c_str()); - if ( m_MemoryTester.find("valgrind") != std::string::npos ) + if ( this->MemoryTester.find("valgrind") != std::string::npos ) { - m_MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND; - if ( !m_MemoryTesterOptions.size() ) + this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND; + if ( !this->MemoryTesterOptions.size() ) { - m_MemoryTesterOptions = "-q --tool=memcheck --leak-check=yes --show-reachable=yes --workaround-gcc296-bugs=yes --num-callers=100"; + this->MemoryTesterOptions = "-q --tool=memcheck --leak-check=yes " + "--show-reachable=yes --workaround-gcc296-bugs=yes --num-callers=100"; } - if ( m_CTest->GetCTestConfiguration("MemoryCheckSuppressionFile").size() ) + if ( this->CTest->GetCTestConfiguration( + "MemoryCheckSuppressionFile").size() ) { - if ( !cmSystemTools::FileExists(m_CTest->GetCTestConfiguration("MemoryCheckSuppressionFile").c_str()) ) + if ( !cmSystemTools::FileExists(this->CTest->GetCTestConfiguration( + "MemoryCheckSuppressionFile").c_str()) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot find memory checker suppression file: " - << m_CTest->GetCTestConfiguration("MemoryCheckSuppressionFile").c_str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Cannot find memory checker suppression file: " + << this->CTest->GetCTestConfiguration( + "MemoryCheckSuppressionFile").c_str() << std::endl); return false; } - m_MemoryTesterOptions += " --suppressions=" + cmSystemTools::EscapeSpaces(m_CTest->GetCTestConfiguration("MemoryCheckSuppressionFile").c_str()) + ""; + this->MemoryTesterOptions += " --suppressions=" + + cmSystemTools::EscapeSpaces(this->CTest->GetCTestConfiguration( + "MemoryCheckSuppressionFile").c_str()) + ""; } } - else if ( m_MemoryTester.find("purify") != std::string::npos ) + else if ( this->MemoryTester.find("purify") != std::string::npos ) { - m_MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY; + this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY; #ifdef _WIN32 - m_MemoryTesterOptions += " /SAVETEXTDATA=" + m_MemoryTesterOutputFile; + this->MemoryTesterOptions += " /SAVETEXTDATA=" + + this->MemoryTesterOutputFile; #else - m_MemoryTesterOptions += " -log-file=" + m_MemoryTesterOutputFile; + this->MemoryTesterOptions += " -log-file=" + this->MemoryTesterOutputFile; #endif } - else if ( m_MemoryTester.find("boundschecker") != std::string::npos ) + else if ( this->MemoryTester.find("boundschecker") != std::string::npos ) { - m_MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER; - cmCTestLog(m_CTest, ERROR_MESSAGE, "Bounds checker not yet implemented" << std::endl); + this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER; + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Bounds checker not yet implemented" << std::endl); return false; } else { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Do not understand memory checker: " << m_MemoryTester.c_str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Do not understand memory checker: " << this->MemoryTester.c_str() + << std::endl); return false; } - m_MemoryTesterOptionsParsed = cmSystemTools::ParseArguments(m_MemoryTesterOptions.c_str()); + this->MemoryTesterOptionsParsed + = cmSystemTools::ParseArguments(this->MemoryTesterOptions.c_str()); std::vector::size_type cc; for ( cc = 0; cmCTestMemCheckResultStrings[cc]; cc ++ ) { - m_MemoryTesterGlobalResults[cc] = 0; + this->MemoryTesterGlobalResults[cc] = 0; } return true; } //---------------------------------------------------------------------- -bool cmCTestMemCheckHandler::ProcessMemCheckOutput(const std::string& str, +bool cmCTestMemCheckHandler::ProcessMemCheckOutput(const std::string& str, std::string& log, int* results) { std::string::size_type cc; @@ -394,15 +437,16 @@ results[cc] = 0; } - if ( m_MemoryTesterStyle == cmCTestMemCheckHandler::VALGRIND ) + if ( this->MemoryTesterStyle == cmCTestMemCheckHandler::VALGRIND ) { return this->ProcessMemCheckValgrindOutput(str, log, results); } - else if ( m_MemoryTesterStyle == cmCTestMemCheckHandler::PURIFY ) + else if ( this->MemoryTesterStyle == cmCTestMemCheckHandler::PURIFY ) { return this->ProcessMemCheckPurifyOutput(str, log, results); } - else if ( m_MemoryTesterStyle == cmCTestMemCheckHandler::BOUNDS_CHECKER ) + else if ( this->MemoryTesterStyle == + cmCTestMemCheckHandler::BOUNDS_CHECKER ) { log.append("\nMemory checking style used was: "); log.append("Bounds Checker"); @@ -420,21 +464,21 @@ //---------------------------------------------------------------------- bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput( - const std::string&, std::string& log, + const std::string&, std::string& log, int* results) { - if ( !cmSystemTools::FileExists(m_MemoryTesterOutputFile.c_str()) ) + if ( !cmSystemTools::FileExists(this->MemoryTesterOutputFile.c_str()) ) { - log = "Cannot find Purify output file: " + m_MemoryTesterOutputFile; - cmCTestLog(m_CTest, ERROR_MESSAGE, log.c_str() << std::endl); + log = "Cannot find Purify output file: " + this->MemoryTesterOutputFile; + cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl); return false; } - std::ifstream ifs(m_MemoryTesterOutputFile.c_str()); + std::ifstream ifs(this->MemoryTesterOutputFile.c_str()); if ( !ifs ) { - log = "Cannot read Purify output file: " + m_MemoryTesterOutputFile; - cmCTestLog(m_CTest, ERROR_MESSAGE, log.c_str() << std::endl); + log = "Cannot read Purify output file: " + this->MemoryTesterOutputFile; + cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl); return false; } @@ -462,8 +506,10 @@ } if ( cc == cmCTestMemCheckHandler::NO_MEMORY_FAULT ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown Purify memory fault: " << pfW.match(1) << std::endl); - ostr << "*** Unknown Purify memory fault: " << pfW.match(1) << std::endl; + cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown Purify memory fault: " + << pfW.match(1) << std::endl); + ostr << "*** Unknown Purify memory fault: " << pfW.match(1) + << std::endl; } } if ( failure != NO_MEMORY_FAULT ) @@ -485,12 +531,12 @@ //---------------------------------------------------------------------- bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput( - const std::string& str, std::string& log, + const std::string& str, std::string& log, int* results) { std::vector lines; cmSystemTools::Split(str.c_str(), lines); - + std::string::size_type cc; cmOStringStream ostr; @@ -517,34 +563,75 @@ " in loss record [0-9][0-9]* of [0-9]"); cmsys::RegularExpression vgUMC( "== .*Conditional jump or move depends on uninitialised value\\(s\\)"); - cmsys::RegularExpression vgUMR1("== .*Use of uninitialised value of size [0-9][0-9]*"); + cmsys::RegularExpression vgUMR1( + "== .*Use of uninitialised value of size [0-9][0-9]*"); cmsys::RegularExpression vgUMR2("== .*Invalid read of size [0-9][0-9]*"); cmsys::RegularExpression vgUMR3("== .*Jump to the invalid address "); - cmsys::RegularExpression vgUMR4( - "== .*Syscall param .* contains uninitialised or unaddressable byte\\(s\\)"); + cmsys::RegularExpression vgUMR4("== .*Syscall param .* contains " + "uninitialised or unaddressable byte\\(s\\)"); cmsys::RegularExpression vgIPW("== .*Invalid write of size [0-9]"); - cmsys::RegularExpression vgABR("== .*pthread_mutex_unlock: mutex is locked by a different thread"); + cmsys::RegularExpression vgABR("== .*pthread_mutex_unlock: mutex is " + "locked by a different thread"); double sttime = cmSystemTools::GetTime(); - cmCTestLog(m_CTest, DEBUG, "Start test: " << lines.size() << std::endl); + cmCTestLog(this->CTest, DEBUG, "Start test: " << lines.size() << std::endl); for ( cc = 0; cc < lines.size(); cc ++ ) { if ( valgrindLine.find(lines[cc]) ) { int failure = cmCTestMemCheckHandler::NO_MEMORY_FAULT; - if ( vgFIM.find(lines[cc]) ) { failure = cmCTestMemCheckHandler::FIM; } - else if ( vgFMM.find(lines[cc]) ) { failure = cmCTestMemCheckHandler::FMM; } - else if ( vgMLK.find(lines[cc]) ) { failure = cmCTestMemCheckHandler::MLK; } - else if ( vgPAR.find(lines[cc]) ) { failure = cmCTestMemCheckHandler::PAR; } - else if ( vgMPK1.find(lines[cc]) ){ failure = cmCTestMemCheckHandler::MPK; } - else if ( vgMPK2.find(lines[cc]) ){ failure = cmCTestMemCheckHandler::MPK; } - else if ( vgUMC.find(lines[cc]) ) { failure = cmCTestMemCheckHandler::UMC; } - else if ( vgUMR1.find(lines[cc]) ){ failure = cmCTestMemCheckHandler::UMR; } - else if ( vgUMR2.find(lines[cc]) ){ failure = cmCTestMemCheckHandler::UMR; } - else if ( vgUMR3.find(lines[cc]) ){ failure = cmCTestMemCheckHandler::UMR; } - else if ( vgUMR4.find(lines[cc]) ){ failure = cmCTestMemCheckHandler::UMR; } - else if ( vgIPW.find(lines[cc]) ) { failure = cmCTestMemCheckHandler::IPW; } - else if ( vgABR.find(lines[cc]) ) { failure = cmCTestMemCheckHandler::ABR; } + if ( vgFIM.find(lines[cc]) ) + { + failure = cmCTestMemCheckHandler::FIM; + } + else if ( vgFMM.find(lines[cc]) ) + { + failure = cmCTestMemCheckHandler::FMM; + } + else if ( vgMLK.find(lines[cc]) ) + { + failure = cmCTestMemCheckHandler::MLK; + } + else if ( vgPAR.find(lines[cc]) ) + { + failure = cmCTestMemCheckHandler::PAR; + } + else if ( vgMPK1.find(lines[cc]) ) + { + failure = cmCTestMemCheckHandler::MPK; + } + else if ( vgMPK2.find(lines[cc]) ) + { + failure = cmCTestMemCheckHandler::MPK; + } + else if ( vgUMC.find(lines[cc]) ) + { + failure = cmCTestMemCheckHandler::UMC; + } + else if ( vgUMR1.find(lines[cc]) ) + { + failure = cmCTestMemCheckHandler::UMR; + } + else if ( vgUMR2.find(lines[cc]) ) + { + failure = cmCTestMemCheckHandler::UMR; + } + else if ( vgUMR3.find(lines[cc]) ) + { + failure = cmCTestMemCheckHandler::UMR; + } + else if ( vgUMR4.find(lines[cc]) ) + { + failure = cmCTestMemCheckHandler::UMR; + } + else if ( vgIPW.find(lines[cc]) ) + { + failure = cmCTestMemCheckHandler::IPW; + } + else if ( vgABR.find(lines[cc]) ) + { + failure = cmCTestMemCheckHandler::ABR; + } if ( failure != cmCTestMemCheckHandler::NO_MEMORY_FAULT ) { @@ -555,7 +642,8 @@ ostr << cmCTest::MakeXMLSafe(lines[cc]) << std::endl; } } - cmCTestLog(m_CTest, DEBUG, "End test (elapsed: " << (cmSystemTools::GetTime() - sttime) << std::endl); + cmCTestLog(this->CTest, DEBUG, "End test (elapsed: " + << (cmSystemTools::GetTime() - sttime) << std::endl); log = ostr.str(); if ( defects ) { diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestMemCheckHandler.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestMemCheckHandler.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestMemCheckHandler.h 2005-06-18 01:04:56.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestMemCheckHandler.h 2006-03-11 04:03:09.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestMemCheckHandler.h,v $ Language: C++ - Date: $Date: 2005/06/17 17:04:56 $ - Version: $Revision: 1.2 $ + Date: $Date: 2006/03/10 20:03:09 $ + Version: $Revision: 1.3 $ Copyright (c) 2002 Kitware, Inc. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -91,12 +91,12 @@ COMPLETED }; - std::string m_MemoryTester; - std::vector m_MemoryTesterOptionsParsed; - std::string m_MemoryTesterOptions; - int m_MemoryTesterStyle; - std::string m_MemoryTesterOutputFile; - int m_MemoryTesterGlobalResults[NO_MEMORY_FAULT]; + std::string MemoryTester; + std::vector MemoryTesterOptionsParsed; + std::string MemoryTesterOptions; + int MemoryTesterStyle; + std::string MemoryTesterOutputFile; + int MemoryTesterGlobalResults[NO_MEMORY_FAULT]; ///! Initialize memory checking subsystem. bool InitializeMemoryChecking(); @@ -106,8 +106,8 @@ */ void GenerateDartOutput(std::ostream& os); - std::vector m_CustomPreMemCheck; - std::vector m_CustomPostMemCheck; + std::vector CustomPreMemCheck; + std::vector CustomPostMemCheck; //! Parse Valgrind/Purify/Bounds Checker result out of the output //string. After running, log holds the output and results hold the diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestRunScriptCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestRunScriptCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestRunScriptCommand.cxx 2005-01-28 02:31:31.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestRunScriptCommand.cxx 2006-03-11 04:03:09.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestRunScriptCommand.cxx,v $ Language: C++ - Date: $Date: 2005/01/27 18:31:31 $ - Version: $Revision: 1.3 $ + Date: $Date: 2006/03/10 20:03:09 $ + Version: $Revision: 1.5 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -18,11 +18,12 @@ #include "cmCTestScriptHandler.h" -bool cmCTestRunScriptCommand::InitialPass(std::vector const& args) +bool cmCTestRunScriptCommand::InitialPass( + std::vector const& args) { if(args.size() < 1 ) { - m_CTestScriptHandler->RunCurrentScript(); + this->CTestScriptHandler->RunCurrentScript(); return true; } @@ -30,7 +31,7 @@ unsigned int i; for (i = 0; i < args.size(); ++i) { - cmCTestScriptHandler::RunScript(m_CTest, args[i].c_str()); + cmCTestScriptHandler::RunScript(this->CTest, args[i].c_str()); } return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestRunScriptCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestRunScriptCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestRunScriptCommand.h 2005-01-27 23:11:04.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestRunScriptCommand.h 2006-03-11 04:03:09.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestRunScriptCommand.h,v $ Language: C++ - Date: $Date: 2005/01/27 15:11:04 $ - Version: $Revision: 1.1 $ + Date: $Date: 2006/03/10 20:03:09 $ + Version: $Revision: 1.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -37,8 +37,8 @@ virtual cmCommand* Clone() { cmCTestRunScriptCommand* ni = new cmCTestRunScriptCommand; - ni->m_CTest = this->m_CTest; - ni->m_CTestScriptHandler = this->m_CTestScriptHandler; + ni->CTest = this->CTest; + ni->CTestScriptHandler = this->CTestScriptHandler; return ni; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestScriptHandler.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestScriptHandler.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestScriptHandler.cxx 2005-06-24 01:04:18.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestScriptHandler.cxx 2006-03-11 04:03:09.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestScriptHandler.cxx,v $ Language: C++ - Date: $Date: 2005/06/23 17:04:18 $ - Version: $Revision: 1.27 $ + Date: $Date: 2006/03/10 20:03:09 $ + Version: $Revision: 1.29 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -33,7 +33,7 @@ #include "windows.h" #endif -#include +#include #include #include #include @@ -67,78 +67,78 @@ cmMakefile &mf); //virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf); //virtual void ScopeEnded(cmMakefile &mf); - - cmCTestScriptHandler* m_CTestScriptHandler; + + cmCTestScriptHandler* CTestScriptHandler; }; // simply update the time and don't block anything bool cmCTestScriptFunctionBlocker:: -IsFunctionBlocked(const cmListFileFunction& , cmMakefile &) +IsFunctionBlocked(const cmListFileFunction& , cmMakefile &) { - m_CTestScriptHandler->UpdateElapsedTime(); + this->CTestScriptHandler->UpdateElapsedTime(); return false; } //---------------------------------------------------------------------- cmCTestScriptHandler::cmCTestScriptHandler() { - m_Backup = false; - m_EmptyBinDir = false; - m_EmptyBinDirOnce = false; - m_Makefile = 0; - m_LocalGenerator = 0; - m_CMake = 0; - m_GlobalGenerator = 0; + this->Backup = false; + this->EmptyBinDir = false; + this->EmptyBinDirOnce = false; + this->Makefile = 0; + this->LocalGenerator = 0; + this->CMake = 0; + this->GlobalGenerator = 0; + + this->ScriptStartTime = 0; - m_ScriptStartTime = 0; - // the *60 is becuase the settings are in minutes but GetTime is seconds - m_MinimumInterval = 30*60; - m_ContinuousDuration = -1; + this->MinimumInterval = 30*60; + this->ContinuousDuration = -1; } //---------------------------------------------------------------------- void cmCTestScriptHandler::Initialize() { this->Superclass::Initialize(); - m_Backup = false; - m_EmptyBinDir = false; - m_EmptyBinDirOnce = false; - - m_SourceDir = ""; - m_BinaryDir = ""; - m_BackupSourceDir = ""; - m_BackupBinaryDir = ""; - m_CTestRoot = ""; - m_CVSCheckOut = ""; - m_CTestCmd = ""; - m_CVSCmd = ""; - m_CTestEnv = ""; - m_InitCache = ""; - m_CMakeCmd = ""; - m_CMOutFile = ""; - m_ExtraUpdates.clear(); + this->Backup = false; + this->EmptyBinDir = false; + this->EmptyBinDirOnce = false; + + this->SourceDir = ""; + this->BinaryDir = ""; + this->BackupSourceDir = ""; + this->BackupBinaryDir = ""; + this->CTestRoot = ""; + this->CVSCheckOut = ""; + this->CTestCmd = ""; + this->CVSCmd = ""; + this->CTestEnv = ""; + this->InitCache = ""; + this->CMakeCmd = ""; + this->CMOutFile = ""; + this->ExtraUpdates.clear(); - m_MinimumInterval = 20*60; - m_ContinuousDuration = -1; + this->MinimumInterval = 20*60; + this->ContinuousDuration = -1; // what time in seconds did this script start running - m_ScriptStartTime = 0; - - m_Makefile = 0; - if (m_LocalGenerator) + this->ScriptStartTime = 0; + + this->Makefile = 0; + if (this->LocalGenerator) { - delete m_LocalGenerator; + delete this->LocalGenerator; } - m_LocalGenerator = 0; - if (m_GlobalGenerator) + this->LocalGenerator = 0; + if (this->GlobalGenerator) { - delete m_GlobalGenerator; + delete this->GlobalGenerator; } - m_GlobalGenerator = 0; - if (m_CMake) + this->GlobalGenerator = 0; + if (this->CMake) { - delete m_CMake; + delete this->CMake; } } @@ -146,20 +146,20 @@ cmCTestScriptHandler::~cmCTestScriptHandler() { // local generator owns the makefile - m_Makefile = 0; - if (m_LocalGenerator) + this->Makefile = 0; + if (this->LocalGenerator) { - delete m_LocalGenerator; + delete this->LocalGenerator; } - m_LocalGenerator = 0; - if (m_GlobalGenerator) + this->LocalGenerator = 0; + if (this->GlobalGenerator) { - delete m_GlobalGenerator; + delete this->GlobalGenerator; } - m_GlobalGenerator = 0; - if (m_CMake) + this->GlobalGenerator = 0; + if (this->CMake) { - delete m_CMake; + delete this->CMake; } } @@ -168,7 +168,7 @@ // just adds an argument to the vector void cmCTestScriptHandler::AddConfigurationScript(const char *script) { - m_ConfigurationScripts.push_back(script); + this->ConfigurationScripts.push_back(script); } @@ -179,8 +179,8 @@ { int res = 0; std::vector::iterator it; - for ( it = m_ConfigurationScripts.begin(); - it != m_ConfigurationScripts.end(); + for ( it = this->ConfigurationScripts.begin(); + it != this->ConfigurationScripts.end(); it ++ ) { // for each script run it @@ -196,14 +196,14 @@ void cmCTestScriptHandler::UpdateElapsedTime() { - if (m_LocalGenerator) + if (this->LocalGenerator) { // set the current elapsed time char timeString[20]; int itime = static_cast(cmSystemTools::GetTime() - - m_ScriptStartTime); + - this->ScriptStartTime); sprintf(timeString,"%i",itime); - m_LocalGenerator->GetMakefile()->AddDefinition("CTEST_ELAPSED_TIME", + this->LocalGenerator->GetMakefile()->AddDefinition("CTEST_ELAPSED_TIME", timeString); } } @@ -212,9 +212,9 @@ void cmCTestScriptHandler::AddCTestCommand(cmCTestCommand* command) { cmCTestCommand* newCom = command; - newCom->m_CTest = m_CTest; - newCom->m_CTestScriptHandler = this; - m_CMake->AddCommand(newCom); + newCom->CTest = this->CTest; + newCom->CTestScriptHandler = this; + this->CMake->AddCommand(newCom); } //---------------------------------------------------------------------- @@ -232,7 +232,7 @@ script = total_script_arg.substr(0,total_script_arg.find(",")); script_arg = total_script_arg.substr(total_script_arg.find(",")+1); } - + // make sure the file exists if (!cmSystemTools::FileExists(script.c_str())) { @@ -242,33 +242,33 @@ // create a cmake instance to read the configuration script // read in the list file to fill the cache - if (m_CMake) + if (this->CMake) { - delete m_CMake; - delete m_GlobalGenerator; - delete m_LocalGenerator; - } - m_CMake = new cmake; - m_CMake->AddCMakePaths(m_CTest->GetCTestExecutable()); - m_GlobalGenerator = new cmGlobalGenerator; - m_GlobalGenerator->SetCMakeInstance(m_CMake); - - m_LocalGenerator = m_GlobalGenerator->CreateLocalGenerator(); - m_LocalGenerator->SetGlobalGenerator(m_GlobalGenerator); - m_Makefile = m_LocalGenerator->GetMakefile(); - + delete this->CMake; + delete this->GlobalGenerator; + delete this->LocalGenerator; + } + this->CMake = new cmake; + this->CMake->AddCMakePaths(this->CTest->GetCTestExecutable()); + this->GlobalGenerator = new cmGlobalGenerator; + this->GlobalGenerator->SetCMakeInstance(this->CMake); + + this->LocalGenerator = this->GlobalGenerator->CreateLocalGenerator(); + this->LocalGenerator->SetGlobalGenerator(this->GlobalGenerator); + this->Makefile = this->LocalGenerator->GetMakefile(); + // set a variable with the path to the current script - m_Makefile->AddDefinition("CTEST_SCRIPT_DIRECTORY", + this->Makefile->AddDefinition("CTEST_SCRIPT_DIRECTORY", cmSystemTools::GetFilenamePath(script).c_str()); - m_Makefile->AddDefinition("CTEST_SCRIPT_NAME", + this->Makefile->AddDefinition("CTEST_SCRIPT_NAME", cmSystemTools::GetFilenameName(script).c_str()); - m_Makefile->AddDefinition("CTEST_EXECUTABLE_NAME", - m_CTest->GetCTestExecutable()); - m_Makefile->AddDefinition("CMAKE_EXECUTABLE_NAME", - m_CTest->GetCMakeExecutable()); - m_Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", true); + this->Makefile->AddDefinition("CTEST_EXECUTABLE_NAME", + this->CTest->GetCTestExecutable()); + this->Makefile->AddDefinition("CMAKE_EXECUTABLE_NAME", + this->CTest->GetCMakeExecutable()); + this->Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", true); this->UpdateElapsedTime(); - + // add any ctest specific commands, probably should have common superclass // for ctest commands to clean this up. If a couple more commands are // created with the same format lets do that - ken @@ -283,24 +283,24 @@ this->AddCTestCommand(new cmCTestSubmitCommand); this->AddCTestCommand(new cmCTestTestCommand); this->AddCTestCommand(new cmCTestUpdateCommand); - + // add the script arg if defined if (script_arg.size()) { - m_Makefile->AddDefinition("CTEST_SCRIPT_ARG", script_arg.c_str()); + this->Makefile->AddDefinition("CTEST_SCRIPT_ARG", script_arg.c_str()); } // always add a function blocker to update the elapsed time cmCTestScriptFunctionBlocker *f = new cmCTestScriptFunctionBlocker(); - f->m_CTestScriptHandler = this; - m_Makefile->AddFunctionBlocker(f); - + f->CTestScriptHandler = this; + this->Makefile->AddFunctionBlocker(f); + // finally read in the script - if (!m_Makefile->ReadListFile(0, script.c_str())) + if (!this->Makefile->ReadListFile(0, script.c_str())) { return 2; } - + return 0; } @@ -313,84 +313,100 @@ const char* minInterval; const char* contDuration; - m_SourceDir = m_Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY"); - m_BinaryDir = m_Makefile->GetSafeDefinition("CTEST_BINARY_DIRECTORY"); - m_CTestCmd = m_Makefile->GetSafeDefinition("CTEST_COMMAND"); - m_CVSCheckOut = m_Makefile->GetSafeDefinition("CTEST_CVS_CHECKOUT"); - m_CTestRoot = m_Makefile->GetSafeDefinition("CTEST_DASHBOARD_ROOT"); - m_CVSCmd = m_Makefile->GetSafeDefinition("CTEST_CVS_COMMAND"); - m_CTestEnv = m_Makefile->GetSafeDefinition("CTEST_ENVIRONMENT"); - m_InitCache = m_Makefile->GetSafeDefinition("CTEST_INITIAL_CACHE"); - m_CMakeCmd = m_Makefile->GetSafeDefinition("CTEST_CMAKE_COMMAND"); - m_CMOutFile = m_Makefile->GetSafeDefinition("CTEST_CMAKE_OUTPUT_FILE_NAME"); - - m_Backup = m_Makefile->IsOn("CTEST_BACKUP_AND_RESTORE"); - m_EmptyBinDir = m_Makefile->IsOn("CTEST_START_WITH_EMPTY_BINARY_DIRECTORY"); - m_EmptyBinDirOnce = m_Makefile->IsOn("CTEST_START_WITH_EMPTY_BINARY_DIRECTORY_ONCE"); - - minInterval = m_Makefile->GetDefinition("CTEST_CONTINUOUS_MINIMUM_INTERVAL"); - contDuration = m_Makefile->GetDefinition("CTEST_CONTINUOUS_DURATION"); + this->SourceDir + = this->Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY"); + this->BinaryDir + = this->Makefile->GetSafeDefinition("CTEST_BINARY_DIRECTORY"); + this->CTestCmd + = this->Makefile->GetSafeDefinition("CTEST_COMMAND"); + this->CVSCheckOut + = this->Makefile->GetSafeDefinition("CTEST_CVS_CHECKOUT"); + this->CTestRoot + = this->Makefile->GetSafeDefinition("CTEST_DASHBOARD_ROOT"); + this->CVSCmd + = this->Makefile->GetSafeDefinition("CTEST_CVS_COMMAND"); + this->CTestEnv + = this->Makefile->GetSafeDefinition("CTEST_ENVIRONMENT"); + this->InitCache + = this->Makefile->GetSafeDefinition("CTEST_INITIAL_CACHE"); + this->CMakeCmd + = this->Makefile->GetSafeDefinition("CTEST_CMAKE_COMMAND"); + this->CMOutFile + = this->Makefile->GetSafeDefinition("CTEST_CMAKE_OUTPUT_FILE_NAME"); + + this->Backup + = this->Makefile->IsOn("CTEST_BACKUP_AND_RESTORE"); + this->EmptyBinDir + = this->Makefile->IsOn("CTEST_START_WITH_EMPTY_BINARY_DIRECTORY"); + this->EmptyBinDirOnce + = this->Makefile->IsOn("CTEST_START_WITH_EMPTY_BINARY_DIRECTORY_ONCE"); + + minInterval + = this->Makefile->GetDefinition("CTEST_CONTINUOUS_MINIMUM_INTERVAL"); + contDuration + = this->Makefile->GetDefinition("CTEST_CONTINUOUS_DURATION"); char updateVar[40]; int i; for (i = 1; i < 10; ++i) { sprintf(updateVar,"CTEST_EXTRA_UPDATES_%i",i); - const char *updateVal = m_Makefile->GetDefinition(updateVar); + const char *updateVal = this->Makefile->GetDefinition(updateVar); if ( updateVal ) { - if ( m_CVSCmd.empty() ) + if ( this->CVSCmd.empty() ) { - cmSystemTools::Error(updateVar, " specified without specifying CTEST_CVS_COMMAND."); + cmSystemTools::Error(updateVar, + " specified without specifying CTEST_CVS_COMMAND."); return 12; } - m_ExtraUpdates.push_back(updateVal); + this->ExtraUpdates.push_back(updateVal); } } // in order to backup and restore we also must have the cvs root - if (m_Backup && m_CVSCheckOut.empty()) + if (this->Backup && this->CVSCheckOut.empty()) { cmSystemTools::Error( - "Backup was requested without specifying CTEST_CVS_CHECKOUT."); + "Backup was requested without specifying CTEST_CVS_CHECKOUT."); return 3; } - + // make sure the required info is here - if (this->m_SourceDir.empty() || - this->m_BinaryDir.empty() || - this->m_CTestCmd.empty()) - { - std::string message = "CTEST_SOURCE_DIRECTORY = "; - message += (!m_SourceDir.empty()) ? m_SourceDir.c_str() : "(Null)"; - message += "\nCTEST_BINARY_DIRECTORY = "; - message += (!m_BinaryDir.empty()) ? m_BinaryDir.c_str() : "(Null)"; - message += "\nCTEST_COMMAND = "; - message += (!m_CTestCmd.empty()) ? m_CTestCmd.c_str() : "(Null)"; + if (this->SourceDir.empty() || + this->BinaryDir.empty() || + this->CTestCmd.empty()) + { + std::string msg = "CTEST_SOURCE_DIRECTORY = "; + msg += (!this->SourceDir.empty()) ? this->SourceDir.c_str() : "(Null)"; + msg += "\nCTEST_BINARY_DIRECTORY = "; + msg += (!this->BinaryDir.empty()) ? this->BinaryDir.c_str() : "(Null)"; + msg += "\nCTEST_COMMAND = "; + msg += (!this->CTestCmd.empty()) ? this->CTestCmd.c_str() : "(Null)"; cmSystemTools::Error( "Some required settings in the configuration file were missing:\n", - message.c_str()); + msg.c_str()); return 4; } - + // if the dashboard root isn't specified then we can compute it from the - // m_SourceDir - if (m_CTestRoot.empty() ) + // this->SourceDir + if (this->CTestRoot.empty() ) { - m_CTestRoot = cmSystemTools::GetFilenamePath(m_SourceDir).c_str(); + this->CTestRoot = cmSystemTools::GetFilenamePath(this->SourceDir).c_str(); } // the script may override the minimum continuous interval if (minInterval) { - m_MinimumInterval = 60 * atof(minInterval); + this->MinimumInterval = 60 * atof(minInterval); } if (contDuration) { - m_ContinuousDuration = 60.0 * atof(contDuration); + this->ContinuousDuration = 60.0 * atof(contDuration); } - - + + this->UpdateElapsedTime(); return 0; @@ -408,22 +424,23 @@ //---------------------------------------------------------------------- // run a specific script -int cmCTestScriptHandler::RunConfigurationScript(const std::string& total_script_arg) +int cmCTestScriptHandler::RunConfigurationScript( + const std::string& total_script_arg) { int result; - - m_ScriptStartTime = + + this->ScriptStartTime = cmSystemTools::GetTime(); - + // read in the script result = this->ReadInScript(total_script_arg); if (result) { return result; } - + // only run the curent script if we should - if (m_Makefile && m_Makefile->IsOn("CTEST_RUN_CURRENT_SCRIPT")) + if (this->Makefile && this->Makefile->IsOn("CTEST_RUN_CURRENT_SCRIPT")) { return this->RunCurrentScript(); } @@ -436,23 +453,23 @@ int result; // do not run twice - m_Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", false); + this->Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", false); // no popup widows cmSystemTools::SetRunCommandHideConsole(true); - + // extract the vars from the cache and store in ivars result = this->ExtractVariables(); if (result) { return result; } - + // set any environment variables - if (!m_CTestEnv.empty()) + if (!this->CTestEnv.empty()) { std::vector envArgs; - cmSystemTools::ExpandListArgument(m_CTestEnv.c_str(),envArgs); + cmSystemTools::ExpandListArgument(this->CTestEnv.c_str(),envArgs); // for each variable/argument do a putenv for (unsigned i = 0; i < envArgs.size(); ++i) { @@ -463,27 +480,27 @@ // now that we have done most of the error checking finally run the // dashboard, we may be asked to repeatedly run this dashboard, such as // for a continuous, do we ned to run it more than once? - if ( m_ContinuousDuration >= 0 ) + if ( this->ContinuousDuration >= 0 ) { this->UpdateElapsedTime(); - double ending_time = cmSystemTools::GetTime() + m_ContinuousDuration; - if (m_EmptyBinDirOnce) + double ending_time = cmSystemTools::GetTime() + this->ContinuousDuration; + if (this->EmptyBinDirOnce) { - m_EmptyBinDir = true; + this->EmptyBinDir = true; } do { double interval = cmSystemTools::GetTime(); result = this->RunConfigurationDashboard(); interval = cmSystemTools::GetTime() - interval; - if (interval < m_MinimumInterval) + if (interval < this->MinimumInterval) { this->SleepInSeconds( - static_cast(m_MinimumInterval - interval)); + static_cast(this->MinimumInterval - interval)); } - if (m_EmptyBinDirOnce) + if (this->EmptyBinDirOnce) { - m_EmptyBinDir = false; + this->EmptyBinDir = false; } } while (cmSystemTools::GetTime() < ending_time); @@ -503,21 +520,22 @@ std::string command; std::string output; int retVal; - bool res; + bool res; - if (!cmSystemTools::FileExists(m_SourceDir.c_str()) && - !m_CVSCheckOut.empty()) + if (!cmSystemTools::FileExists(this->SourceDir.c_str()) && + !this->CVSCheckOut.empty()) { // we must now checkout the src dir output = ""; - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run cvs: " << m_CVSCheckOut << std::endl); - res = cmSystemTools::RunSingleCommand(m_CVSCheckOut.c_str(), &output, - &retVal, m_CTestRoot.c_str(), - m_HandlerVerbose, 0 /*m_TimeOut*/); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "Run cvs: " << this->CVSCheckOut << std::endl); + res = cmSystemTools::RunSingleCommand(this->CVSCheckOut.c_str(), &output, + &retVal, this->CTestRoot.c_str(), this->HandlerVerbose, + 0 /*this->TimeOut*/); if (!res || retVal != 0) { - cmSystemTools::Error("Unable to perform cvs checkout:\n", - output.c_str()); + cmSystemTools::Error("Unable to perform cvs checkout:\n", + output.c_str()); return 6; } } @@ -530,28 +548,28 @@ int retVal; // compute the backup names - m_BackupSourceDir = m_SourceDir; - m_BackupSourceDir += "_CMakeBackup"; - m_BackupBinaryDir = m_BinaryDir; - m_BackupBinaryDir += "_CMakeBackup"; - + this->BackupSourceDir = this->SourceDir; + this->BackupSourceDir += "_CMakeBackup"; + this->BackupBinaryDir = this->BinaryDir; + this->BackupBinaryDir += "_CMakeBackup"; + // backup the binary and src directories if requested - if (m_Backup) + if (this->Backup) { // if for some reason those directories exist then first delete them - if (cmSystemTools::FileExists(m_BackupSourceDir.c_str())) + if (cmSystemTools::FileExists(this->BackupSourceDir.c_str())) { - cmSystemTools::RemoveADirectory(m_BackupSourceDir.c_str()); + cmSystemTools::RemoveADirectory(this->BackupSourceDir.c_str()); } - if (cmSystemTools::FileExists(m_BackupBinaryDir.c_str())) + if (cmSystemTools::FileExists(this->BackupBinaryDir.c_str())) { - cmSystemTools::RemoveADirectory(m_BackupBinaryDir.c_str()); + cmSystemTools::RemoveADirectory(this->BackupBinaryDir.c_str()); } - - // first rename the src and binary directories - rename(m_SourceDir.c_str(), m_BackupSourceDir.c_str()); - rename(m_BinaryDir.c_str(), m_BackupBinaryDir.c_str()); - + + // first rename the src and binary directories + rename(this->SourceDir.c_str(), this->BackupSourceDir.c_str()); + rename(this->BinaryDir.c_str(), this->BackupBinaryDir.c_str()); + // we must now checkout the src dir retVal = this->CheckOutSourceDir(); if (retVal) @@ -571,12 +589,14 @@ std::string command; std::string output; int retVal; - bool res; + bool res; // do an initial cvs update as required - command = m_CVSCmd; + command = this->CVSCmd; std::vector::iterator it; - for (it = m_ExtraUpdates.begin(); it != m_ExtraUpdates.end(); ++ it ) + for (it = this->ExtraUpdates.begin(); + it != this->ExtraUpdates.end(); + ++ it ) { std::vector cvsArgs; cmSystemTools::ExpandListArgument(it->c_str(),cvsArgs); @@ -587,13 +607,14 @@ fullCommand += cvsArgs[1]; output = ""; retVal = 0; - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run CVS: " << fullCommand.c_str() << std::endl); - res = cmSystemTools::RunSingleCommand(fullCommand.c_str(), &output, + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run CVS: " + << fullCommand.c_str() << std::endl); + res = cmSystemTools::RunSingleCommand(fullCommand.c_str(), &output, &retVal, cvsArgs[0].c_str(), - m_HandlerVerbose, 0 /*m_TimeOut*/); + this->HandlerVerbose, 0 /*this->TimeOut*/); if (!res || retVal != 0) { - cmSystemTools::Error("Unable to perform extra cvs updates:\n", + cmSystemTools::Error("Unable to perform extra cvs updates:\n", output.c_str()); return 0; } @@ -611,7 +632,7 @@ std::string command; std::string output; int retVal; - bool res; + bool res; // make sure the src directory is there, if it isn't then we might be able // to check it out from cvs @@ -627,24 +648,26 @@ { return retVal; } - + // clear the binary directory? - if (m_EmptyBinDir) + if (this->EmptyBinDir) { - if ( !cmCTestScriptHandler::EmptyBinaryDirectory(m_BinaryDir.c_str()) ) + if ( !cmCTestScriptHandler::EmptyBinaryDirectory( + this->BinaryDir.c_str()) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem removing the binary directory" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Problem removing the binary directory" << std::endl); } } - + // make sure the binary directory exists if it isn't the srcdir - if (!cmSystemTools::FileExists(m_BinaryDir.c_str()) && - m_SourceDir != m_BinaryDir) + if (!cmSystemTools::FileExists(this->BinaryDir.c_str()) && + this->SourceDir != this->BinaryDir) { - if (!cmSystemTools::MakeDirectory(m_BinaryDir.c_str())) + if (!cmSystemTools::MakeDirectory(this->BinaryDir.c_str())) { - cmSystemTools::Error("Unable to create the binary directory:\n", - m_BinaryDir.c_str()); + cmSystemTools::Error("Unable to create the binary directory:\n", + this->BinaryDir.c_str()); this->RestoreBackupDirectories(); return 7; } @@ -653,15 +676,19 @@ // if the binary directory and the source directory are the same, // and we are starting with an empty binary directory, then that means // we must check out the source tree - if (m_EmptyBinDir && m_SourceDir == m_BinaryDir) + if (this->EmptyBinDir && this->SourceDir == this->BinaryDir) { // make sure we have the required info - if (m_CVSCheckOut.empty()) + if (this->CVSCheckOut.empty()) { - cmSystemTools::Error("You have specified the source and binary directories to be the same (an in source build). You have also specified that the binary directory is to be erased. This means that the source will have to be checked out from CVS. But you have not specified CTEST_CVS_CHECKOUT"); + cmSystemTools::Error("You have specified the source and binary " + "directories to be the same (an in source build). You have also " + "specified that the binary directory is to be erased. This means " + "that the source will have to be checked out from CVS. But you have " + "not specified CTEST_CVS_CHECKOUT"); return 8; } - + // we must now checkout the src dir retVal = this->CheckOutSourceDir(); if (retVal) @@ -670,7 +697,7 @@ return retVal; } } - + // backup the dirs if requested retVal = this->PerformExtraUpdates(); if (retVal) @@ -679,9 +706,9 @@ } // put the initial cache into the bin dir - if (!m_InitCache.empty()) + if (!this->InitCache.empty()) { - std::string cacheFile = m_BinaryDir; + std::string cacheFile = this->BinaryDir; cacheFile += "/CMakeCache.txt"; cmGeneratedFileStream fout(cacheFile.c_str()); if(!fout) @@ -690,7 +717,7 @@ return 9; } - fout.write(m_InitCache.c_str(), m_InitCache.size()); + fout.write(this->InitCache.c_str(), this->InitCache.size()); // Make sure the operating system has finished writing the file // before closing it. This will ensure the file is finished before @@ -702,28 +729,30 @@ // do an initial cmake to setup the DartConfig file int cmakeFailed = 0; std::string cmakeFailedOuput; - if (!m_CMakeCmd.empty()) + if (!this->CMakeCmd.empty()) { - command = m_CMakeCmd; + command = this->CMakeCmd; command += " \""; - command += m_SourceDir; + command += this->SourceDir; output = ""; command += "\""; retVal = 0; - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run cmake command: " << command.c_str() << std::endl); - res = cmSystemTools::RunSingleCommand(command.c_str(), &output, - &retVal, m_BinaryDir.c_str(), - m_HandlerVerbose, 0 /*m_TimeOut*/); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run cmake command: " + << command.c_str() << std::endl); + res = cmSystemTools::RunSingleCommand(command.c_str(), &output, + &retVal, this->BinaryDir.c_str(), + this->HandlerVerbose, 0 /*this->TimeOut*/); - if ( !m_CMOutFile.empty() ) + if ( !this->CMOutFile.empty() ) { - std::string cmakeOutputFile = m_CMOutFile; + std::string cmakeOutputFile = this->CMOutFile; if ( !cmSystemTools::FileIsFullPath(cmakeOutputFile.c_str()) ) { - cmakeOutputFile = m_BinaryDir + "/" + cmakeOutputFile; + cmakeOutputFile = this->BinaryDir + "/" + cmakeOutputFile; } - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Write CMake output to file: " << cmakeOutputFile.c_str() + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "Write CMake output to file: " << cmakeOutputFile.c_str() << std::endl); cmGeneratedFileStream fout(cmakeOutputFile.c_str()); if ( fout ) @@ -732,7 +761,8 @@ } else { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot open CMake output file: " + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Cannot open CMake output file: " << cmakeOutputFile.c_str() << " for writing" << std::endl); } } @@ -746,18 +776,19 @@ // run ctest, it may be more than one command in here std::vector ctestCommands; - cmSystemTools::ExpandListArgument(m_CTestCmd,ctestCommands); + cmSystemTools::ExpandListArgument(this->CTestCmd,ctestCommands); // for each variable/argument do a putenv for (unsigned i = 0; i < ctestCommands.size(); ++i) { command = ctestCommands[i]; output = ""; retVal = 0; - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run ctest command: " << command.c_str() << std::endl); - res = cmSystemTools::RunSingleCommand(command.c_str(), &output, - &retVal, m_BinaryDir.c_str(), - m_HandlerVerbose, 0 /*m_TimeOut*/); - + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run ctest command: " + << command.c_str() << std::endl); + res = cmSystemTools::RunSingleCommand(command.c_str(), &output, + &retVal, this->BinaryDir.c_str(), this->HandlerVerbose, + 0 /*this->TimeOut*/); + // did something critical fail in ctest if (!res || cmakeFailed || retVal & cmCTest::BUILD_ERRORS) @@ -765,11 +796,13 @@ this->RestoreBackupDirectories(); if (cmakeFailed) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Unable to run cmake:" << std::endl + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Unable to run cmake:" << std::endl << cmakeFailedOuput.c_str() << std::endl); return 10; } - cmCTestLog(m_CTest, ERROR_MESSAGE, "Unable to run ctest:" << std::endl + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Unable to run ctest:" << std::endl << output.c_str() << std::endl); if (!res) { @@ -778,15 +811,15 @@ return retVal * 100; } } - + // if all was succesful, delete the backup dirs to free up disk space - if (m_Backup) + if (this->Backup) { - cmSystemTools::RemoveADirectory(m_BackupSourceDir.c_str()); - cmSystemTools::RemoveADirectory(m_BackupBinaryDir.c_str()); + cmSystemTools::RemoveADirectory(this->BackupSourceDir.c_str()); + cmSystemTools::RemoveADirectory(this->BackupBinaryDir.c_str()); } - return 0; + return 0; } @@ -795,20 +828,20 @@ { // if we backed up the dirs and the build failed, then restore // the backed up dirs - if (m_Backup) + if (this->Backup) { // if for some reason those directories exist then first delete them - if (cmSystemTools::FileExists(m_SourceDir.c_str())) + if (cmSystemTools::FileExists(this->SourceDir.c_str())) { - cmSystemTools::RemoveADirectory(m_SourceDir.c_str()); + cmSystemTools::RemoveADirectory(this->SourceDir.c_str()); } - if (cmSystemTools::FileExists(m_BinaryDir.c_str())) + if (cmSystemTools::FileExists(this->BinaryDir.c_str())) { - cmSystemTools::RemoveADirectory(m_BinaryDir.c_str()); + cmSystemTools::RemoveADirectory(this->BinaryDir.c_str()); } - // rename the src and binary directories - rename(m_BackupSourceDir.c_str(), m_SourceDir.c_str()); - rename(m_BackupBinaryDir.c_str(), m_BinaryDir.c_str()); + // rename the src and binary directories + rename(this->BackupSourceDir.c_str(), this->SourceDir.c_str()); + rename(this->BackupBinaryDir.c_str(), this->BinaryDir.c_str()); } } @@ -829,7 +862,7 @@ { return false; } - + // try to avoid deleting directories that we shouldn't std::string check = sname; check += "/CMakeCache.txt"; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestScriptHandler.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestScriptHandler.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestScriptHandler.h 2005-11-24 01:33:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestScriptHandler.h 2006-03-11 04:03:09.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestScriptHandler.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:39 $ - Version: $Revision: 1.13.2.1 $ + Date: $Date: 2006/03/10 20:03:09 $ + Version: $Revision: 1.15 $ Copyright (c) 2002 Kitware, Inc. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -50,7 +50,7 @@ * CTEST_INITIAL_CACHE * CTEST_START_WITH_EMPTY_BINARY_DIRECTORY * CTEST_START_WITH_EMPTY_BINARY_DIRECTORY_ONCE - * + * * In addition the following variables can be used. The number can be 1-10. * CTEST_EXTRA_UPDATES_1 * CTEST_EXTRA_UPDATES_2 @@ -83,7 +83,7 @@ */ static bool RunScript(cmCTest* ctest, const char *script); int RunCurrentScript(); - + /* * Empty Binary Directory */ @@ -97,7 +97,7 @@ cmCTestScriptHandler(); ~cmCTestScriptHandler(); - + void Initialize(); private: // reads in a script @@ -111,7 +111,7 @@ // perform any extra cvs updates that were requested int PerformExtraUpdates(); - + // backup and restore dirs int BackupDirectories(); void RestoreBackupDirectories(); @@ -122,36 +122,36 @@ // Add ctest command void AddCTestCommand(cmCTestCommand* command); - std::vector m_ConfigurationScripts; + std::vector ConfigurationScripts; - bool m_Backup; - bool m_EmptyBinDir; - bool m_EmptyBinDirOnce; - - cmStdString m_SourceDir; - cmStdString m_BinaryDir; - cmStdString m_BackupSourceDir; - cmStdString m_BackupBinaryDir; - cmStdString m_CTestRoot; - cmStdString m_CVSCheckOut; - cmStdString m_CTestCmd; - cmStdString m_CVSCmd; - cmStdString m_CTestEnv; - cmStdString m_InitCache; - cmStdString m_CMakeCmd; - cmStdString m_CMOutFile; - std::vector m_ExtraUpdates; + bool Backup; + bool EmptyBinDir; + bool EmptyBinDirOnce; + + cmStdString SourceDir; + cmStdString BinaryDir; + cmStdString BackupSourceDir; + cmStdString BackupBinaryDir; + cmStdString CTestRoot; + cmStdString CVSCheckOut; + cmStdString CTestCmd; + cmStdString CVSCmd; + cmStdString CTestEnv; + cmStdString InitCache; + cmStdString CMakeCmd; + cmStdString CMOutFile; + std::vector ExtraUpdates; - double m_MinimumInterval; - double m_ContinuousDuration; + double MinimumInterval; + double ContinuousDuration; // what time in seconds did this script start running - double m_ScriptStartTime; - - cmMakefile *m_Makefile; - cmLocalGenerator *m_LocalGenerator; - cmGlobalGenerator *m_GlobalGenerator; - cmake *m_CMake; + double ScriptStartTime; + + cmMakefile *Makefile; + cmLocalGenerator *LocalGenerator; + cmGlobalGenerator *GlobalGenerator; + cmake *CMake; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestSleepCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestSleepCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestSleepCommand.cxx 2005-01-28 00:01:56.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestSleepCommand.cxx 2006-03-11 04:03:09.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestSleepCommand.cxx,v $ Language: C++ - Date: $Date: 2005/01/27 16:01:56 $ - Version: $Revision: 1.2 $ + Date: $Date: 2006/03/10 20:03:09 $ + Version: $Revision: 1.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -34,7 +34,7 @@ { cmCTestScriptHandler::SleepInSeconds(time1); // update the elapsed time since it could have slept for a while - m_CTestScriptHandler->UpdateElapsedTime(); + this->CTestScriptHandler->UpdateElapsedTime(); return true; } @@ -48,7 +48,7 @@ duration = (time1 + duration - time2); cmCTestScriptHandler::SleepInSeconds(duration); // update the elapsed time since it could have slept for a while - m_CTestScriptHandler->UpdateElapsedTime(); + this->CTestScriptHandler->UpdateElapsedTime(); } return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestSleepCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestSleepCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestSleepCommand.h 2005-01-27 23:11:04.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestSleepCommand.h 2006-03-11 04:03:09.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestSleepCommand.h,v $ Language: C++ - Date: $Date: 2005/01/27 15:11:04 $ - Version: $Revision: 1.1 $ + Date: $Date: 2006/03/10 20:03:09 $ + Version: $Revision: 1.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -37,8 +37,8 @@ virtual cmCommand* Clone() { cmCTestSleepCommand* ni = new cmCTestSleepCommand; - ni->m_CTest = this->m_CTest; - ni->m_CTestScriptHandler = this->m_CTestScriptHandler; + ni->CTest = this->CTest; + ni->CTestScriptHandler = this->CTestScriptHandler; return ni; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestStartCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestStartCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestStartCommand.cxx 2005-06-24 01:04:18.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestStartCommand.cxx 2006-03-16 00:02:08.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestStartCommand.cxx,v $ Language: C++ - Date: $Date: 2005/06/23 17:04:18 $ - Version: $Revision: 1.9 $ + Date: $Date: 2006/03/15 16:02:08 $ + Version: $Revision: 1.12 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -48,37 +48,40 @@ } if ( !src_dir ) { - src_dir = m_Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY"); + src_dir = this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY"); } if ( !bld_dir) { - bld_dir = m_Makefile->GetDefinition("CTEST_BINARY_DIRECTORY"); + bld_dir = this->Makefile->GetDefinition("CTEST_BINARY_DIRECTORY"); } if ( !src_dir ) { - this->SetError("source directory not specified. Specify source directory as an argument or set CTEST_SOURCE_DIRECTORY"); + this->SetError("source directory not specified. Specify source directory " + "as an argument or set CTEST_SOURCE_DIRECTORY"); return false; } if ( !bld_dir) { - this->SetError("binary directory not specified. Specify binary directory as an argument or set CTEST_BINARY_DIRECTORY"); + this->SetError("binary directory not specified. Specify binary directory " + "as an argument or set CTEST_BINARY_DIRECTORY"); return false; } - m_CTest->EmptyCTestConfiguration(); - m_CTest->SetCTestConfiguration("SourceDirectory", src_dir); - m_CTest->SetCTestConfiguration("BuildDirectory", bld_dir); + this->CTest->EmptyCTestConfiguration(); + this->CTest->SetCTestConfiguration("SourceDirectory", src_dir); + this->CTest->SetCTestConfiguration("BuildDirectory", bld_dir); - cmCTestLog(m_CTest, HANDLER_OUTPUT, "Run dashboard with model " << smodel << std::endl + cmCTestLog(this->CTest, HANDLER_OUTPUT, "Run dashboard with model " + << smodel << std::endl << " Source directory: " << src_dir << std::endl << " Build directory: " << bld_dir << std::endl); - m_Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", "OFF"); - m_CTest->SetSuppressUpdatingCTestConfiguration(true); - int model = m_CTest->GetTestModelFromString(smodel); - m_CTest->SetTestModel(model); - m_CTest->SetProduceXML(true); + this->Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", "OFF"); + this->CTest->SetSuppressUpdatingCTestConfiguration(true); + int model = this->CTest->GetTestModelFromString(smodel); + this->CTest->SetTestModel(model); + this->CTest->SetProduceXML(true); - return m_CTest->InitializeFromCommand(this, true); + return this->CTest->InitializeFromCommand(this, true); } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestStartCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestStartCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestStartCommand.h 2005-02-17 23:51:52.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestStartCommand.h 2006-03-11 04:03:09.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestStartCommand.h,v $ Language: C++ - Date: $Date: 2005/02/17 15:51:52 $ - Version: $Revision: 1.1 $ + Date: $Date: 2006/03/10 20:03:09 $ + Version: $Revision: 1.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -29,15 +29,15 @@ public: cmCTestStartCommand() {} - + /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { cmCTestStartCommand* ni = new cmCTestStartCommand; - ni->m_CTest = this->m_CTest; - ni->m_CTestScriptHandler = this->m_CTestScriptHandler; + ni->CTest = this->CTest; + ni->CTestScriptHandler = this->CTestScriptHandler; return ni; } @@ -55,11 +55,11 @@ /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { return "Starts the testing for a given model"; } - + /** * More documentation. */ @@ -67,10 +67,10 @@ { return " CTEST_START(Model [source [binary]])\n" - "Starts the testing for a given model. The command should be called after " - "the binary directory is initialized. If the 'source' and 'binary' " - "directory are not specified, it reads the CTEST_SOURCE_DIRECTORY and " - "CTEST_BINARY_DIRECTORY."; + "Starts the testing for a given model. The command should be called " + "after the binary directory is initialized. If the 'source' and " + "'binary' directory are not specified, it reads the " + "CTEST_SOURCE_DIRECTORY and CTEST_BINARY_DIRECTORY."; } cmTypeMacro(cmCTestStartCommand, cmCTestCommand); diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestSubmitCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestSubmitCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestSubmitCommand.cxx 2005-08-12 02:02:20.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestSubmitCommand.cxx 2006-03-16 00:02:08.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestSubmitCommand.cxx,v $ Language: C++ - Date: $Date: 2005/08/11 18:02:20 $ - Version: $Revision: 1.7.2.1 $ + Date: $Date: 2006/03/15 16:02:08 $ + Version: $Revision: 1.11 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -36,24 +36,30 @@ { if ( res_var ) { - this->SetError("called with incorrect number of arguments. RETURN_VALUE specified twice."); + this->SetError("called with incorrect number of arguments. " + "RETURN_VALUE specified twice."); return false; } havereturn_variable = true; - } + } else { cmOStringStream str; - str << "called with incorrect number of arguments. Extra argument is: " << args[i].c_str() << "."; + str << "called with incorrect number of arguments. Extra argument is: " + << args[i].c_str() << "."; this->SetError(str.str().c_str()); return false; } } - const char* ctestDropMethod = m_Makefile->GetDefinition("CTEST_DROP_METHOD"); - const char* ctestDropSite = m_Makefile->GetDefinition("CTEST_DROP_SITE"); - const char* ctestDropLocation = m_Makefile->GetDefinition("CTEST_DROP_LOCATION"); - const char* ctestTriggerSite = m_Makefile->GetDefinition("CTEST_TRIGGER_SITE"); + const char* ctestDropMethod + = this->Makefile->GetDefinition("CTEST_DROP_METHOD"); + const char* ctestDropSite + = this->Makefile->GetDefinition("CTEST_DROP_SITE"); + const char* ctestDropLocation + = this->Makefile->GetDefinition("CTEST_DROP_LOCATION"); + const char* ctestTriggerSite + = this->Makefile->GetDefinition("CTEST_TRIGGER_SITE"); if ( !ctestDropMethod ) { @@ -69,55 +75,63 @@ } if ( !ctestTriggerSite ) { - ctestTriggerSite = "http://public.kitware.com/cgi-bin/Submit-Random-TestingResults.cgi"; - cmCTestLog(m_CTest, HANDLER_OUTPUT, "* Use default trigger site: " << ctestTriggerSite << std::endl;); - } - - m_CTest->SetCTestConfiguration("DropMethod", ctestDropMethod); - m_CTest->SetCTestConfiguration("DropSite", ctestDropSite); - m_CTest->SetCTestConfiguration("DropLocation", ctestDropLocation); - m_CTest->SetCTestConfiguration("TriggerSite", ctestTriggerSite); - - m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "DropSiteUser", "CTEST_DROP_SITE_USER"); - m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "DropSitePassword", "CTEST_DROP_SITE_PASSWORD"); - m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "ScpCommand", "CTEST_SCP_COMMAND"); + ctestTriggerSite + = "http://public.kitware.com/cgi-bin/Submit-Random-TestingResults.cgi"; + cmCTestLog(this->CTest, HANDLER_OUTPUT, "* Use default trigger site: " + << ctestTriggerSite << std::endl;); + } + + this->CTest->SetCTestConfiguration("DropMethod", ctestDropMethod); + this->CTest->SetCTestConfiguration("DropSite", ctestDropSite); + this->CTest->SetCTestConfiguration("DropLocation", ctestDropLocation); + this->CTest->SetCTestConfiguration("TriggerSite", ctestTriggerSite); + + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, + "DropSiteUser", "CTEST_DROP_SITE_USER"); + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, + "DropSitePassword", "CTEST_DROP_SITE_PASSWORD"); + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, + "ScpCommand", "CTEST_SCP_COMMAND"); - const char* notesFilesVariable = m_Makefile->GetDefinition("CTEST_NOTES_FILES"); + const char* notesFilesVariable + = this->Makefile->GetDefinition("CTEST_NOTES_FILES"); if (notesFilesVariable) { std::vector notesFiles; std::vector newNotesFiles; cmSystemTools::ExpandListArgument(notesFilesVariable,notesFiles); std::vector::iterator it; - for ( it = notesFiles.begin(); + for ( it = notesFiles.begin(); it != notesFiles.end(); ++ it ) { newNotesFiles.push_back(*it); } - m_CTest->GenerateNotesFile(newNotesFiles); + this->CTest->GenerateNotesFile(newNotesFiles); } - const char* extraFilesVariable = m_Makefile->GetDefinition("CTEST_EXTRA_SUBMIT_FILES"); + const char* extraFilesVariable + = this->Makefile->GetDefinition("CTEST_EXTRA_SUBMIT_FILES"); if (extraFilesVariable) { std::vector extraFiles; std::vector newExtraFiles; cmSystemTools::ExpandListArgument(extraFilesVariable,extraFiles); std::vector::iterator it; - for ( it = extraFiles.begin(); + for ( it = extraFiles.begin(); it != extraFiles.end(); ++ it ) { newExtraFiles.push_back(*it); } - if ( !m_CTest->SubmitExtraFiles(newExtraFiles)) + if ( !this->CTest->SubmitExtraFiles(newExtraFiles)) { this->SetError("problem submitting extra files."); return false; } } - cmCTestGenericHandler* handler = m_CTest->GetInitializedHandler("submit"); + cmCTestGenericHandler* handler + = this->CTest->GetInitializedHandler("submit"); if ( !handler ) { this->SetError("internal CTest error. Cannot instantiate submit handler"); @@ -128,7 +142,7 @@ { cmOStringStream str; str << res; - m_Makefile->AddDefinition(res_var, str.str().c_str()); + this->Makefile->AddDefinition(res_var, str.str().c_str()); } return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestSubmitCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestSubmitCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestSubmitCommand.h 2005-05-04 23:13:35.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestSubmitCommand.h 2006-03-11 04:03:09.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestSubmitCommand.h,v $ Language: C++ - Date: $Date: 2005/05/04 15:13:35 $ - Version: $Revision: 1.2 $ + Date: $Date: 2006/03/10 20:03:09 $ + Version: $Revision: 1.4 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -22,22 +22,23 @@ /** \class cmCTestSubmit * \brief Run a ctest script * - * cmCTestSubmitCommand defineds the command to submit the test results for the project. + * cmCTestSubmitCommand defineds the command to submit the test results for + * the project. */ class cmCTestSubmitCommand : public cmCTestCommand { public: cmCTestSubmitCommand() {} - + /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { cmCTestSubmitCommand* ni = new cmCTestSubmitCommand; - ni->m_CTest = this->m_CTest; - ni->m_CTestScriptHandler = this->m_CTestScriptHandler; + ni->CTest = this->CTest; + ni->CTestScriptHandler = this->CTestScriptHandler; return ni; } @@ -55,11 +56,11 @@ /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { return "Submits the repository."; } - + /** * More documentation. */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestSubmitHandler.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestSubmitHandler.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestSubmitHandler.cxx 2005-11-24 01:33:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestSubmitHandler.cxx 2006-03-11 04:03:09.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestSubmitHandler.cxx,v $ Language: C++ -Date: $Date: 2005/11/23 17:33:39 $ -Version: $Revision: 1.16.2.2 $ +Date: $Date: 2006/03/10 20:03:09 $ +Version: $Revision: 1.22 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -36,11 +36,13 @@ typedef std::vector cmCTestSubmitHandlerVectorOfChar; static size_t -cmCTestSubmitHandlerWriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data) +cmCTestSubmitHandlerWriteMemoryCallback(void *ptr, size_t size, size_t nmemb, + void *data) { register int realsize = size * nmemb; - cmCTestSubmitHandlerVectorOfChar *vec = static_cast(data); + cmCTestSubmitHandlerVectorOfChar *vec + = static_cast(data); const char* chPtr = static_cast(ptr); vec->insert(vec->end(), chPtr, chPtr + realsize); @@ -48,41 +50,43 @@ } static size_t -cmCTestSubmitHandlerCurlDebugCallback(CURL *, curl_infotype, char *chPtr, size_t size, void *data) +cmCTestSubmitHandlerCurlDebugCallback(CURL *, curl_infotype, char *chPtr, + size_t size, void *data) { - cmCTestSubmitHandlerVectorOfChar *vec = static_cast(data); + cmCTestSubmitHandlerVectorOfChar *vec + = static_cast(data); vec->insert(vec->end(), chPtr, chPtr + size); return size; } //---------------------------------------------------------------------------- -cmCTestSubmitHandler::cmCTestSubmitHandler() : m_HTTPProxy(), m_FTPProxy() +cmCTestSubmitHandler::cmCTestSubmitHandler() : HTTPProxy(), FTPProxy() { - m_HTTPProxy = ""; - m_HTTPProxyType = 0; - m_HTTPProxyAuth = ""; + this->HTTPProxy = ""; + this->HTTPProxyType = 0; + this->HTTPProxyAuth = ""; - m_FTPProxy = ""; - m_FTPProxyType = 0; + this->FTPProxy = ""; + this->FTPProxyType = 0; } //---------------------------------------------------------------------------- void cmCTestSubmitHandler::Initialize() { this->Superclass::Initialize(); - m_HTTPProxy = ""; - m_HTTPProxyType = 0; - m_HTTPProxyAuth = ""; - m_FTPProxy = ""; - m_FTPProxyType = 0; - m_LogFile = 0; + this->HTTPProxy = ""; + this->HTTPProxyType = 0; + this->HTTPProxyAuth = ""; + this->FTPProxy = ""; + this->FTPProxyType = 0; + this->LogFile = 0; } //---------------------------------------------------------------------------- -bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, +bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, const std::set& files, - const cmStdString& remoteprefix, + const cmStdString& remoteprefix, const cmStdString& url) { CURL *curl; @@ -93,18 +97,18 @@ /* In windows, this will init the winsock stuff */ ::curl_global_init(CURL_GLOBAL_ALL); - cmCTest::tm_SetOfStrings::const_iterator file; + cmCTest::SetOfStrings::const_iterator file; for ( file = files.begin(); file != files.end(); ++file ) { /* get a curl handle */ curl = curl_easy_init(); - if(curl) + if(curl) { // Using proxy - if ( m_FTPProxyType > 0 ) + if ( this->FTPProxyType > 0 ) { - curl_easy_setopt(curl, CURLOPT_PROXY, m_FTPProxy.c_str()); - switch (m_FTPProxyType) + curl_easy_setopt(curl, CURLOPT_PROXY, this->FTPProxy.c_str()); + switch (this->FTPProxyType) { case 2: curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4); @@ -113,7 +117,7 @@ curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); break; default: - curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); + curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); } } @@ -125,21 +129,24 @@ { local_file = localprefix + "/" + *file; } - cmStdString upload_as = url + "/" + remoteprefix + cmSystemTools::GetFilenameName(*file); + cmStdString upload_as + = url + "/" + remoteprefix + cmSystemTools::GetFilenameName(*file); struct stat st; if ( ::stat(local_file.c_str(), &st) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Cannot find file: " << local_file.c_str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find file: " + << local_file.c_str() << std::endl); ::curl_easy_cleanup(curl); - ::curl_global_cleanup(); + ::curl_global_cleanup(); return false; } ftpfile = ::fopen(local_file.c_str(), "rb"); - *m_LogFile << "\tUpload file: " << local_file.c_str() << " to " + *this->LogFile << "\tUpload file: " << local_file.c_str() << " to " << upload_as.c_str() << std::endl; - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " << local_file.c_str() << " to " + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " + << local_file.c_str() << " to " << upload_as.c_str() << std::endl); ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); @@ -151,14 +158,17 @@ ::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile); // and give the size of the upload (optional) - ::curl_easy_setopt(curl, CURLOPT_INFILESIZE, static_cast(st.st_size)); + ::curl_easy_setopt(curl, CURLOPT_INFILESIZE, + static_cast(st.st_size)); // and give curl the buffer for errors ::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer); // specify handler for output - ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cmCTestSubmitHandlerWriteMemoryCallback); - ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, cmCTestSubmitHandlerCurlDebugCallback); + ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, + cmCTestSubmitHandlerWriteMemoryCallback); + ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, + cmCTestSubmitHandlerCurlDebugCallback); /* we pass our 'chunk' struct to the callback function */ cmCTestSubmitHandlerVectorOfChar chunk; @@ -169,39 +179,55 @@ // Now run off and do what you've been told! res = ::curl_easy_perform(curl); - cmCTestLog(m_CTest, DEBUG, "CURL output: [" - << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl); - cmCTestLog(m_CTest, DEBUG, "CURL debug output: [" - << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]" << std::endl); + if ( chunk.size() > 0 ) + { + cmCTestLog(this->CTest, DEBUG, "CURL output: [" + << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" + << std::endl); + } + if ( chunkDebug.size() > 0 ) + { + cmCTestLog(this->CTest, DEBUG, "CURL debug output: [" + << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]" + << std::endl); + } fclose(ftpfile); if ( res ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Error when uploading file: " << local_file.c_str() << std::endl); - cmCTestLog(m_CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); - *m_LogFile << " Error when uploading file: " << local_file.c_str() << std::endl + cmCTestLog(this->CTest, ERROR_MESSAGE, + " Error when uploading file: " + << local_file.c_str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: " + << error_buffer << std::endl); + *this->LogFile << " Error when uploading file: " + << local_file.c_str() + << std::endl << " Error message was: " << error_buffer << std::endl - << " Curl output was: " << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; - cmCTestLog(m_CTest, ERROR_MESSAGE, "CURL output: [" - << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl); + << " Curl output was: " + << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; + cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: [" + << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" + << std::endl); ::curl_easy_cleanup(curl); - ::curl_global_cleanup(); + ::curl_global_cleanup(); return false; } // always cleanup ::curl_easy_cleanup(curl); - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Uploaded: " + local_file << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Uploaded: " + local_file + << std::endl); } } - ::curl_global_cleanup(); + ::curl_global_cleanup(); return true; } //---------------------------------------------------------------------------- // Uploading files is simpler -bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, +bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, const std::set& files, - const cmStdString& remoteprefix, + const cmStdString& remoteprefix, const cmStdString& url) { CURL *curl; @@ -213,19 +239,19 @@ ::curl_global_init(CURL_GLOBAL_ALL); cmStdString::size_type kk; - cmCTest::tm_SetOfStrings::const_iterator file; + cmCTest::SetOfStrings::const_iterator file; for ( file = files.begin(); file != files.end(); ++file ) { /* get a curl handle */ curl = curl_easy_init(); - if(curl) + if(curl) { // Using proxy - if ( m_HTTPProxyType > 0 ) + if ( this->HTTPProxyType > 0 ) { - curl_easy_setopt(curl, CURLOPT_PROXY, m_HTTPProxy.c_str()); - switch (m_HTTPProxyType) + curl_easy_setopt(curl, CURLOPT_PROXY, this->HTTPProxy.c_str()); + switch (this->HTTPProxyType) { case 2: curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4); @@ -235,10 +261,10 @@ break; default: curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); - if (m_HTTPProxyAuth.size() > 0) + if (this->HTTPProxyAuth.size() > 0) { curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, - m_HTTPProxyAuth.c_str()); + this->HTTPProxyAuth.c_str()); } } } @@ -255,9 +281,10 @@ { local_file = localprefix + "/" + *file; } - cmStdString remote_file = remoteprefix + cmSystemTools::GetFilenameName(*file); + cmStdString remote_file + = remoteprefix + cmSystemTools::GetFilenameName(*file); - *m_LogFile << "\tUpload file: " << local_file.c_str() << " to " + *this->LogFile << "\tUpload file: " << local_file.c_str() << " to " << remote_file.c_str() << std::endl; cmStdString ofile = ""; @@ -279,25 +306,27 @@ sprintf(hexCh, "%%%02X", (int)c); ofile.append(hexCh); break; - default: + default: ofile.append(hexCh); } } - cmStdString upload_as - = url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&") + cmStdString upload_as + = url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&") + "FileName=" + ofile; struct stat st; if ( ::stat(local_file.c_str(), &st) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Cannot find file: " << local_file.c_str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find file: " + << local_file.c_str() << std::endl); ::curl_easy_cleanup(curl); - ::curl_global_cleanup(); + ::curl_global_cleanup(); return false; } ftpfile = ::fopen(local_file.c_str(), "rb"); - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " << local_file.c_str() << " to " + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " + << local_file.c_str() << " to " << upload_as.c_str() << " Size: " << st.st_size << std::endl); @@ -308,14 +337,17 @@ ::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile); // and give the size of the upload (optional) - ::curl_easy_setopt(curl, CURLOPT_INFILESIZE, static_cast(st.st_size)); + ::curl_easy_setopt(curl, CURLOPT_INFILESIZE, + static_cast(st.st_size)); // and give curl the buffer for errors ::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer); // specify handler for output - ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cmCTestSubmitHandlerWriteMemoryCallback); - ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, cmCTestSubmitHandlerCurlDebugCallback); + ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, + cmCTestSubmitHandlerWriteMemoryCallback); + ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, + cmCTestSubmitHandlerCurlDebugCallback); /* we pass our 'chunk' struct to the callback function */ cmCTestSubmitHandlerVectorOfChar chunk; @@ -326,37 +358,54 @@ // Now run off and do what you've been told! res = ::curl_easy_perform(curl); - cmCTestLog(m_CTest, DEBUG, "CURL output: [" - << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl); - cmCTestLog(m_CTest, DEBUG, "CURL debug output: [" - << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]" << std::endl); + if ( chunk.size() > 0 ) + { + cmCTestLog(this->CTest, DEBUG, "CURL output: [" + << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" + << std::endl); + } + if ( chunkDebug.size() > 0 ) + { + cmCTestLog(this->CTest, DEBUG, "CURL debug output: [" + << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]" + << std::endl); + } fclose(ftpfile); if ( res ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Error when uploading file: " << local_file.c_str() << std::endl); - cmCTestLog(m_CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); - *m_LogFile << " Error when uploading file: " << local_file.c_str() << std::endl + cmCTestLog(this->CTest, ERROR_MESSAGE, + " Error when uploading file: " + << local_file.c_str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: " + << error_buffer << std::endl); + *this->LogFile << " Error when uploading file: " + << local_file.c_str() + << std::endl << " Error message was: " << error_buffer << std::endl - << " Curl output was: " << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; - cmCTestLog(m_CTest, ERROR_MESSAGE, "CURL output: [" - << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl); + << " Curl output was: " + << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; + cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: [" + << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" + << std::endl); ::curl_easy_cleanup(curl); - ::curl_global_cleanup(); + ::curl_global_cleanup(); return false; } // always cleanup ::curl_easy_cleanup(curl); - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Uploaded: " + local_file << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Uploaded: " + local_file + << std::endl); } } - ::curl_global_cleanup(); + ::curl_global_cleanup(); return true; } //---------------------------------------------------------------------------- -bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set& files, - const cmStdString& remoteprefix, +bool cmCTestSubmitHandler::TriggerUsingHTTP( + const std::set& files, + const cmStdString& remoteprefix, const cmStdString& url) { CURL *curl; @@ -365,18 +414,18 @@ /* In windows, this will init the winsock stuff */ ::curl_global_init(CURL_GLOBAL_ALL); - cmCTest::tm_SetOfStrings::const_iterator file; + cmCTest::SetOfStrings::const_iterator file; for ( file = files.begin(); file != files.end(); ++file ) { /* get a curl handle */ curl = curl_easy_init(); - if(curl) + if(curl) { // Using proxy - if ( m_HTTPProxyType > 0 ) + if ( this->HTTPProxyType > 0 ) { - curl_easy_setopt(curl, CURLOPT_PROXY, m_HTTPProxy.c_str()); - switch (m_HTTPProxyType) + curl_easy_setopt(curl, CURLOPT_PROXY, this->HTTPProxy.c_str()); + switch (this->HTTPProxyType) { case 2: curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4); @@ -385,11 +434,11 @@ curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); break; default: - curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); - if (m_HTTPProxyAuth.size() > 0) + curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); + if (this->HTTPProxyAuth.size() > 0) { curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, - m_HTTPProxyAuth.c_str()); + this->HTTPProxyAuth.c_str()); } } } @@ -400,8 +449,10 @@ ::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer); // specify handler for output - ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cmCTestSubmitHandlerWriteMemoryCallback); - ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, cmCTestSubmitHandlerCurlDebugCallback); + ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, + cmCTestSubmitHandlerWriteMemoryCallback); + ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, + cmCTestSubmitHandlerCurlDebugCallback); /* we pass our 'chunk' struct to the callback function */ cmCTestSubmitHandlerVectorOfChar chunk; @@ -409,7 +460,8 @@ ::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk); ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug); - cmStdString rfile = remoteprefix + cmSystemTools::GetFilenameName(*file); + cmStdString rfile + = remoteprefix + cmSystemTools::GetFilenameName(*file); cmStdString ofile = ""; cmStdString::iterator kk; for ( kk = rfile.begin(); kk < rfile.end(); ++ kk) @@ -430,51 +482,66 @@ sprintf(hexCh, "%%%02X", (int)c); ofile.append(hexCh); break; - default: + default: ofile.append(hexCh); } } - cmStdString turl - = url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&") + cmStdString turl + = url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&") + "xmlfile=" + ofile; - *m_LogFile << "Trigger url: " << turl.c_str() << std::endl; - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " Trigger url: " << turl.c_str() << std::endl); + *this->LogFile << "Trigger url: " << turl.c_str() << std::endl; + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Trigger url: " + << turl.c_str() << std::endl); curl_easy_setopt(curl, CURLOPT_URL, turl.c_str()); if ( curl_easy_perform(curl) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Error when triggering: " << turl.c_str() << std::endl); - cmCTestLog(m_CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); - *m_LogFile << "\tTrigerring failed with error: " << error_buffer << std::endl + cmCTestLog(this->CTest, ERROR_MESSAGE, " Error when triggering: " + << turl.c_str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: " + << error_buffer << std::endl); + *this->LogFile << "\tTrigerring failed with error: " << error_buffer + << std::endl << " Error message was: " << error_buffer << std::endl - << " Curl output was: " << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; - cmCTestLog(m_CTest, ERROR_MESSAGE, "CURL output: [" - << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl); + << " Curl output was: " + << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; + cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: [" + << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" + << std::endl); ::curl_easy_cleanup(curl); - ::curl_global_cleanup(); + ::curl_global_cleanup(); return false; } - cmCTestLog(m_CTest, DEBUG, "CURL output: [" - << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl); - cmCTestLog(m_CTest, DEBUG, "CURL debug output: [" - << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]" << std::endl); + if ( chunk.size() > 0 ) + { + cmCTestLog(this->CTest, DEBUG, "CURL output: [" + << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" + << std::endl); + } + if ( chunkDebug.size() > 0 ) + { + cmCTestLog(this->CTest, DEBUG, "CURL debug output: [" + << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) + << "]" << std::endl); + } // always cleanup ::curl_easy_cleanup(curl); - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl); } } - ::curl_global_cleanup(); - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Dart server triggered..." << std::endl); + ::curl_global_cleanup(); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Dart server triggered..." + << std::endl); return true; } //---------------------------------------------------------------------------- bool cmCTestSubmitHandler::SubmitUsingSCP( - const cmStdString& scp_command, - const cmStdString& localprefix, + const cmStdString& scp_command, + const cmStdString& localprefix, const std::set& files, - const cmStdString& remoteprefix, + const cmStdString& remoteprefix, const cmStdString& url) { if ( !scp_command.size() || !localprefix.size() || @@ -494,7 +561,7 @@ int problems = 0; - cmCTest::tm_SetOfStrings::const_iterator file; + cmCTest::SetOfStrings::const_iterator file; for ( file = files.begin(); file != files.end(); ++file ) { int retVal; @@ -506,9 +573,10 @@ argv[1] = lfname.c_str(); std::string rfname = url + "/" + remoteprefix + *file; argv[2] = rfname.c_str(); - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Execute \"" << argv[0] << "\" \"" << argv[1] << "\" \"" + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Execute \"" << argv[0] + << "\" \"" << argv[1] << "\" \"" << argv[2] << "\"" << std::endl); - *m_LogFile << "Execute \"" << argv[0] << "\" \"" << argv[1] << "\" \"" + *this->LogFile << "Execute \"" << argv[0] << "\" \"" << argv[1] << "\" \"" << argv[2] << "\"" << std::endl; cmsysProcess_SetCommand(cp, &*argv.begin()); @@ -518,7 +586,8 @@ while(cmsysProcess_WaitForData(cp, &data, &length, 0)) { - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, cmCTestLogWrite(data, length)); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + cmCTestLogWrite(data, length)); } cmsysProcess_WaitForExit(cp, 0); @@ -530,29 +599,32 @@ retVal = cmsysProcess_GetExitValue(cp); if ( retVal != 0 ) { - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "\tSCP returned: " << retVal << std::endl); - *m_LogFile << "\tSCP returned: " << retVal << std::endl; + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "\tSCP returned: " + << retVal << std::endl); + *this->LogFile << "\tSCP returned: " << retVal << std::endl; problems ++; } } else if(result == cmsysProcess_State_Exception) { retVal = cmsysProcess_GetExitException(cp); - cmCTestLog(m_CTest, ERROR_MESSAGE, "\tThere was an exception: " << retVal << std::endl); - *m_LogFile << "\tThere was an exception: " << retVal << std::endl; + cmCTestLog(this->CTest, ERROR_MESSAGE, "\tThere was an exception: " + << retVal << std::endl); + *this->LogFile << "\tThere was an exception: " << retVal << std::endl; problems ++; } else if(result == cmsysProcess_State_Expired) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "\tThere was a timeout" << std::endl); - *m_LogFile << "\tThere was a timeout" << std::endl; + cmCTestLog(this->CTest, ERROR_MESSAGE, "\tThere was a timeout" + << std::endl); + *this->LogFile << "\tThere was a timeout" << std::endl; problems ++; - } + } else if(result == cmsysProcess_State_Error) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "\tError executing SCP: " + cmCTestLog(this->CTest, ERROR_MESSAGE, "\tError executing SCP: " << cmsysProcess_GetErrorString(cp) << std::endl); - *m_LogFile << "\tError executing SCP: " + *this->LogFile << "\tError executing SCP: " << cmsysProcess_GetErrorString(cp) << std::endl; problems ++; } @@ -566,9 +638,9 @@ } //---------------------------------------------------------------------------- -bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix, +bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix, const std::set& files, - const cmStdString& remoteprefix, + const cmStdString& remoteprefix, const cmStdString& url) { xmlrpc_env env; @@ -583,8 +655,9 @@ xmlrpc_env_init(&env); /* Call the famous server at UserLand. */ - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submitting to: " << realURL.c_str() << " (" << remoteprefix.c_str() << ")" << std::endl); - cmCTest::tm_SetOfStrings::const_iterator file; + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Submitting to: " + << realURL.c_str() << " (" << remoteprefix.c_str() << ")" << std::endl); + cmCTest::SetOfStrings::const_iterator file; for ( file = files.begin(); file != files.end(); ++file ) { xmlrpc_value *result; @@ -594,11 +667,13 @@ { local_file = localprefix + "/" + *file; } - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submit file: " << local_file.c_str() << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Submit file: " + << local_file.c_str() << std::endl); struct stat st; if ( ::stat(local_file.c_str(), &st) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Cannot find file: " << local_file.c_str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find file: " + << local_file.c_str() << std::endl); return false; } @@ -606,7 +681,8 @@ FILE* fp = fopen(local_file.c_str(), "rb"); if ( !fp ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Cannot open file: " << local_file.c_str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot open file: " + << local_file.c_str() << std::endl); return false; } @@ -615,7 +691,8 @@ { delete [] fileBuffer; fclose(fp); - cmCTestLog(m_CTest, ERROR_MESSAGE, " Cannot read file: " << local_file.c_str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot read file: " + << local_file.c_str() << std::endl); return false; } fclose(fp); @@ -629,7 +706,8 @@ if ( env.fault_occurred ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Submission problem: " << env.fault_string << " (" << env.fault_code << ")" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, " Submission problem: " + << env.fault_string << " (" << env.fault_code << ")" << std::endl); xmlrpc_env_clean(&env); xmlrpc_client_cleanup(); return false; @@ -650,21 +728,24 @@ //---------------------------------------------------------------------------- int cmCTestSubmitHandler::ProcessHandler() { - const std::string &buildDirectory = m_CTest->GetCTestConfiguration("BuildDirectory"); + const std::string &buildDirectory + = this->CTest->GetCTestConfiguration("BuildDirectory"); if ( buildDirectory.size() == 0 ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot find BuildDirectory key in the DartConfiguration.tcl" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Cannot find BuildDirectory key in the DartConfiguration.tcl" + << std::endl); return -1; } if ( getenv("HTTP_PROXY") ) { - m_HTTPProxyType = 1; - m_HTTPProxy = getenv("HTTP_PROXY"); + this->HTTPProxyType = 1; + this->HTTPProxy = getenv("HTTP_PROXY"); if ( getenv("HTTP_PROXY_PORT") ) { - m_HTTPProxy += ":"; - m_HTTPProxy += getenv("HTTP_PROXY_PORT"); + this->HTTPProxy += ":"; + this->HTTPProxy += getenv("HTTP_PROXY_PORT"); } if ( getenv("HTTP_PROXY_TYPE") ) { @@ -672,36 +753,36 @@ // HTTP/SOCKS4/SOCKS5 if ( type == "HTTP" ) { - m_HTTPProxyType = 1; + this->HTTPProxyType = 1; } else if ( type == "SOCKS4" ) { - m_HTTPProxyType = 2; + this->HTTPProxyType = 2; } else if ( type == "SOCKS5" ) { - m_HTTPProxyType = 3; + this->HTTPProxyType = 3; } } if ( getenv("HTTP_PROXY_USER") ) { - m_HTTPProxyAuth = getenv("HTTP_PROXY_USER"); + this->HTTPProxyAuth = getenv("HTTP_PROXY_USER"); } if ( getenv("HTTP_PROXY_PASSWD") ) { - m_HTTPProxyAuth += ":"; - m_HTTPProxyAuth += getenv("HTTP_PROXY_PASSWD"); + this->HTTPProxyAuth += ":"; + this->HTTPProxyAuth += getenv("HTTP_PROXY_PASSWD"); } } if ( getenv("FTP_PROXY") ) { - m_FTPProxyType = 1; - m_FTPProxy = getenv("FTP_PROXY"); + this->FTPProxyType = 1; + this->FTPProxy = getenv("FTP_PROXY"); if ( getenv("FTP_PROXY_PORT") ) { - m_FTPProxy += ":"; - m_FTPProxy += getenv("FTP_PROXY_PORT"); + this->FTPProxy += ":"; + this->FTPProxy += getenv("FTP_PROXY_PORT"); } if ( getenv("FTP_PROXY_TYPE") ) { @@ -709,67 +790,72 @@ // HTTP/SOCKS4/SOCKS5 if ( type == "HTTP" ) { - m_FTPProxyType = 1; + this->FTPProxyType = 1; } else if ( type == "SOCKS4" ) { - m_FTPProxyType = 2; + this->FTPProxyType = 2; } else if ( type == "SOCKS5" ) { - m_FTPProxyType = 3; + this->FTPProxyType = 3; } } } - if ( m_HTTPProxy.size() > 0 ) + if ( this->HTTPProxy.size() > 0 ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Use HTTP Proxy: " << m_HTTPProxy << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Use HTTP Proxy: " + << this->HTTPProxy << std::endl); } - if ( m_FTPProxy.size() > 0 ) + if ( this->FTPProxy.size() > 0 ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Use FTP Proxy: " << m_FTPProxy << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Use FTP Proxy: " + << this->FTPProxy << std::endl); } cmGeneratedFileStream ofs; this->StartLogFile("Submit", ofs); - cmCTest::tm_SetOfStrings files; + cmCTest::SetOfStrings files; std::string prefix = this->GetSubmitResultsPrefix(); // TODO: // Check if test is enabled - m_CTest->AddIfExists(files, "Update.xml"); - m_CTest->AddIfExists(files, "Configure.xml"); - m_CTest->AddIfExists(files, "Build.xml"); - m_CTest->AddIfExists(files, "Test.xml"); - if ( m_CTest->AddIfExists(files, "Coverage.xml") ) + this->CTest->AddIfExists(files, "Update.xml"); + this->CTest->AddIfExists(files, "Configure.xml"); + this->CTest->AddIfExists(files, "Build.xml"); + this->CTest->AddIfExists(files, "Test.xml"); + if ( this->CTest->AddIfExists(files, "Coverage.xml") ) { - cmCTest::tm_VectorOfStrings gfiles; - std::string gpath = buildDirectory + "/Testing/" + m_CTest->GetCurrentTag(); + cmCTest::VectorOfStrings gfiles; + std::string gpath + = buildDirectory + "/Testing/" + this->CTest->GetCurrentTag(); std::string::size_type glen = gpath.size() + 1; gpath = gpath + "/CoverageLog*"; - cmCTestLog(m_CTest, DEBUG, "Globbing for: " << gpath.c_str() << std::endl); + cmCTestLog(this->CTest, DEBUG, "Globbing for: " << gpath.c_str() + << std::endl); if ( cmSystemTools::SimpleGlob(gpath, gfiles, 1) ) { size_t cc; for ( cc = 0; cc < gfiles.size(); cc ++ ) { gfiles[cc] = gfiles[cc].substr(glen); - cmCTestLog(m_CTest, DEBUG, "Glob file: " << gfiles[cc].c_str() << std::endl); + cmCTestLog(this->CTest, DEBUG, "Glob file: " << gfiles[cc].c_str() + << std::endl); files.insert(gfiles[cc]); } } else { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem globbing" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem globbing" << std::endl); } } - m_CTest->AddIfExists(files, "DynamicAnalysis.xml"); - m_CTest->AddIfExists(files, "Purify.xml"); - m_CTest->AddIfExists(files, "Notes.xml"); - - cmCTest::tm_SetOfStrings::iterator it; - for ( it = m_CTest->GetSubmitFiles()->begin(); - it != m_CTest->GetSubmitFiles()->end(); + this->CTest->AddIfExists(files, "DynamicAnalysis.xml"); + this->CTest->AddIfExists(files, "Purify.xml"); + this->CTest->AddIfExists(files, "Notes.xml"); + + cmCTest::SetOfStrings::iterator it; + for ( it = this->CTest->GetSubmitFiles()->begin(); + it != this->CTest->GetSubmitFiles()->end(); ++ it ) { files.insert(files.end(), *it); @@ -785,145 +871,184 @@ cnt ++; } } - cmCTestLog(m_CTest, HANDLER_OUTPUT, "Submit files (using " << m_CTest->GetCTestConfiguration("DropMethod") << ")" + cmCTestLog(this->CTest, HANDLER_OUTPUT, "Submit files (using " + << this->CTest->GetCTestConfiguration("DropMethod") << ")" << std::endl); this->SetLogFile(&ofs); - if ( m_CTest->GetCTestConfiguration("DropMethod") == "" || - m_CTest->GetCTestConfiguration("DropMethod") == "ftp" ) + if ( this->CTest->GetCTestConfiguration("DropMethod") == "" || + this->CTest->GetCTestConfiguration("DropMethod") == "ftp" ) { ofs << "Using drop method: FTP" << std::endl; - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using FTP submit method" << std::endl + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Using FTP submit method" + << std::endl << " Drop site: ftp://"); std::string url = "ftp://"; - url += cmCTest::MakeURLSafe(m_CTest->GetCTestConfiguration("DropSiteUser")) + ":" + - cmCTest::MakeURLSafe(m_CTest->GetCTestConfiguration("DropSitePassword")) + "@" + - m_CTest->GetCTestConfiguration("DropSite") + - cmCTest::MakeURLSafe(m_CTest->GetCTestConfiguration("DropLocation")); - if ( m_CTest->GetCTestConfiguration("DropSiteUser").size() > 0 ) - { - cmCTestLog(m_CTest, HANDLER_OUTPUT, m_CTest->GetCTestConfiguration("DropSiteUser").c_str()); - if ( m_CTest->GetCTestConfiguration("DropSitePassword").size() > 0 ) - { - cmCTestLog(m_CTest, HANDLER_OUTPUT, ":******"); - } - cmCTestLog(m_CTest, HANDLER_OUTPUT, "@"); - } - cmCTestLog(m_CTest, HANDLER_OUTPUT, m_CTest->GetCTestConfiguration("DropSite") - << m_CTest->GetCTestConfiguration("DropLocation") << std::endl); - if ( !this->SubmitUsingFTP(buildDirectory+"/Testing/"+m_CTest->GetCurrentTag(), + url += cmCTest::MakeURLSafe( + this->CTest->GetCTestConfiguration("DropSiteUser")) + ":" + + cmCTest::MakeURLSafe(this->CTest->GetCTestConfiguration( + "DropSitePassword")) + "@" + + this->CTest->GetCTestConfiguration("DropSite") + + cmCTest::MakeURLSafe( + this->CTest->GetCTestConfiguration("DropLocation")); + if ( this->CTest->GetCTestConfiguration("DropSiteUser").size() > 0 ) + { + cmCTestLog(this->CTest, HANDLER_OUTPUT, + this->CTest->GetCTestConfiguration( + "DropSiteUser").c_str()); + if ( this->CTest->GetCTestConfiguration("DropSitePassword").size() > 0 ) + { + cmCTestLog(this->CTest, HANDLER_OUTPUT, ":******"); + } + cmCTestLog(this->CTest, HANDLER_OUTPUT, "@"); + } + cmCTestLog(this->CTest, HANDLER_OUTPUT, + this->CTest->GetCTestConfiguration("DropSite") + << this->CTest->GetCTestConfiguration("DropLocation") << std::endl); + if ( !this->SubmitUsingFTP(buildDirectory + "/Testing/" + + this->CTest->GetCurrentTag(), files, prefix, url) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Problems when submitting via FTP" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + " Problems when submitting via FTP" + << std::endl); ofs << " Problems when submitting via FTP" << std::endl; return -1; } - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using HTTP trigger method" << std::endl - << " Trigger site: " << m_CTest->GetCTestConfiguration("TriggerSite") << std::endl); - if ( !this->TriggerUsingHTTP(files, prefix, m_CTest->GetCTestConfiguration("TriggerSite")) ) + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Using HTTP trigger method" + << std::endl + << " Trigger site: " + << this->CTest->GetCTestConfiguration("TriggerSite") + << std::endl); + if ( !this->TriggerUsingHTTP(files, prefix, + this->CTest->GetCTestConfiguration("TriggerSite")) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Problems when triggering via HTTP" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + " Problems when triggering via HTTP" << std::endl); ofs << " Problems when triggering via HTTP" << std::endl; return -1; } - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submission successful" << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Submission successful" + << std::endl); ofs << " Submission successful" << std::endl; return 0; } - else if ( m_CTest->GetCTestConfiguration("DropMethod") == "http" ) + else if ( this->CTest->GetCTestConfiguration("DropMethod") == "http" ) { ofs << "Using drop method: HTTP" << std::endl; - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using HTTP submit method" << std::endl + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Using HTTP submit method" + << std::endl << " Drop site: http://"); std::string url = "http://"; - if ( m_CTest->GetCTestConfiguration("DropSiteUser").size() > 0 ) + if ( this->CTest->GetCTestConfiguration("DropSiteUser").size() > 0 ) { - url += m_CTest->GetCTestConfiguration("DropSiteUser"); - cmCTestLog(m_CTest, HANDLER_OUTPUT, m_CTest->GetCTestConfiguration("DropSiteUser").c_str()); - if ( m_CTest->GetCTestConfiguration("DropSitePassword").size() > 0 ) + url += this->CTest->GetCTestConfiguration("DropSiteUser"); + cmCTestLog(this->CTest, HANDLER_OUTPUT, + this->CTest->GetCTestConfiguration("DropSiteUser").c_str()); + if ( this->CTest->GetCTestConfiguration("DropSitePassword").size() > 0 ) { - url += ":" + m_CTest->GetCTestConfiguration("DropSitePassword"); - cmCTestLog(m_CTest, HANDLER_OUTPUT, ":******"); + url += ":" + this->CTest->GetCTestConfiguration("DropSitePassword"); + cmCTestLog(this->CTest, HANDLER_OUTPUT, ":******"); } url += "@"; - cmCTestLog(m_CTest, HANDLER_OUTPUT, "@"); + cmCTestLog(this->CTest, HANDLER_OUTPUT, "@"); } - url += m_CTest->GetCTestConfiguration("DropSite") + m_CTest->GetCTestConfiguration("DropLocation"); - cmCTestLog(m_CTest, HANDLER_OUTPUT, m_CTest->GetCTestConfiguration("DropSite") - << m_CTest->GetCTestConfiguration("DropLocation") << std::endl); - if ( !this->SubmitUsingHTTP(buildDirectory +"/Testing/"+m_CTest->GetCurrentTag(), files, prefix, url) ) + url += this->CTest->GetCTestConfiguration("DropSite") + + this->CTest->GetCTestConfiguration("DropLocation"); + cmCTestLog(this->CTest, HANDLER_OUTPUT, + this->CTest->GetCTestConfiguration("DropSite") + << this->CTest->GetCTestConfiguration("DropLocation") << std::endl); + if ( !this->SubmitUsingHTTP(buildDirectory + "/Testing/" + + this->CTest->GetCurrentTag(), files, prefix, url) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Problems when submitting via HTTP" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + " Problems when submitting via HTTP" << std::endl); ofs << " Problems when submitting via HTTP" << std::endl; return -1; } - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using HTTP trigger method" << std::endl - << " Trigger site: " << m_CTest->GetCTestConfiguration("TriggerSite") << std::endl); - if ( !this->TriggerUsingHTTP(files, prefix, m_CTest->GetCTestConfiguration("TriggerSite")) ) + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Using HTTP trigger method" + << std::endl + << " Trigger site: " + << this->CTest->GetCTestConfiguration("TriggerSite") + << std::endl); + if ( !this->TriggerUsingHTTP(files, prefix, + this->CTest->GetCTestConfiguration("TriggerSite")) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Problems when triggering via HTTP" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + " Problems when triggering via HTTP" << std::endl); ofs << " Problems when triggering via HTTP" << std::endl; return -1; } - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submission successful" << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Submission successful" + << std::endl); ofs << " Submission successful" << std::endl; return 0; } - else if ( m_CTest->GetCTestConfiguration("DropMethod") == "xmlrpc" ) + else if ( this->CTest->GetCTestConfiguration("DropMethod") == "xmlrpc" ) { ofs << "Using drop method: XML-RPC" << std::endl; - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using XML-RPC submit method" << std::endl); - std::string url = m_CTest->GetCTestConfiguration("DropSite"); - prefix = m_CTest->GetCTestConfiguration("DropLocation"); - if ( !this->SubmitUsingXMLRPC(buildDirectory+"/Testing/"+m_CTest->GetCurrentTag(), files, prefix, url) ) + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Using XML-RPC submit method" + << std::endl); + std::string url = this->CTest->GetCTestConfiguration("DropSite"); + prefix = this->CTest->GetCTestConfiguration("DropLocation"); + if ( !this->SubmitUsingXMLRPC(buildDirectory + "/Testing/" + + this->CTest->GetCurrentTag(), files, prefix, url) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Problems when submitting via XML-RPC" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + " Problems when submitting via XML-RPC" << std::endl); ofs << " Problems when submitting via XML-RPC" << std::endl; return -1; } - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submission successful" << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Submission successful" + << std::endl); ofs << " Submission successful" << std::endl; return 0; } - else if ( m_CTest->GetCTestConfiguration("DropMethod") == "scp" ) + else if ( this->CTest->GetCTestConfiguration("DropMethod") == "scp" ) { std::string url; std::string oldWorkingDirectory; - if ( m_CTest->GetCTestConfiguration("DropSiteUser").size() > 0 ) + if ( this->CTest->GetCTestConfiguration("DropSiteUser").size() > 0 ) { - url += m_CTest->GetCTestConfiguration("DropSiteUser") + "@"; + url += this->CTest->GetCTestConfiguration("DropSiteUser") + "@"; } - url += m_CTest->GetCTestConfiguration("DropSite") + ":" + m_CTest->GetCTestConfiguration("DropLocation"); + url += this->CTest->GetCTestConfiguration("DropSite") + ":" + + this->CTest->GetCTestConfiguration("DropLocation"); // change to the build directory so that we can uses a relative path // on windows since scp dosn't support "c:" a drive in the path oldWorkingDirectory = cmSystemTools::GetCurrentWorkingDirectory(); cmSystemTools::ChangeDirectory(buildDirectory.c_str()); - if ( !this->SubmitUsingSCP(m_CTest->GetCTestConfiguration("ScpCommand"), - "Testing/"+m_CTest->GetCurrentTag(), files, prefix, url) ) + if ( !this->SubmitUsingSCP( + this->CTest->GetCTestConfiguration("ScpCommand"), + "Testing/"+this->CTest->GetCurrentTag(), files, prefix, url) ) { cmSystemTools::ChangeDirectory(oldWorkingDirectory.c_str()); - cmCTestLog(m_CTest, ERROR_MESSAGE, " Problems when submitting via SCP" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + " Problems when submitting via SCP" + << std::endl); ofs << " Problems when submitting via SCP" << std::endl; return -1; } cmSystemTools::ChangeDirectory(oldWorkingDirectory.c_str()); - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submission successful" << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Submission successful" + << std::endl); ofs << " Submission successful" << std::endl; return 0; } - cmCTestLog(m_CTest, ERROR_MESSAGE, " Unknown submission method: \"" << m_CTest->GetCTestConfiguration("DropMethod") << "\"" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, " Unknown submission method: \"" + << this->CTest->GetCTestConfiguration("DropMethod") << "\"" << std::endl); return -1; } //---------------------------------------------------------------------------- std::string cmCTestSubmitHandler::GetSubmitResultsPrefix() { - std::string name = m_CTest->GetCTestConfiguration("Site") + - "___" + m_CTest->GetCTestConfiguration("BuildName") + - "___" + m_CTest->GetCurrentTag() + "-" + - m_CTest->GetTestModelString() + "___XML___"; + std::string name = this->CTest->GetCTestConfiguration("Site") + + "___" + this->CTest->GetCTestConfiguration("BuildName") + + "___" + this->CTest->GetCurrentTag() + "-" + + this->CTest->GetTestModelString() + "___XML___"; return name; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestSubmitHandler.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestSubmitHandler.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestSubmitHandler.h 2005-06-24 01:04:18.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestSubmitHandler.h 2006-03-11 04:03:09.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestSubmitHandler.h,v $ Language: C++ - Date: $Date: 2005/06/23 17:04:18 $ - Version: $Revision: 1.3 $ + Date: $Date: 2006/03/10 20:03:09 $ + Version: $Revision: 1.4 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -31,7 +31,7 @@ cmTypeMacro(cmCTestSubmitHandler, cmCTestGenericHandler); cmCTestSubmitHandler(); - ~cmCTestSubmitHandler() { m_LogFile = 0; } + ~cmCTestSubmitHandler() { this->LogFile = 0; } /* * The main entry point for this class @@ -41,7 +41,7 @@ void Initialize(); private: - void SetLogFile(std::ostream* ost) { m_LogFile = ost; } + void SetLogFile(std::ostream* ost) { this->LogFile = ost; } /** * Submit file using various ways @@ -71,12 +71,12 @@ std::string GetSubmitResultsPrefix(); - cmStdString m_HTTPProxy; - int m_HTTPProxyType; - cmStdString m_HTTPProxyAuth; - cmStdString m_FTPProxy; - int m_FTPProxyType; - std::ostream* m_LogFile; + cmStdString HTTPProxy; + int HTTPProxyType; + cmStdString HTTPProxyAuth; + cmStdString FTPProxy; + int FTPProxyType; + std::ostream* LogFile; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestTestCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestTestCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestTestCommand.cxx 2005-10-07 03:28:33.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestTestCommand.cxx 2006-03-16 00:02:08.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestTestCommand.cxx,v $ Language: C++ - Date: $Date: 2005/10/06 19:28:33 $ - Version: $Revision: 1.4.2.2 $ + Date: $Date: 2006/03/15 16:02:08 $ + Version: $Revision: 1.10 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -21,17 +21,18 @@ cmCTestTestCommand::cmCTestTestCommand() { - m_Arguments[ctt_START] = "START"; - m_Arguments[ctt_END] = "END"; - m_Arguments[ctt_STRIDE] = "STRIDE"; - m_Arguments[ctt_LAST] = 0; - m_Last = ctt_LAST; + this->Arguments[ctt_START] = "START"; + this->Arguments[ctt_END] = "END"; + this->Arguments[ctt_STRIDE] = "STRIDE"; + this->Arguments[ctt_LAST] = 0; + this->Last = ctt_LAST; } cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() { - const char* ctestTimeout = m_Makefile->GetDefinition("CTEST_TEST_TIMEOUT"); - double timeout = m_CTest->GetTimeOut(); + const char* ctestTimeout = + this->Makefile->GetDefinition("CTEST_TEST_TIMEOUT"); + double timeout = this->CTest->GetTimeOut(); if ( ctestTimeout ) { timeout = atof(ctestTimeout); @@ -44,32 +45,34 @@ timeout = 600; } } - m_CTest->SetTimeOut(timeout); + this->CTest->SetTimeOut(timeout); cmCTestGenericHandler* handler = this->InitializeActualHandler(); - if ( m_Values[ctt_START] || m_Values[ctt_END] || m_Values[ctt_STRIDE] ) + if ( this->Values[ctt_START] || this->Values[ctt_END] || + this->Values[ctt_STRIDE] ) { cmOStringStream testsToRunString; - if ( m_Values[ctt_START] ) + if ( this->Values[ctt_START] ) { - testsToRunString << m_Values[ctt_START]; + testsToRunString << this->Values[ctt_START]; } testsToRunString << ","; - if ( m_Values[ctt_END] ) + if ( this->Values[ctt_END] ) { - testsToRunString << m_Values[ctt_END]; + testsToRunString << this->Values[ctt_END]; } testsToRunString << ","; - if ( m_Values[ctt_STRIDE] ) + if ( this->Values[ctt_STRIDE] ) { - testsToRunString << m_Values[ctt_STRIDE]; + testsToRunString << this->Values[ctt_STRIDE]; } - handler->SetOption("TestsToRunInformation", testsToRunString.str().c_str()); + handler->SetOption("TestsToRunInformation", + testsToRunString.str().c_str()); } return handler; } cmCTestGenericHandler* cmCTestTestCommand::InitializeActualHandler() { - return m_CTest->GetInitializedHandler("test"); + return this->CTest->GetInitializedHandler("test"); } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestTestCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestTestCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestTestCommand.h 2005-10-07 03:28:33.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestTestCommand.h 2006-03-11 04:03:09.000000000 +0800 @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestTestCommand.h,v $ Language: C++ - Date: $Date: 2005/10/06 19:28:33 $ - Version: $Revision: 1.3.2.1 $ + Date: $Date: 2006/03/10 20:03:09 $ + Version: $Revision: 1.5 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -38,8 +38,8 @@ virtual cmCommand* Clone() { cmCTestTestCommand* ni = new cmCTestTestCommand; - ni->m_CTest = this->m_CTest; - ni->m_CTestScriptHandler = this->m_CTestScriptHandler; + ni->CTest = this->CTest; + ni->CTestScriptHandler = this->CTestScriptHandler; return ni; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestTestHandler.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestTestHandler.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestTestHandler.cxx 2005-11-24 01:33:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestTestHandler.cxx 2006-03-17 00:29:12.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestTestHandler.cxx,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:39 $ - Version: $Revision: 1.23.2.7 $ + Date: $Date: 2006/03/16 16:29:12 $ + Version: $Revision: 1.40 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -29,7 +29,7 @@ #include "cmCommand.h" #include "cmSystemTools.h" -#include +#include #include #include @@ -42,10 +42,10 @@ /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { cmCTestSubdirCommand* c = new cmCTestSubdirCommand; - c->m_TestHandler = m_TestHandler; + c->TestHandler = this->TestHandler; return c; } @@ -66,7 +66,7 @@ cmTypeMacro(cmCTestSubdirCommand, cmCommand); - cmCTestTestHandler* m_TestHandler; + cmCTestTestHandler* TestHandler; }; //---------------------------------------------------------------------- @@ -78,14 +78,14 @@ return false; } std::vector::const_iterator it; - std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); + std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); for ( it = args.begin(); it != args.end(); ++ it ) { cmSystemTools::ChangeDirectory(cwd.c_str()); std::string fname = cwd; fname += "/"; fname += *it; - + if ( !cmSystemTools::FileExists(fname.c_str()) ) { // No subdirectory? So what... @@ -111,7 +111,8 @@ } fname += "/"; fname += testFilename; - bool readit = m_Makefile->ReadListFile( m_Makefile->GetCurrentListFile(), fname.c_str()); + bool readit = this->Makefile->ReadListFile( this->Makefile->GetCurrentListFile(), + fname.c_str()); cmSystemTools::ChangeDirectory(cwd.c_str()); if(!readit) { @@ -131,10 +132,10 @@ /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { cmCTestAddTestCommand* c = new cmCTestAddTestCommand; - c->m_TestHandler = m_TestHandler; + c->TestHandler = this->TestHandler; return c; } @@ -155,7 +156,7 @@ cmTypeMacro(cmCTestAddTestCommand, cmCommand); - cmCTestTestHandler* m_TestHandler; + cmCTestTestHandler* TestHandler; }; //---------------------------------------------------------------------- @@ -166,7 +167,7 @@ this->SetError("called with incorrect number of arguments"); return false; } - return m_TestHandler->AddTest(args); + return this->TestHandler->AddTest(args); } //---------------------------------------------------------------------- @@ -176,10 +177,11 @@ /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { - cmCTestSetTestsPropertiesCommand* c = new cmCTestSetTestsPropertiesCommand; - c->m_TestHandler = m_TestHandler; + cmCTestSetTestsPropertiesCommand* c + = new cmCTestSetTestsPropertiesCommand; + c->TestHandler = this->TestHandler; return c; } @@ -200,13 +202,14 @@ cmTypeMacro(cmCTestSetTestsPropertiesCommand, cmCommand); - cmCTestTestHandler* m_TestHandler; + cmCTestTestHandler* TestHandler; }; //---------------------------------------------------------------------- -bool cmCTestSetTestsPropertiesCommand::InitialPass(std::vector const& args) +bool cmCTestSetTestsPropertiesCommand::InitialPass( + std::vector const& args) { - return m_TestHandler->SetTestsProperties(args); + return this->TestHandler->SetTestsProperties(args); } //---------------------------------------------------------------------- @@ -224,15 +227,15 @@ tryPath = dir; tryPath += "/"; } - + if (subdir && strcmp(subdir,"")) { tryPath += subdir; tryPath += "/"; } - + tryPath += file; - + // find the file without an executable extension if(cmSystemTools::FileExists(tryPath.c_str())) { @@ -247,7 +250,7 @@ *fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str()); return true; } - + // not found at all, return false return false; } @@ -255,9 +258,9 @@ //---------------------------------------------------------------------- // get the next number in a string with numbers separated by , // pos is the start of the search and pos2 is the end of the search -// pos becomes pos2 after a call to GetNextNumber. +// pos becomes pos2 after a call to GetNextNumber. // -1 is returned at the end of the list. -inline int GetNextNumber(std::string const& in, +inline int GetNextNumber(std::string const& in, int& val, std::string::size_type& pos, std::string::size_type& pos2) @@ -293,9 +296,9 @@ //---------------------------------------------------------------------- // get the next number in a string with numbers separated by , // pos is the start of the search and pos2 is the end of the search -// pos becomes pos2 after a call to GetNextNumber. +// pos becomes pos2 after a call to GetNextNumber. // -1 is returned at the end of the list. -inline int GetNextRealNumber(std::string const& in, +inline int GetNextRealNumber(std::string const& in, double& val, std::string::size_type& pos, std::string::size_type& pos2) @@ -328,24 +331,24 @@ } } - + //---------------------------------------------------------------------- cmCTestTestHandler::cmCTestTestHandler() { - m_UseUnion = false; - - m_UseIncludeRegExp = false; - m_UseExcludeRegExp = false; - m_UseExcludeRegExpFirst = false; - - m_CustomMaximumPassedTestOutputSize = 1 * 1024; - m_CustomMaximumFailedTestOutputSize = 300 * 1024; - - m_MemCheck = false; + this->UseUnion = false; + + this->UseIncludeRegExpFlag = false; + this->UseExcludeRegExpFlag = false; + this->UseExcludeRegExpFirst = false; + + this->CustomMaximumPassedTestOutputSize = 1 * 1024; + this->CustomMaximumFailedTestOutputSize = 300 * 1024; - m_LogFile = 0; + this->MemCheck = false; - m_DartStuff.compile("()"); + this->LogFile = 0; + + this->DartStuff.compile("()"); } //---------------------------------------------------------------------- @@ -353,56 +356,57 @@ { this->Superclass::Initialize(); - m_ElapsedTestingTime = -1; + this->ElapsedTestingTime = -1; - m_TestResults.clear(); + this->TestResults.clear(); - m_CustomTestsIgnore.clear(); - m_StartTest = ""; - m_EndTest = ""; - - m_CustomPreTest.clear(); - m_CustomPostTest.clear(); - m_CustomMaximumPassedTestOutputSize = 1 * 1024; - m_CustomMaximumFailedTestOutputSize = 300 * 1024; - - m_TestsToRun.clear(); - - m_UseIncludeRegExp = false; - m_UseExcludeRegExp = false; - m_UseExcludeRegExpFirst = false; - m_IncludeRegExp = ""; - m_ExcludeRegExp = ""; + this->CustomTestsIgnore.clear(); + this->StartTest = ""; + this->EndTest = ""; + + this->CustomPreTest.clear(); + this->CustomPostTest.clear(); + this->CustomMaximumPassedTestOutputSize = 1 * 1024; + this->CustomMaximumFailedTestOutputSize = 300 * 1024; + + this->TestsToRun.clear(); + + this->UseIncludeRegExpFlag = false; + this->UseExcludeRegExpFlag = false; + this->UseExcludeRegExpFirst = false; + this->IncludeRegExp = ""; + this->ExcludeRegExp = ""; TestsToRunString = ""; - m_UseUnion = false; - m_TestList.clear(); + this->UseUnion = false; + this->TestList.clear(); } //---------------------------------------------------------------------- void cmCTestTestHandler::PopulateCustomVectors(cmMakefile *mf) { - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_PRE_TEST", - m_CustomPreTest); - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_POST_TEST", - m_CustomPostTest); + cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_PRE_TEST", + this->CustomPreTest); + cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_POST_TEST", + this->CustomPostTest); cmCTest::PopulateCustomVector(mf, - "CTEST_CUSTOM_TESTS_IGNORE", - m_CustomTestsIgnore); - cmCTest::PopulateCustomInteger(mf, - "CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE", - m_CustomMaximumPassedTestOutputSize); - cmCTest::PopulateCustomInteger(mf, - "CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE", - m_CustomMaximumFailedTestOutputSize); + "CTEST_CUSTOM_TESTS_IGNORE", + this->CustomTestsIgnore); + cmCTest::PopulateCustomInteger(mf, + "CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE", + this->CustomMaximumPassedTestOutputSize); + cmCTest::PopulateCustomInteger(mf, + "CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE", + this->CustomMaximumFailedTestOutputSize); } //---------------------------------------------------------------------- int cmCTestTestHandler::PreProcessHandler() { - if ( !this->ExecuteCommands(m_CustomPreTest) ) + if ( !this->ExecuteCommands(this->CustomPreTest) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem executing pre-test command(s)." << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Problem executing pre-test command(s)." << std::endl); return 0; } return 1; @@ -411,9 +415,10 @@ //---------------------------------------------------------------------- int cmCTestTestHandler::PostProcessHandler() { - if ( !this->ExecuteCommands(m_CustomPostTest) ) + if ( !this->ExecuteCommands(this->CustomPostTest) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem executing post-test command(s)." << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Problem executing post-test command(s)." << std::endl); return 0; } return 1; @@ -441,17 +446,19 @@ this->SetExcludeRegExp(val); } - m_TestResults.clear(); + this->TestResults.clear(); - cmCTestLog(m_CTest, HANDLER_OUTPUT, (m_MemCheck ? "Memory check" : "Test") << " project" << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, + (this->MemCheck ? "Memory check" : "Test") + << " project" << std::endl); if ( ! this->PreProcessHandler() ) { return -1; } cmGeneratedFileStream mLogFile; - this->StartLogFile("Tests", mLogFile); - m_LogFile = &mLogFile; + this->StartLogFile((this->MemCheck ? "DynamicAnalysis" : "Test"), mLogFile); + this->LogFile = &mLogFile; std::vector passed; std::vector failed; @@ -463,21 +470,24 @@ if (total == 0) { - if ( !m_CTest->GetShowOnly() ) + if ( !this->CTest->GetShowOnly() ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "No tests were found!!!" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, "No tests were found!!!" + << std::endl); } } else { - if (m_HandlerVerbose && passed.size() && - (m_UseIncludeRegExp || m_UseExcludeRegExp)) + if (this->HandlerVerbose && passed.size() && + (this->UseIncludeRegExpFlag || this->UseExcludeRegExpFlag)) { - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, std::endl << "The following tests passed:" << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl + << "The following tests passed:" << std::endl); for(std::vector::iterator j = passed.begin(); j != passed.end(); ++j) - { - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "\t" << *j << std::endl); + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "\t" << *j + << std::endl); } } @@ -486,42 +496,46 @@ { percent = 99; } - cmCTestLog(m_CTest, HANDLER_OUTPUT, std::endl << static_cast(percent + .5) << "% tests passed, " + cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl + << static_cast(percent + .5) << "% tests passed, " << failed.size() << " tests failed out of " << total << std::endl); //fprintf(stderr,"\n%.0f%% tests passed, %i tests failed out of %i\n", // percent, int(failed.size()), total); - if (failed.size()) + if (failed.size()) { cmGeneratedFileStream ofs; - cmCTestLog(m_CTest, ERROR_MESSAGE, std::endl << "The following tests FAILED:" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, std::endl + << "The following tests FAILED:" << std::endl); this->StartLogFile("TestsFailed", ofs); std::vector::iterator ftit; - for(ftit = m_TestResults.begin(); - ftit != m_TestResults.end(); ++ftit) + for(ftit = this->TestResults.begin(); + ftit != this->TestResults.end(); ++ftit) { - if ( ftit->m_Status != cmCTestTestHandler::COMPLETED ) + if ( ftit->Status != cmCTestTestHandler::COMPLETED ) { - ofs << ftit->m_TestCount << ":" << ftit->m_Name << std::endl; - cmCTestLog(m_CTest, HANDLER_OUTPUT, "\t" << std::setw(3) << ftit->m_TestCount << " - " << ftit->m_Name.c_str() << " (" << this->GetTestStatus(ftit->m_Status) << ")" << std::endl); - //fprintf(stderr, "\t%3d - %s (%s)\n", ftit->m_TestCount, ftit->m_Name.c_str(), - // this->GetTestStatus(ftit->m_Status)); + ofs << ftit->TestCount << ":" << ftit->Name << std::endl; + cmCTestLog(this->CTest, HANDLER_OUTPUT, "\t" << std::setw(3) + << ftit->TestCount << " - " << ftit->Name.c_str() << " (" + << this->GetTestStatus(ftit->Status) << ")" << std::endl); } } } } - if ( m_CTest->GetProduceXML() ) + if ( this->CTest->GetProduceXML() ) { cmGeneratedFileStream xmlfile; - if( !this->StartResultingXML((m_MemCheck ? "DynamicAnalysis" : "Test"), xmlfile) ) + if( !this->StartResultingXML( + (this->MemCheck ? "DynamicAnalysis" : "Test"), xmlfile) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create " << (m_MemCheck ? "memory check" : "testing") + cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create " + << (this->MemCheck ? "memory check" : "testing") << " XML file" << std::endl); - m_LogFile = 0; + this->LogFile = 0; return 1; } this->GenerateDartOutput(xmlfile); @@ -529,48 +543,48 @@ if ( ! this->PostProcessHandler() ) { - m_LogFile = 0; + this->LogFile = 0; return -1; } if ( !failed.empty() ) { - m_LogFile = 0; + this->LogFile = 0; return -1; } - m_LogFile = 0; + this->LogFile = 0; return 0; } //---------------------------------------------------------------------- -void cmCTestTestHandler::ProcessDirectory(std::vector &passed, +void cmCTestTestHandler::ProcessDirectory(std::vector &passed, std::vector &failed) { std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory(); - m_TestList.clear(); + this->TestList.clear(); this->GetListOfTests(); - tm_ListOfTests::size_type tmsize = m_TestList.size(); + cmCTestTestHandler::ListOfTests::size_type tmsize = this->TestList.size(); - m_StartTest = m_CTest->CurrentTime(); + this->StartTest = this->CTest->CurrentTime(); double elapsed_time_start = cmSystemTools::GetTime(); - *m_LogFile << "Start testing: " << m_StartTest << std::endl - << "----------------------------------------------------------" - << std::endl; + *this->LogFile << "Start testing: " << this->StartTest << std::endl + << "----------------------------------------------------------" + << std::endl; // how many tests are in based on RegExp? int inREcnt = 0; - tm_ListOfTests::iterator it; - for ( it = m_TestList.begin(); it != m_TestList.end(); it ++ ) + cmCTestTestHandler::ListOfTests::iterator it; + for ( it = this->TestList.begin(); it != this->TestList.end(); it ++ ) { - if (it->m_IsInBasedOnREOptions) + if (it->IsInBasedOnREOptions) { inREcnt ++; } } // expand the test list based on the union flag - if (m_UseUnion) + if (this->UseUnion) { this->ExpandTestsToRunInformation((int)tmsize); } @@ -578,43 +592,43 @@ { this->ExpandTestsToRunInformation(inREcnt); } - + int cnt = 0; inREcnt = 0; std::string last_directory = ""; - for ( it = m_TestList.begin(); it != m_TestList.end(); it ++ ) + for ( it = this->TestList.begin(); it != this->TestList.end(); it ++ ) { cnt ++; - if (it->m_IsInBasedOnREOptions) + if (it->IsInBasedOnREOptions) { inREcnt++; } - const std::string& testname = it->m_Name; - std::vector& args = it->m_Args; + const std::string& testname = it->Name; + std::vector& args = it->Args; cmCTestTestResult cres; - cres.m_ExecutionTime = 0; - cres.m_ReturnValue = -1; - cres.m_Status = cmCTestTestHandler::NOT_RUN; - cres.m_TestCount = cnt; - - if (!(last_directory == it->m_Directory)) - { - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Changing directory into " - << it->m_Directory.c_str() << "\n"); - *m_LogFile << "Changing directory into: " << it->m_Directory.c_str() + cres.ExecutionTime = 0; + cres.ReturnValue = -1; + cres.Status = cmCTestTestHandler::NOT_RUN; + cres.TestCount = cnt; + + if (!(last_directory == it->Directory)) + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "Changing directory into " << it->Directory.c_str() << "\n"); + *this->LogFile << "Changing directory into: " << it->Directory.c_str() << std::endl; - last_directory = it->m_Directory; - cmSystemTools::ChangeDirectory(it->m_Directory.c_str()); + last_directory = it->Directory; + cmSystemTools::ChangeDirectory(it->Directory.c_str()); } - cres.m_Name = testname; - cres.m_Path = it->m_Directory.c_str(); - - if (m_UseUnion) + cres.Name = testname; + cres.Path = it->Directory.c_str(); + + if (this->UseUnion) { // if it is not in the list and not in the regexp then skip - if ((m_TestsToRun.size() && - std::find(m_TestsToRun.begin(), m_TestsToRun.end(), cnt) - == m_TestsToRun.end()) && !it->m_IsInBasedOnREOptions) + if ((this->TestsToRun.size() && + std::find(this->TestsToRun.begin(), this->TestsToRun.end(), cnt) + == this->TestsToRun.end()) && !it->IsInBasedOnREOptions) { continue; } @@ -622,55 +636,57 @@ else { // is this test in the list of tests to run? If not then skip it - if ((m_TestsToRun.size() && - std::find(m_TestsToRun.begin(), m_TestsToRun.end(), inREcnt) - == m_TestsToRun.end()) || !it->m_IsInBasedOnREOptions) + if ((this->TestsToRun.size() && + std::find(this->TestsToRun.begin(), + this->TestsToRun.end(), inREcnt) + == this->TestsToRun.end()) || !it->IsInBasedOnREOptions) { continue; } } - cmCTestLog(m_CTest, HANDLER_OUTPUT, std::setw(3) << cnt << "/"); - cmCTestLog(m_CTest, HANDLER_OUTPUT, std::setw(3) << tmsize << " "); - if ( m_MemCheck ) + cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(3) << cnt << "/"); + cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(3) << tmsize << " "); + if ( this->MemCheck ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, "Memory Check"); + cmCTestLog(this->CTest, HANDLER_OUTPUT, "Memory Check"); } else { - cmCTestLog(m_CTest, HANDLER_OUTPUT, "Testing"); + cmCTestLog(this->CTest, HANDLER_OUTPUT, "Testing"); } - cmCTestLog(m_CTest, HANDLER_OUTPUT, " "); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " "); std::string outname = testname; outname.resize(30, ' '); - *m_LogFile << cnt << "/" << tmsize << " Testing: " << testname + *this->LogFile << cnt << "/" << tmsize << " Testing: " << testname << std::endl; - if ( m_CTest->GetShowOnly() ) + if ( this->CTest->GetShowOnly() ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, outname.c_str() << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, outname.c_str() << std::endl); } else { - cmCTestLog(m_CTest, HANDLER_OUTPUT, outname.c_str()); + cmCTestLog(this->CTest, HANDLER_OUTPUT, outname.c_str()); } - - cmCTestLog(m_CTest, DEBUG, "Testing " << args[0].c_str() << " ... "); + + cmCTestLog(this->CTest, DEBUG, "Testing " << args[0].c_str() << " ... "); // find the test executable std::string actualCommand = this->FindTheExecutable(args[1].c_str()); - std::string testCommand = cmSystemTools::ConvertToOutputPath(actualCommand.c_str()); + std::string testCommand + = cmSystemTools::ConvertToOutputPath(actualCommand.c_str()); // continue if we did not find the executable if (testCommand == "") { - *m_LogFile << "Unable to find executable: " << args[1].c_str() + *this->LogFile << "Unable to find executable: " << args[1].c_str() << std::endl; - cmCTestLog(m_CTest, ERROR_MESSAGE, "Unable to find executable: " + cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to find executable: " << args[1].c_str() << std::endl); - if ( !m_CTest->GetShowOnly() ) + if ( !this->CTest->GetShowOnly() ) { - cres.m_FullCommandLine = actualCommand; - m_TestResults.push_back( cres ); + cres.FullCommandLine = actualCommand; + this->TestResults.push_back( cres ); failed.push_back(testname); continue; } @@ -698,35 +714,37 @@ int retVal = 0; - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, std::endl << (m_MemCheck?"MemCheck":"Test") << " command: " << testCommand << std::endl); - *m_LogFile << cnt << "/" << tmsize - << " Test: " << testname.c_str() << std::endl; - *m_LogFile << "Command: "; - std::vector::size_type ll; - for ( ll = 0; ll < arguments.size()-1; ll ++ ) - { - *m_LogFile << "\"" << arguments[ll] << "\" "; - } - *m_LogFile - << std::endl - << "Directory: " << it->m_Directory << std::endl - << "\"" << testname.c_str() << "\" start time: " - << m_CTest->CurrentTime() << std::endl - << "Output:" << std::endl - << "----------------------------------------------------------" - << std::endl; + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl + << (this->MemCheck?"MemCheck":"Test") << " command: " << testCommand + << std::endl); + *this->LogFile << cnt << "/" << tmsize + << " Test: " << testname.c_str() << std::endl; + *this->LogFile << "Command: "; + std::vector::size_type ll; + for ( ll = 0; ll < arguments.size()-1; ll ++ ) + { + *this->LogFile << "\"" << arguments[ll] << "\" "; + } + *this->LogFile + << std::endl + << "Directory: " << it->Directory << std::endl + << "\"" << testname.c_str() << "\" start time: " + << this->CTest->CurrentTime() << std::endl + << "Output:" << std::endl + << "----------------------------------------------------------" + << std::endl; int res = 0; double clock_start, clock_finish; clock_start = cmSystemTools::GetTime(); - if ( !m_CTest->GetShowOnly() ) + if ( !this->CTest->GetShowOnly() ) { - res = m_CTest->RunTest(arguments, &output, &retVal, m_LogFile); + res = this->CTest->RunTest(arguments, &output, &retVal, this->LogFile); } clock_finish = cmSystemTools::GetTime(); - if ( m_LogFile ) + if ( this->LogFile ) { double ttime = clock_finish - clock_start; int hours = static_cast(ttime / (60 * 60)); @@ -734,30 +752,30 @@ int seconds = static_cast(ttime) % 60; char buffer[100]; sprintf(buffer, "%02d:%02d:%02d", hours, minutes, seconds); - *m_LogFile + *this->LogFile << "----------------------------------------------------------" << std::endl - << "\"" << testname.c_str() << "\" end time: " - << m_CTest->CurrentTime() << std::endl - << "\"" << testname.c_str() << "\" time elapsed: " + << "\"" << testname.c_str() << "\" end time: " + << this->CTest->CurrentTime() << std::endl + << "\"" << testname.c_str() << "\" time elapsed: " << buffer << std::endl << "----------------------------------------------------------" << std::endl << std::endl; } - cres.m_ExecutionTime = (double)(clock_finish - clock_start); - cres.m_FullCommandLine = testCommand; + cres.ExecutionTime = (double)(clock_finish - clock_start); + cres.FullCommandLine = testCommand; - if ( !m_CTest->GetShowOnly() ) + if ( !this->CTest->GetShowOnly() ) { bool testFailed = false; std::vector::iterator passIt; bool forceFail = false; - if ( it->m_RequiredRegularExpressions.size() > 0 ) + if ( it->RequiredRegularExpressions.size() > 0 ) { bool found = false; - for ( passIt = it->m_RequiredRegularExpressions.begin(); - passIt != it->m_RequiredRegularExpressions.end(); + for ( passIt = it->RequiredRegularExpressions.begin(); + passIt != it->RequiredRegularExpressions.end(); ++ passIt ) { if ( passIt->find(output.c_str()) ) @@ -770,10 +788,10 @@ forceFail = true; } } - if ( it->m_ErrorRegularExpressions.size() > 0 ) + if ( it->ErrorRegularExpressions.size() > 0 ) { - for ( passIt = it->m_ErrorRegularExpressions.begin(); - passIt != it->m_ErrorRegularExpressions.end(); + for ( passIt = it->ErrorRegularExpressions.begin(); + passIt != it->ErrorRegularExpressions.end(); ++ passIt ) { if ( passIt->find(output.c_str()) ) @@ -783,76 +801,77 @@ } } - if (res == cmsysProcess_State_Exited && - (retVal == 0 || it->m_RequiredRegularExpressions.size()) && + if (res == cmsysProcess_State_Exited && + (retVal == 0 || it->RequiredRegularExpressions.size()) && !forceFail) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Passed"); - if ( it->m_WillFail ) + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Passed"); + if ( it->WillFail ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, " - But it should fail!"); - cres.m_Status = cmCTestTestHandler::FAILED; + cmCTestLog(this->CTest, HANDLER_OUTPUT, " - But it should fail!"); + cres.Status = cmCTestTestHandler::FAILED; testFailed = true; } else { - cres.m_Status = cmCTestTestHandler::COMPLETED; - } - cmCTestLog(m_CTest, HANDLER_OUTPUT, std::endl); + cres.Status = cmCTestTestHandler::COMPLETED; + } + cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl); } else { testFailed = true; - cres.m_Status = cmCTestTestHandler::FAILED; + cres.Status = cmCTestTestHandler::FAILED; if ( res == cmsysProcess_State_Expired ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, "***Timeout" << std::endl); - cres.m_Status = cmCTestTestHandler::TIMEOUT; + cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Timeout" << std::endl); + cres.Status = cmCTestTestHandler::TIMEOUT; } else if ( res == cmsysProcess_State_Exception ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, "***Exception: "); + cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Exception: "); switch ( retVal ) { case cmsysProcess_Exception_Fault: - cmCTestLog(m_CTest, HANDLER_OUTPUT, "SegFault"); - cres.m_Status = cmCTestTestHandler::SEGFAULT; + cmCTestLog(this->CTest, HANDLER_OUTPUT, "SegFault"); + cres.Status = cmCTestTestHandler::SEGFAULT; break; case cmsysProcess_Exception_Illegal: - cmCTestLog(m_CTest, HANDLER_OUTPUT, "Illegal"); - cres.m_Status = cmCTestTestHandler::ILLEGAL; + cmCTestLog(this->CTest, HANDLER_OUTPUT, "Illegal"); + cres.Status = cmCTestTestHandler::ILLEGAL; break; case cmsysProcess_Exception_Interrupt: - cmCTestLog(m_CTest, HANDLER_OUTPUT, "Interrupt"); - cres.m_Status = cmCTestTestHandler::INTERRUPT; + cmCTestLog(this->CTest, HANDLER_OUTPUT, "Interrupt"); + cres.Status = cmCTestTestHandler::INTERRUPT; break; case cmsysProcess_Exception_Numerical: - cmCTestLog(m_CTest, HANDLER_OUTPUT, "Numerical"); - cres.m_Status = cmCTestTestHandler::NUMERICAL; + cmCTestLog(this->CTest, HANDLER_OUTPUT, "Numerical"); + cres.Status = cmCTestTestHandler::NUMERICAL; break; default: - cmCTestLog(m_CTest, HANDLER_OUTPUT, "Other"); - cres.m_Status = cmCTestTestHandler::OTHER_FAULT; + cmCTestLog(this->CTest, HANDLER_OUTPUT, "Other"); + cres.Status = cmCTestTestHandler::OTHER_FAULT; } - cmCTestLog(m_CTest, HANDLER_OUTPUT, std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl); } else if ( res == cmsysProcess_State_Error ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, "***Bad command " << res << std::endl); - cres.m_Status = cmCTestTestHandler::BAD_COMMAND; + cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Bad command " << res + << std::endl); + cres.Status = cmCTestTestHandler::BAD_COMMAND; } else { // Force fail will also be here? - cmCTestLog(m_CTest, HANDLER_OUTPUT, "***Failed"); - if ( it->m_WillFail ) + cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Failed"); + if ( it->WillFail ) { - cres.m_Status = cmCTestTestHandler::COMPLETED; - cmCTestLog(m_CTest, HANDLER_OUTPUT, " - supposed to fail"); + cres.Status = cmCTestTestHandler::COMPLETED; + cmCTestLog(this->CTest, HANDLER_OUTPUT, " - supposed to fail"); testFailed = false; } - cmCTestLog(m_CTest, HANDLER_OUTPUT, std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl); } } if ( testFailed ) @@ -865,35 +884,38 @@ } if (!output.empty() && output.find("DartStuff.find(output.c_str())) { - std::string dartString = m_DartStuff.match(1); + std::string dartString = this->DartStuff.match(1); cmSystemTools::ReplaceString(output, dartString.c_str(),""); - cres.m_RegressionImages = this->GenerateRegressionImages(dartString); + cres.RegressionImages + = this->GenerateRegressionImages(dartString); } } } - if ( cres.m_Status == cmCTestTestHandler::COMPLETED ) + if ( cres.Status == cmCTestTestHandler::COMPLETED ) { - this->CleanTestOutput(output, static_cast(m_CustomMaximumPassedTestOutputSize)); + this->CleanTestOutput(output, static_cast( + this->CustomMaximumPassedTestOutputSize)); } else { - this->CleanTestOutput(output, static_cast(m_CustomMaximumFailedTestOutputSize)); + this->CleanTestOutput(output, static_cast( + this->CustomMaximumFailedTestOutputSize)); } - cres.m_Output = output; - cres.m_ReturnValue = retVal; - cres.m_CompletionStatus = "Completed"; - m_TestResults.push_back( cres ); + cres.Output = output; + cres.ReturnValue = retVal; + cres.CompletionStatus = "Completed"; + this->TestResults.push_back( cres ); } - m_EndTest = m_CTest->CurrentTime(); - m_ElapsedTestingTime = cmSystemTools::GetTime() - elapsed_time_start; - if ( m_LogFile ) + this->EndTest = this->CTest->CurrentTime(); + this->ElapsedTestingTime = cmSystemTools::GetTime() - elapsed_time_start; + if ( this->LogFile ) { - *m_LogFile << "End testing: " << m_EndTest << std::endl; + *this->LogFile << "End testing: " << this->EndTest << std::endl; } cmSystemTools::ChangeDirectory(current_dir.c_str()); } @@ -906,34 +928,34 @@ //---------------------------------------------------------------------- void cmCTestTestHandler::GenerateDartOutput(std::ostream& os) { - if ( !m_CTest->GetProduceXML() ) + if ( !this->CTest->GetProduceXML() ) { return; } - m_CTest->StartXML(os); + this->CTest->StartXML(os); os << "\n" - << "\t" << m_StartTest << "\n" + << "\t" << this->StartTest << "\n" << "\t\n"; - tm_TestResultsVector::size_type cc; - for ( cc = 0; cc < m_TestResults.size(); cc ++ ) + cmCTestTestHandler::TestResultsVector::size_type cc; + for ( cc = 0; cc < this->TestResults.size(); cc ++ ) { - cmCTestTestResult *result = &m_TestResults[cc]; - std::string testPath = result->m_Path + "/" + result->m_Name; + cmCTestTestResult *result = &this->TestResults[cc]; + std::string testPath = result->Path + "/" + result->Name; os << "\t\t" << cmCTest::MakeXMLSafe( - m_CTest->GetShortPathToFile(testPath.c_str())) + this->CTest->GetShortPathToFile(testPath.c_str())) << "" << std::endl; } os << "\t\n"; - for ( cc = 0; cc < m_TestResults.size(); cc ++ ) + for ( cc = 0; cc < this->TestResults.size(); cc ++ ) { - cmCTestTestResult *result = &m_TestResults[cc]; + cmCTestTestResult *result = &this->TestResults[cc]; os << "\tm_Status == cmCTestTestHandler::COMPLETED ) + if ( result->Status == cmCTestTestHandler::COMPLETED ) { os << "passed"; } - else if ( result->m_Status == cmCTestTestHandler::NOT_RUN ) + else if ( result->Status == cmCTestTestHandler::NOT_RUN ) { os << "notrun"; } @@ -941,39 +963,44 @@ { os << "failed"; } - std::string testPath = result->m_Path + "/" + result->m_Name; + std::string testPath = result->Path + "/" + result->Name; os << "\">\n" - << "\t\t" << cmCTest::MakeXMLSafe(result->m_Name) << "\n" + << "\t\t" << cmCTest::MakeXMLSafe(result->Name) << "\n" << "\t\t" << cmCTest::MakeXMLSafe( - m_CTest->GetShortPathToFile(result->m_Path.c_str())) << "\n" + this->CTest->GetShortPathToFile(result->Path.c_str())) << "\n" << "\t\t" << cmCTest::MakeXMLSafe( - m_CTest->GetShortPathToFile(testPath.c_str())) << "\n" - << "\t\t" - << cmCTest::MakeXMLSafe(result->m_FullCommandLine) + this->CTest->GetShortPathToFile(testPath.c_str())) << "\n" + << "\t\t" + << cmCTest::MakeXMLSafe(result->FullCommandLine) << "\n" << "\t\t" << std::endl; - if ( result->m_Status != cmCTestTestHandler::NOT_RUN ) + if ( result->Status != cmCTestTestHandler::NOT_RUN ) { - if ( result->m_Status != cmCTestTestHandler::COMPLETED || result->m_ReturnValue ) + if ( result->Status != cmCTestTestHandler::COMPLETED || + result->ReturnValue ) { - os << "\t\t\t" - << this->GetTestStatus(result->m_Status) << "\n" - << "\t\t\t" - << result->m_ReturnValue << "" << std::endl; + os << "\t\t\t" + << this->GetTestStatus(result->Status) << "" + "\n" + << "\t\t\t" + << result->ReturnValue << "" + << std::endl; } - os << result->m_RegressionImages; + os << result->RegressionImages; os << "\t\t\t" - << result->m_ExecutionTime << "\n"; - os + << result->ExecutionTime << "\n"; + os << "\t\t\t" - << result->m_CompletionStatus << "\n"; + << result->CompletionStatus << "\n"; } - os + os << "\t\t\t\n" << "\t\t\t\t"; - os << cmCTest::MakeXMLSafe(result->m_Output); + os << cmCTest::MakeXMLSafe(result->Output); os << "\n" << "\t\t\t\n" @@ -981,12 +1008,12 @@ << "\t" << std::endl; } - os << "\t" << m_EndTest << "\n" - << "" - << static_cast(m_ElapsedTestingTime/6)/10.0 + os << "\t" << this->EndTest << "\n" + << "" + << static_cast(this->ElapsedTestingTime/6)/10.0 << "" << "" << std::endl; - m_CTest->EndXML(os); + this->CTest->EndXML(os); } //---------------------------------------------------------------------- @@ -996,11 +1023,13 @@ for ( it = vec.begin(); it != vec.end(); ++it ) { int retVal = 0; - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " << *it << std::endl); - if ( !cmSystemTools::RunSingleCommand(it->c_str(), 0, &retVal, 0, true /*m_Verbose*/) || - retVal != 0 ) + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " << *it + << std::endl); + if ( !cmSystemTools::RunSingleCommand(it->c_str(), 0, &retVal, 0, true + /*this->Verbose*/) || retVal != 0 ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem running command: " << *it << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem running command: " + << *it << std::endl); return 0; } } @@ -1017,10 +1046,11 @@ std::string file; cmSystemTools::SplitProgramPath(exe, dir, file); - // first try to find the executable given a config type subdir if there is one - if(m_CTest->GetConfigType() != "" && - ::TryExecutable(dir.c_str(), file.c_str(), &fullPath, - m_CTest->GetConfigType().c_str())) + // first try to find the executable given a config type subdir if there is + // one + if(this->CTest->GetConfigType() != "" && + ::TryExecutable(dir.c_str(), file.c_str(), &fullPath, + this->CTest->GetConfigType().c_str())) { return fullPath; } @@ -1037,7 +1067,7 @@ return fullPath; } - if ( m_CTest->GetConfigType() == "" ) + if ( this->CTest->GetConfigType() == "" ) { // No config type, so try to guess it if (::TryExecutable(dir.c_str(),file.c_str(),&fullPath,"Deployment")) @@ -1082,13 +1112,14 @@ } } - if ( m_CTest->GetConfigType() != "" ) + if ( this->CTest->GetConfigType() != "" ) { dir += "/"; - dir += m_CTest->GetConfigType(); + dir += this->CTest->GetConfigType(); dir += "/"; dir += file; - cmSystemTools::Error("config type specified on the command line, but test executable not found.", + cmSystemTools::Error("config type specified on the command line, but " + "test executable not found.", dir.c_str()); return ""; } @@ -1099,36 +1130,39 @@ //---------------------------------------------------------------------- void cmCTestTestHandler::GetListOfTests() { - if ( !m_IncludeRegExp.empty() ) + if ( !this->IncludeRegExp.empty() ) { - m_IncludeTestsRegularExpression.compile(m_IncludeRegExp.c_str()); + this->IncludeTestsRegularExpression.compile(this->IncludeRegExp.c_str()); } - if ( !m_ExcludeRegExp.empty() ) + if ( !this->ExcludeRegExp.empty() ) { - m_ExcludeTestsRegularExpression.compile(m_ExcludeRegExp.c_str()); + this->ExcludeTestsRegularExpression.compile(this->ExcludeRegExp.c_str()); } - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Constructing a list of tests" << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "Constructing a list of tests" << std::endl); cmake cm; cmGlobalGenerator gg; gg.SetCMakeInstance(&cm); std::auto_ptr lg(gg.CreateLocalGenerator()); lg->SetGlobalGenerator(&gg); cmMakefile *mf = lg->GetMakefile(); - mf->AddDefinition("CTEST_CONFIGURATION_TYPE", m_CTest->GetConfigType().c_str()); + mf->AddDefinition("CTEST_CONFIGURATION_TYPE", + this->CTest->GetConfigType().c_str()); // Add handler for ADD_TEST cmCTestAddTestCommand* newCom1 = new cmCTestAddTestCommand; - newCom1->m_TestHandler = this; + newCom1->TestHandler = this; cm.AddCommand(newCom1); - // Add handler for SUBDIR + // Add handler for SUBDIR cmCTestSubdirCommand* newCom2 = new cmCTestSubdirCommand; - newCom2->m_TestHandler = this; + newCom2->TestHandler = this; cm.AddCommand(newCom2); // Add handler for SET_SOURCE_FILES_PROPERTIES - cmCTestSetTestsPropertiesCommand* newCom3 = new cmCTestSetTestsPropertiesCommand; - newCom3->m_TestHandler = this; + cmCTestSetTestsPropertiesCommand* newCom3 + = new cmCTestSetTestsPropertiesCommand; + newCom3->TestHandler = this; cm.AddCommand(newCom3); const char* testFilename; @@ -1155,22 +1189,23 @@ { return; } - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Done constructing a list of tests" << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "Done constructing a list of tests" << std::endl); } //---------------------------------------------------------------------- void cmCTestTestHandler::UseIncludeRegExp() { - this->m_UseIncludeRegExp = true; + this->UseIncludeRegExpFlag = true; } //---------------------------------------------------------------------- void cmCTestTestHandler::UseExcludeRegExp() { - this->m_UseExcludeRegExp = true; - this->m_UseExcludeRegExpFirst = this->m_UseIncludeRegExp ? false : true; + this->UseExcludeRegExpFlag = true; + this->UseExcludeRegExpFirst = this->UseIncludeRegExpFlag ? false : true; } - + //---------------------------------------------------------------------- const char* cmCTestTestHandler::GetTestStatus(int status) { @@ -1187,7 +1222,7 @@ "Completed" }; - if ( status < cmCTestTestHandler::NOT_RUN || + if ( status < cmCTestTestHandler::NOT_RUN || status > cmCTestTestHandler::COMPLETED ) { return "No Status"; @@ -1202,7 +1237,7 @@ { return; } - + int start; int end = -1; double stride = -1; @@ -1221,9 +1256,9 @@ // now read specific numbers while(GetNextNumber(this->TestsToRunString, val, pos, pos2)) { - m_TestsToRun.push_back(val); + this->TestsToRun.push_back(val); } - m_TestsToRun.push_back(val); + this->TestsToRun.push_back(val); } } } @@ -1239,7 +1274,7 @@ { end = numTests; } - + // if the stride wasn't specified then it defaults to 1 if(stride == -1) { @@ -1252,17 +1287,18 @@ int i = 0; while (i*stride + start <= end) { - m_TestsToRun.push_back(static_cast(i*stride+start)); + this->TestsToRun.push_back(static_cast(i*stride+start)); ++i; } } // sort the array - std::sort(m_TestsToRun.begin(), m_TestsToRun.end(), std::less()); + std::sort(this->TestsToRun.begin(), this->TestsToRun.end(), + std::less()); // remove duplicates - std::vector::iterator new_end = - std::unique(m_TestsToRun.begin(), m_TestsToRun.end()); - m_TestsToRun.erase(new_end, m_TestsToRun.end()); + std::vector::iterator new_end = + std::unique(this->TestsToRun.begin(), this->TestsToRun.end()); + this->TestsToRun.erase(new_end, this->TestsToRun.end()); } //---------------------------------------------------------------------- @@ -1273,27 +1309,27 @@ const std::string& xml) { cmsys::RegularExpression twoattributes( - "([^<]*)"); cmsys::RegularExpression threeattributes( - "([^<]*)"); cmsys::RegularExpression fourattributes( - "([^<]*)"); cmsys::RegularExpression measurementfile( - "([^<]*)"); cmOStringStream ostr; @@ -1304,42 +1340,54 @@ if ( twoattributes.find(cxml) ) { ostr - << "\t\t\t" << twoattributes.match(5) - << "" + << "\t\t\t" << twoattributes.match(5) + << "" << std::endl; - cxml.erase(twoattributes.start(), twoattributes.end() - twoattributes.start()); + cxml.erase(twoattributes.start(), + twoattributes.end() - twoattributes.start()); } else if ( threeattributes.find(cxml) ) { ostr - << "\t\t\t" << threeattributes.match(7) - << "" + << "\t\t\t" << threeattributes.match(7) + << "" << std::endl; - cxml.erase(threeattributes.start(), threeattributes.end() - threeattributes.start()); + cxml.erase(threeattributes.start(), + threeattributes.end() - threeattributes.start()); } else if ( fourattributes.find(cxml) ) { ostr - << "\t\t\t" << fourattributes.match(9) - << "" + << "\t\t\t" << fourattributes.match(9) + << "" << std::endl; - cxml.erase(fourattributes.start(), fourattributes.end() - fourattributes.start()); + cxml.erase(fourattributes.start(), + fourattributes.end() - fourattributes.start()); } else if ( measurementfile.find(cxml) ) { - const std::string& filename = + const std::string& filename = cmCTest::CleanString(measurementfile.match(5)); if ( cmSystemTools::FileExists(filename.c_str()) ) { @@ -1357,34 +1405,38 @@ if ( cmSystemTools::LowerCase(k2) == "type" ) { v2 = "text/string"; - } - + } + ostr - << "\t\t\tImage " << filename.c_str() + << ">Image " << filename.c_str() << " is empty"; } else { - std::ifstream ifs(filename.c_str(), std::ios::in + std::ifstream ifs(filename.c_str(), std::ios::in #ifdef _WIN32 | std::ios::binary #endif ); unsigned char *file_buffer = new unsigned char [ len + 1 ]; ifs.read(reinterpret_cast(file_buffer), len); - unsigned char *encoded_buffer = new unsigned char [ static_cast(len * 1.5 + 5) ]; - - unsigned long rlen = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1); + unsigned char *encoded_buffer + = new unsigned char [ static_cast(len * 1.5 + 5) ]; + + unsigned long rlen + = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1); unsigned long cc; - + ostr - << "\t\t\t" << std::endl << "\t\t\t\t"; for ( cc = 0; cc < rlen; cc ++ ) @@ -1396,7 +1448,7 @@ } } ostr - << "" << std::endl << "\t\t\t" + << "" << std::endl << "\t\t\t" << std::endl; delete [] file_buffer; delete [] encoded_buffer; @@ -1410,14 +1462,17 @@ idx = 2; } ostr - << "\t\t\tFile " << filename.c_str() << " not found" + << ">File " << filename.c_str() + << " not found" << std::endl; - cmCTestLog(m_CTest, HANDLER_OUTPUT, "File \"" << filename.c_str() << "\" not found." << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, "File \"" << filename.c_str() + << "\" not found." << std::endl); } - cxml.erase(measurementfile.start(), measurementfile.end() - measurementfile.start()); + cxml.erase(measurementfile.start(), + measurementfile.end() - measurementfile.start()); } else { @@ -1430,13 +1485,13 @@ //---------------------------------------------------------------------- void cmCTestTestHandler::SetIncludeRegExp(const char *arg) { - m_IncludeRegExp = arg; + this->IncludeRegExp = arg; } //---------------------------------------------------------------------- void cmCTestTestHandler::SetExcludeRegExp(const char *arg) { - m_ExcludeRegExp = arg; + this->ExcludeRegExp = arg; } //---------------------------------------------------------------------- @@ -1447,7 +1502,8 @@ return; } this->TestsToRunString = in; - // if the argument is a file, then read it and use the contents as the string + // if the argument is a file, then read it and use the contents as the + // string if(cmSystemTools::FileExists(in)) { std::ifstream fin(in); @@ -1460,7 +1516,8 @@ } //---------------------------------------------------------------------- -bool cmCTestTestHandler::CleanTestOutput(std::string& output, size_t remove_threshold) +bool cmCTestTestHandler::CleanTestOutput(std::string& output, + size_t remove_threshold) { if ( remove_threshold == 0 ) { @@ -1512,7 +1569,8 @@ } if ( skipped ) { - ostr << "..." << std::endl << "The rest of the test output was removed since it exceeds the threshold of " + ostr << "..." << std::endl << "The rest of the test output was removed " + "since it exceeds the threshold of " << remove_threshold << " characters." << std::endl; } output = ostr.str(); @@ -1520,7 +1578,8 @@ } //---------------------------------------------------------------------- -bool cmCTestTestHandler::SetTestsProperties(const std::vector& args) +bool cmCTestTestHandler::SetTestsProperties( + const std::vector& args) { std::vector::const_iterator it; std::vector tests; @@ -1551,14 +1610,16 @@ std::vector::const_iterator tit; for ( tit = tests.begin(); tit != tests.end(); ++ tit ) { - tm_ListOfTests::iterator rtit; - for ( rtit = m_TestList.begin(); rtit != m_TestList.end(); ++ rtit ) + cmCTestTestHandler::ListOfTests::iterator rtit; + for ( rtit = this->TestList.begin(); + rtit != this->TestList.end(); + ++ rtit ) { - if ( *tit == rtit->m_Name ) + if ( *tit == rtit->Name ) { if ( key == "WILL_FAIL" ) { - rtit->m_WillFail = cmSystemTools::IsOn(val.c_str()); + rtit->WillFail = cmSystemTools::IsOn(val.c_str()); } if ( key == "FAIL_REGULAR_EXPRESSION" ) { @@ -1567,7 +1628,8 @@ std::vector::iterator crit; for ( crit = lval.begin(); crit != lval.end(); ++ crit ) { - rtit->m_ErrorRegularExpressions.push_back(cmsys::RegularExpression(crit->c_str())); + rtit->ErrorRegularExpressions.push_back( + cmsys::RegularExpression(crit->c_str())); } } if ( key == "PASS_REGULAR_EXPRESSION" ) @@ -1577,7 +1639,8 @@ std::vector::iterator crit; for ( crit = lval.begin(); crit != lval.end(); ++ crit ) { - rtit->m_RequiredRegularExpressions.push_back(cmsys::RegularExpression(crit->c_str())); + rtit->RequiredRegularExpressions.push_back( + cmsys::RegularExpression(crit->c_str())); } } } @@ -1591,18 +1654,18 @@ bool cmCTestTestHandler::AddTest(const std::vector& args) { const std::string& testname = args[0]; - if (this->m_UseExcludeRegExp && - this->m_UseExcludeRegExpFirst && - m_ExcludeTestsRegularExpression.find(testname.c_str())) + if (this->UseExcludeRegExpFlag && + this->UseExcludeRegExpFirst && + this->ExcludeTestsRegularExpression.find(testname.c_str())) { return true; } - if ( m_MemCheck ) + if ( this->MemCheck ) { std::vector::iterator it; bool found = false; - for ( it = m_CustomTestsIgnore.begin(); - it != m_CustomTestsIgnore.end(); ++ it ) + for ( it = this->CustomTestsIgnore.begin(); + it != this->CustomTestsIgnore.end(); ++ it ) { if ( *it == testname ) { @@ -1612,7 +1675,8 @@ } if ( found ) { - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Ignore memcheck: " << *it << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Ignore memcheck: " + << *it << std::endl); return true; } } @@ -1620,8 +1684,8 @@ { std::vector::iterator it; bool found = false; - for ( it = m_CustomTestsIgnore.begin(); - it != m_CustomTestsIgnore.end(); ++ it ) + for ( it = this->CustomTestsIgnore.begin(); + it != this->CustomTestsIgnore.end(); ++ it ) { if ( *it == testname ) { @@ -1631,28 +1695,30 @@ } if ( found ) { - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Ignore test: " << *it << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Ignore test: " + << *it << std::endl); return true; } } cmCTestTestProperties test; - test.m_Name = testname; - test.m_Args = args; - test.m_Directory = cmSystemTools::GetCurrentWorkingDirectory(); - test.m_IsInBasedOnREOptions = true; - test.m_WillFail = false; - if (this->m_UseIncludeRegExp && !m_IncludeTestsRegularExpression.find(testname.c_str())) - { - test.m_IsInBasedOnREOptions = false; - } - else if (this->m_UseExcludeRegExp && - !this->m_UseExcludeRegExpFirst && - m_ExcludeTestsRegularExpression.find(testname.c_str())) + test.Name = testname; + test.Args = args; + test.Directory = cmSystemTools::GetCurrentWorkingDirectory(); + test.IsInBasedOnREOptions = true; + test.WillFail = false; + if (this->UseIncludeRegExpFlag && + !this->IncludeTestsRegularExpression.find(testname.c_str())) + { + test.IsInBasedOnREOptions = false; + } + else if (this->UseExcludeRegExpFlag && + !this->UseExcludeRegExpFirst && + this->ExcludeTestsRegularExpression.find(testname.c_str())) { - test.m_IsInBasedOnREOptions = false; + test.IsInBasedOnREOptions = false; } - m_TestList.push_back(test); + this->TestList.push_back(test); return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestTestHandler.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestTestHandler.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestTestHandler.h 2005-11-24 01:33:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestTestHandler.h 2006-03-17 00:34:58.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestTestHandler.h,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:39 $ - Version: $Revision: 1.11.2.3 $ + Date: $Date: 2006/03/16 16:34:58 $ + Version: $Revision: 1.18 $ Copyright (c) 2002 Kitware, Inc. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -37,26 +37,26 @@ * The main entry point for this class */ int ProcessHandler(); - + /** * When both -R and -I are used should te resulting test list be the * intersection or the union of the lists. By default it is the * intersection. */ - void SetUseUnion(bool val) { m_UseUnion = val; } + void SetUseUnion(bool val) { this->UseUnion = val; } /** * This method is called when reading CTest custom file */ void PopulateCustomVectors(cmMakefile *mf); - + ///! Control the use of the regular expresisons, call these methods to turn ///them on void UseIncludeRegExp(); void UseExcludeRegExp(); void SetIncludeRegExp(const char *); void SetExcludeRegExp(const char *); - + ///! pass the -I argument down void SetTestsToRunInformation(const char*); @@ -75,16 +75,16 @@ struct cmCTestTestResult { - std::string m_Name; - std::string m_Path; - std::string m_FullCommandLine; - double m_ExecutionTime; - int m_ReturnValue; - int m_Status; - std::string m_CompletionStatus; - std::string m_Output; - std::string m_RegressionImages; - int m_TestCount; + std::string Name; + std::string Path; + std::string FullCommandLine; + double ExecutionTime; + int ReturnValue; + int Status; + std::string CompletionStatus; + std::string Output; + std::string RegressionImages; + int TestCount; }; void Initialize(); @@ -92,13 +92,13 @@ protected: struct cmCTestTestProperties { - cmStdString m_Name; - cmStdString m_Directory; - std::vector m_Args; - std::vector m_ErrorRegularExpressions; - std::vector m_RequiredRegularExpressions; - bool m_IsInBasedOnREOptions; - bool m_WillFail; + cmStdString Name; + cmStdString Directory; + std::vector Args; + std::vector ErrorRegularExpressions; + std::vector RequiredRegularExpressions; + bool IsInBasedOnREOptions; + bool WillFail; }; @@ -107,15 +107,21 @@ virtual void GenerateTestCommand(std::vector& args); int ExecuteCommands(std::vector& vec); - double m_ElapsedTestingTime; + //! Clean test output to specified length + bool CleanTestOutput(std::string& output, size_t length); + + double ElapsedTestingTime; - typedef std::vector tm_TestResultsVector; - tm_TestResultsVector m_TestResults; + typedef std::vector TestResultsVector; + TestResultsVector TestResults; + + std::vector CustomTestsIgnore; + std::string StartTest; + std::string EndTest; + bool MemCheck; + int CustomMaximumPassedTestOutputSize; + int CustomMaximumFailedTestOutputSize; - std::vector m_CustomTestsIgnore; - std::string m_StartTest; - std::string m_EndTest; - bool m_MemCheck; private: enum { // Program statuses @@ -140,11 +146,11 @@ /** * Run the test for a directory and any subdirectories */ - void ProcessDirectory(std::vector &passed, + void ProcessDirectory(std::vector &passed, std::vector &failed); - - typedef std::vector tm_ListOfTests; + + typedef std::vector ListOfTests; /** * Get the list of tests in directory and subdirectories. */ @@ -158,33 +164,27 @@ const char* GetTestStatus(int status); void ExpandTestsToRunInformation(int numPossibleTests); - std::vector m_CustomPreTest; - std::vector m_CustomPostTest; - - int m_CustomMaximumPassedTestOutputSize; - int m_CustomMaximumFailedTestOutputSize; + std::vector CustomPreTest; + std::vector CustomPostTest; - std::vector m_TestsToRun; + std::vector TestsToRun; - bool m_UseIncludeRegExp; - bool m_UseExcludeRegExp; - bool m_UseExcludeRegExpFirst; - std::string m_IncludeRegExp; - std::string m_ExcludeRegExp; - cmsys::RegularExpression m_IncludeTestsRegularExpression; - cmsys::RegularExpression m_ExcludeTestsRegularExpression; + bool UseIncludeRegExpFlag; + bool UseExcludeRegExpFlag; + bool UseExcludeRegExpFirst; + std::string IncludeRegExp; + std::string ExcludeRegExp; + cmsys::RegularExpression IncludeTestsRegularExpression; + cmsys::RegularExpression ExcludeTestsRegularExpression; std::string GenerateRegressionImages(const std::string& xml); - //! Clean test output to specified length - bool CleanTestOutput(std::string& output, size_t length); - std::string TestsToRunString; - bool m_UseUnion; - tm_ListOfTests m_TestList; - cmsys::RegularExpression m_DartStuff; + bool UseUnion; + ListOfTests TestList; + cmsys::RegularExpression DartStuff; - std::ostream* m_LogFile; + std::ostream* LogFile; }; #endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestUpdateCommand.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestUpdateCommand.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestUpdateCommand.cxx 2005-08-30 04:19:32.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestUpdateCommand.cxx 2006-03-16 00:02:08.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestUpdateCommand.cxx,v $ Language: C++ - Date: $Date: 2005/08/29 20:19:32 $ - Version: $Revision: 1.7.2.1 $ + Date: $Date: 2006/03/15 16:02:08 $ + Version: $Revision: 1.11 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -43,16 +43,18 @@ { if ( res_var ) { - this->SetError("called with incorrect number of arguments. RETURN_VALUE specified twice."); + this->SetError("called with incorrect number of arguments. " + "RETURN_VALUE specified twice."); return false; } havereturn_variable = true; - } + } else if(args[i] == "SOURCE") { if ( source_dir ) { - this->SetError("called with incorrect number of arguments. SOURCE specified twice."); + this->SetError("called with incorrect number of arguments. SOURCE " + "specified twice."); return false; } havesource = true; @@ -60,26 +62,35 @@ else { cmOStringStream str; - str << "called with incorrect number of arguments. Extra argument is: " << args[i].c_str() << "."; + str << "called with incorrect number of arguments. Extra argument is: " + << args[i].c_str() << "."; this->SetError(str.str().c_str()); return false; } } - m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "UpdateCommand", "CTEST_UPDATE_COMMAND"); - m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "UpdateOptions", "CTEST_UPDATE_OPTIONS"); - m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "CVSCommand", "CTEST_CVS_COMMAND"); - m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "CVSUpdateOptions", "CTEST_CVS_UPDATE_OPTIONS"); - m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "SVNCommand", "CTEST_SVN_COMMAND"); - m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "SVNUpdateOptions", "CTEST_SVN_UPDATE_OPTIONS"); + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, + "UpdateCommand", "CTEST_UPDATE_COMMAND"); + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, + "UpdateOptions", "CTEST_UPDATE_OPTIONS"); + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, + "CVSCommand", "CTEST_CVS_COMMAND"); + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, + "CVSUpdateOptions", "CTEST_CVS_UPDATE_OPTIONS"); + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, + "SVNCommand", "CTEST_SVN_COMMAND"); + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, + "SVNUpdateOptions", "CTEST_SVN_UPDATE_OPTIONS"); - const char* initialCheckoutCommand = m_Makefile->GetDefinition("CTEST_CHECKOUT_COMMAND"); + const char* initialCheckoutCommand + = this->Makefile->GetDefinition("CTEST_CHECKOUT_COMMAND"); if ( !initialCheckoutCommand ) { - initialCheckoutCommand = m_Makefile->GetDefinition("CTEST_CVS_CHECKOUT"); + initialCheckoutCommand = this->Makefile->GetDefinition("CTEST_CVS_CHECKOUT"); } - cmCTestGenericHandler* handler = m_CTest->GetInitializedHandler("update"); + cmCTestGenericHandler* handler + = this->CTest->GetInitializedHandler("update"); if ( !handler ) { this->SetError("internal CTest error. Cannot instantiate update handler"); @@ -95,14 +106,16 @@ { handler->SetOption("InitialCheckout", initialCheckoutCommand); } - if ( (!cmSystemTools::FileExists(source_dir) || !cmSystemTools::FileIsDirectory(source_dir)) + if ( (!cmSystemTools::FileExists(source_dir) || + !cmSystemTools::FileIsDirectory(source_dir)) && !initialCheckoutCommand ) { cmOStringStream str; str << "cannot find source directory: " << source_dir << "."; if ( !cmSystemTools::FileExists(source_dir) ) { - str << " Looks like it is not checked out yet. Please specify CTEST_CHECKOUT_COMMAND."; + str << " Looks like it is not checked out yet. Please specify " + "CTEST_CHECKOUT_COMMAND."; } this->SetError(str.str().c_str()); return false; @@ -113,7 +126,7 @@ { cmOStringStream str; str << res; - m_Makefile->AddDefinition(res_var, str.str().c_str()); + this->Makefile->AddDefinition(res_var, str.str().c_str()); } return true; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestUpdateCommand.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestUpdateCommand.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestUpdateCommand.h 2005-05-04 23:13:35.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestUpdateCommand.h 2006-03-11 04:03:09.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestUpdateCommand.h,v $ Language: C++ - Date: $Date: 2005/05/04 15:13:35 $ - Version: $Revision: 1.2 $ + Date: $Date: 2006/03/10 20:03:09 $ + Version: $Revision: 1.4 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -29,15 +29,15 @@ public: cmCTestUpdateCommand() {} - + /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { cmCTestUpdateCommand* ni = new cmCTestUpdateCommand; - ni->m_CTest = this->m_CTest; - ni->m_CTestScriptHandler = this->m_CTestScriptHandler; + ni->CTest = this->CTest; + ni->CTestScriptHandler = this->CTestScriptHandler; return ni; } @@ -55,11 +55,11 @@ /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { return "Updates the repository."; } - + /** * More documentation. */ @@ -67,8 +67,8 @@ { return " CTEST_UPDATE([SOURCE source] [RETURN_VALUE res])\n" - "Updates the given source directory and stores results in Update.xml. The " - "second argument is a variable that will hold the number of files " + "Updates the given source directory and stores results in Update.xml. " + "The second argument is a variable that will hold the number of files " "modified. If there is a problem, the variable will be -1."; } diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestUpdateHandler.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestUpdateHandler.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestUpdateHandler.cxx 2005-10-25 03:43:52.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestUpdateHandler.cxx 2006-03-15 22:23:35.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestUpdateHandler.cxx,v $ Language: C++ - Date: $Date: 2005/10/24 19:43:52 $ - Version: $Revision: 1.25.2.4 $ + Date: $Date: 2006/03/15 14:23:35 $ + Version: $Revision: 1.35 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -34,7 +34,7 @@ #include "windows.h" #endif -#include +#include #include #include @@ -48,7 +48,8 @@ static const char* cmCTestUpdateHandlerUpdateToString(int type) { - if ( type < cmCTestUpdateHandler::e_UNKNOWN || type >= cmCTestUpdateHandler::e_LAST ) + if ( type < cmCTestUpdateHandler::e_UNKNOWN || + type >= cmCTestUpdateHandler::e_LAST ) { return cmCTestUpdateHandlerUpdateStrings[cmCTestUpdateHandler::e_UNKNOWN]; } @@ -62,22 +63,22 @@ public: struct t_CommitLog { - int m_Revision; - std::string m_Author; - std::string m_Date; - std::string m_Message; + int Revision; + std::string Author; + std::string Date; + std::string Message; }; cmCTestUpdateHandlerSVNXMLParser(cmCTestUpdateHandler* up) - : cmXMLParser(), m_UpdateHandler(up), m_MinRevision(-1), m_MaxRevision(-1) + : cmXMLParser(), UpdateHandler(up), MinRevision(-1), MaxRevision(-1) { } int Parse(const char* str) { - m_MinRevision = -1; - m_MaxRevision = -1; + this->MinRevision = -1; + this->MaxRevision = -1; int res = this->cmXMLParser::Parse(str); - if ( m_MinRevision == -1 || m_MaxRevision == -1 ) + if ( this->MinRevision == -1 || this->MaxRevision == -1 ) { return 0; } @@ -86,59 +87,68 @@ typedef std::vector t_VectorOfCommits; - t_VectorOfCommits* GetCommits() { return &m_Commits; } - int GetMinRevision() { return m_MinRevision; } - int GetMaxRevision() { return m_MaxRevision; } + t_VectorOfCommits* GetCommits() { return &this->Commits; } + int GetMinRevision() { return this->MinRevision; } + int GetMaxRevision() { return this->MaxRevision; } protected: void StartElement(const char* name, const char** atts) { if ( strcmp(name, "logentry") == 0 ) { - m_CommitLog = t_CommitLog(); + this->CommitLog = t_CommitLog(); const char* rev = this->FindAttribute(atts, "revision"); if ( rev) { - m_CommitLog.m_Revision = atoi(rev); - if ( m_MinRevision < 0 || m_MinRevision > m_CommitLog.m_Revision ) + this->CommitLog.Revision = atoi(rev); + if ( this->MinRevision < 0 || + this->MinRevision > this->CommitLog.Revision ) { - m_MinRevision = m_CommitLog.m_Revision; + this->MinRevision = this->CommitLog.Revision; } - if ( m_MaxRevision < 0 || m_MaxRevision < m_CommitLog.m_Revision ) + if ( this->MaxRevision < 0 || + this->MaxRevision < this->CommitLog.Revision ) { - m_MaxRevision = m_CommitLog.m_Revision; + this->MaxRevision = this->CommitLog.Revision; } } } - m_CharacterData.erase(m_CharacterData.begin(), m_CharacterData.end()); + this->CharacterData.erase( + this->CharacterData.begin(), this->CharacterData.end()); } void EndElement(const char* name) { if ( strcmp(name, "logentry") == 0 ) { - cmCTestLog(m_UpdateHandler->GetCTestInstance(), HANDLER_VERBOSE_OUTPUT, "\tRevision: " << m_CommitLog.m_Revision<< std::endl - << "\tAuthor: " << m_CommitLog.m_Author.c_str() << std::endl - << "\tDate: " << m_CommitLog.m_Date.c_str() << std::endl - << "\tMessage: " << m_CommitLog.m_Message.c_str() << std::endl); - m_Commits.push_back(m_CommitLog); + cmCTestLog(this->UpdateHandler->GetCTestInstance(), + HANDLER_VERBOSE_OUTPUT, + "\tRevision: " << this->CommitLog.Revision<< std::endl + << "\tAuthor: " << this->CommitLog.Author.c_str() << std::endl + << "\tDate: " << this->CommitLog.Date.c_str() << std::endl + << "\tMessage: " << this->CommitLog.Message.c_str() << std::endl); + this->Commits.push_back(this->CommitLog); } else if ( strcmp(name, "author") == 0 ) { - m_CommitLog.m_Author.assign(&(*(m_CharacterData.begin())), m_CharacterData.size()); + this->CommitLog.Author.assign(&(*(this->CharacterData.begin())), + this->CharacterData.size()); } else if ( strcmp(name, "date") == 0 ) { - m_CommitLog.m_Date.assign(&(*(m_CharacterData.begin())), m_CharacterData.size()); + this->CommitLog.Date.assign(&(*(this->CharacterData.begin())), + this->CharacterData.size()); } else if ( strcmp(name, "msg") == 0 ) { - m_CommitLog.m_Message.assign(&(*(m_CharacterData.begin())), m_CharacterData.size()); + this->CommitLog.Message.assign(&(*(this->CharacterData.begin())), + this->CharacterData.size()); } - m_CharacterData.erase(m_CharacterData.begin(), m_CharacterData.end()); + this->CharacterData.erase(this->CharacterData.begin(), + this->CharacterData.end()); } void CharacterDataHandler(const char* data, int length) { - m_CharacterData.insert(m_CharacterData.end(), data, data+length); + this->CharacterData.insert(this->CharacterData.end(), data, data+length); } const char* FindAttribute( const char** atts, const char* attribute ) { @@ -159,13 +169,13 @@ } private: - std::vector m_CharacterData; - cmCTestUpdateHandler* m_UpdateHandler; - t_CommitLog m_CommitLog; - - t_VectorOfCommits m_Commits; - int m_MinRevision; - int m_MaxRevision; + std::vector CharacterData; + cmCTestUpdateHandler* UpdateHandler; + t_CommitLog CommitLog; + + t_VectorOfCommits Commits; + int MinRevision; + int MaxRevision; }; //********************************************************************** //---------------------------------------------------------------------- @@ -184,10 +194,11 @@ //---------------------------------------------------------------------- int cmCTestUpdateHandler::DetermineType(const char* cmd, const char* type) { - cmCTestLog(m_CTest, DEBUG, "Determine update type from command: " << cmd << " and type: " << type << std::endl); + cmCTestLog(this->CTest, DEBUG, "Determine update type from command: " << cmd + << " and type: " << type << std::endl); if ( type && *type ) { - cmCTestLog(m_CTest, DEBUG, "Type specified: " << type << std::endl); + cmCTestLog(this->CTest, DEBUG, "Type specified: " << type << std::endl); std::string stype = cmSystemTools::LowerCase(type); if ( stype.find("cvs") != std::string::npos ) { @@ -200,7 +211,8 @@ } else { - cmCTestLog(m_CTest, DEBUG, "Type not specified, check command: " << cmd << std::endl); + cmCTestLog(this->CTest, DEBUG, "Type not specified, check command: " + << cmd << std::endl); std::string stype = cmSystemTools::LowerCase(cmd); if ( stype.find("cvs") != std::string::npos ) { @@ -212,7 +224,8 @@ } } std::string sourceDirectory = this->GetOption("SourceDirectory"); - cmCTestLog(m_CTest, DEBUG, "Check directory: " << sourceDirectory.c_str() << std::endl); + cmCTestLog(this->CTest, DEBUG, "Check directory: " + << sourceDirectory.c_str() << std::endl); sourceDirectory += "/.svn"; if ( cmSystemTools::FileExists(sourceDirectory.c_str()) ) { @@ -246,66 +259,83 @@ const char* sourceDirectory = this->GetOption("SourceDirectory"); if ( !sourceDirectory ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot find SourceDirectory key in the DartConfiguration.tcl" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Cannot find SourceDirectory key in the DartConfiguration.tcl" + << std::endl); return -1; } cmGeneratedFileStream ofs; - if ( !m_CTest->GetShowOnly() ) + if ( !this->CTest->GetShowOnly() ) { this->StartLogFile("Update", ofs); } - cmCTestLog(m_CTest, HANDLER_OUTPUT, "Updating the repository" << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, + "Updating the repository" << std::endl); const char* initialCheckoutCommand = this->GetOption("InitialCheckout"); if ( initialCheckoutCommand ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, " First perform the initil checkout: " << initialCheckoutCommand << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, + " First perform the initil checkout: " << initialCheckoutCommand + << std::endl); cmStdString parent = cmSystemTools::GetParentDirectory(sourceDirectory); if ( parent.empty() ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, - "Something went wrong when trying to determine the parent directory of " << sourceDirectory << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Something went wrong when trying " + "to determine the parent directory of " << sourceDirectory + << std::endl); return -1; } - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Perform checkout in directory: " << parent.c_str() << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, + " Perform checkout in directory: " << parent.c_str() << std::endl); if ( !cmSystemTools::MakeDirectory(parent.c_str()) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, - "Cannot create parent directory: " << parent.c_str() << " of the source directory: " << sourceDirectory << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Cannot create parent directory: " << parent.c_str() + << " of the source directory: " << sourceDirectory << std::endl); return -1; } ofs << "* Run initial checkout" << std::endl; ofs << " Command: " << initialCheckoutCommand << std::endl; - cmCTestLog(m_CTest, DEBUG, " Before: " << initialCheckoutCommand << std::endl); - bool retic = m_CTest->RunCommand(initialCheckoutCommand, &goutput, &errors, &retVal, parent.c_str(), 0 /* Timeout */); - cmCTestLog(m_CTest, DEBUG, " After: " << initialCheckoutCommand << std::endl); + cmCTestLog(this->CTest, DEBUG, " Before: " + << initialCheckoutCommand << std::endl); + bool retic = this->CTest->RunCommand(initialCheckoutCommand, &goutput, + &errors, &retVal, parent.c_str(), 0 /* Timeout */); + cmCTestLog(this->CTest, DEBUG, " After: " + << initialCheckoutCommand << std::endl); ofs << " Output: " << goutput.c_str() << std::endl; ofs << " Errors: " << errors.c_str() << std::endl; if ( !retic || retVal ) { cmOStringStream ostr; - ostr << "Problem running initial checkout Output [" << goutput << "] Errors [" << errors << "]"; - cmCTestLog(m_CTest, ERROR_MESSAGE, ostr.str().c_str() << std::endl); + ostr << "Problem running initial checkout Output [" << goutput + << "] Errors [" << errors << "]"; + cmCTestLog(this->CTest, ERROR_MESSAGE, ostr.str().c_str() << std::endl); checkoutErrorMessages += ostr.str(); updateProducedError = true; } - m_CTest->InitializeFromCommand(m_Command); + this->CTest->InitializeFromCommand(this->Command); } - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Updating the repository: " << sourceDirectory << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Updating the repository: " + << sourceDirectory << std::endl); // Get update command - std::string updateCommand = m_CTest->GetCTestConfiguration("UpdateCommand"); + std::string updateCommand + = this->CTest->GetCTestConfiguration("UpdateCommand"); if ( updateCommand.empty() ) { - updateCommand = m_CTest->GetCTestConfiguration("CVSCommand"); + updateCommand = this->CTest->GetCTestConfiguration("CVSCommand"); if ( updateCommand.empty() ) { - updateCommand = m_CTest->GetCTestConfiguration("SVNCommand"); + updateCommand = this->CTest->GetCTestConfiguration("SVNCommand"); if ( updateCommand.empty() ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot find CVSCommand, SVNCommand, or UpdateCommand key in the DartConfiguration.tcl" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Cannot find CVSCommand, SVNCommand, or UpdateCommand key in the " + "DartConfiguration.tcl" << std::endl); return -1; } else @@ -320,36 +350,41 @@ } else { - updateType = this->DetermineType(updateCommand.c_str(), m_CTest->GetCTestConfiguration("UpdateType").c_str()); + updateType = this->DetermineType(updateCommand.c_str(), + this->CTest->GetCTestConfiguration("UpdateType").c_str()); } - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Use " << cmCTestUpdateHandlerUpdateToString(updateType) << " repository type" << std::endl;); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Use " + << cmCTestUpdateHandlerUpdateToString(updateType) << " repository type" + << std::endl;); // And update options - std::string updateOptions = m_CTest->GetCTestConfiguration("UpdateOptions"); + std::string updateOptions + = this->CTest->GetCTestConfiguration("UpdateOptions"); if ( updateOptions.empty() ) { switch (updateType) { case cmCTestUpdateHandler::e_CVS: - updateOptions = m_CTest->GetCTestConfiguration("CVSUpdateOptions"); + updateOptions = this->CTest->GetCTestConfiguration("CVSUpdateOptions"); if ( updateOptions.empty() ) { updateOptions = "-dP"; } break; case cmCTestUpdateHandler::e_SVN: - updateOptions = m_CTest->GetCTestConfiguration("SVNUpdateOptions"); + updateOptions = this->CTest->GetCTestConfiguration("SVNUpdateOptions"); break; } } // Get update time std::string extra_update_opts; - if ( m_CTest->GetTestModel() == cmCTest::NIGHTLY ) + if ( this->CTest->GetTestModel() == cmCTest::NIGHTLY ) { - struct tm* t = m_CTest->GetNightlyTime(m_CTest->GetCTestConfiguration("NightlyStartTime"), - m_CTest->GetTomorrowTag()); + struct tm* t = this->CTest->GetNightlyTime( + this->CTest->GetCTestConfiguration("NightlyStartTime"), + this->CTest->GetTomorrowTag()); char current_time[1024]; sprintf(current_time, "%04d-%02d-%02d %02d:%02d:%02d", t->tm_year + 1900, @@ -372,6 +407,8 @@ } } + bool res = true; + updateCommand = "\"" + updateCommand + "\""; // First, check what the current state of repository is @@ -382,6 +419,48 @@ // TODO: CVS - for now just leave empty break; case cmCTestUpdateHandler::e_SVN: + command = updateCommand + " cleanup"; + break; + } + + // + // Get initial repository information if that is possible. With subversion, + // this will check the current revision. + // + if ( !command.empty() ) + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "* Cleanup repository: " << command.c_str() << std::endl); + if ( !this->CTest->GetShowOnly() ) + { + ofs << "* Cleanup repository" << std::endl; + ofs << " Command: " << command.c_str() << std::endl; + res = this->CTest->RunCommand(command.c_str(), &goutput, &errors, + &retVal, sourceDirectory, 0 /*this->TimeOut*/); + + ofs << " Output: " << goutput.c_str() << std::endl; + ofs << " Errors: " << errors.c_str() << std::endl; + if ( ofs ) + { + ofs << "--- Cleanup ---" << std::endl; + ofs << goutput << std::endl; + } + } + else + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "Cleanup with command: " << command << std::endl); + } + } + + // First, check what the current state of repository is + command = ""; + switch( updateType ) + { + case cmCTestUpdateHandler::e_CVS: + // TODO: CVS - for now just leave empty + break; + case cmCTestUpdateHandler::e_SVN: command = updateCommand + " info"; break; } @@ -392,21 +471,20 @@ int svn_latest_revision = 0; int svn_use_status = 0; - bool res = true; - - // - // Get initial repository information if that is possible. With subversion, this will check the current revision. + // Get initial repository information if that is possible. With subversion, + // this will check the current revision. // if ( !command.empty() ) { - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "* Get repository information: " << command.c_str() << std::endl); - if ( !m_CTest->GetShowOnly() ) + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "* Get repository information: " << command.c_str() << std::endl); + if ( !this->CTest->GetShowOnly() ) { ofs << "* Get repository information" << std::endl; ofs << " Command: " << command.c_str() << std::endl; - res = m_CTest->RunCommand(command.c_str(), &goutput, &errors, - &retVal, sourceDirectory, 0 /*m_TimeOut*/); + res = this->CTest->RunCommand(command.c_str(), &goutput, &errors, + &retVal, sourceDirectory, 0 /*this->TimeOut*/); ofs << " Output: " << goutput.c_str() << std::endl; ofs << " Errors: " << errors.c_str() << std::endl; @@ -422,12 +500,16 @@ break; case cmCTestUpdateHandler::e_SVN: { - cmsys::RegularExpression current_revision_regex("Revision: ([0-9]+)"); + cmsys::RegularExpression current_revision_regex( + "Revision: ([0-9]+)"); if ( current_revision_regex.find(goutput.c_str()) ) { - std::string currentRevisionString = current_revision_regex.match(1); + std::string currentRevisionString + = current_revision_regex.match(1); svn_current_revision = atoi(currentRevisionString.c_str()); - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Old revision of repository is: " << svn_current_revision << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, + " Old revision of repository is: " << svn_current_revision + << std::endl); } } break; @@ -435,24 +517,27 @@ } else { - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Update with command: " << command << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "Get information with command: " << command << std::endl); } } // // Now update repository and remember what files were updated - // - cmGeneratedFileStream os; + // + cmGeneratedFileStream os; if ( !this->StartResultingXML("Update", os) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot open log file" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open log file" + << std::endl); } - std::string start_time = m_CTest->CurrentTime(); + std::string start_time = this->CTest->CurrentTime(); double elapsed_time_start = cmSystemTools::GetTime(); - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "* Update repository: " << command.c_str() << std::endl); - if ( !m_CTest->GetShowOnly() ) + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "* Update repository: " + << command.c_str() << std::endl); + if ( !this->CTest->GetShowOnly() ) { command = ""; switch( updateType ) @@ -462,8 +547,8 @@ " " + extra_update_opts; ofs << "* Update repository: " << std::endl; ofs << " Command: " << command.c_str() << std::endl; - res = m_CTest->RunCommand(command.c_str(), &goutput, &errors, - &retVal, sourceDirectory, 0 /*m_TimeOut*/); + res = this->CTest->RunCommand(command.c_str(), &goutput, &errors, + &retVal, sourceDirectory, 0 /*this->TimeOut*/); ofs << " Output: " << goutput.c_str() << std::endl; ofs << " Errors: " << errors.c_str() << std::endl; break; @@ -474,16 +559,17 @@ " " + extra_update_opts; ofs << "* Update repository: " << std::endl; ofs << " Command: " << command.c_str() << std::endl; - bool res1 = m_CTest->RunCommand(command.c_str(), &partialOutput, &errors, - &retVal, sourceDirectory, 0 /*m_TimeOut*/); + bool res1 = this->CTest->RunCommand(command.c_str(), &partialOutput, + &errors, + &retVal, sourceDirectory, 0 /*this->TimeOut*/); ofs << " Output: " << partialOutput.c_str() << std::endl; ofs << " Errors: " << errors.c_str() << std::endl; goutput = partialOutput; command = updateCommand + " status"; ofs << "* Status repository: " << std::endl; ofs << " Command: " << command.c_str() << std::endl; - res = m_CTest->RunCommand(command.c_str(), &partialOutput, &errors, - &retVal, sourceDirectory, 0 /*m_TimeOut*/); + res = this->CTest->RunCommand(command.c_str(), &partialOutput, + &errors, &retVal, sourceDirectory, 0 /*this->TimeOut*/); ofs << " Output: " << partialOutput.c_str() << std::endl; ofs << " Errors: " << errors.c_str() << std::endl; goutput += partialOutput; @@ -494,7 +580,7 @@ if ( ofs ) { ofs << "--- Update repository ---" << std::endl; - ofs << goutput << std::endl;; + ofs << goutput << std::endl; } } if ( !res || retVal ) @@ -506,18 +592,20 @@ os << "\n" << "\n" - << "\t" << m_CTest->GetCTestConfiguration("Site") << "\n" - << "\t" << m_CTest->GetCTestConfiguration("BuildName") + << "\t" << this->CTest->GetCTestConfiguration("Site") << "\n" + << "\t" << this->CTest->GetCTestConfiguration("BuildName") << "\n" - << "\t" << m_CTest->GetCurrentTag() << "-" - << m_CTest->GetTestModelString() << "" << std::endl; + << "\t" << this->CTest->GetCurrentTag() << "-" + << this->CTest->GetTestModelString() << "" << std::endl; os << "\t" << start_time << "\n" - << "\t" << m_CTest->MakeXMLSafe(command) + << "\t" << this->CTest->MakeXMLSafe(command) << "\n" - << "\t" << m_CTest->MakeXMLSafe(cmCTestUpdateHandlerUpdateToString(updateType)) + << "\t" << this->CTest->MakeXMLSafe( + cmCTestUpdateHandlerUpdateToString(updateType)) << "\n"; - // Even though it failed, we may have some useful information. Try to continue... + // Even though it failed, we may have some useful information. Try to + // continue... std::vector lines; cmSystemTools::Split(goutput.c_str(), lines); std::vector errLines; @@ -525,49 +613,64 @@ lines.insert(lines.end(), errLines.begin(), errLines.end()); // CVS style regular expressions - cmsys::RegularExpression cvs_date_author_regex("^date: +([^;]+); +author: +([^;]+); +state: +[^;]+;"); + cmsys::RegularExpression cvs_date_author_regex( + "^date: +([^;]+); +author: +([^;]+); +state: +[^;]+;"); cmsys::RegularExpression cvs_revision_regex("^revision +([^ ]*) *$"); - cmsys::RegularExpression cvs_end_of_file_regex("^=============================================================================$"); - cmsys::RegularExpression cvs_end_of_comment_regex("^----------------------------$"); + cmsys::RegularExpression cvs_end_of_file_regex( + "^==========================================" + "===================================$"); + cmsys::RegularExpression cvs_end_of_comment_regex( + "^----------------------------$"); // Subversion style regular expressions - cmsys::RegularExpression svn_status_line_regex("^ *([0-9]+) *([0-9]+) *([^ ]+) *([^ ][^\t\r\n]*)[ \t\r\n]*$"); - cmsys::RegularExpression svn_latest_revision_regex("(Updated to|At) revision ([0-9]+)\\."); + cmsys::RegularExpression svn_status_line_regex( + "^ *([0-9]+) *([0-9]+) *([^ ]+) *([^ ][^\t\r\n]*)[ \t\r\n]*$"); + cmsys::RegularExpression svn_latest_revision_regex( + "(Updated to|At) revision ([0-9]+)\\."); - cmsys::RegularExpression file_removed_line("cvs update: `(.*)' is no longer in the repository"); + cmsys::RegularExpression file_removed_line( + "cvs update: `(.*)' is no longer in the repository"); cmsys::RegularExpression file_update_line("([A-Z]) *(.*)"); std::string current_path = ""; bool first_file = true; cmCTestUpdateHandler::AuthorsToUpdatesMap authors_files_map; - int num_updated = 0; - int num_modified = 0; - int num_conflicting = 0; + int numUpdated = 0; + int numModiefied = 0; + int numConflicting = 0; // In subversion, get the latest revision if ( updateType == cmCTestUpdateHandler::e_SVN ) { - for ( cc= 0 ; cc < lines.size(); cc ++ ) + for ( cc= 0; cc < lines.size(); cc ++ ) { const char* line = lines[cc].c_str(); if ( svn_latest_revision_regex.find(line) ) { - svn_latest_revision = atoi(svn_latest_revision_regex.match(2).c_str()); + svn_latest_revision = atoi( + svn_latest_revision_regex.match(2).c_str()); } } if ( svn_latest_revision <= 0 ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem determining the current revision of the repository from output:" << std::endl << goutput.c_str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Problem determining the current " + "revision of the repository from output:" << std::endl + << goutput.c_str() << std::endl); } else { - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Current revision of repository is: " << svn_latest_revision << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, + " Current revision of repository is: " << svn_latest_revision + << std::endl); } } - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Gathering version information (each . represents one updated file):" << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, + " Gathering version information (each . represents one updated file):" + << std::endl); int file_count = 0; std::string removed_line; - for ( cc= 0 ; cc < lines.size(); cc ++ ) + for ( cc= 0; cc < lines.size(); cc ++ ) { const char* line = lines[cc].c_str(); if ( file_removed_line.find(line) ) @@ -579,20 +682,25 @@ { if ( file_count == 0 ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, " " << std::flush); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " " << std::flush); } - cmCTestLog(m_CTest, HANDLER_OUTPUT, "." << std::flush); + cmCTestLog(this->CTest, HANDLER_OUTPUT, "." << std::flush); std::string upChar = file_update_line.match(1); std::string upFile = file_update_line.match(2); char mod = upChar[0]; bool modifiedOrConflict = false; + if ( mod == 'X') + { + continue; + } if ( mod != 'M' && mod != 'C' && mod != 'G' ) { count ++; modifiedOrConflict = true; } const char* file = upFile.c_str(); - cmCTestLog(m_CTest, DEBUG, "Line" << cc << ": " << mod << " - " << file << std::endl); + cmCTestLog(this->CTest, DEBUG, "Line" << cc << ": " << mod << " - " + << file << std::endl); std::string output; if ( modifiedOrConflict ) @@ -604,26 +712,31 @@ logcommand = updateCommand + " -z3 log -N \"" + file + "\""; break; case cmCTestUpdateHandler::e_SVN: - if ( svn_latest_revision > 0 && svn_latest_revision > svn_current_revision ) + if ( svn_latest_revision > 0 && + svn_latest_revision > svn_current_revision ) { cmOStringStream logCommandStream; - logCommandStream << updateCommand << " log -r " << svn_current_revision << ":" << svn_latest_revision + logCommandStream << updateCommand << " log -r " + << svn_current_revision << ":" << svn_latest_revision << " --xml \"" << file << "\""; logcommand = logCommandStream.str(); } else { - logcommand = updateCommand + " status --verbose \"" + file + "\""; + logcommand = updateCommand + + " status --verbose \"" + file + "\""; svn_use_status = 1; } break; } - cmCTestLog(m_CTest, DEBUG, "Do log: " << logcommand << std::endl); - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "* Get file update information: " << logcommand.c_str() << std::endl); + cmCTestLog(this->CTest, DEBUG, "Do log: " << logcommand << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "* Get file update information: " << logcommand.c_str() + << std::endl); ofs << "* Get log information for file: " << file << std::endl; ofs << " Command: " << logcommand.c_str() << std::endl; - res = m_CTest->RunCommand(logcommand.c_str(), &output, &errors, - &retVal, sourceDirectory, 0 /*m_TimeOut*/); + res = this->CTest->RunCommand(logcommand.c_str(), &output, &errors, + &retVal, sourceDirectory, 0 /*this->TimeOut*/); ofs << " Output: " << output.c_str() << std::endl; ofs << " Errors: " << errors.c_str() << std::endl; if ( ofs ) @@ -633,7 +746,7 @@ } if ( res && retVal == 0) { - cmCTestLog(m_CTest, DEBUG, output << std::endl); + cmCTestLog(this->CTest, DEBUG, output << std::endl); std::string::size_type sline = 0; std::string srevision1 = "Unknown"; std::string sdate1 = "Unknown"; @@ -665,7 +778,8 @@ srevision2 = cvs_revision_regex.match(1); } } - else if ( !have_second && !sline && cvs_date_author_regex.find(clp) ) + else if ( !have_second && !sline && + cvs_date_author_regex.find(clp) ) { sline = kk + 1; if ( !have_first ) @@ -679,7 +793,8 @@ sauthor2 = cvs_date_author_regex.match(2); } } - else if ( sline && cvs_end_of_comment_regex.find(clp) || cvs_end_of_file_regex.find(clp)) + else if ( sline && cvs_end_of_comment_regex.find(clp) || + cvs_end_of_file_regex.find(clp)) { if ( !have_first ) { @@ -715,16 +830,24 @@ srevision1 = str.str(); if (!svn_status_line_regex.find(output)) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Bad output from SVN status command: " << output << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Bad output from SVN status command: " << output + << std::endl); } else if ( svn_status_line_regex.match(4) != file ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Bad output from SVN status command. The file name returned: \"" << svn_status_line_regex.match(4) << "\" was different than the file specified: \"" << file << "\"" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Bad output from SVN status command. " + "The file name returned: \"" + << svn_status_line_regex.match(4) + << "\" was different than the file specified: \"" << file + << "\"" << std::endl); } else { srevision1 = svn_status_line_regex.match(2); - int latest_revision = atoi(svn_status_line_regex.match(2).c_str()); + int latest_revision = atoi( + svn_status_line_regex.match(2).c_str()); if ( svn_current_revision < latest_revision ) { srevision2 = str.str(); @@ -739,28 +862,29 @@ { int minrev = parser.GetMinRevision(); int maxrev = parser.GetMaxRevision(); - cmCTestUpdateHandlerSVNXMLParser::t_VectorOfCommits::iterator it; - for ( it = parser.GetCommits()->begin(); - it != parser.GetCommits()->end(); + cmCTestUpdateHandlerSVNXMLParser:: + t_VectorOfCommits::iterator it; + for ( it = parser.GetCommits()->begin(); + it != parser.GetCommits()->end(); ++ it ) { - if ( it->m_Revision == maxrev ) + if ( it->Revision == maxrev ) { cmOStringStream mRevStream; mRevStream << maxrev; srevision1 = mRevStream.str(); - sauthor1 = it->m_Author; - comment1 = it->m_Message; - sdate1 = it->m_Date; + sauthor1 = it->Author; + comment1 = it->Message; + sdate1 = it->Date; } - else if ( it->m_Revision == minrev ) + else if ( it->Revision == minrev ) { cmOStringStream mRevStream; mRevStream << minrev; srevision2 = mRevStream.str(); - sauthor2 = it->m_Author; - comment2 = it->m_Message; - sdate2 = it->m_Date; + sauthor2 = it->Author; + comment2 = it->Message; + sdate2 = it->Date; } } } @@ -797,36 +921,40 @@ } if ( mod == 'C' ) { - num_conflicting ++; + numConflicting ++; os << "\t" << std::endl; } else if ( mod == 'G' ) { - num_conflicting ++; + numConflicting ++; os << "\t" << std::endl; } else if ( mod == 'M' ) { - num_modified ++; + numModiefied ++; os << "\t" << std::endl; } else { - num_updated ++; + numUpdated ++; os << "\t" << std::endl; } if ( srevision2 == "Unknown" ) { srevision2 = srevision1; } - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "File: " << path.c_str() << " / " << fname.c_str() << " was updated by " + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "File: " + << path.c_str() << " / " << fname.c_str() << " was updated by " << sauthor1.c_str() << " to revision: " << srevision1.c_str() << " from revision: " << srevision2.c_str() << std::endl); - os << "\t\t" << cmCTest::MakeXMLSafe(fname) + os << "\t\t" + << cmCTest::MakeXMLSafe(fname) << "\n" - << "\t\t" << cmCTest::MakeXMLSafe(path) << "\n" + << "\t\t" << cmCTest::MakeXMLSafe(path) + << "\n" << "\t\t" << cmCTest::MakeXMLSafe(file) << "\n" - << "\t\t" << cmCTest::MakeXMLSafe(sdate1) << "\n" + << "\t\t" << cmCTest::MakeXMLSafe(sdate1) + << "\n" << "\t\t" << cmCTest::MakeXMLSafe(sauthor1) << "\n" << "\t\t" << cmCTest::MakeXMLSafe(semail1) << "\n" << "\t\t" << cmCTest::MakeXMLSafe(comment1) << "\n" @@ -838,19 +966,29 @@ os << "\t\t\n" << "\t\t\t" << srevision1 << "\n" - << "\t\t\t" << srevision2 << "\n" - << "\t\t\t" << cmCTest::MakeXMLSafe(sauthor1) << "\n" - << "\t\t\t" << cmCTest::MakeXMLSafe(sdate1) << "\n" - << "\t\t\t" << cmCTest::MakeXMLSafe(comment1) << "\n" - << "\t\t\t" << cmCTest::MakeXMLSafe(semail1) << "\n" + << "\t\t\t" << srevision2 + << "\n" + << "\t\t\t" << cmCTest::MakeXMLSafe(sauthor1) + << "\n" + << "\t\t\t" << cmCTest::MakeXMLSafe(sdate1) + << "\n" + << "\t\t\t" << cmCTest::MakeXMLSafe(comment1) + << "\n" + << "\t\t\t" << cmCTest::MakeXMLSafe(semail1) + << "\n" << "\t\t\n" << "\t\t\n" << "\t\t\t" << srevision2 << "\n" - << "\t\t\t" << srevision2 << "\n" - << "\t\t\t" << cmCTest::MakeXMLSafe(sauthor2) << "\n" - << "\t\t\t" << cmCTest::MakeXMLSafe(sdate2) << "\n" - << "\t\t\t" << cmCTest::MakeXMLSafe(comment2) << "\n" - << "\t\t\t" << cmCTest::MakeXMLSafe(semail2) << "\n" + << "\t\t\t" << srevision2 + << "\n" + << "\t\t\t" << cmCTest::MakeXMLSafe(sauthor2) + << "\n" + << "\t\t\t" << cmCTest::MakeXMLSafe(sdate2) + << "\n" + << "\t\t\t" << cmCTest::MakeXMLSafe(comment2) + << "\n" + << "\t\t\t" << cmCTest::MakeXMLSafe(semail2) + << "\n" << "\t\t" << std::endl; } if ( mod == 'C' ) @@ -882,25 +1020,29 @@ } if ( file_count ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl); } - if ( num_updated ) + if ( numUpdated ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Found " << num_updated << " updated files" << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Found " << numUpdated + << " updated files" << std::endl); } - if ( num_modified ) + if ( numModiefied ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Found " << num_modified << " locally modified files" + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Found " << numModiefied + << " locally modified files" << std::endl); } - if ( num_conflicting ) + if ( numConflicting ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Found " << num_conflicting << " conflicting files" + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Found " << numConflicting + << " conflicting files" << std::endl); } - if ( num_modified == 0 && num_conflicting == 0 && num_updated == 0 ) + if ( numModiefied == 0 && numConflicting == 0 && numUpdated == 0 ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Project is up-to-date" << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Project is up-to-date" + << std::endl); } if ( !first_file ) { @@ -923,36 +1065,37 @@ os << "\t" << std::endl; } - cmCTestLog(m_CTest, DEBUG, "End" << std::endl); - std::string end_time = m_CTest->CurrentTime(); + cmCTestLog(this->CTest, DEBUG, "End" << std::endl); + std::string end_time = this->CTest->CurrentTime(); os << "\t" << end_time << "\n" - << "" << - static_cast((cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0 + << "" << + static_cast((cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0 << "\n" << "\t"; - if ( num_modified > 0 || num_conflicting > 0 ) + if ( numModiefied > 0 || numConflicting > 0 ) { - os << "Update error: There are modified or conflicting files in the repository"; - cmCTestLog(m_CTest, ERROR_MESSAGE, " There are modified or conflicting files in the repository" << std::endl); + os << "Update error: There are modified or conflicting files in the " + "repository"; + cmCTestLog(this->CTest, ERROR_MESSAGE, + " There are modified or conflicting files in the repository" + << std::endl); } if ( updateProducedError ) { os << "Update error: "; - os << m_CTest->MakeXMLSafe(checkoutErrorMessages); - cmCTestLog(m_CTest, ERROR_MESSAGE, " Update with command: " << command << " failed" << std::endl); + os << this->CTest->MakeXMLSafe(checkoutErrorMessages); + cmCTestLog(this->CTest, ERROR_MESSAGE, " Update with command: " + << command << " failed" << std::endl); } os << "" << std::endl; os << "" << std::endl; - if ( ofs ) - { - ofs.close(); - } - if (! res || retVal ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Error(s) when updating the project" << std::endl); - cmCTestLog(m_CTest, ERROR_MESSAGE, "Output: " << goutput << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Error(s) when updating the project" << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, "Output: " + << goutput << std::endl); return -1; } return count; diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestUpdateHandler.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestUpdateHandler.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/cmCTestUpdateHandler.h 2005-06-18 01:04:56.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/cmCTestUpdateHandler.h 2006-03-11 04:03:09.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestUpdateHandler.h,v $ Language: C++ - Date: $Date: 2005/06/17 17:04:56 $ - Version: $Revision: 1.7 $ + Date: $Date: 2006/03/10 20:03:09 $ + Version: $Revision: 1.8 $ Copyright (c) 2002 Kitware, Inc. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -39,7 +39,7 @@ * The main entry point for this class */ int ProcessHandler(); - + cmCTestUpdateHandler(); enum { @@ -53,13 +53,13 @@ * Initialize handler */ virtual void Initialize(); - + private: // Some structures needed for update - struct StringPair : + struct StringPair : public std::pair{}; struct UpdateFiles : public std::vector{}; - struct AuthorsToUpdatesMap : + struct AuthorsToUpdatesMap : public std::map{}; // Determine the type of version control diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/amigaos.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/amigaos.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/amigaos.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/amigaos.c 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,49 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: amigaos.c,v 1.1 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +#include "amigaos.h" +#include /* for stderr */ + +struct Library *SocketBase = NULL; + +void amiga_cleanup() +{ + if(SocketBase) + CloseLibrary(SocketBase); + + SocketBase = NULL; +} + +BOOL amiga_init() +{ + if(!SocketBase) + SocketBase = OpenLibrary("bsdsocket.library", 4); + + if(!SocketBase) { + fprintf(stderr, "No TCP/IP Stack running!\n\a"); + return FALSE; + } + + atexit(amiga_cleanup); + return TRUE; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/amigaos.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/amigaos.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/amigaos.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/amigaos.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,52 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: amigaos.h,v 1.1 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +#ifndef LIBCURL_AMIGAOS_H +#define LIBCURL_AMIGAOS_H + +#ifndef __ixemul__ + +#include +#include + +#include +#include + +#include + +#include "config-amigaos.h" + +#define select(args...) WaitSelect( args, NULL) +#define inet_ntoa(x) Inet_NtoA( x ## .s_addr) +#define ioctl(a,b,c,d) IoctlSocket( (LONG)a, (ULONG)b, (char*)c) +#define _AMIGASF 1 + +extern void amiga_cleanup(); +extern BOOL amiga_init(); + +#else /* __ixemul__ */ + +#warning compiling with ixemul... + +#endif /* __ixemul__ */ +#endif /* LIBCURL_AMIGAOS_H */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/arpa_telnet.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/arpa_telnet.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/arpa_telnet.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/arpa_telnet.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,101 @@ +#ifndef __ARPA_TELNET_H +#define __ARPA_TELNET_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: arpa_telnet.h,v 1.5 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ +#ifndef CURL_DISABLE_TELNET +/* + * Telnet option defines. Add more here if in need. + */ +#define CURL_TELOPT_BINARY 0 /* binary 8bit data */ +#define CURL_TELOPT_SGA 3 /* Supress Go Ahead */ +#define CURL_TELOPT_EXOPL 255 /* EXtended OPtions List */ +#define CURL_TELOPT_TTYPE 24 /* Terminal TYPE */ +#define CURL_TELOPT_XDISPLOC 35 /* X DISPlay LOCation */ + +#define CURL_TELOPT_NEW_ENVIRON 39 /* NEW ENVIRONment variables */ +#define CURL_NEW_ENV_VAR 0 +#define CURL_NEW_ENV_VALUE 1 + +/* + * The telnet options represented as strings + */ +static const char *telnetoptions[]= +{ + "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", + "NAME", "STATUS", "TIMING MARK", "RCTE", + "NAOL", "NAOP", "NAOCRD", "NAOHTS", + "NAOHTD", "NAOFFD", "NAOVTS", "NAOVTD", + "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO", + "DE TERMINAL", "SUPDUP", "SUPDUP OUTPUT", "SEND LOCATION", + "TERM TYPE", "END OF RECORD", "TACACS UID", "OUTPUT MARKING", + "TTYLOC", "3270 REGIME", "X3 PAD", "NAWS", + "TERM SPEED", "LFLOW", "LINEMODE", "XDISPLOC", + "OLD-ENVIRON", "AUTHENTICATION", "ENCRYPT", "NEW-ENVIRON" +}; + +#define CURL_TELOPT_MAXIMUM CURL_TELOPT_NEW_ENVIRON + +#define CURL_TELOPT_OK(x) ((x) <= CURL_TELOPT_MAXIMUM) +#define CURL_TELOPT(x) telnetoptions[x] + +#define CURL_NTELOPTS 40 + +/* + * First some defines + */ +#define CURL_xEOF 236 /* End Of File */ +#define CURL_SE 240 /* Sub negotiation End */ +#define CURL_NOP 241 /* No OPeration */ +#define CURL_DM 242 /* Data Mark */ +#define CURL_GA 249 /* Go Ahead, reverse the line */ +#define CURL_SB 250 /* SuBnegotiation */ +#define CURL_WILL 251 /* Our side WILL use this option */ +#define CURL_WONT 252 /* Our side WON'T use this option */ +#define CURL_DO 253 /* DO use this option! */ +#define CURL_DONT 254 /* DON'T use this option! */ +#define CURL_IAC 255 /* Interpret As Command */ + +/* + * Then those numbers represented as strings: + */ +static const char *telnetcmds[]= +{ + "EOF", "SUSP", "ABORT", "EOR", "SE", + "NOP", "DMARK", "BRK", "IP", "AO", + "AYT", "EC", "EL", "GA", "SB", + "WILL", "WONT", "DO", "DONT", "IAC" +}; + +#define CURL_TELCMD_MINIMUM CURL_xEOF /* the first one */ +#define CURL_TELCMD_MAXIMUM CURL_IAC /* surprise, 255 is the last one! ;-) */ + +#define CURL_TELQUAL_IS 0 +#define CURL_TELQUAL_SEND 1 +#define CURL_TELQUAL_INFO 2 +#define CURL_TELQUAL_NAME 3 + +#define CURL_TELCMD_OK(x) ( ((unsigned int)(x) >= CURL_TELCMD_MINIMUM) && \ + ((unsigned int)(x) <= CURL_TELCMD_MAXIMUM) ) +#define CURL_TELCMD(x) telnetcmds[(x)-CURL_TELCMD_MINIMUM] +#endif +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/base64.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/base64.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/base64.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/base64.c 2004-10-13 22:01:04.000000000 +0800 @@ -0,0 +1,288 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: base64.c,v 1.8 2004/10/13 14:01:04 andy Exp $ + ***************************************************************************/ + +/* Base64 encoding/decoding + * + * Test harnesses down the bottom - compile with -DTEST_ENCODE for + * a program that will read in raw data from stdin and write out + * a base64-encoded version to stdout, and the length returned by the + * encoding function to stderr. Compile with -DTEST_DECODE for a program that + * will go the other way. + * + * This code will break if int is smaller than 32 bits + */ + +#include "setup.h" + +#include +#include + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +#include "base64.h" +#include "curl_memory.h" + +/* include memdebug.h last */ +#include "memdebug.h" + + +static void decodeQuantum(unsigned char *dest, const char *src) +{ + unsigned int x = 0; + int i; + for(i = 0; i < 4; i++) { + if(src[i] >= 'A' && src[i] <= 'Z') + x = (x << 6) + (unsigned int)(src[i] - 'A' + 0); + else if(src[i] >= 'a' && src[i] <= 'z') + x = (x << 6) + (unsigned int)(src[i] - 'a' + 26); + else if(src[i] >= '0' && src[i] <= '9') + x = (x << 6) + (unsigned int)(src[i] - '0' + 52); + else if(src[i] == '+') + x = (x << 6) + 62; + else if(src[i] == '/') + x = (x << 6) + 63; + else if(src[i] == '=') + x = (x << 6); + } + + dest[2] = (unsigned char)(x & 255); + x >>= 8; + dest[1] = (unsigned char)(x & 255); + x >>= 8; + dest[0] = (unsigned char)(x & 255); +} + +/* + * Curl_base64_decode() + * + * Given a base64 string at src, decode it into the memory pointed to by + * dest. Returns the length of the decoded data. + */ +size_t Curl_base64_decode(const char *src, char *dest) +{ + int length = 0; + int equalsTerm = 0; + int i; + int numQuantums; + unsigned char lastQuantum[3]; + size_t rawlen; + + while((src[length] != '=') && src[length]) + length++; + while(src[length+equalsTerm] == '=') + equalsTerm++; + + numQuantums = (length + equalsTerm) / 4; + + rawlen = (numQuantums * 3) - equalsTerm; + + for(i = 0; i < numQuantums - 1; i++) { + decodeQuantum((unsigned char *)dest, src); + dest += 3; src += 4; + } + + decodeQuantum(lastQuantum, src); + for(i = 0; i < 3 - equalsTerm; i++) + dest[i] = lastQuantum[i]; + + return rawlen; +} + +/* ---- Base64 Encoding --- */ +static char table64[]= + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + +/* + * Curl_base64_encode() + * + * Returns the length of the newly created base64 string. The third argument + * is a pointer to an allocated area holding the base64 data. If something + * went wrong, -1 is returned. + * + */ +size_t Curl_base64_encode(const char *inp, size_t insize, char **outptr) +{ + unsigned char ibuf[3]; + unsigned char obuf[4]; + int i; + int inputparts; + char *output; + char *base64data; + + char *indata = (char *)inp; + + *outptr = NULL; /* set to NULL in case of failure before we reach the end */ + + if(0 == insize) + insize = strlen(indata); + + base64data = output = (char*)malloc(insize*4/3+4); + if(NULL == output) + return 0; + + while(insize > 0) { + for (i = inputparts = 0; i < 3; i++) { + if(insize > 0) { + inputparts++; + ibuf[i] = *indata; + indata++; + insize--; + } + else + ibuf[i] = 0; + } + + obuf [0] = (ibuf [0] & 0xFC) >> 2; + obuf [1] = ((ibuf [0] & 0x03) << 4) | ((ibuf [1] & 0xF0) >> 4); + obuf [2] = ((ibuf [1] & 0x0F) << 2) | ((ibuf [2] & 0xC0) >> 6); + obuf [3] = ibuf [2] & 0x3F; + + switch(inputparts) { + case 1: /* only one byte read */ + snprintf(output, 5, "%c%c==", + table64[obuf[0]], + table64[obuf[1]]); + break; + case 2: /* two bytes read */ + snprintf(output, 5, "%c%c%c=", + table64[obuf[0]], + table64[obuf[1]], + table64[obuf[2]]); + break; + default: + snprintf(output, 5, "%c%c%c%c", + table64[obuf[0]], + table64[obuf[1]], + table64[obuf[2]], + table64[obuf[3]] ); + break; + } + output += 4; + } + *output=0; + *outptr = base64data; /* make it return the actual data memory */ + + return strlen(base64data); /* return the length of the new data */ +} +/* ---- End of Base64 Encoding ---- */ + +/************* TEST HARNESS STUFF ****************/ + + +#ifdef TEST_ENCODE +/* encoding test harness. Read in standard input and write out the length + * returned by Curl_base64_encode, followed by the base64'd data itself + */ +#include + +#define TEST_NEED_SUCK +void *suck(int *); + +int main(int argc, char **argv, char **envp) +{ + char *base64; + size_t base64Len; + unsigned char *data; + int dataLen; + + data = (unsigned char *)suck(&dataLen); + base64Len = Curl_base64_encode(data, dataLen, &base64); + + fprintf(stderr, "%d\n", base64Len); + fprintf(stdout, "%s", base64); + + free(base64); free(data); + return 0; +} +#endif + +#ifdef TEST_DECODE +/* decoding test harness. Read in a base64 string from stdin and write out the + * length returned by Curl_base64_decode, followed by the decoded data itself + * + * gcc -DTEST_DECODE base64.c -o base64 mprintf.o memdebug.o + */ +#include + +#define TEST_NEED_SUCK +void *suck(int *); + +int main(int argc, char **argv, char **envp) +{ + char *base64; + int base64Len; + unsigned char *data; + int dataLen; + int i, j; + + base64 = (char *)suck(&base64Len); + data = (unsigned char *)malloc(base64Len * 3/4 + 8); + dataLen = Curl_base64_decode(base64, data); + + fprintf(stderr, "%d\n", dataLen); + + for(i=0; i < dataLen; i+=0x10) { + printf("0x%02x: ", i); + for(j=0; j < 0x10; j++) + if((j+i) < dataLen) + printf("%02x ", data[i+j]); + else + printf(" "); + + printf(" | "); + + for(j=0; j < 0x10; j++) + if((j+i) < dataLen) + printf("%c", isgraph(data[i+j])?data[i+j]:'.'); + else + break; + puts(""); + } + + free(base64); free(data); + return 0; +} +#endif + +#ifdef TEST_NEED_SUCK +/* this function 'sucks' in as much as possible from stdin */ +void *suck(int *lenptr) +{ + int cursize = 8192; + unsigned char *buf = NULL; + int lastread; + int len = 0; + + do { + cursize *= 2; + buf = (unsigned char *)realloc(buf, cursize); + memset(buf + len, 0, cursize - len); + lastread = fread(buf + len, 1, cursize - len, stdin); + len += lastread; + } while(!feof(stdin)); + + lenptr[0] = len; + return (void *)buf; +} +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/base64.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/base64.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/base64.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/base64.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,27 @@ +#ifndef __BASE64_H +#define __BASE64_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: base64.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ +size_t Curl_base64_encode(const char *input, size_t size, char **str); +size_t Curl_base64_decode(const char *source, char *dest); +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/ca-bundle.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/ca-bundle.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/ca-bundle.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/ca-bundle.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1 @@ +/* ca bundle path set in here*/ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/CMake/CheckTypeSize.c.in /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/CMake/CheckTypeSize.c.in --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/CMake/CheckTypeSize.c.in 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/CMake/CheckTypeSize.c.in 2004-10-05 21:04:58.000000000 +0800 @@ -0,0 +1,34 @@ +#ifdef CHECK_TYPE_SIZE_TYPE + +@CHECK_TYPE_SIZE_PREINCLUDE@ + +#ifdef HAVE_SYS_TYPES_H +# include +#endif /* HAVE_SYS_TYPES_H */ + +#ifdef HAVE_STDINT_H +# include +#endif /* HAVE_STDINT_H */ + +#ifdef HAVE_STDDEF_H +# include +#endif /* HAVE_STDDEF_H */ + +@CHECK_TYPE_SIZE_PREMAIN@ + +#ifdef __CLASSIC_C__ +int main(){ + int ac; + char*av[]; +#else +int main(int ac, char*av[]){ +#endif + if(ac > 1000){return *av[0];} + return sizeof(CHECK_TYPE_SIZE_TYPE); +} + +#else /* CHECK_TYPE_SIZE_TYPE */ + +# error "CHECK_TYPE_SIZE_TYPE has to specify the type" + +#endif /* CHECK_TYPE_SIZE_TYPE */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/CMake/CheckTypeSize.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/CMake/CheckTypeSize.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/CMake/CheckTypeSize.cmake 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/CMake/CheckTypeSize.cmake 2006-01-13 02:49:01.000000000 +0800 @@ -0,0 +1,51 @@ +# +# Check if the type exists and determine size of type. if the type +# exists, the size will be stored to the variable. +# +# CHECK_TYPE_SIZE - macro which checks the size of type +# VARIABLE - variable to store size if the type exists. +# HAVE_${VARIABLE} - does the variable exists or not +# + +MACRO(CHECK_TYPE_SIZE TYPE VARIABLE) + SET(CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS 1) + IF("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$") + SET(MACRO_CHECK_TYPE_SIZE_FLAGS + "-DCHECK_TYPE_SIZE_TYPE=\"${TYPE}\" ${CMAKE_REQUIRED_FLAGS}") + FOREACH(def HAVE_SYS_TYPES_H HAVE_STDINT_H HAVE_STDDEF_H) + IF("${def}") + SET(MACRO_CHECK_TYPE_SIZE_FLAGS + "${MACRO_CHECK_TYPE_SIZE_FLAGS} -D${def}") + ENDIF("${def}") + ENDFOREACH(def) + SET(CHECK_TYPE_SIZE_PREMAIN) + FOREACH(def ${CMAKE_EXTRA_INCLUDE_FILES}) + SET(CHECK_TYPE_SIZE_PREMAIN "${CHECK_TYPE_SIZE_PREMAIN}#include \"${def}\"\n") + ENDFOREACH(def) + CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/CMake/CheckTypeSize.c.in" + "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckTypeSize.c" @ONLY) + FILE(READ "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckTypeSize.c" + CHECK_TYPE_SIZE_FILE_CONTENT) + MESSAGE(STATUS "Check size of ${TYPE}") + IF(CMAKE_REQUIRED_LIBRARIES) + SET(CHECK_TYPE_SIZE_ADD_LIBRARIES + "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + ENDIF(CMAKE_REQUIRED_LIBRARIES) + TRY_RUN(${VARIABLE} HAVE_${VARIABLE} + ${CMAKE_BINARY_DIR} + "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckTypeSize.c" + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_TYPE_SIZE_FLAGS} + "${CHECK_TYPE_SIZE_ADD_LIBRARIES}" + OUTPUT_VARIABLE OUTPUT) + IF(HAVE_${VARIABLE}) + MESSAGE(STATUS "Check size of ${TYPE} - done") + FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeOutput.log + "Determining size of ${TYPE} passed with the following output:\n${OUTPUT}\n\n") + ELSE(HAVE_${VARIABLE}) + MESSAGE(STATUS "Check size of ${TYPE} - failed") + FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log + "Determining size of ${TYPE} failed with the following output:\n${OUTPUT}\nCheckTypeSize.c:\n${CHECK_TYPE_SIZE_FILE_CONTENT}\n\n") + ENDIF(HAVE_${VARIABLE}) + ENDIF("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$") + SET(CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS ) +ENDMACRO(CHECK_TYPE_SIZE) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/CMake/CurlTests.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/CMake/CurlTests.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/CMake/CurlTests.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/CMake/CurlTests.c 2004-10-08 05:48:36.000000000 +0800 @@ -0,0 +1,535 @@ +#ifdef TIME_WITH_SYS_TIME +/* Time with sys/time test */ + +#include +#include +#include + +int +main () +{ +if ((struct tm *) 0) +return 0; + ; + return 0; +} + +#endif + +#ifdef HAVE_O_NONBLOCK + +#include +#include +#include + +int +main () +{ + /* try to compile O_NONBLOCK */ + +#if defined(sun) || defined(__sun__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) +# if defined(__SVR4) || defined(__srv4__) +# define PLATFORM_SOLARIS +# else +# define PLATFORM_SUNOS4 +# endif +#endif +#if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX4) +# define PLATFORM_AIX_V3 +#endif + +#if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__) +#error "O_NONBLOCK does not work on this platform" +#endif + int socket; + int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK); + return 0; +} +#endif + +#ifdef HAVE_GETHOSTBYADDR_R_5 +#include +#include +int +main () +{ + +char * address; +int length; +int type; +struct hostent h; +struct hostent_data hdata; +int rc; +#ifndef gethostbyaddr_r + (void)gethostbyaddr_r; +#endif +rc = gethostbyaddr_r(address, length, type, &h, &hdata); + ; + return 0; +} +#endif +#ifdef HAVE_GETHOSTBYADDR_R_5_REENTRANT +#define _REENTRANT +#include +#include +int +main () +{ + +char * address; +int length;q +int type; +struct hostent h; +struct hostent_data hdata; +int rc; +#ifndef gethostbyaddr_r + (void)gethostbyaddr_r; +#endif +rc = gethostbyaddr_r(address, length, type, &h, &hdata); + ; + return 0; +} +#endif +#ifdef HAVE_GETHOSTBYADDR_R_7 +#include +#include +int +main () +{ + +char * address; +int length; +int type; +struct hostent h; +char buffer[8192]; +int h_errnop; +struct hostent * hp; + +#ifndef gethostbyaddr_r + (void)gethostbyaddr_r; +#endif +hp = gethostbyaddr_r(address, length, type, &h, + buffer, 8192, &h_errnop); + ; + return 0; +} +#endif +#ifdef HAVE_GETHOSTBYADDR_R_7_REENTRANT +#define _REENTRANT +#include +#include +int +main () +{ + +char * address; +int length; +int type; +struct hostent h; +char buffer[8192]; +int h_errnop; +struct hostent * hp; + +#ifndef gethostbyaddr_r + (void)gethostbyaddr_r; +#endif +hp = gethostbyaddr_r(address, length, type, &h, + buffer, 8192, &h_errnop); + ; + return 0; +} +#endif +#ifdef HAVE_GETHOSTBYADDR_R_8 +#include +#include +int +main () +{ + +char * address; +int length; +int type; +struct hostent h; +char buffer[8192]; +int h_errnop; +struct hostent * hp; +int rc; + +#ifndef gethostbyaddr_r + (void)gethostbyaddr_r; +#endif +rc = gethostbyaddr_r(address, length, type, &h, + buffer, 8192, &hp, &h_errnop); + ; + return 0; +} +#endif +#ifdef HAVE_GETHOSTBYADDR_R_8_REENTRANT +#define _REENTRANT +#include +#include +int +main () +{ + +char * address; +int length; +int type; +struct hostent h; +char buffer[8192]; +int h_errnop; +struct hostent * hp; +int rc; + +#ifndef gethostbyaddr_r + (void)gethostbyaddr_r; +#endif +rc = gethostbyaddr_r(address, length, type, &h, + buffer, 8192, &hp, &h_errnop); + ; + return 0; +} +#endif +#ifdef HAVE_GETHOSTBYNAME_R_3 +#include +#include +#include +#undef NULL +#define NULL (void *)0 + +int +main () +{ + +struct hostent_data data; +#ifndef gethostbyname_r + (void)gethostbyname_r; +#endif +gethostbyname_r(NULL, NULL, NULL); + ; + return 0; +} +#endif +#ifdef HAVE_GETHOSTBYNAME_R_3_REENTRANT +#define _REENTRANT +#include +#include +#include +#undef NULL +#define NULL (void *)0 + +int +main () +{ + +struct hostent_data data; +#ifndef gethostbyname_r + (void)gethostbyname_r; +#endif +gethostbyname_r(NULL, NULL, NULL); + ; + return 0; +} +#endif +#ifdef HAVE_GETHOSTBYNAME_R_5 +#include +#include +#include +#undef NULL +#define NULL (void *)0 + +int +main () +{ +#ifndef gethostbyname_r + (void)gethostbyname_r; +#endif +gethostbyname_r(NULL, NULL, NULL, 0, NULL); + ; + return 0; +} +#endif +#ifdef HAVE_GETHOSTBYNAME_R_5_REENTRANT +#define _REENTRANT +#include +#include +#undef NULL +#define NULL (void *)0 + +int +main () +{ + +#ifndef gethostbyname_r + (void)gethostbyname_r; +#endif +gethostbyname_r(NULL, NULL, NULL, 0, NULL); + ; + return 0; +} +#endif +#ifdef HAVE_GETHOSTBYNAME_R_6 +#include +#include +#undef NULL +#define NULL (void *)0 + +int +main () +{ + +#ifndef gethostbyname_r + (void)gethostbyname_r; +#endif +gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL); + ; + return 0; +} +#endif +#ifdef HAVE_GETHOSTBYNAME_R_6_REENTRANT +#define _REENTRANT +#include +#include +#undef NULL +#define NULL (void *)0 + +int +main () +{ + +#ifndef gethostbyname_r + (void)gethostbyname_r; +#endif +gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL); + ; + return 0; +} +#endif +#ifdef HAVE_SOCKLEN_T +#include +#include + +int +main () +{ +if ((socklen_t *) 0) + return 0; +if (sizeof (socklen_t)) + return 0; + ; + return 0; +} +#endif +#ifdef HAVE_IN_ADDR_T +#include +#include +#include + +int +main () +{ +if ((in_addr_t *) 0) + return 0; +if (sizeof (in_addr_t)) + return 0; + ; + return 0; +} +#endif +#ifdef STDC_HEADERS +#include +#include +#include +#include +int main() { return 0; } +#endif +#ifdef RETSIGTYPE_TEST +#include +#include +#ifdef signal +# undef signal +#endif +#ifdef __cplusplus +extern "C" void (*signal (int, void (*)(int)))(int); +#else +void (*signal ()) (); +#endif + +int +main () +{ + return 0; +} +#endif +#ifdef HAVE_INET_NTOA_R_DECL +#include + +typedef void (*func_type)(); + +int main() +{ +#ifndef inet_ntoa_r + func_type func; + func = (func_type)inet_ntoa_r; +#endif + return 0; +} +#endif +#ifdef HAVE_INET_NTOA_R_DECL_REENTRANT +#define _REENTRANT +#include + +typedef void (*func_type)(); + +int main() +{ +#ifndef inet_ntoa_r + func_type func; + func = (func_type)&inet_ntoa_r; +#endif + return 0; +} +#endif +#ifdef HAVE_GETADDRINFO +#include +#include +#include + +int main(void) { + struct addrinfo hints, *ai; + int error; + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; +#ifndef getaddrinfo + (void)getaddrinfo; +#endif + error = getaddrinfo("127.0.0.1", "8080", &hints, &ai); + if (error) { + return 1; + } + return 0; +} +#endif +#ifdef HAVE_FILE_OFFSET_BITS +#ifdef _FILE_OFFSET_BITS +#undef _FILE_OFFSET_BITS +#endif +#define _FILE_OFFSET_BITS 64 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int main () { ; return 0; } +#endif +#ifdef HAVE_IOCTLSOCKET +#include + +int +main () +{ + +/* ioctlsocket source code */ + int socket; + unsigned long flags = ioctlsocket(socket, FIONBIO, &flags); + + ; + return 0; +} + +#endif +#ifdef HAVE_IOCTLSOCKET_CASE +#include + +int +main () +{ + +/* IoctlSocket source code */ + int socket; + int flags = IoctlSocket(socket, FIONBIO, (long)1); + + ; + return 0; +} +#endif +#ifdef HAVE_FIONBIO +/* headers for FIONBIO test */ +#include +#include + +int +main () +{ + +/* FIONBIO source test (old-style unix) */ + int socket; + int flags = ioctl(socket, FIONBIO, &flags); + + ; + return 0; +} +#endif +#ifdef HAVE_SO_NONBLOCK + +/* headers for SO_NONBLOCK test (BeOS) */ +#include +#include +#include + +int main() +{ +/* SO_NONBLOCK source code */ + long b = 1; + int socket; + int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b)); + return 0; +} +#endif +#ifdef HAVE_GLIBC_STRERROR_R +#include +#include +int +main () { + char buffer[1024]; /* big enough to play with */ + char *string = + strerror_r(EACCES, buffer, sizeof(buffer)); + /* this should've returned a string */ + if(!string || !string[0]) + return 99; + return 0; +} +#endif +#ifdef HAVE_POSIX_STRERROR_R +#include +#include +int +main () { + char buffer[1024]; /* big enough to play with */ + int error = + strerror_r(EACCES, buffer, sizeof(buffer)); + /* This should've returned zero, and written an error string in the + buffer.*/ + if(!buffer[0] || error) + return 99; + return 0; +} +#endif +#ifdef HAVE_LONG_LONG_CONSTANT +int main() +{ + long long c = 0x8000000000000000LL; + long long k = 0x7FFFFFFFFFFFFFFFLL; + if ( c == 0x8000000000000000LL && c != k ) + { + return 0; + } + return 1; +} +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/CMakeLists.txt /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/CMakeLists.txt --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/CMakeLists.txt 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/CMakeLists.txt 2005-06-24 00:05:11.000000000 +0800 @@ -0,0 +1,586 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.0) +PROJECT(LIBCURL C) + +INCLUDE_REGULAR_EXPRESSION("^.*\\.h$") + +# Setup package meta-data +SET(PACKAGE "curl") +SET(VERSION "7.12.1") +SET(PACKAGE_TARNAME "curl") +SET(PACKAGE_BUGREPORT " ") +SET(PACKAGE_NAME "curl") +SET(PACKAGE_VERSION "-") +SET(PACKAGE_STRING "curl-") +SET(PACKAGE_BUGREPORT "a suitable curl mailing list => http://curl.haxx.se/mail/") +SET(OPERATING_SYSTEM "${CMAKE_SYSTEM_NAME}") + +# We need ansi c-flags, especially on HP +SET(CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}") +SET(CMAKE_REQUIRED_FLAGS ${CMAKE_ANSI_CFLAGS}) + +# If we are on AIX, do the _ALL_SOURCE magic +IF(${CMAKE_SYSTEM_NAME} MATCHES AIX) + SET(_ALL_SOURCE 1) +ENDIF(${CMAKE_SYSTEM_NAME} MATCHES AIX) + +# Include all the necessary files for macros +SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake") +INCLUDE (CheckFunctionExists) +INCLUDE (CheckIncludeFile) +INCLUDE (CheckIncludeFiles) +INCLUDE (CheckLibraryExists) +INCLUDE (CheckSymbolExists) +INCLUDE (CheckTypeSize) + +SET(libCurl_SRCS + base64.c + connect.c + content_encoding.c + cookie.c + dict.c + easy.c + escape.c + file.c + formdata.c + ftp.c + getdate.c + getenv.c + getinfo.c + hash.c + hostares.c + hostasyn.c + hostip.c + hostip4.c + hostip6.c + hostsyn.c + hostthre.c + http.c + http_chunks.c + http_digest.c + http_negotiate.c + http_ntlm.c + if2ip.c + inet_ntop.c + inet_pton.c + krb4.c + llist.c + md5.c + memdebug.c + mprintf.c + multi.c + netrc.c + progress.c + sendf.c + share.c + speedcheck.c + ssluse.c + strequal.c + strerror.c + telnet.c + timeval.c + transfer.c + url.c + version.c + ) + +SET(CURL_DISABLE_LDAP 1) +IF(NOT CURL_DISABLE_LDAP) + SET(libCurl_SRCS + ${libCurl_SRCS} + ldap.c + ) +ENDIF(NOT CURL_DISABLE_LDAP) + +# if we have Kerberos 4, right now this is never on +#OPTION(CURL_KRB4 "Use Kerberos 4" OFF) +IF(CURL_KRB4) + SET(libCurl_SRCS ${libCurl_SRCS} + krb4.c + security.c + ) +ENDIF(CURL_KRB4) + +#OPTION(CURL_MALLOC_DEBUG "Debug mallocs in Curl" OFF) +MARK_AS_ADVANCED(CURL_MALLOC_DEBUG) +IF(CURL_MALLOC_DEBUG) + SET(libCurl_SRCS ${libCurl_SRCS} + memdebug.c + ) +ENDIF(CURL_MALLOC_DEBUG) + +# On windows preload settings +IF(WIN32) + INCLUDE(${LIBCURL_SOURCE_DIR}/Platforms/WindowsCache.cmake) +ENDIF(WIN32) + +# This macro checks if the symbol exists in the library and if it +# does, it appends library to the list. +SET(CURL_LIBS "") +MACRO(CHECK_LIBRARY_EXISTS_CONCAT LIBRARY SYMBOL VARIABLE) + CHECK_LIBRARY_EXISTS("${LIBRARY};${CURL_LIBS}" ${SYMBOL} "" + ${VARIABLE}) + IF(${VARIABLE}) + SET(CURL_LIBS ${CURL_LIBS} ${LIBRARY}) + ENDIF(${VARIABLE}) +ENDMACRO(CHECK_LIBRARY_EXISTS_CONCAT) + +# Check for all needed libraries +CHECK_LIBRARY_EXISTS_CONCAT("dl" dlopen HAVE_LIBDL) +CHECK_LIBRARY_EXISTS_CONCAT("ucb" gethostname HAVE_LIBUCB) +CHECK_LIBRARY_EXISTS_CONCAT("socket" connect HAVE_LIBSOCKET) +CHECK_LIBRARY_EXISTS("c" gethostbyname "" NOT_NEED_LIBNSL) + +IF(NOT NOT_NEED_LIBNSL) + CHECK_LIBRARY_EXISTS_CONCAT("nsl" gethostbyname HAVE_LIBNSL) +ENDIF(NOT NOT_NEED_LIBNSL) + +CHECK_LIBRARY_EXISTS_CONCAT("ws2_32" getch HAVE_LIBWS2_32) +CHECK_LIBRARY_EXISTS_CONCAT("winmm" getch HAVE_LIBWINMM) +IF(NOT CURL_SPECIAL_LIBZ) + CHECK_LIBRARY_EXISTS_CONCAT("z" inflateEnd HAVE_LIBZ) +ENDIF(NOT CURL_SPECIAL_LIBZ) + +#OPTION(CMAKE_USE_OPENSSL "Use OpenSSL code. Experimental" OFF) +MARK_AS_ADVANCED(CMAKE_USE_OPENSSL) +IF(CMAKE_USE_OPENSSL) + CHECK_LIBRARY_EXISTS_CONCAT("crypto" CRYPTO_lock HAVE_LIBCRYPTO) + CHECK_LIBRARY_EXISTS_CONCAT("ssl" SSL_connect HAVE_LIBSSL) +ENDIF(CMAKE_USE_OPENSSL) + +# Check for symbol dlopen (same as HAVE_LIBDL) +CHECK_LIBRARY_EXISTS("${CURL_LIBS}" dlopen "" HAVE_DLOPEN) + +# For other tests to use the same libraries +SET(CMAKE_REQUIRED_LIBRARIES ${CURL_LIBS}) + +IF(CURL_SPECIAL_LIBZ) + SET(CURL_LIBS ${CURL_LIBS} "${CURL_SPECIAL_LIBZ}") + INCLUDE_DIRECTORIES(${CURL_SPECIAL_LIBZ_INCLUDES}) + SET(HAVE_LIBZ 0) + SET(HAVE_ZLIB_H 0) +ENDIF(CURL_SPECIAL_LIBZ) + + +# If we have features.h, then do the _BSD_SOURCE magic +CHECK_INCLUDE_FILE("features.h" HAVE_FEATURES_H) +IF(HAVE_FEATURES_H) + SET_SOURCE_FILES_PROPERTIES( + cookie.c + easy.c + formdata.c + getenv.c + hash.c + http.c + if2ip.c + mprintf.c + multi.c + sendf.c + telnet.c + transfer.c + url.c + COMPILE_FLAGS -D_BSD_SOURCE) +ENDIF(HAVE_FEATURES_H) + +# Check if header file exists and add it to the list. +MACRO(CHECK_INCLUDE_FILE_CONCAT FILE VARIABLE) + CHECK_INCLUDE_FILES("${CURL_INCLUDES};${FILE}" ${VARIABLE}) + IF(${VARIABLE}) + SET(CURL_INCLUDES ${CURL_INCLUDES} ${FILE}) + ENDIF(${VARIABLE}) +ENDMACRO(CHECK_INCLUDE_FILE_CONCAT) + +# Check for header files +CHECK_INCLUDE_FILE_CONCAT("stdio.h" HAVE_STDIO_H) +CHECK_INCLUDE_FILE_CONCAT("stddef.h" HAVE_STDDEF_H) +CHECK_INCLUDE_FILE_CONCAT("sys/types.h" HAVE_SYS_TYPES_H) +CHECK_INCLUDE_FILE_CONCAT("inttypes.h" HAVE_INTTYPES_H) +CHECK_INCLUDE_FILE_CONCAT("alloca.h" HAVE_ALLOCA_H) +CHECK_INCLUDE_FILE_CONCAT("arpa/inet.h" HAVE_ARPA_INET_H) +CHECK_INCLUDE_FILE_CONCAT("dlfcn.h" HAVE_DLFCN_H) +CHECK_INCLUDE_FILE_CONCAT("fcntl.h" HAVE_FCNTL_H) +CHECK_INCLUDE_FILE_CONCAT("malloc.h" HAVE_MALLOC_H) +CHECK_INCLUDE_FILE_CONCAT("memory.h" HAVE_MEMORY_H) +CHECK_INCLUDE_FILE_CONCAT("netdb.h" HAVE_NETDB_H) +CHECK_INCLUDE_FILE_CONCAT("sys/poll.h" HAVE_SYS_POLL_H) +CHECK_INCLUDE_FILE_CONCAT("assert.h" HAVE_ASSERT_H) +CHECK_INCLUDE_FILE_CONCAT("limits.h" HAVE_LIMITS_H) + +IF(CMAKE_USE_OPENSSL) + CHECK_INCLUDE_FILE_CONCAT("openssl/x509.h" HAVE_OPENSSL_X509_H) + CHECK_INCLUDE_FILE_CONCAT("openssl/engine.h" HAVE_OPENSSL_ENGINE_H) + CHECK_INCLUDE_FILE_CONCAT("openssl/rsa.h" HAVE_OPENSSL_RSA_H) + CHECK_INCLUDE_FILE_CONCAT("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H) + CHECK_INCLUDE_FILE_CONCAT("openssl/pem.h" HAVE_OPENSSL_PEM_H) + CHECK_INCLUDE_FILE_CONCAT("openssl/ssl.h" HAVE_OPENSSL_SSL_H) + CHECK_INCLUDE_FILE_CONCAT("openssl/err.h" HAVE_OPENSSL_ERR_H) + CHECK_INCLUDE_FILE_CONCAT("openssl/rand.h" HAVE_OPENSSL_RAND_H) +ENDIF(CMAKE_USE_OPENSSL) + +IF(NOT CURL_SPECIAL_LIBZ) + CHECK_INCLUDE_FILE_CONCAT("zlib.h" HAVE_ZLIB_H) +ENDIF(NOT CURL_SPECIAL_LIBZ) +CHECK_INCLUDE_FILE_CONCAT("sys/socket.h" HAVE_SYS_SOCKET_H) +CHECK_INCLUDE_FILE_CONCAT("netinet/in.h" HAVE_NETINET_IN_H) +CHECK_INCLUDE_FILE_CONCAT("net/if.h" HAVE_NET_IF_H) +CHECK_INCLUDE_FILE_CONCAT("netinet/if_ether.h" + HAVE_NETINET_IF_ETHER_H) +CHECK_INCLUDE_FILE_CONCAT("netinet/tcp.h" + HAVE_NETINET_TCP_H) +CHECK_INCLUDE_FILE_CONCAT("sys/select.h" HAVE_SYS_SELECT_H) +CHECK_INCLUDE_FILE_CONCAT("utime.h" HAVE_UTIME_H) +CHECK_INCLUDE_FILE_CONCAT("netinet/in.h" HAVE_NETINET_IN_H) +CHECK_INCLUDE_FILE_CONCAT("pwd.h" HAVE_PWD_H) +CHECK_INCLUDE_FILE_CONCAT("sgtty.h" HAVE_SGTTY_H) +CHECK_INCLUDE_FILE_CONCAT("stdint.h" HAVE_STDINT_H) +CHECK_INCLUDE_FILE_CONCAT("stdlib.h" HAVE_STDLIB_H) +CHECK_INCLUDE_FILE_CONCAT("string.h" HAVE_STRING_H) +CHECK_INCLUDE_FILE_CONCAT("strings.h" HAVE_STRINGS_H) +CHECK_INCLUDE_FILE_CONCAT("sys/param.h" HAVE_SYS_PARAM_H) +CHECK_INCLUDE_FILE_CONCAT("sys/stat.h" HAVE_SYS_STAT_H) +CHECK_INCLUDE_FILE_CONCAT("sys/time.h" HAVE_SYS_TIME_H) +CHECK_INCLUDE_FILE_CONCAT("termios.h" HAVE_TERMIOS_H) +CHECK_INCLUDE_FILE_CONCAT("termio.h" HAVE_TERMIO_H) +CHECK_INCLUDE_FILE_CONCAT("io.h" HAVE_IO_H) +CHECK_INCLUDE_FILE_CONCAT("time.h" HAVE_TIME_H) +CHECK_INCLUDE_FILE_CONCAT("unistd.h" HAVE_UNISTD_H) +CHECK_INCLUDE_FILE_CONCAT("sys/utime.h" HAVE_SYS_UTIME_H) +CHECK_INCLUDE_FILE_CONCAT("winsock.h" HAVE_WINSOCK_H) +CHECK_INCLUDE_FILE_CONCAT("sockio.h" HAVE_SOCKIO_H) +CHECK_INCLUDE_FILE_CONCAT("sys/sockio.h" HAVE_SYS_SOCKIO_H) +CHECK_INCLUDE_FILE_CONCAT("x509.h" HAVE_X509_H) +CHECK_INCLUDE_FILE_CONCAT("setjmp.h" HAVE_SETJMP_H) +CHECK_INCLUDE_FILE_CONCAT("signal.h" HAVE_SIGNAL_H) +CHECK_INCLUDE_FILE_CONCAT("sys/ioctl.h" HAVE_SYS_IOCTL_H) +CHECK_INCLUDE_FILE_CONCAT("sys/utsname.h" HAVE_SYS_UTSNAME_H) + +CHECK_TYPE_SIZE(size_t SIZEOF_SIZE_T) +CHECK_TYPE_SIZE(ssize_t SIZEOF_SSIZE_T) +CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG) +CHECK_TYPE_SIZE("long double" SIZEOF_LONG_DOUBLE) +IF(NOT HAVE_SIZEOF_SSIZE_T) + SET(ssize_t int) +ENDIF(NOT HAVE_SIZEOF_SSIZE_T) +IF(HAVE_SIZEOF_LONG_LONG) + SET(HAVE_LONGLONG 1) +ENDIF(HAVE_SIZEOF_LONG_LONG) + +FIND_FILE(RANDOM_FILE urandom /dev) +MARK_AS_ADVANCED(RANDOM_FILE) + +# Check for some functions that are used +CHECK_SYMBOL_EXISTS(socket "${CURL_INCLUDES}" HAVE_SOCKET) +CHECK_SYMBOL_EXISTS(poll "${CURL_INCLUDES}" HAVE_POLL) +CHECK_SYMBOL_EXISTS(select "${CURL_INCLUDES}" HAVE_SELECT) +CHECK_SYMBOL_EXISTS(strdup "${CURL_INCLUDES}" HAVE_STRDUP) +CHECK_SYMBOL_EXISTS(strstr "${CURL_INCLUDES}" HAVE_STRSTR) +CHECK_SYMBOL_EXISTS(strtok_r "${CURL_INCLUDES}" HAVE_STRTOK_R) +CHECK_SYMBOL_EXISTS(strftime "${CURL_INCLUDES}" HAVE_STRFTIME) +CHECK_SYMBOL_EXISTS(uname "${CURL_INCLUDES}" HAVE_UNAME) +CHECK_SYMBOL_EXISTS(strcasecmp "${CURL_INCLUDES}" HAVE_STRCASECMP) +CHECK_SYMBOL_EXISTS(stricmp "${CURL_INCLUDES}" HAVE_STRICMP) +CHECK_SYMBOL_EXISTS(strcmpi "${CURL_INCLUDES}" HAVE_STRCMPI) +CHECK_SYMBOL_EXISTS(strncmpi "${CURL_INCLUDES}" HAVE_STRNCMPI) +IF(NOT HAVE_STRNCMPI) + SET(HAVE_STRCMPI) +ENDIF(NOT HAVE_STRNCMPI) +CHECK_SYMBOL_EXISTS(gethostbyaddr "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR) +CHECK_SYMBOL_EXISTS(gettimeofday "${CURL_INCLUDES}" HAVE_GETTIMEOFDAY) +CHECK_SYMBOL_EXISTS(inet_addr "${CURL_INCLUDES}" HAVE_INET_ADDR) +CHECK_SYMBOL_EXISTS(inet_pton "${CURL_INCLUDES}" HAVE_INET_PTON) +CHECK_SYMBOL_EXISTS(inet_ntoa "${CURL_INCLUDES}" HAVE_INET_NTOA) +CHECK_SYMBOL_EXISTS(inet_ntoa_r "${CURL_INCLUDES}" HAVE_INET_NTOA_R) +CHECK_SYMBOL_EXISTS(tcsetattr "${CURL_INCLUDES}" HAVE_TCSETATTR) +CHECK_SYMBOL_EXISTS(tcgetattr "${CURL_INCLUDES}" HAVE_TCGETATTR) +CHECK_SYMBOL_EXISTS(perror "${CURL_INCLUDES}" HAVE_PERROR) +CHECK_SYMBOL_EXISTS(closesocket "${CURL_INCLUDES}" HAVE_CLOSESOCKET) +CHECK_SYMBOL_EXISTS(setvbuf "${CURL_INCLUDES}" HAVE_SETVBUF) +CHECK_SYMBOL_EXISTS(sigsetjmp "${CURL_INCLUDES}" HAVE_SIGSETJMP) +CHECK_SYMBOL_EXISTS(getpass_r "${CURL_INCLUDES}" HAVE_GETPASS_R) +CHECK_SYMBOL_EXISTS(strlcat "${CURL_INCLUDES}" HAVE_STRLCAT) +CHECK_SYMBOL_EXISTS(getpwuid "${CURL_INCLUDES}" HAVE_GETPWUID) +CHECK_SYMBOL_EXISTS(geteuid "${CURL_INCLUDES}" HAVE_GETEUID) +CHECK_SYMBOL_EXISTS(utime "${CURL_INCLUDES}" HAVE_UTIME) +IF(CMAKE_USE_OPENSSL) + CHECK_SYMBOL_EXISTS(RAND_status "${CURL_INCLUDES}" HAVE_RAND_STATUS) + CHECK_SYMBOL_EXISTS(RAND_screen "${CURL_INCLUDES}" HAVE_RAND_SCREEN) + CHECK_SYMBOL_EXISTS(RAND_egd "${CURL_INCLUDES}" HAVE_RAND_EGD) + CHECK_SYMBOL_EXISTS(CRYPTO_cleanup_all_ex_data "${CURL_INCLUDES}" + HAVE_CRYPTO_CLEANUP_ALL_EX_DATA) +ENDIF(CMAKE_USE_OPENSSL) +CHECK_SYMBOL_EXISTS(gmtime_r "${CURL_INCLUDES}" HAVE_GMTIME_R) +CHECK_SYMBOL_EXISTS(localtime_r "${CURL_INCLUDES}" HAVE_LOCALTIME_R) + +CHECK_SYMBOL_EXISTS(gethostbyname "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME) +CHECK_SYMBOL_EXISTS(gethostbyname_r "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME_R) +CHECK_SYMBOL_EXISTS(gethostbyaddr_r "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR_R) + +CHECK_SYMBOL_EXISTS(signal "${CURL_INCLUDES}" HAVE_SIGNAL_FUNC) +CHECK_SYMBOL_EXISTS(SIGALRM "${CURL_INCLUDES}" HAVE_SIGNAL_MACRO) +IF(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO) + SET(HAVE_SIGNAL 1) +ENDIF(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO) +CHECK_SYMBOL_EXISTS(uname "${CURL_INCLUDES}" HAVE_UNAME) +CHECK_SYMBOL_EXISTS(strtoll "${CURL_INCLUDES}" HAVE_STRTOLL) +CHECK_SYMBOL_EXISTS(_strtoi64 "${CURL_INCLUDES}" HAVE__STRTOI64) +CHECK_SYMBOL_EXISTS(strerror_r "${CURL_INCLUDES}" HAVE_STRERROR_R) +CHECK_SYMBOL_EXISTS(siginterrupt "${CURL_INCLUDES}" HAVE_SIGINTERRUPT) +CHECK_SYMBOL_EXISTS(perror "${CURL_INCLUDES}" HAVE_PERROR) + +# only build compat strtok if we need to +IF (NOT HAVE_STRTOK_R) + SET(libCurl_SRCS ${libCurl_SRCS} + strtok.c + ) +ENDIF (NOT HAVE_STRTOK_R) +IF(NOT HAVE_STRTOLL AND NOT HAVE__STRTOI64) + SET(libCurl_SRCS ${libCurl_SRCS} + strtoofft.c + ) +ENDIF(NOT HAVE_STRTOLL AND NOT HAVE__STRTOI64) + +# sigaction and sigsetjmp are special. Use special mechanism for +# detecting those, but only if previous attempt failed. +IF(HAVE_SIGNAL_H) + CHECK_SYMBOL_EXISTS(sigaction "signal.h" HAVE_SIGACTION) +ENDIF(HAVE_SIGNAL_H) + +IF(NOT HAVE_SIGSETJMP) + IF(HAVE_SETJMP_H) + CHECK_SYMBOL_EXISTS(sigsetjmp "setjmp.h" HAVE_MACRO_SIGSETJMP) + IF(HAVE_MACRO_SIGSETJMP) + SET(HAVE_SIGSETJMP 1) + ENDIF(HAVE_MACRO_SIGSETJMP) + ENDIF(HAVE_SETJMP_H) +ENDIF(NOT HAVE_SIGSETJMP) + +# For other curl specific tests, use this macro. +MACRO(CURL_INTERNAL_TEST CURL_TEST) + IF("${CURL_TEST}" MATCHES "^${CURL_TEST}$") + SET(MACRO_CHECK_FUNCTION_DEFINITIONS + "-D${CURL_TEST} ${CMAKE_REQUIRED_FLAGS}") + IF(CMAKE_REQUIRED_LIBRARIES) + SET(CURL_TEST_ADD_LIBRARIES + "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + ENDIF(CMAKE_REQUIRED_LIBRARIES) + + MESSAGE(STATUS "Performing Curl Test ${CURL_TEST}") + TRY_COMPILE(${CURL_TEST} + ${CMAKE_BINARY_DIR} + ${LIBCURL_SOURCE_DIR}/CMake/CurlTests.c + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} + "${CURL_TEST_ADD_LIBRARIES}" + OUTPUT_VARIABLE OUTPUT) + IF(${CURL_TEST}) + SET(${CURL_TEST} 1 CACHE INTERNAL "Curl test ${FUNCTION}") + MESSAGE(STATUS "Performing Curl Test ${CURL_TEST} - Success") + ELSE(${CURL_TEST}) + MESSAGE(STATUS "Performing Curl Test ${CURL_TEST} - Failed") + SET(${CURL_TEST} "" CACHE INTERNAL "Curl test ${FUNCTION}") + FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log + "Performing Curl Test ${CURL_TEST} failed with the following output:\n" + "${OUTPUT}\n") + ENDIF(${CURL_TEST}) + ENDIF("${CURL_TEST}" MATCHES "^${CURL_TEST}$") +ENDMACRO(CURL_INTERNAL_TEST) +MACRO(CURL_INTERNAL_TEST_RUN CURL_TEST) + IF("${CURL_TEST}_COMPILE" MATCHES "^${CURL_TEST}_COMPILE$") + SET(MACRO_CHECK_FUNCTION_DEFINITIONS + "-D${CURL_TEST} ${CMAKE_REQUIRED_FLAGS}") + IF(CMAKE_REQUIRED_LIBRARIES) + SET(CURL_TEST_ADD_LIBRARIES + "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + ENDIF(CMAKE_REQUIRED_LIBRARIES) + + MESSAGE(STATUS "Performing Curl Test ${CURL_TEST}") + TRY_RUN(${CURL_TEST} ${CURL_TEST}_COMPILE + ${CMAKE_BINARY_DIR} + ${LIBCURL_SOURCE_DIR}/CMake/CurlTests.c + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} + "${CURL_TEST_ADD_LIBRARIES}" + OUTPUT_VARIABLE OUTPUT) + IF(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST}) + SET(${CURL_TEST} 1 CACHE INTERNAL "Curl test ${FUNCTION}") + MESSAGE(STATUS "Performing Curl Test ${CURL_TEST} - Success") + ELSE(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST}) + MESSAGE(STATUS "Performing Curl Test ${CURL_TEST} - Failed") + SET(${CURL_TEST} "" CACHE INTERNAL "Curl test ${FUNCTION}") + FILE(APPEND "${CMAKE_BINARY_DIR}/CMakeError.log" + "Performing Curl Test ${CURL_TEST} failed with the following output:\n" + "${OUTPUT}") + IF(${CURL_TEST}_COMPILE) + FILE(APPEND "${CMAKE_BINARY_DIR}/CMakeError.log" + "There was a running problem of this test\n") + ENDIF(${CURL_TEST}_COMPILE) + FILE(APPEND "${CMAKE_BINARY_DIR}/CMakeError.log" + "\n\n") + ENDIF(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST}) + ENDIF("${CURL_TEST}_COMPILE" MATCHES "^${CURL_TEST}_COMPILE$") +ENDMACRO(CURL_INTERNAL_TEST_RUN) + +# Do curl specific tests +#OPTION(CURL_HAVE_DISABLED_NONBLOCKING "Disable non-blocking socket detection" OFF) +SET(CURL_NONBLOCKING_TESTS) +IF(NOT CURL_HAVE_DISABLED_NONBLOCKING) + SET(CURL_NONBLOCKING_TESTS + HAVE_FIONBIO + HAVE_IOCTLSOCKET + HAVE_IOCTLSOCKET_CASE + HAVE_O_NONBLOCK + HAVE_SO_NONBLOCK + ) +ENDIF(NOT CURL_HAVE_DISABLED_NONBLOCKING) +FOREACH(CURL_TEST + ${CURL_NONBLOCKING_TESTS} + TIME_WITH_SYS_TIME + HAVE_O_NONBLOCKHAVE_GETHOSTBYADDR_R_5 + HAVE_GETHOSTBYADDR_R_7 + HAVE_GETHOSTBYADDR_R_8 + HAVE_GETHOSTBYADDR_R_5_REENTRANT + HAVE_GETHOSTBYADDR_R_7_REENTRANT + HAVE_GETHOSTBYADDR_R_8_REENTRANT + HAVE_GETHOSTBYNAME_R_3 + HAVE_GETHOSTBYNAME_R_5 + HAVE_GETHOSTBYNAME_R_6 + HAVE_GETHOSTBYNAME_R_3_REENTRANT + HAVE_GETHOSTBYNAME_R_5_REENTRANT + HAVE_GETHOSTBYNAME_R_6_REENTRANT + HAVE_SOCKLEN_T + HAVE_IN_ADDR_T + STDC_HEADERS + RETSIGTYPE_TEST + HAVE_INET_NTOA_R_DECL + HAVE_INET_NTOA_R_DECL_REENTRANT + HAVE_GETADDRINFO + HAVE_FILE_OFFSET_BITS + ) + CURL_INTERNAL_TEST(${CURL_TEST}) +ENDFOREACH(CURL_TEST) +IF(HAVE_FILE_OFFSET_BITS) + SET(_FILE_OFFSET_BITS 64) +ENDIF(HAVE_FILE_OFFSET_BITS) + +FOREACH(CURL_TEST + HAVE_GLIBC_STRERROR_R + HAVE_POSIX_STRERROR_R + HAVE_LONG_LONG_CONSTANT + ) + CURL_INTERNAL_TEST_RUN(${CURL_TEST}) +ENDFOREACH(CURL_TEST) + +# Check for reentrant +FOREACH(CURL_TEST + HAVE_GETHOSTBYADDR_R_5 + HAVE_GETHOSTBYADDR_R_7 + HAVE_GETHOSTBYADDR_R_8 + HAVE_GETHOSTBYNAME_R_3 + HAVE_GETHOSTBYNAME_R_5 + HAVE_GETHOSTBYNAME_R_6 + HAVE_INET_NTOA_R_DECL_REENTRANT) + IF(NOT ${CURL_TEST}) + IF(${CURL_TEST}_REENTRANT) + SET(NEED_REENTRANT 1) + ENDIF(${CURL_TEST}_REENTRANT) + ENDIF(NOT ${CURL_TEST}) +ENDFOREACH(CURL_TEST) + +IF(NEED_REENTRANT) + FOREACH(CURL_TEST + HAVE_GETHOSTBYADDR_R_5 + HAVE_GETHOSTBYADDR_R_7 + HAVE_GETHOSTBYADDR_R_8 + HAVE_GETHOSTBYNAME_R_3 + HAVE_GETHOSTBYNAME_R_5 + HAVE_GETHOSTBYNAME_R_6) + SET(${CURL_TEST} 0) + IF(${CURL_TEST}_REENTRANT) + SET(${CURL_TEST} 1) + ENDIF(${CURL_TEST}_REENTRANT) + ENDFOREACH(CURL_TEST) +ENDIF(NEED_REENTRANT) + +IF(HAVE_INET_NTOA_R_DECL_REENTRANT) + SET(HAVE_INET_NTOA_R_DECL 1) + SET(NEED_REENTRANT 1) +ENDIF(HAVE_INET_NTOA_R_DECL_REENTRANT) + +# Some other minor tests + +IF(NOT HAVE_SOCKLEN_T) + SET(socklen_t "int") +ENDIF(NOT HAVE_SOCKLEN_T) + +IF(NOT HAVE_IN_ADDR_T) + SET(in_addr_t "unsigned long") +ENDIF(NOT HAVE_IN_ADDR_T) + +# Fix libz / zlib.h + +IF(NOT CURL_SPECIAL_LIBZ) + IF(NOT HAVE_LIBZ) + SET(HAVE_ZLIB_H 0) + ENDIF(NOT HAVE_LIBZ) + + IF(NOT HAVE_ZLIB_H) + SET(HAVE_LIBZ 0) + ENDIF(NOT HAVE_ZLIB_H) +ENDIF(NOT CURL_SPECIAL_LIBZ) + +IF(_FILE_OFFSET_BITS) + SET(_FILE_OFFSET_BITS 64) +ENDIF(_FILE_OFFSET_BITS) +SET(CMAKE_REQUIRED_FLAGS "-D_FILE_OFFSET_BITS=64") +SET(CMAKE_EXTRA_INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/curl/curl.h") +CHECK_TYPE_SIZE("curl_off_t" SIZEOF_CURL_OFF_T) +SET(CMAKE_EXTRA_INCLUDE_FILES) +SET(CMAKE_REQUIRED_FLAGS) + + +# Check for nonblocking +SET(HAVE_DISABLED_NONBLOCKING 1) +IF(HAVE_FIONBIO OR + HAVE_IOCTLSOCKET OR + HAVE_IOCTLSOCKET_CASE OR + HAVE_O_NONBLOCK) + SET(HAVE_DISABLED_NONBLOCKING) +ENDIF(HAVE_FIONBIO OR + HAVE_IOCTLSOCKET OR + HAVE_IOCTLSOCKET_CASE OR + HAVE_O_NONBLOCK) + +IF(RETSIGTYPE_TEST) + SET(RETSIGTYPE void) +ELSE(RETSIGTYPE_TEST) + SET(RETSIGTYPE int) +ENDIF(RETSIGTYPE_TEST) + +IF(CMAKE_COMPILER_IS_GNUCC AND APPLE) + # The Mac version of GCC warns about use of long double. Disable it. + GET_SOURCE_FILE_PROPERTY(MPRINTF_COMPILE_FLAGS mprintf.c COMPILE_FLAGS) + IF(MPRINTF_COMPILE_FLAGS) + SET(MPRINTF_COMPILE_FLAGS "${MPRINTF_COMPILE_FLAGS} -Wno-long-double") + ELSE(MPRINTF_COMPILE_FLAGS) + SET(MPRINTF_COMPILE_FLAGS "-Wno-long-double") + ENDIF(MPRINTF_COMPILE_FLAGS) + SET_SOURCE_FILES_PROPERTIES(mprintf.c PROPERTIES + COMPILE_FLAGS ${MPRINTF_COMPILE_FLAGS}) +ENDIF(CMAKE_COMPILER_IS_GNUCC AND APPLE) + +# The rest of the build + +INCLUDE_DIRECTORIES(${LIBCURL_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${LIBCURL_BINARY_DIR}) +ADD_DEFINITIONS(-DHAVE_CONFIG_H) +CONFIGURE_FILE(${LIBCURL_SOURCE_DIR}/config.h.in + ${LIBCURL_BINARY_DIR}/config.h) + +ADD_LIBRARY(Curl ${libCurl_SRCS}) +TARGET_LINK_LIBRARIES(Curl ${CURL_LIBS}) + +OPTION(CURL_TESTING "Do libCurl testing" OFF) +IF(CURL_TESTING) + SUBDIRS(Testing) +ENDIF(CURL_TESTING) + +ADD_EXECUTABLE(LIBCURL Testing/curltest.c) +TARGET_LINK_LIBRARIES(LIBCURL Curl) +ADD_TEST(curl "${EXECUTABLE_OUTPUT_PATH}/LIBCURL") diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/config.h.in /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/config.h.in --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/config.h.in 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/config.h.in 2005-03-17 01:54:35.000000000 +0800 @@ -0,0 +1,512 @@ +/* lib/config.h.in. Generated from configure.in by autoheader. */ + +/* to disable DICT */ +#cmakedefine CURL_DISABLE_DICT ${CURL_DISABLE_DICT} + +/* to disable FILE */ +#cmakedefine CURL_DISABLE_FILE ${CURL_DISABLE_FILE} + +/* to disable FTP */ +#cmakedefine CURL_DISABLE_FTP ${CURL_DISABLE_FTP} + +/* to disable GOPHER */ +#cmakedefine CURL_DISABLE_GOPHER ${CURL_DISABLE_GOPHER} + +/* to disable HTTP */ +#cmakedefine CURL_DISABLE_HTTP ${CURL_DISABLE_HTTP} + +/* to disable LDAP */ +#cmakedefine CURL_DISABLE_LDAP ${CURL_DISABLE_LDAP} + +/* to disable TELNET */ +#cmakedefine CURL_DISABLE_TELNET ${CURL_DISABLE_TELNET} + +/* Set to explicitly specify we don't want to use thread-safe functions */ +#cmakedefine DISABLED_THREADSAFE ${DISABLED_THREADSAFE} + +/* your Entropy Gathering Daemon socket pathname */ +#cmakedefine EGD_SOCKET ${EGD_SOCKET} + +/* Define if you want to enable IPv6 support */ +#cmakedefine ENABLE_IPV6 ${ENABLE_IPV6} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ALLOCA_H ${HAVE_ALLOCA_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ARPA_INET_H ${HAVE_ARPA_INET_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ASSERT_H ${HAVE_ASSERT_H} + +/* Define to 1 if you have the `closesocket' function. */ +#cmakedefine HAVE_CLOSESOCKET ${HAVE_CLOSESOCKET} + +/* Define to 1 if you have the `CRYPTO_cleanup_all_ex_data' function. */ +#cmakedefine HAVE_CRYPTO_CLEANUP_ALL_EX_DATA ${HAVE_CRYPTO_CLEANUP_ALL_EX_DATA} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_CRYPTO_H ${HAVE_CRYPTO_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_DES_H ${HAVE_DES_H} + +/* disabled non-blocking sockets */ +#cmakedefine HAVE_DISABLED_NONBLOCKING ${HAVE_DISABLED_NONBLOCKING} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_DLFCN_H ${HAVE_DLFCN_H} + +/* Define to 1 if you have the `dlopen' function. */ +#cmakedefine HAVE_DLOPEN ${HAVE_DLOPEN} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ERR_H ${HAVE_ERR_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_FCNTL_H ${HAVE_FCNTL_H} + +/* use FIONBIO for non-blocking sockets */ +#cmakedefine HAVE_FIONBIO ${HAVE_FIONBIO} + +/* Define if getaddrinfo exists and works */ +#cmakedefine HAVE_GETADDRINFO ${HAVE_GETADDRINFO} + +/* Define to 1 if you have the `geteuid' function. */ +#cmakedefine HAVE_GETEUID ${HAVE_GETEUID} + +/* Define to 1 if you have the `gethostbyaddr' function. */ +#cmakedefine HAVE_GETHOSTBYADDR ${HAVE_GETHOSTBYADDR} + +/* If you have gethostbyname */ +#cmakedefine HAVE_GETHOSTBYNAME ${HAVE_GETHOSTBYNAME} + +/* Define to 1 if you have the `gethostbyname_r' function. */ +#cmakedefine HAVE_GETHOSTBYNAME_R ${HAVE_GETHOSTBYNAME_R} + +/* gethostbyname_r() takes 3 args */ +#cmakedefine HAVE_GETHOSTBYNAME_R_3 ${HAVE_GETHOSTBYNAME_R_3} + +/* gethostbyname_r() takes 5 args */ +#cmakedefine HAVE_GETHOSTBYNAME_R_5 ${HAVE_GETHOSTBYNAME_R_5} + +/* gethostbyname_r() takes 6 args */ +#cmakedefine HAVE_GETHOSTBYNAME_R_6 ${HAVE_GETHOSTBYNAME_R_6} + +/* Define to 1 if you have the `getpass_r' function. */ +#cmakedefine HAVE_GETPASS_R ${HAVE_GETPASS_R} + +/* Define to 1 if you have the `getpwuid' function. */ +#cmakedefine HAVE_GETPWUID ${HAVE_GETPWUID} + +/* Define to 1 if you have the `gettimeofday' function. */ +#cmakedefine HAVE_GETTIMEOFDAY ${HAVE_GETTIMEOFDAY} + +/* we have a glibc-style strerror_r() */ +#cmakedefine HAVE_GLIBC_STRERROR_R ${HAVE_GLIBC_STRERROR_R} + +/* Define to 1 if you have the `gmtime_r' function. */ +#cmakedefine HAVE_GMTIME_R ${HAVE_GMTIME_R} + +/* if you have the gssapi libraries */ +#cmakedefine HAVE_GSSAPI ${HAVE_GSSAPI} + +/* if you have the Heimdal gssapi libraries */ +#cmakedefine HAVE_GSSHEIMDAL ${HAVE_GSSHEIMDAL} + +/* if you have the MIT gssapi libraries */ +#cmakedefine HAVE_GSSMIT ${HAVE_GSSMIT} + +/* Define to 1 if you have the `idn_free' function. */ +#cmakedefine HAVE_IDN_FREE ${HAVE_IDN_FREE} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_IDN_FREE_H ${HAVE_IDN_FREE_H} + +/* Define to 1 if you have the `inet_addr' function. */ +#cmakedefine HAVE_INET_ADDR ${HAVE_INET_ADDR} + +/* Define to 1 if you have the `inet_ntoa' function. */ +#cmakedefine HAVE_INET_NTOA ${HAVE_INET_NTOA} + +/* Define to 1 if you have the `inet_ntoa_r' function. */ +#cmakedefine HAVE_INET_NTOA_R ${HAVE_INET_NTOA_R} + +/* inet_ntoa_r() is declared */ +#cmakedefine HAVE_INET_NTOA_R_DECL ${HAVE_INET_NTOA_R_DECL} + +/* Define to 1 if you have the `inet_pton' function. */ +#cmakedefine HAVE_INET_PTON ${HAVE_INET_PTON} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_INTTYPES_H ${HAVE_INTTYPES_H} + +/* use ioctlsocket() for non-blocking sockets */ +#cmakedefine HAVE_IOCTLSOCKET ${HAVE_IOCTLSOCKET} + +/* use Ioctlsocket() for non-blocking sockets */ +#cmakedefine HAVE_IOCTLSOCKET_CASE ${HAVE_IOCTLSOCKET_CASE} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_IO_H ${HAVE_IO_H} + +/* if you have the Kerberos4 libraries (including -ldes) */ +#cmakedefine HAVE_KRB4 ${HAVE_KRB4} + +/* Define to 1 if you have the `krb_get_our_ip_for_realm' function. */ +#cmakedefine HAVE_KRB_GET_OUR_IP_FOR_REALM ${HAVE_KRB_GET_OUR_IP_FOR_REALM} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_KRB_H ${HAVE_KRB_H} + +/* Define to 1 if you have the `crypto' library (-lcrypto). */ +#cmakedefine HAVE_LIBCRYPTO ${HAVE_LIBCRYPTO} + +/* Define to 1 if you have the `dl' library (-ldl). */ +#cmakedefine HAVE_LIBDL ${HAVE_LIBDL} + +/* Define to 1 if you have the `idn' library (-lidn). */ +#cmakedefine HAVE_LIBIDN ${HAVE_LIBIDN} + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +#cmakedefine HAVE_LIBRESOLV ${HAVE_LIBRESOLV} + +/* Define to 1 if you have the `resolve' library (-lresolve). */ +#cmakedefine HAVE_LIBRESOLVE ${HAVE_LIBRESOLVE} + +/* Define to 1 if you have the `socket' library (-lsocket). */ +#cmakedefine HAVE_LIBSOCKET ${HAVE_LIBSOCKET} + +/* Define to 1 if you have the `ssl' library (-lssl). */ +#cmakedefine HAVE_LIBSSL ${HAVE_LIBSSL} + +/* if zlib is available */ +#cmakedefine HAVE_LIBZ ${HAVE_LIBZ} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LIMITS_H ${HAVE_LIMITS_H} + +/* Define to 1 if you have the `localtime_r' function. */ +#cmakedefine HAVE_LOCALTIME_R ${HAVE_LOCALTIME_R} + +/* if your compiler supports 'long long' */ +#cmakedefine HAVE_LONGLONG ${HAVE_LONGLONG} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_MALLOC_H ${HAVE_MALLOC_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_MEMORY_H ${HAVE_MEMORY_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NETDB_H ${HAVE_NETDB_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NETINET_IN_H ${HAVE_NETINET_IN_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NETINET_TCP_H ${HAVE_NETINET_TCP_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NET_IF_H ${HAVE_NET_IF_H} + +/* Define if NI_WITHSCOPEID exists and works */ +#cmakedefine HAVE_NI_WITHSCOPEID ${HAVE_NI_WITHSCOPEID} + +/* we have no strerror_r() proto */ +#cmakedefine HAVE_NO_STRERROR_R_DECL ${HAVE_NO_STRERROR_R_DECL} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_OPENSSL_CRYPTO_H ${HAVE_OPENSSL_CRYPTO_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_OPENSSL_ENGINE_H ${HAVE_OPENSSL_ENGINE_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_OPENSSL_ERR_H ${HAVE_OPENSSL_ERR_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_OPENSSL_PEM_H ${HAVE_OPENSSL_PEM_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_OPENSSL_RSA_H ${HAVE_OPENSSL_RSA_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_OPENSSL_SSL_H ${HAVE_OPENSSL_SSL_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_OPENSSL_X509_H ${HAVE_OPENSSL_X509_H} + +/* use O_NONBLOCK for non-blocking sockets */ +#cmakedefine HAVE_O_NONBLOCK ${HAVE_O_NONBLOCK} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_PEM_H ${HAVE_PEM_H} + +/* Define to 1 if you have the `perror' function. */ +#cmakedefine HAVE_PERROR ${HAVE_PERROR} + +/* Define to 1 if you have the `poll' function. */ +#cmakedefine HAVE_POLL ${HAVE_POLL} + +/* If you have a fine poll */ +#cmakedefine HAVE_POLL_FINE ${HAVE_POLL_FINE} + +/* we have a POSIX-style strerror_r() */ +#cmakedefine HAVE_POSIX_STRERROR_R ${HAVE_POSIX_STRERROR_R} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_PWD_H ${HAVE_PWD_H} + +/* Define to 1 if you have the `RAND_egd' function. */ +#cmakedefine HAVE_RAND_EGD ${HAVE_RAND_EGD} + +/* Define to 1 if you have the `RAND_screen' function. */ +#cmakedefine HAVE_RAND_SCREEN ${HAVE_RAND_SCREEN} + +/* Define to 1 if you have the `RAND_status' function. */ +#cmakedefine HAVE_RAND_STATUS ${HAVE_RAND_STATUS} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_RSA_H ${HAVE_RSA_H} + +/* Define to 1 if you have the `select' function. */ +#cmakedefine HAVE_SELECT ${HAVE_SELECT} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SETJMP_H ${HAVE_SETJMP_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SGTTY_H ${HAVE_SGTTY_H} + +/* Define to 1 if you have the `sigaction' function. */ +#cmakedefine HAVE_SIGACTION ${HAVE_SIGACTION} + +/* Define to 1 if you have the `siginterrupt' function. */ +#cmakedefine HAVE_SIGINTERRUPT ${HAVE_SIGINTERRUPT} + +/* Define to 1 if you have the `signal' function. */ +#cmakedefine HAVE_SIGNAL ${HAVE_SIGNAL} + +/* If you have sigsetjmp */ +#cmakedefine HAVE_SIGSETJMP ${HAVE_SIGSETJMP} + +/* Define to 1 if you have the `socket' function. */ +#cmakedefine HAVE_SOCKET ${HAVE_SOCKET} + +/* use SO_NONBLOCK for non-blocking sockets */ +#cmakedefine HAVE_SO_NONBLOCK ${HAVE_SO_NONBLOCK} + +/* Define this if you have the SPNEGO library fbopenssl */ +#cmakedefine HAVE_SPNEGO ${HAVE_SPNEGO} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SSL_H ${HAVE_SSL_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDINT_H ${HAVE_STDINT_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDLIB_H ${HAVE_STDLIB_H} + +/* Define to 1 if you have the `strcasecmp' function. */ +#cmakedefine HAVE_STRCASECMP ${HAVE_STRCASECMP} + +/* Define to 1 if you have the `strcmpi' function. */ +#cmakedefine HAVE_STRCMPI ${HAVE_STRCMPI} + +/* Define to 1 if you have the `strdup' function. */ +#cmakedefine HAVE_STRDUP ${HAVE_STRDUP} + +/* Define to 1 if you have the `strerror_r' function. */ +#cmakedefine HAVE_STRERROR_R ${HAVE_STRERROR_R} + +/* Define to 1 if you have the `strftime' function. */ +#cmakedefine HAVE_STRFTIME ${HAVE_STRFTIME} + +/* Define to 1 if you have the `stricmp' function. */ +#cmakedefine HAVE_STRICMP ${HAVE_STRICMP} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRINGS_H ${HAVE_STRINGS_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRING_H ${HAVE_STRING_H} + +/* Define to 1 if you have the `strlcat' function. */ +#cmakedefine HAVE_STRLCAT ${HAVE_STRLCAT} + +/* Define to 1 if you have the `strlcpy' function. */ +#cmakedefine HAVE_STRLCPY ${HAVE_STRLCPY} + +/* Define to 1 if you have the `strstr' function. */ +#cmakedefine HAVE_STRSTR ${HAVE_STRSTR} + +/* Define to 1 if you have the `strtok_r' function. */ +#cmakedefine HAVE_STRTOK_R ${HAVE_STRTOK_R} + +/* Define to 1 if you have the `strtoll' function. */ +#cmakedefine HAVE_STRTOLL ${HAVE_STRTOLL} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_IOCTL_H ${HAVE_SYS_IOCTL_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_PARAM_H ${HAVE_SYS_PARAM_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_POLL_H ${HAVE_SYS_POLL_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_SELECT_H ${HAVE_SYS_SELECT_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_SOCKET_H ${HAVE_SYS_SOCKET_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_SOCKIO_H ${HAVE_SYS_SOCKIO_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_STAT_H ${HAVE_SYS_STAT_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TIME_H ${HAVE_SYS_TIME_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TYPES_H ${HAVE_SYS_TYPES_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_UTIME_H ${HAVE_SYS_UTIME_H} + +/* Define to 1 if you have the `tcgetattr' function. */ +#cmakedefine HAVE_TCGETATTR ${HAVE_TCGETATTR} + +/* Define to 1 if you have the `tcsetattr' function. */ +#cmakedefine HAVE_TCSETATTR ${HAVE_TCSETATTR} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_TERMIOS_H ${HAVE_TERMIOS_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_TERMIO_H ${HAVE_TERMIO_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_TIME_H ${HAVE_TIME_H} + +/* Define to 1 if you have the `uname' function. */ +#cmakedefine HAVE_UNAME ${HAVE_UNAME} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UNISTD_H ${HAVE_UNISTD_H} + +/* Define to 1 if you have the `utime' function. */ +#cmakedefine HAVE_UTIME ${HAVE_UTIME} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UTIME_H ${HAVE_UTIME_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_WINSOCK_H ${HAVE_WINSOCK_H} + +/* Define this symbol if your OS supports changing the contents of argv */ +#cmakedefine HAVE_WRITABLE_ARGV ${HAVE_WRITABLE_ARGV} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_X509_H ${HAVE_X509_H} + +/* if you have the zlib.h header file */ +#cmakedefine HAVE_ZLIB_H ${HAVE_ZLIB_H} + +/* need REENTRANT defined */ +#cmakedefine NEED_REENTRANT ${NEED_REENTRANT} + +/* cpu-machine-OS */ +#define OS "${OPERATING_SYSTEM}" + +/* Name of package */ +#cmakedefine PACKAGE "${PACKAGE}" + +/* Define to the address where bug reports for this package should be sent. */ +#cmakedefine PACKAGE_BUGREPORT "${PACKAGE_BUGREPORT}" + +/* Define to the full name of this package. */ +#cmakedefine PACKAGE_NAME "${PACKAGE_NAME}" + +/* Define to the full name and version of this package. */ +#cmakedefine PACKAGE_STRING "${PACKAGE_STRING}" + +/* Define to the one symbol short name of this package. */ +#cmakedefine PACKAGE_TARNAME "${PACKAGE_TARNAME}" + +/* Define to the version of this package. */ +#cmakedefine PACKAGE_VERSION "${PACKAGE_VERSION}" + +/* a suitable file to read random data from */ +#cmakedefine RANDOM_FILE "${RANDOM_FILE}" + +/* Define as the return type of signal handlers (`int' or `void'). */ +#cmakedefine RETSIGTYPE ${RETSIGTYPE} + +/* Define to the type of arg 1 for `select'. */ +#cmakedefine SELECT_TYPE_ARG1 ${SELECT_TYPE_ARG1} + +/* Define to the type of args 2, 3 and 4 for `select'. */ +#cmakedefine SELECT_TYPE_ARG234 ${SELECT_TYPE_ARG234} + +/* Define to the type of arg 5 for `select'. */ +#cmakedefine SELECT_TYPE_ARG5 ${SELECT_TYPE_ARG5} + +/* The size of a `curl_off_t', as computed by sizeof. */ +#cmakedefine SIZEOF_CURL_OFF_T ${SIZEOF_CURL_OFF_T} + +/* The size of a `size_t', as computed by sizeof. */ +#cmakedefine SIZEOF_SIZE_T ${SIZEOF_SIZE_T} + +/* Define to 1 if you have the ANSI C header files. */ +#cmakedefine STDC_HEADERS ${STDC_HEADERS} + +/* Define to 1 if you can safely include both and . */ +#cmakedefine TIME_WITH_SYS_TIME ${TIME_WITH_SYS_TIME} + +/* Define if you want to enable ares support */ +#cmakedefine USE_ARES ${USE_ARES} + +/* If you want to build curl with the built-in manual */ +#cmakedefine USE_MANUAL ${USE_MANUAL} + +/* Version number of package */ +#cmakedefine VERSION "${VERSION}" + +/* Define to 1 if on AIX 3. + System headers sometimes define this. + We just want to avoid a redefinition error message. */ +#ifndef _ALL_SOURCE +#cmakedefine _ALL_SOURCE ${_ALL_SOURCE} +#endif + +/* Number of bits in a file offset, on hosts where this is settable. */ +#cmakedefine _FILE_OFFSET_BITS ${_FILE_OFFSET_BITS} + +/* Define for large files, on AIX-style hosts. */ +#cmakedefine _LARGE_FILES ${_LARGE_FILES} + +/* Define to empty if `const' does not conform to ANSI C. */ +#cmakedefine const ${const} + +/* type to use in place of in_addr_t if not defined */ +#cmakedefine in_addr_t ${in_addr_t} + +/* Define to `unsigned' if does not define. */ +#cmakedefine size_t ${size_t} + +/* type to use in place of socklen_t if not defined */ +#cmakedefine socklen_t ${socklen_t} + +/* the signed version of size_t */ +#cmakedefine ssize_t ${ssize_t} + +/* define if the compiler supports number 0x3627676LL */ +#cmakedefine HAVE_LONG_LONG_CONSTANT ${HAVE_LONG_LONG_CONSTANT} + +/* Special handling of zlib library */ +#cmakedefine CURL_SPECIAL_ZLIB_H "${CURL_SPECIAL_ZLIB_H}" diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/connect.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/connect.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/connect.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/connect.c 2004-10-13 22:01:04.000000000 +0800 @@ -0,0 +1,788 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: connect.c,v 1.18 2004/10/13 14:01:04 andy Exp $ + ***************************************************************************/ + +#include "setup.h" + +#ifndef WIN32 +/* headers for non-win32 */ +#include +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include /* may need it */ +#endif +#ifdef HAVE_NETINET_TCP_H +#include /* for TCP_NODELAY */ +#endif +#ifdef HAVE_SYS_IOCTL_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_NETDB_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_ARPA_INET_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include /* required for free() prototype, without it, this crashes + on macos 68K */ +#endif +#if (defined(HAVE_FIONBIO) && defined(__NOVELL_LIBC__)) +#include +#endif +#if (defined(NETWARE) && defined(__NOVELL_LIBC__)) +#undef in_addr_t +#define in_addr_t unsigned long +#endif +#ifdef VMS +#include +#include +#endif + +#endif +#include +#include +#include + +#ifndef TRUE +#define TRUE 1 +#define FALSE 0 +#endif + +#ifdef WIN32 +#include +#define EINPROGRESS WSAEINPROGRESS +#define EWOULDBLOCK WSAEWOULDBLOCK +#define EISCONN WSAEISCONN +#define ENOTSOCK WSAENOTSOCK +#define ECONNREFUSED WSAECONNREFUSED +#endif + +#include "urldata.h" +#include "sendf.h" +#include "if2ip.h" +#include "strerror.h" +#include "connect.h" +#include "curl_memory.h" + +/* The last #include file should be: */ +#include "memdebug.h" + +static bool verifyconnect(curl_socket_t sockfd, int *error); + +static curl_socket_t +singleipconnect(struct connectdata *conn, + Curl_addrinfo *ai, /* start connecting to this */ + long timeout_ms, + bool *connected); + +/* + * Curl_ourerrno() returns the errno (or equivalent) on this platform to + * hide platform specific for the function that calls this. + */ +int Curl_ourerrno(void) +{ +#ifdef WIN32 + return (int)GetLastError(); +#else + return errno; +#endif +} + +/* + * Curl_nonblock() set the given socket to either blocking or non-blocking + * mode based on the 'nonblock' boolean argument. This function is highly + * portable. + */ +int Curl_nonblock(curl_socket_t sockfd, /* operate on this */ + int nonblock /* TRUE or FALSE */) +{ +#undef SETBLOCK +#ifdef HAVE_O_NONBLOCK + { + /* most recent unix versions */ + int flags; + + flags = fcntl(sockfd, F_GETFL, 0); + if (TRUE == nonblock) + return fcntl(sockfd, F_SETFL, flags | O_NONBLOCK); + else + return fcntl(sockfd, F_SETFL, flags & (~O_NONBLOCK)); + } +#define SETBLOCK 1 +#endif + +#ifdef HAVE_FIONBIO + { + /* older unix versions */ + int flags; + + flags = nonblock; + return ioctl(sockfd, FIONBIO, &flags); + } +#ifdef SETBLOCK +# undef SETBLOCK +#endif +#define SETBLOCK 2 +#endif + +#ifdef HAVE_IOCTLSOCKET + /* Windows? */ + unsigned long flags; + flags = nonblock; + return ioctlsocket(sockfd, FIONBIO, &flags); +#define SETBLOCK 3 +#endif + +#ifdef HAVE_IOCTLSOCKET_CASE + /* presumably for Amiga */ + return IoctlSocket(sockfd, FIONBIO, (long)nonblock); +#ifdef SETBLOCK +# undef SETBLOCK +#endif +#define SETBLOCK 4 +#endif + +#ifdef HAVE_SO_NONBLOCK + /* BeOS */ + long b = nonblock ? 1 : 0; + return setsockopt(sockfd, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b)); +#ifdef SETBLOCK +# undef SETBLOCK +#endif +#define SETBLOCK 5 +#endif + +#ifdef HAVE_DISABLED_NONBLOCKING + (void)nonblock; + (void)sockfd; + return 0; /* returns success */ +#ifdef SETBLOCK +# undef SETBLOCK +#endif +#define SETBLOCK 6 +#endif + +#ifndef SETBLOCK +#error "no non-blocking method was found/used/set" +#endif +} + +/* + * waitconnect() waits for a TCP connect on the given socket for the specified + * number if milliseconds. It returns: + * 0 fine connect + * -1 select() error + * 1 select() timeout + * 2 select() returned with an error condition fd_set + */ + +#define WAITCONN_CONNECTED 0 +#define WAITCONN_SELECT_ERROR -1 +#define WAITCONN_TIMEOUT 1 +#define WAITCONN_FDSET_ERROR 2 + +static +int waitconnect(curl_socket_t sockfd, /* socket */ + long timeout_msec) +{ + fd_set fd; + fd_set errfd; + struct timeval interval; + int rc; +#ifdef mpeix + /* Call this function once now, and ignore the results. We do this to + "clear" the error state on the socket so that we can later read it + reliably. This is reported necessary on the MPE/iX operating system. */ + verifyconnect(sockfd, NULL); +#endif + + /* now select() until we get connect or timeout */ + FD_ZERO(&fd); + FD_SET(sockfd, &fd); + + FD_ZERO(&errfd); + FD_SET(sockfd, &errfd); + + interval.tv_sec = (int)(timeout_msec/1000); + timeout_msec -= interval.tv_sec*1000; + + interval.tv_usec = timeout_msec*1000; + + rc = select(sockfd+1, NULL, &fd, &errfd, &interval); + if(-1 == rc) + /* error, no connect here, try next */ + return WAITCONN_SELECT_ERROR; + + else if(0 == rc) + /* timeout, no connect today */ + return WAITCONN_TIMEOUT; + + if(FD_ISSET(sockfd, &errfd)) + /* error condition caught */ + return WAITCONN_FDSET_ERROR; + + /* we have a connect! */ + return WAITCONN_CONNECTED; +} + +static CURLcode bindlocal(struct connectdata *conn, + curl_socket_t sockfd) +{ +#ifdef HAVE_INET_NTOA + bool bindworked = FALSE; + struct SessionHandle *data = conn->data; + + /************************************************************* + * Select device to bind socket to + *************************************************************/ + if (strlen(data->set.device)<255) { + struct Curl_dns_entry *h=NULL; + char myhost[256] = ""; + in_addr_t in; + int rc; + bool was_iface = FALSE; + + /* First check if the given name is an IP address */ + in=inet_addr(data->set.device); + + if((in == CURL_INADDR_NONE) && + Curl_if2ip(data->set.device, myhost, sizeof(myhost))) { + /* + * We now have the numerical IPv4-style x.y.z.w in the 'myhost' buffer + */ + rc = Curl_resolv(conn, myhost, 0, &h); + if(rc == CURLRESOLV_PENDING) + (void)Curl_wait_for_resolv(conn, &h); + + if(h) + was_iface = TRUE; + } + + if(!was_iface) { + /* + * This was not an interface, resolve the name as a host name + * or IP number + */ + rc = Curl_resolv(conn, data->set.device, 0, &h); + if(rc == CURLRESOLV_PENDING) + (void)Curl_wait_for_resolv(conn, &h); + + if(h) + /* we know data->set.device is shorter than the myhost array */ + strcpy(myhost, data->set.device); + } + + if(! *myhost) { + /* need to fix this + h=Curl_gethost(data, + getmyhost(*myhost,sizeof(myhost)), + hostent_buf, + sizeof(hostent_buf)); + */ + failf(data, "Couldn't bind to '%s'", data->set.device); + return CURLE_HTTP_PORT_FAILED; + } + + infof(data, "We bind local end to %s\n", myhost); + +#ifdef SO_BINDTODEVICE + /* I am not sure any other OSs than Linux that provide this feature, and + * at the least I cannot test. --Ben + * + * This feature allows one to tightly bind the local socket to a + * particular interface. This will force even requests to other local + * interfaces to go out the external interface. + * + */ + if (was_iface) { + /* Only bind to the interface when specified as interface, not just as a + * hostname or ip address. + */ + if (setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE, + data->set.device, strlen(data->set.device)+1) != 0) { + /* printf("Failed to BINDTODEVICE, socket: %d device: %s error: %s\n", + sockfd, data->set.device, Curl_strerror(Curl_ourerrno())); */ + infof(data, "SO_BINDTODEVICE %s failed\n", + data->set.device); + /* This is typically "errno 1, error: Operation not permitted" if + you're not running as root or another suitable privileged user */ + } + } +#endif + + in=inet_addr(myhost); + if (CURL_INADDR_NONE != in) { + + if ( h ) { + Curl_addrinfo *addr = h->addr; + + Curl_resolv_unlock(data, h); + /* we don't need it anymore after this function has returned */ + + if( bind(sockfd, addr->ai_addr, (socklen_t)addr->ai_addrlen) >= 0) { + /* we succeeded to bind */ +#ifdef ENABLE_IPV6 + struct sockaddr_in6 add; +#else + struct sockaddr_in add; +#endif + +#ifdef __hpux + int gsize = sizeof(add); +#else + socklen_t gsize = sizeof(add); +#endif + bindworked = TRUE; + + if(getsockname(sockfd, (struct sockaddr *) &add, + &gsize)<0) { + failf(data, "getsockname() failed"); + return CURLE_HTTP_PORT_FAILED; + } + } + + if(!bindworked) { + failf(data, "%s", Curl_strerror(conn, Curl_ourerrno())); + return CURLE_HTTP_PORT_FAILED; + } + + } /* end of if h */ + else { + failf(data,"could't find my own IP address (%s)", myhost); + return CURLE_HTTP_PORT_FAILED; + } + } /* end of inet_addr */ + + else { + failf(data, "could't find my own IP address (%s)", myhost); + return CURLE_HTTP_PORT_FAILED; + } + + return CURLE_OK; + + } /* end of device selection support */ +#endif /* end of HAVE_INET_NTOA */ + + return CURLE_HTTP_PORT_FAILED; +} + +/* + * verifyconnect() returns TRUE if the connect really has happened. + */ +static bool verifyconnect(curl_socket_t sockfd, int *error) +{ + bool rc; +#ifdef SO_ERROR + int err = 0; +#ifdef __hpux + int errSize = sizeof(err); +#else + socklen_t errSize = sizeof(err); +#endif + + +#ifdef WIN32 + /* + * In October 2003 we effectively nullified this function on Windows due to + * problems with it using all CPU in multi-threaded cases. + * + * In May 2004, we bring it back to offer more info back on connect failures. + * Gisle Vanem could reproduce the former problems with this function, but + * could avoid them by adding this SleepEx() call below: + * + * "I don't have Rational Quantify, but the hint from his post was + * ntdll::NtRemoveIoCompletion(). So I'd assume the SleepEx (or maybe + * just Sleep(0) would be enough?) would release whatever + * mutex/critical-section the ntdll call is waiting on. + * + * Someone got to verify this on Win-NT 4.0, 2000." + */ + SleepEx(0, FALSE); +#endif + + if( -1 == getsockopt(sockfd, SOL_SOCKET, SO_ERROR, + (void *)&err, &errSize)) + err = Curl_ourerrno(); + + if ((0 == err) || (EISCONN == err)) + /* we are connected, awesome! */ + rc = TRUE; + else + /* This wasn't a successful connect */ + rc = FALSE; + if (error) + *error = err; +#else + (void)sockfd; + if (error) + *error = Curl_ourerrno(); +#endif + return rc; +} + +/* Used within the multi interface. Try next IP address, return TRUE if no + more address exists */ +static bool trynextip(struct connectdata *conn, + int sockindex, + bool *connected) +{ + curl_socket_t sockfd; + Curl_addrinfo *ai; + + if(sockindex != FIRSTSOCKET) + return TRUE; /* no next */ + + /* try the next address */ + ai = conn->ip_addr->ai_next; + + while (ai) { + sockfd = singleipconnect(conn, ai, 0L, connected); + if(sockfd != CURL_SOCKET_BAD) { + /* store the new socket descriptor */ + conn->sock[sockindex] = sockfd; + conn->ip_addr = ai; + return FALSE; + } + ai = ai->ai_next; + } + return TRUE; +} + +/* + * Curl_is_connected() is used from the multi interface to check if the + * firstsocket has connected. + */ + +CURLcode Curl_is_connected(struct connectdata *conn, + int sockindex, + bool *connected) +{ + int rc; + struct SessionHandle *data = conn->data; + CURLcode code = CURLE_OK; + curl_socket_t sockfd = conn->sock[sockindex]; + long allow = DEFAULT_CONNECT_TIMEOUT; + long has_passed; + + curlassert(sockindex >= FIRSTSOCKET && sockindex <= SECONDARYSOCKET); + + *connected = FALSE; /* a very negative world view is best */ + + /* Evaluate in milliseconds how much time that has passed */ + has_passed = Curl_tvdiff(Curl_tvnow(), data->progress.start); + + /* subtract the most strict timeout of the ones */ + if(data->set.timeout && data->set.connecttimeout) { + if (data->set.timeout < data->set.connecttimeout) + allow = data->set.timeout*1000; + else + allow = data->set.connecttimeout*1000; + } + else if(data->set.timeout) { + allow = data->set.timeout*1000; + } + else if(data->set.connecttimeout) { + allow = data->set.connecttimeout*1000; + } + + if(has_passed > allow ) { + /* time-out, bail out, go home */ + failf(data, "Connection time-out after %ld ms", has_passed); + return CURLE_OPERATION_TIMEOUTED; + } + if(conn->bits.tcpconnect) { + /* we are connected already! */ + *connected = TRUE; + return CURLE_OK; + } + + /* check for connect without timeout as we want to return immediately */ + rc = waitconnect(sockfd, 0); + + if(WAITCONN_CONNECTED == rc) { + if (verifyconnect(sockfd, NULL)) { + /* we are connected, awesome! */ + *connected = TRUE; + return CURLE_OK; + } + /* nope, not connected for real */ + infof(data, "Connection failed\n"); + if(trynextip(conn, sockindex, connected)) { + code = CURLE_COULDNT_CONNECT; + } + } + else if(WAITCONN_TIMEOUT != rc) { + /* nope, not connected */ + infof(data, "Connection failed\n"); + if(trynextip(conn, sockindex, connected)) { + int error = Curl_ourerrno(); + failf(data, "Failed connect to %s:%d; %s", + conn->host.name, conn->port, Curl_strerror(conn,error)); + code = CURLE_COULDNT_CONNECT; + } + } + /* + * If the connection failed here, we should attempt to connect to the "next + * address" for the given host. + */ + + return code; +} + +static void tcpnodelay(struct connectdata *conn, + curl_socket_t sockfd) +{ +#ifdef TCP_NODELAY + struct SessionHandle *data= conn->data; + socklen_t onoff = (socklen_t) data->set.tcp_nodelay; + if(setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (void *)&onoff, + sizeof(onoff)) < 0) + infof(data, "Could not set TCP_NODELAY: %s\n", + Curl_strerror(conn, Curl_ourerrno())); + else + infof(data,"TCP_NODELAY set\n"); +#else + (void)conn; + (void)sockfd; +#endif +} + +/* singleipconnect() connects to the given IP only, and it may return without + having connected if used from the multi interface. */ +static curl_socket_t +singleipconnect(struct connectdata *conn, + Curl_addrinfo *ai, + long timeout_ms, + bool *connected) +{ + char addr_buf[128]; + int rc; + int error; + bool conected; + struct SessionHandle *data = conn->data; + curl_socket_t sockfd = socket(ai->ai_family, ai->ai_socktype, + ai->ai_protocol); + if (sockfd == CURL_SOCKET_BAD) + return CURL_SOCKET_BAD; + + *connected = FALSE; /* default is not connected */ + + Curl_printable_address(ai, addr_buf, sizeof(addr_buf)); + infof(data, " Trying %s... ", addr_buf); + + if(data->set.tcp_nodelay) + tcpnodelay(conn, sockfd); + + if(conn->data->set.device) { + /* user selected to bind the outgoing socket to a specified "device" + before doing connect */ + CURLcode res = bindlocal(conn, sockfd); + if(res) + return res; + } + + /* set socket non-blocking */ + Curl_nonblock(sockfd, TRUE); + + rc = connect(sockfd, ai->ai_addr, ai->ai_addrlen); + + if(-1 == rc) { + error = Curl_ourerrno(); + + switch (error) { + case EINPROGRESS: + case EWOULDBLOCK: +#if defined(EAGAIN) && EAGAIN != EWOULDBLOCK + /* On some platforms EAGAIN and EWOULDBLOCK are the + * same value, and on others they are different, hence + * the odd #if + */ + case EAGAIN: +#endif + rc = waitconnect(sockfd, timeout_ms); + break; + default: + /* unknown error, fallthrough and try another address! */ + failf(data, "Failed to connect to %s: %s", + addr_buf, Curl_strerror(conn,error)); + break; + } + } + + /* The 'WAITCONN_TIMEOUT == rc' comes from the waitconnect(), and not from + connect(). We can be sure of this since connect() cannot return 1. */ + if((WAITCONN_TIMEOUT == rc) && + (data->state.used_interface == Curl_if_multi)) { + /* Timeout when running the multi interface */ + return sockfd; + } + + conected = verifyconnect(sockfd, &error); + + if(!rc && conected) { + /* we are connected, awesome! */ + *connected = TRUE; /* this is a true connect */ + infof(data, "connected\n"); + return sockfd; + } + else if(WAITCONN_TIMEOUT == rc) + infof(data, "Timeout\n"); + else + infof(data, "%s\n", Curl_strerror(conn, error)); + + /* connect failed or timed out */ + sclose(sockfd); + + return CURL_SOCKET_BAD; +} + +/* + * TCP connect to the given host with timeout, proxy or remote doesn't matter. + * There might be more than one IP address to try out. Fill in the passed + * pointer with the connected socket. + */ + +CURLcode Curl_connecthost(struct connectdata *conn, /* context */ + struct Curl_dns_entry *remotehost, /* use this one */ + curl_socket_t *sockconn, /* the connected socket */ + Curl_addrinfo **addr, /* the one we used */ + bool *connected) /* really connected? */ +{ + struct SessionHandle *data = conn->data; + curl_socket_t sockfd = CURL_SOCKET_BAD; + int aliasindex; + int num_addr; + Curl_addrinfo *ai; + Curl_addrinfo *curr_addr; + + struct timeval after; + struct timeval before = Curl_tvnow(); + + /************************************************************* + * Figure out what maximum time we have left + *************************************************************/ + long timeout_ms= DEFAULT_CONNECT_TIMEOUT; + long timeout_per_addr; + + *connected = FALSE; /* default to not connected */ + + if(data->set.timeout || data->set.connecttimeout) { + long has_passed; + + /* Evaluate in milliseconds how much time that has passed */ + has_passed = Curl_tvdiff(Curl_tvnow(), data->progress.start); + +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + + /* get the most strict timeout of the ones converted to milliseconds */ + if(data->set.timeout && data->set.connecttimeout) { + if (data->set.timeout < data->set.connecttimeout) + timeout_ms = data->set.timeout*1000; + else + timeout_ms = data->set.connecttimeout*1000; + } + else if(data->set.timeout) + timeout_ms = data->set.timeout*1000; + else + timeout_ms = data->set.connecttimeout*1000; + + /* subtract the passed time */ + timeout_ms -= has_passed; + + if(timeout_ms < 0) { + /* a precaution, no need to continue if time already is up */ + failf(data, "Connection time-out"); + return CURLE_OPERATION_TIMEOUTED; + } + } + + /* Max time for each address */ + num_addr = Curl_num_addresses(remotehost->addr); + timeout_per_addr = timeout_ms / num_addr; + + ai = remotehost->addr; + + /* Below is the loop that attempts to connect to all IP-addresses we + * know for the given host. One by one until one IP succeeds. + */ + + if(data->state.used_interface == Curl_if_multi) + /* don't hang when doing multi */ + timeout_per_addr = timeout_ms = 0; + + /* + * Connecting with a Curl_addrinfo chain + */ + for (curr_addr = ai, aliasindex=0; curr_addr; + curr_addr = curr_addr->ai_next, aliasindex++) { + + /* start connecting to the IP curr_addr points to */ + sockfd = singleipconnect(conn, curr_addr, timeout_per_addr, connected); + + if(sockfd != CURL_SOCKET_BAD) + break; + + /* get a new timeout for next attempt */ + after = Curl_tvnow(); + timeout_ms -= Curl_tvdiff(after, before); + if(timeout_ms < 0) { + failf(data, "connect() timed out!"); + return CURLE_OPERATION_TIMEOUTED; + } + before = after; + } /* end of connect-to-each-address loop */ + + if (sockfd == CURL_SOCKET_BAD) { + /* no good connect was made */ + *sockconn = CURL_SOCKET_BAD; + return CURLE_COULDNT_CONNECT; + } + + /* leave the socket in non-blocking mode */ + + /* store the address we use */ + if(addr) + *addr = curr_addr; + + /* allow NULL-pointers to get passed in */ + if(sockconn) + *sockconn = sockfd; /* the socket descriptor we've connected */ + + return CURLE_OK; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/connect.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/connect.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/connect.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/connect.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,44 @@ +#ifndef __CONNECT_H +#define __CONNECT_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: connect.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +int Curl_nonblock(curl_socket_t sockfd, /* operate on this */ + int nonblock /* TRUE or FALSE */); + +CURLcode Curl_is_connected(struct connectdata *conn, + int sockindex, + bool *connected); + +CURLcode Curl_connecthost(struct connectdata *conn, + struct Curl_dns_entry *host, /* connect to this */ + curl_socket_t *sockconn, /* not set if error */ + Curl_addrinfo **addr, /* the one we used */ + bool *connected /* truly connected? */ + ); + +int Curl_ourerrno(void); + +#define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */ + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/content_encoding.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/content_encoding.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/content_encoding.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/content_encoding.c 2004-10-06 00:42:37.000000000 +0800 @@ -0,0 +1,363 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: content_encoding.c,v 1.5 2004/10/05 16:42:37 hoffman Exp $ + ***************************************************************************/ + +#include "setup.h" + +#ifdef HAVE_LIBZ + +#include +#include + +#include "urldata.h" +#include +#include "sendf.h" +#include "content_encoding.h" +#include "curl_memory.h" + +#include "memdebug.h" + +#define DSIZ 0x10000 /* buffer size for decompressed data */ + +#define GZIP_MAGIC_0 0x1f +#define GZIP_MAGIC_1 0x8b + +/* gzip flag byte */ +#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ +#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */ +#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ +#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ +#define COMMENT 0x10 /* bit 4 set: file comment present */ +#define RESERVED 0xE0 /* bits 5..7: reserved */ + +static CURLcode +process_zlib_error(struct SessionHandle *data, z_stream *z) +{ + if (z->msg) + failf (data, "Error while processing content unencoding.\n%s", + z->msg); + else + failf (data, "Error while processing content unencoding.\n" + "Unknown failure within decompression software."); + + return CURLE_BAD_CONTENT_ENCODING; +} + +static CURLcode +exit_zlib(z_stream *z, bool *zlib_init, CURLcode result) +{ + inflateEnd(z); + *zlib_init = 0; + return result; +} + +CURLcode +Curl_unencode_deflate_write(struct SessionHandle *data, + struct Curl_transfer_keeper *k, + ssize_t nread) +{ + int status; /* zlib status */ + CURLcode result = CURLE_OK; /* Curl_client_write status */ + char decomp[DSIZ]; /* Put the decompressed data here. */ + z_stream *z = &k->z; /* zlib state structure */ + + /* Initialize zlib? */ + if (!k->zlib_init) { + z->zalloc = (alloc_func)Z_NULL; + z->zfree = (free_func)Z_NULL; + z->opaque = 0; + z->next_in = NULL; + z->avail_in = 0; + if (inflateInit(z) != Z_OK) + return process_zlib_error(data, z); + k->zlib_init = 1; + } + + /* Set the compressed input when this function is called */ + z->next_in = (Bytef *)k->str; + z->avail_in = (uInt)nread; + + /* because the buffer size is fixed, iteratively decompress + and transfer to the client via client_write. */ + for (;;) { + /* (re)set buffer for decompressed output for every iteration */ + z->next_out = (Bytef *)&decomp[0]; + z->avail_out = DSIZ; + + status = inflate(z, Z_SYNC_FLUSH); + if (status == Z_OK || status == Z_STREAM_END) { + if (DSIZ - z->avail_out) { + result = Curl_client_write(data, CLIENTWRITE_BODY, decomp, + DSIZ - z->avail_out); + /* if !CURLE_OK, clean up, return */ + if (result) + return exit_zlib(z, &k->zlib_init, result); + } + + /* Done?; clean up, return */ + if (status == Z_STREAM_END) { + if (inflateEnd(z) == Z_OK) + return exit_zlib(z, &k->zlib_init, result); + else + return exit_zlib(z, &k->zlib_init, process_zlib_error(data, z)); + } + + /* Done with these bytes, exit */ + if (status == Z_OK && z->avail_in == 0 && z->avail_out > 0) + return result; + } + else { /* Error; exit loop, handle below */ + return exit_zlib(z, &k->zlib_init, process_zlib_error(data, z)); + } + } +} + +/* Skip over the gzip header */ +static enum { + GZIP_OK, + GZIP_BAD, + GZIP_UNDERFLOW +} check_gzip_header(unsigned char const *data, ssize_t len, ssize_t *headerlen) +{ + int method, flags; + const ssize_t totallen = len; + + /* The shortest header is 10 bytes */ + if (len < 10) + return GZIP_UNDERFLOW; + + if ((data[0] != GZIP_MAGIC_0) || (data[1] != GZIP_MAGIC_1)) + return GZIP_BAD; + + method = data[2]; + flags = data[3]; + + if (method != Z_DEFLATED || (flags & RESERVED) != 0) { + /* Can't handle this compression method or unknown flag */ + return GZIP_BAD; + } + + /* Skip over time, xflags, OS code and all previous bytes */ + len -= 10; + data += 10; + + if (flags & EXTRA_FIELD) { + ssize_t extra_len; + + if (len < 2) + return GZIP_UNDERFLOW; + + extra_len = (data[1] << 8) | data[0]; + + if (len < (extra_len+2)) + return GZIP_UNDERFLOW; + + len -= (extra_len + 2); + } + + if (flags & ORIG_NAME) { + /* Skip over NUL-terminated file name */ + while (len && *data) { + --len; + ++data; + } + if (!len || *data) + return GZIP_UNDERFLOW; + + /* Skip over the NUL */ + --len; + ++data; + } + + if (flags & COMMENT) { + /* Skip over NUL-terminated comment */ + while (len && *data) { + --len; + ++data; + } + if (!len || *data) + return GZIP_UNDERFLOW; + + /* Skip over the NUL */ + --len; + ++data; + } + + if (flags & HEAD_CRC) { + if (len < 2) + return GZIP_UNDERFLOW; + + len -= 2; + data += 2; + } + + *headerlen = totallen - len; + return GZIP_OK; +} + +CURLcode +Curl_unencode_gzip_write(struct SessionHandle *data, + struct Curl_transfer_keeper *k, + ssize_t nread) +{ + int status; /* zlib status */ + CURLcode result = CURLE_OK; /* Curl_client_write status */ + char decomp[DSIZ]; /* Put the decompressed data here. */ + z_stream *z = &k->z; /* zlib state structure */ + + /* Initialize zlib? */ + if (!k->zlib_init) { + z->zalloc = (alloc_func)Z_NULL; + z->zfree = (free_func)Z_NULL; + z->opaque = 0; + z->next_in = NULL; + z->avail_in = 0; + if (inflateInit2(z, -MAX_WBITS) != Z_OK) + return process_zlib_error(data, z); + k->zlib_init = 1; /* Initial call state */ + } + + /* This next mess is to get around the potential case where there isn't + * enough data passed in to skip over the gzip header. If that happens, we + * malloc a block and copy what we have then wait for the next call. If + * there still isn't enough (this is definitely a worst-case scenario), we + * make the block bigger, copy the next part in and keep waiting. + */ + + /* Skip over gzip header? */ + if (k->zlib_init == 1) { + /* Initial call state */ + ssize_t hlen; + + switch (check_gzip_header((unsigned char *)k->str, nread, &hlen)) { + case GZIP_OK: + z->next_in = (Bytef *)k->str + hlen; + z->avail_in = (uInt)(nread - hlen); + k->zlib_init = 3; /* Inflating stream state */ + break; + + case GZIP_UNDERFLOW: + /* We need more data so we can find the end of the gzip header. It's + * possible that the memory block we malloc here will never be freed if + * the transfer abruptly aborts after this point. Since it's unlikely + * that circumstances will be right for this code path to be followed in + * the first place, and it's even more unlikely for a transfer to fail + * immediately afterwards, it should seldom be a problem. + */ + z->avail_in = (uInt)nread; + z->next_in = malloc(z->avail_in); + if (z->next_in == NULL) { + return exit_zlib(z, &k->zlib_init, CURLE_OUT_OF_MEMORY); + } + memcpy(z->next_in, k->str, z->avail_in); + k->zlib_init = 2; /* Need more gzip header data state */ + /* We don't have any data to inflate yet */ + return CURLE_OK; + + case GZIP_BAD: + default: + return exit_zlib(z, &k->zlib_init, process_zlib_error(data, z)); + } + + } + else if (k->zlib_init == 2) { + /* Need more gzip header data state */ + ssize_t hlen; + unsigned char *oldblock = z->next_in; + + z->avail_in += nread; + z->next_in = realloc(z->next_in, z->avail_in); + if (z->next_in == NULL) { + free(oldblock); + return exit_zlib(z, &k->zlib_init, CURLE_OUT_OF_MEMORY); + } + /* Append the new block of data to the previous one */ + memcpy(z->next_in + z->avail_in - nread, k->str, nread); + + switch (check_gzip_header(z->next_in, z->avail_in, &hlen)) { + case GZIP_OK: + /* This is the zlib stream data */ + free(z->next_in); + /* Don't point into the malloced block since we just freed it */ + z->next_in = (Bytef *)k->str + hlen + nread - z->avail_in; + z->avail_in = (uInt)(z->avail_in - hlen); + k->zlib_init = 3; /* Inflating stream state */ + break; + + case GZIP_UNDERFLOW: + /* We still don't have any data to inflate! */ + return CURLE_OK; + + case GZIP_BAD: + default: + free(z->next_in); + return exit_zlib(z, &k->zlib_init, process_zlib_error(data, z)); + } + + } + else { + /* Inflating stream state */ + z->next_in = (Bytef *)k->str; + z->avail_in = (uInt)nread; + } + + if (z->avail_in == 0) { + /* We don't have any data to inflate; wait until next time */ + return CURLE_OK; + } + + /* because the buffer size is fixed, iteratively decompress and transfer to + the client via client_write. */ + for (;;) { + /* (re)set buffer for decompressed output for every iteration */ + z->next_out = (Bytef *)&decomp[0]; + z->avail_out = DSIZ; + + status = inflate(z, Z_SYNC_FLUSH); + if (status == Z_OK || status == Z_STREAM_END) { + if(DSIZ - z->avail_out) { + result = Curl_client_write(data, CLIENTWRITE_BODY, decomp, + DSIZ - z->avail_out); + /* if !CURLE_OK, clean up, return */ + if (result) + return exit_zlib(z, &k->zlib_init, result); + } + + /* Done?; clean up, return */ + /* We should really check the gzip CRC here */ + if (status == Z_STREAM_END) { + if (inflateEnd(z) == Z_OK) + return exit_zlib(z, &k->zlib_init, result); + else + return exit_zlib(z, &k->zlib_init, process_zlib_error(data, z)); + } + + /* Done with these bytes, exit */ + if (status == Z_OK && z->avail_in == 0 && z->avail_out > 0) + return result; + } + else { /* Error; exit loop, handle below */ + return exit_zlib(z, &k->zlib_init, process_zlib_error(data, z)); + } + } +} +#endif /* HAVE_LIBZ */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/content_encoding.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/content_encoding.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/content_encoding.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/content_encoding.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,41 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: content_encoding.h,v 1.3 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ +#include "setup.h" + +/* + * Comma-separated list all supported Content-Encodings ('identity' is implied) + */ +#ifdef HAVE_LIBZ +#define ALL_CONTENT_ENCODINGS "deflate, gzip" +#else +#define ALL_CONTENT_ENCODINGS "identity" +#endif + +CURLcode Curl_unencode_deflate_write(struct SessionHandle *data, + struct Curl_transfer_keeper *k, + ssize_t nread); + +CURLcode +Curl_unencode_gzip_write(struct SessionHandle *data, + struct Curl_transfer_keeper *k, + ssize_t nread); diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/cookie.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/cookie.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/cookie.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/cookie.c 2004-10-13 22:01:04.000000000 +0800 @@ -0,0 +1,879 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: cookie.c,v 1.8 2004/10/13 14:01:04 andy Exp $ + ***************************************************************************/ + +/*** + + +RECEIVING COOKIE INFORMATION +============================ + +struct CookieInfo *cookie_init(char *file); + + Inits a cookie struct to store data in a local file. This is always + called before any cookies are set. + +int cookies_set(struct CookieInfo *cookie, char *cookie_line); + + The 'cookie_line' parameter is a full "Set-cookie:" line as + received from a server. + + The function need to replace previously stored lines that this new + line superceeds. + + It may remove lines that are expired. + + It should return an indication of success/error. + + +SENDING COOKIE INFORMATION +========================== + +struct Cookies *cookie_getlist(struct CookieInfo *cookie, + char *host, char *path, bool secure); + + For a given host and path, return a linked list of cookies that + the client should send to the server if used now. The secure + boolean informs the cookie if a secure connection is achieved or + not. + + It shall only return cookies that haven't expired. + + +Example set of cookies: + + Set-cookie: PRODUCTINFO=webxpress; domain=.fidelity.com; path=/; secure + Set-cookie: PERSONALIZE=none;expires=Monday, 13-Jun-1988 03:04:55 GMT; + domain=.fidelity.com; path=/ftgw; secure + Set-cookie: FidHist=none;expires=Monday, 13-Jun-1988 03:04:55 GMT; + domain=.fidelity.com; path=/; secure + Set-cookie: FidOrder=none;expires=Monday, 13-Jun-1988 03:04:55 GMT; + domain=.fidelity.com; path=/; secure + Set-cookie: DisPend=none;expires=Monday, 13-Jun-1988 03:04:55 GMT; + domain=.fidelity.com; path=/; secure + Set-cookie: FidDis=none;expires=Monday, 13-Jun-1988 03:04:55 GMT; + domain=.fidelity.com; path=/; secure + Set-cookie: + Session_Key@6791a9e0-901a-11d0-a1c8-9b012c88aa77=none;expires=Monday, + 13-Jun-1988 03:04:55 GMT; domain=.fidelity.com; path=/; secure +****/ + + +#include "setup.h" + +#ifndef CURL_DISABLE_HTTP + +#include +#include +#include + +#include "urldata.h" +#include "cookie.h" +#include "getdate.h" +#include "strequal.h" +#include "strtok.h" +#include "sendf.h" +#include "curl_memory.h" + +/* The last #include file should be: */ +#ifdef CURLDEBUG +#include "memdebug.h" +#endif + +static void freecookie(struct Cookie *co) +{ + if(co->expirestr) + free(co->expirestr); + if(co->domain) + free(co->domain); + if(co->path) + free(co->path); + if(co->name) + free(co->name); + if(co->value) + free(co->value); + + free(co); +} + +static bool tailmatch(const char *little, const char *bigone) +{ + size_t littlelen = strlen(little); + size_t biglen = strlen(bigone); + + if(littlelen > biglen) + return FALSE; + + return (bool)strequal(little, bigone+biglen-littlelen); +} + +/**************************************************************************** + * + * Curl_cookie_add() + * + * Add a single cookie line to the cookie keeping object. + * + ***************************************************************************/ + +struct Cookie * +Curl_cookie_add(struct SessionHandle *data, + /* The 'data' pointer here may be NULL at times, and thus + must only be used very carefully for things that can deal + with data being NULL. Such as infof() and similar */ + + struct CookieInfo *c, + bool httpheader, /* TRUE if HTTP header-style line */ + char *lineptr, /* first character of the line */ + char *domain, /* default domain */ + char *path) /* full path used when this cookie is set, + used to get default path for the cookie + unless set */ +{ + struct Cookie *clist; + char *what; + char name[MAX_NAME]; + char *ptr; + char *semiptr; + struct Cookie *co; + struct Cookie *lastc=NULL; + time_t now = time(NULL); + bool replace_old; + bool badcookie = FALSE; /* cookies are good by default. mmmmm yummy */ + + /* First, alloc and init a new struct for it */ + co = (struct Cookie *)calloc(sizeof(struct Cookie), 1); + if(!co) + return NULL; /* bail out if we're this low on memory */ + + if(httpheader) { + /* This line was read off a HTTP-header */ + char *sep; + + what = malloc(MAX_COOKIE_LINE); + if(!what) { + free(co); + return NULL; + } + + semiptr=strchr(lineptr, ';'); /* first, find a semicolon */ + + while(*lineptr && isspace((int)*lineptr)) + lineptr++; + + ptr = lineptr; + do { + /* we have a = pair or a 'secure' word here */ + sep = strchr(ptr, '='); + if(sep && (!semiptr || (semiptr>sep)) ) { + /* + * There is a = sign and if there was a semicolon too, which make sure + * that the semicolon comes _after_ the equal sign. + */ + + name[0]=what[0]=0; /* init the buffers */ + if(1 <= sscanf(ptr, "%" MAX_NAME_TXT "[^;=]=%" + MAX_COOKIE_LINE_TXT "[^;\r\n]", + name, what)) { + /* this is a = pair */ + + char *whatptr; + + /* Strip off trailing whitespace from the 'what' */ + size_t len=strlen(what); + while(len && isspace((int)what[len-1])) { + what[len-1]=0; + len--; + } + + /* Skip leading whitespace from the 'what' */ + whatptr=what; + while(isspace((int)*whatptr)) { + whatptr++; + } + + if(strequal("path", name)) { + co->path=strdup(whatptr); + if(!co->path) { + badcookie = TRUE; /* out of memory bad */ + break; + } + } + else if(strequal("domain", name)) { + /* note that this name may or may not have a preceeding dot, but + we don't care about that, we treat the names the same anyway */ + + const char *domptr=whatptr; + int dotcount=1; + + /* Count the dots, we need to make sure that there are enough + of them. */ + + if('.' == whatptr[0]) + /* don't count the initial dot, assume it */ + domptr++; + + do { + domptr = strchr(domptr, '.'); + if(domptr) { + domptr++; + dotcount++; + } + } while(domptr); + + /* The original Netscape cookie spec defined that this domain name + MUST have three dots (or two if one of the seven holy TLDs), + but it seems that these kinds of cookies are in use "out there" + so we cannot be that strict. I've therefore lowered the check + to not allow less than two dots. */ + + if(dotcount < 2) { + /* Received and skipped a cookie with a domain using too few + dots. */ + badcookie=TRUE; /* mark this as a bad cookie */ + infof(data, "skipped cookie with illegal dotcount domain: %s\n", + whatptr); + } + else { + /* Now, we make sure that our host is within the given domain, + or the given domain is not valid and thus cannot be set. */ + + if('.' == whatptr[0]) + whatptr++; /* ignore preceeding dot */ + + if(!domain || tailmatch(whatptr, domain)) { + const char *tailptr=whatptr; + if(tailptr[0] == '.') + tailptr++; + co->domain=strdup(tailptr); /* don't prefix w/dots + internally */ + if(!co->domain) { + badcookie = TRUE; + break; + } + co->tailmatch=TRUE; /* we always do that if the domain name was + given */ + } + else { + /* we did not get a tailmatch and then the attempted set domain + is not a domain to which the current host belongs. Mark as + bad. */ + badcookie=TRUE; + infof(data, "skipped cookie with bad tailmatch domain: %s\n", + whatptr); + } + } + } + else if(strequal("version", name)) { + co->version=strdup(whatptr); + if(!co->version) { + badcookie = TRUE; + break; + } + } + else if(strequal("max-age", name)) { + /* Defined in RFC2109: + + Optional. The Max-Age attribute defines the lifetime of the + cookie, in seconds. The delta-seconds value is a decimal non- + negative integer. After delta-seconds seconds elapse, the + client should discard the cookie. A value of zero means the + cookie should be discarded immediately. + + */ + co->maxage = strdup(whatptr); + if(!co->maxage) { + badcookie = TRUE; + break; + } + co->expires = + atoi((*co->maxage=='\"')?&co->maxage[1]:&co->maxage[0]) + now; + } + else if(strequal("expires", name)) { + co->expirestr=strdup(whatptr); + if(!co->expirestr) { + badcookie = TRUE; + break; + } + co->expires = curl_getdate(what, &now); + } + else if(!co->name) { + co->name = strdup(name); + co->value = strdup(whatptr); + if(!co->name || !co->value) { + badcookie = TRUE; + break; + } + } + /* + else this is the second (or more) name we don't know + about! */ + } + else { + /* this is an "illegal" = pair */ + } + } + else { + if(sscanf(ptr, "%" MAX_COOKIE_LINE_TXT "[^;\r\n]", + what)) { + if(strequal("secure", what)) + co->secure = TRUE; + /* else, + unsupported keyword without assign! */ + + } + } + if(!semiptr || !*semiptr) { + /* we already know there are no more cookies */ + semiptr = NULL; + continue; + } + + ptr=semiptr+1; + while(ptr && *ptr && isspace((int)*ptr)) + ptr++; + semiptr=strchr(ptr, ';'); /* now, find the next semicolon */ + + if(!semiptr && *ptr) + /* There are no more semicolons, but there's a final name=value pair + coming up */ + semiptr=strchr(ptr, '\0'); + } while(semiptr); + + if(!badcookie && !co->domain) { + if(domain) { + /* no domain was given in the header line, set the default */ + co->domain=strdup(domain); + if(!co->domain) + badcookie = TRUE; + } + } + + if(!badcookie && !co->path && path) { + /* no path was given in the header line, set the default */ + char *endslash = strrchr(path, '/'); + if(endslash) { + size_t pathlen = endslash-path+1; /* include the ending slash */ + co->path=malloc(pathlen+1); /* one extra for the zero byte */ + if(co->path) { + memcpy(co->path, path, pathlen); + co->path[pathlen]=0; /* zero terminate */ + } + else + badcookie = TRUE; + } + } + + free(what); + + if(badcookie || !co->name) { + /* we didn't get a cookie name or a bad one, + this is an illegal line, bail out */ + freecookie(co); + return NULL; + } + + } + else { + /* This line is NOT a HTTP header style line, we do offer support for + reading the odd netscape cookies-file format here */ + char *firstptr; + char *tok_buf; + int fields; + + if(lineptr[0]=='#') { + /* don't even try the comments */ + free(co); + return NULL; + } + /* strip off the possible end-of-line characters */ + ptr=strchr(lineptr, '\r'); + if(ptr) + *ptr=0; /* clear it */ + ptr=strchr(lineptr, '\n'); + if(ptr) + *ptr=0; /* clear it */ + + firstptr=strtok_r(lineptr, "\t", &tok_buf); /* tokenize it on the TAB */ + + /* Here's a quick check to eliminate normal HTTP-headers from this */ + if(!firstptr || strchr(firstptr, ':')) { + free(co); + return NULL; + } + + /* Now loop through the fields and init the struct we already have + allocated */ + for(ptr=firstptr, fields=0; ptr && !badcookie; + ptr=strtok_r(NULL, "\t", &tok_buf), fields++) { + switch(fields) { + case 0: + if(ptr[0]=='.') /* skip preceeding dots */ + ptr++; + co->domain = strdup(ptr); + if(!co->domain) + badcookie = TRUE; + break; + case 1: + /* This field got its explanation on the 23rd of May 2001 by + Andrés García: + + flag: A TRUE/FALSE value indicating if all machines within a given + domain can access the variable. This value is set automatically by + the browser, depending on the value you set for the domain. + + As far as I can see, it is set to true when the cookie says + .domain.com and to false when the domain is complete www.domain.com + */ + co->tailmatch=(bool)strequal(ptr, "TRUE"); /* store information */ + break; + case 2: + /* It turns out, that sometimes the file format allows the path + field to remain not filled in, we try to detect this and work + around it! Andrés García made us aware of this... */ + if (strcmp("TRUE", ptr) && strcmp("FALSE", ptr)) { + /* only if the path doesn't look like a boolean option! */ + co->path = strdup(ptr); + if(!co->path) + badcookie = TRUE; + break; + } + /* this doesn't look like a path, make one up! */ + co->path = strdup("/"); + if(!co->path) + badcookie = TRUE; + fields++; /* add a field and fall down to secure */ + /* FALLTHROUGH */ + case 3: + co->secure = (bool)strequal(ptr, "TRUE"); + break; + case 4: + co->expires = atoi(ptr); + break; + case 5: + co->name = strdup(ptr); + if(!co->name) + badcookie = TRUE; + break; + case 6: + co->value = strdup(ptr); + if(!co->value) + badcookie = TRUE; + break; + } + } + if(6 == fields) { + /* we got a cookie with blank contents, fix it */ + co->value = strdup(""); + if(!co->value) + badcookie = TRUE; + else + fields++; + } + + if(!badcookie && (7 != fields)) + /* we did not find the sufficient number of fields */ + badcookie = TRUE; + + if(badcookie) { + freecookie(co); + return NULL; + } + + } + + if(!c->running && /* read from a file */ + c->newsession && /* clean session cookies */ + !co->expires) { /* this is a session cookie since it doesn't expire! */ + freecookie(co); + return NULL; + } + + co->livecookie = c->running; + + /* now, we have parsed the incoming line, we must now check if this + superceeds an already existing cookie, which it may if the previous have + the same domain and path as this */ + + clist = c->cookies; + replace_old = FALSE; + while(clist) { + if(strequal(clist->name, co->name)) { + /* the names are identical */ + + if(clist->domain && co->domain) { + if(strequal(clist->domain, co->domain)) + /* The domains are identical */ + replace_old=TRUE; + } + else if(!clist->domain && !co->domain) + replace_old = TRUE; + + if(replace_old) { + /* the domains were identical */ + + if(clist->path && co->path) { + if(strequal(clist->path, co->path)) { + replace_old = TRUE; + } + else + replace_old = FALSE; + } + else if(!clist->path && !co->path) + replace_old = TRUE; + else + replace_old = FALSE; + + } + + if(replace_old && !co->livecookie && clist->livecookie) { + /* Both cookies matched fine, except that the already present + cookie is "live", which means it was set from a header, while + the new one isn't "live" and thus only read from a file. We let + live cookies stay alive */ + + /* Free the newcomer and get out of here! */ + freecookie(co); + return NULL; + } + + if(replace_old) { + co->next = clist->next; /* get the next-pointer first */ + + /* then free all the old pointers */ + if(clist->name) + free(clist->name); + if(clist->value) + free(clist->value); + if(clist->domain) + free(clist->domain); + if(clist->path) + free(clist->path); + if(clist->expirestr) + free(clist->expirestr); + + if(clist->version) + free(clist->version); + if(clist->maxage) + free(clist->maxage); + + *clist = *co; /* then store all the new data */ + + free(co); /* free the newly alloced memory */ + co = clist; /* point to the previous struct instead */ + + /* We have replaced a cookie, now skip the rest of the list but + make sure the 'lastc' pointer is properly set */ + do { + lastc = clist; + clist = clist->next; + } while(clist); + break; + } + } + lastc = clist; + clist = clist->next; + } + + if(c->running) + /* Only show this when NOT reading the cookies from a file */ + infof(data, "%s cookie %s=\"%s\" for domain %s, path %s, expire %d\n", + replace_old?"Replaced":"Added", co->name, co->value, + co->domain, co->path, co->expires); + + if(!replace_old) { + /* then make the last item point on this new one */ + if(lastc) + lastc->next = co; + else + c->cookies = co; + } + + c->numcookies++; /* one more cookie in the jar */ + return co; +} + +/***************************************************************************** + * + * Curl_cookie_init() + * + * Inits a cookie struct to read data from a local file. This is always + * called before any cookies are set. File may be NULL. + * + * If 'newsession' is TRUE, discard all "session cookies" on read from file. + * + ****************************************************************************/ +struct CookieInfo *Curl_cookie_init(struct SessionHandle *data, + char *file, + struct CookieInfo *inc, + bool newsession) +{ + struct CookieInfo *c; + FILE *fp; + bool fromfile=TRUE; + + if(NULL == inc) { + /* we didn't get a struct, create one */ + c = (struct CookieInfo *)calloc(1, sizeof(struct CookieInfo)); + if(!c) + return NULL; /* failed to get memory */ + c->filename = strdup(file?file:"none"); /* copy the name just in case */ + } + else { + /* we got an already existing one, use that */ + c = inc; + } + c->running = FALSE; /* this is not running, this is init */ + + if(file && strequal(file, "-")) { + fp = stdin; + fromfile=FALSE; + } + else + fp = file?fopen(file, "r"):NULL; + + c->newsession = newsession; /* new session? */ + + if(fp) { + char *lineptr; + bool headerline; + + char *line = (char *)malloc(MAX_COOKIE_LINE); + if(line) { + while(fgets(line, MAX_COOKIE_LINE, fp)) { + if(checkprefix("Set-Cookie:", line)) { + /* This is a cookie line, get it! */ + lineptr=&line[11]; + headerline=TRUE; + } + else { + lineptr=line; + headerline=FALSE; + } + while(*lineptr && isspace((int)*lineptr)) + lineptr++; + + Curl_cookie_add(data, c, headerline, lineptr, NULL, NULL); + } + free(line); /* free the line buffer */ + } + if(fromfile) + fclose(fp); + } + + c->running = TRUE; /* now, we're running */ + + return c; +} + +/***************************************************************************** + * + * Curl_cookie_getlist() + * + * For a given host and path, return a linked list of cookies that the + * client should send to the server if used now. The secure boolean informs + * the cookie if a secure connection is achieved or not. + * + * It shall only return cookies that haven't expired. + * + ****************************************************************************/ + +struct Cookie *Curl_cookie_getlist(struct CookieInfo *c, + char *host, char *path, bool secure) +{ + struct Cookie *newco; + struct Cookie *co; + time_t now = time(NULL); + struct Cookie *mainco=NULL; + + if(!c || !c->cookies) + return NULL; /* no cookie struct or no cookies in the struct */ + + co = c->cookies; + + while(co) { + /* only process this cookie if it is not expired or had no expire + date AND that if the cookie requires we're secure we must only + continue if we are! */ + if( (co->expires<=0 || (co->expires> now)) && + (co->secure?secure:TRUE) ) { + + /* now check if the domain is correct */ + if(!co->domain || + (co->tailmatch && tailmatch(co->domain, host)) || + (!co->tailmatch && strequal(host, co->domain)) ) { + /* the right part of the host matches the domain stuff in the + cookie data */ + + /* now check the left part of the path with the cookies path + requirement */ + if(!co->path || + checkprefix(co->path, path) ) { + + /* and now, we know this is a match and we should create an + entry for the return-linked-list */ + + newco = (struct Cookie *)malloc(sizeof(struct Cookie)); + if(newco) { + /* first, copy the whole source cookie: */ + memcpy(newco, co, sizeof(struct Cookie)); + + /* then modify our next */ + newco->next = mainco; + + /* point the main to us */ + mainco = newco; + } + else { + /* failure, clear up the allocated chain and return NULL */ + while(mainco) { + co = mainco->next; + free(mainco); + mainco = co; + } + + return NULL; + } + } + } + } + co = co->next; + } + + return mainco; /* return the new list */ +} + + +/***************************************************************************** + * + * Curl_cookie_freelist() + * + * Free a list of cookies previously returned by Curl_cookie_getlist(); + * + ****************************************************************************/ + +void Curl_cookie_freelist(struct Cookie *co) +{ + struct Cookie *next; + if(co) { + while(co) { + next = co->next; + free(co); /* we only free the struct since the "members" are all + just copied! */ + co = next; + } + } +} + +/***************************************************************************** + * + * Curl_cookie_cleanup() + * + * Free a "cookie object" previous created with cookie_init(). + * + ****************************************************************************/ +void Curl_cookie_cleanup(struct CookieInfo *c) +{ + struct Cookie *co; + struct Cookie *next; + if(c) { + if(c->filename) + free(c->filename); + co = c->cookies; + + while(co) { + next = co->next; + freecookie(co); + co = next; + } + free(c); /* free the base struct as well */ + } +} + +/* + * Curl_cookie_output() + * + * Writes all internally known cookies to the specified file. Specify + * "-" as file name to write to stdout. + * + * The function returns non-zero on write failure. + */ +int Curl_cookie_output(struct CookieInfo *c, char *dumphere) +{ + struct Cookie *co; + FILE *out; + bool use_stdout=FALSE; + + if((NULL == c) || (0 == c->numcookies)) + /* If there are no known cookies, we don't write or even create any + destination file */ + return 0; + + if(strequal("-", dumphere)) { + /* use stdout */ + out = stdout; + use_stdout=TRUE; + } + else { + out = fopen(dumphere, "w"); + if(!out) + return 1; /* failure */ + } + + if(c) { + fputs("# Netscape HTTP Cookie File\n" + "# http://www.netscape.com/newsref/std/cookie_spec.html\n" + "# This file was generated by libcurl! Edit at your own risk.\n\n", + out); + co = c->cookies; + + while(co) { + fprintf(out, + "%s%s\t" /* domain */ + "%s\t" /* tailmatch */ + "%s\t" /* path */ + "%s\t" /* secure */ + "%u\t" /* expires */ + "%s\t" /* name */ + "%s\n", /* value */ + + /* Make sure all domains are prefixed with a dot if they allow + tailmatching. This is Mozilla-style. */ + (co->tailmatch && co->domain && co->domain[0] != '.')? ".":"", + co->domain?co->domain:"unknown", + co->tailmatch?"TRUE":"FALSE", + co->path?co->path:"/", + co->secure?"TRUE":"FALSE", + (unsigned int)co->expires, + co->name, + co->value?co->value:""); + + co=co->next; + } + } + + if(!use_stdout) + fclose(out); + + return 0; +} + +#endif /* CURL_DISABLE_HTTP */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/cookie.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/cookie.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/cookie.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/cookie.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,95 @@ +#ifndef __COOKIE_H +#define __COOKIE_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: cookie.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +#include +#ifdef WIN32 +#include +#else +#include +#endif + +#include + +struct Cookie { + struct Cookie *next; /* next in the chain */ + char *name; /* = value */ + char *value; /* name = */ + char *path; /* path = */ + char *domain; /* domain = */ + long expires; /* expires = */ + char *expirestr; /* the plain text version */ + bool tailmatch; /* weather we do tail-matchning of the domain name */ + + /* RFC 2109 keywords. Version=1 means 2109-compliant cookie sending */ + char *version; /* Version = */ + char *maxage; /* Max-Age = */ + + bool secure; /* whether the 'secure' keyword was used */ + bool livecookie; /* updated from a server, not a stored file */ +}; + +struct CookieInfo { + /* linked list of cookies we know of */ + struct Cookie *cookies; + + char *filename; /* file we read from/write to */ + bool running; /* state info, for cookie adding information */ + long numcookies; /* number of cookies in the "jar" */ + bool newsession; /* new session, discard session cookies on load */ +}; + +/* This is the maximum line length we accept for a cookie line. RFC 2109 + section 6.3 says: + + "at least 4096 bytes per cookie (as measured by the size of the characters + that comprise the cookie non-terminal in the syntax description of the + Set-Cookie header)" + +*/ +#define MAX_COOKIE_LINE 5000 +#define MAX_COOKIE_LINE_TXT "4999" + +/* This is the maximum length of a cookie name we deal with: */ +#define MAX_NAME 1024 +#define MAX_NAME_TXT "1023" + +struct SessionHandle; +/* + * Add a cookie to the internal list of cookies. The domain and path arguments + * are only used if the header boolean is TRUE. + */ + +struct Cookie *Curl_cookie_add(struct SessionHandle *data, + struct CookieInfo *, bool header, char *line, + char *domain, char *path); + +struct CookieInfo *Curl_cookie_init(struct SessionHandle *data, + char *, struct CookieInfo *, bool); +struct Cookie *Curl_cookie_getlist(struct CookieInfo *, char *, char *, bool); +void Curl_cookie_freelist(struct Cookie *); +void Curl_cookie_cleanup(struct CookieInfo *); +int Curl_cookie_output(struct CookieInfo *, char *); + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/curl/curl.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/curl/curl.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/curl/curl.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/curl/curl.h 2004-10-05 21:34:20.000000000 +0800 @@ -0,0 +1,1340 @@ +#ifndef __CURL_CURL_H +#define __CURL_CURL_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: curl.h,v 1.6 2004/10/05 13:34:20 andy Exp $ + ***************************************************************************/ + +/* If you have problems, all libcurl docs and details are found here: + http://curl.haxx.se/libcurl/ +*/ + +#include "curlver.h" /* the libcurl version defines */ + +#include +#include + +/* The include stuff here below is mainly for time_t! */ +#ifdef vms +# include +# include +#else +# include +# include +#endif /* defined (vms) */ + +typedef void CURL; + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * We want the typedef curl_off_t setup for large file support on all + * platforms. We also provide a CURL_FORMAT_OFF_T define to use in *printf + * format strings when outputting a variable of type curl_off_t. + */ +#if defined(_MSC_VER) || defined(__LCC__) +/* MSVC */ + typedef signed __int64 curl_off_t; +#define CURL_FORMAT_OFF_T "%I64d" +#else /* _MSC_VER || __LCC__ */ +#if (defined(__GNUC__) && defined(WIN32)) || defined(__WATCOMC__) +/* gcc on windows or Watcom */ + typedef long long curl_off_t; +#define CURL_FORMAT_OFF_T "%I64d" +#else /* GCC or Watcom on Windows */ + +/* "normal" POSIX approach, do note that this does not necessarily mean that + the type is >32 bits, see the SIZEOF_CURL_OFF_T define for that! */ + typedef off_t curl_off_t; + +/* Check a range of defines to detect large file support. On Linux it seems + none of these are set by default, so if you don't explicitly switches on + large file support, this define will be made for "small file" support. */ +#ifndef _FILE_OFFSET_BITS +#define _FILE_OFFSET_BITS 0 /* to prevent warnings in the check below */ +#define UNDEF_FILE_OFFSET_BITS +#endif +#ifndef FILESIZEBITS +#define FILESIZEBITS 0 /* to prevent warnings in the check below */ +#define UNDEF_FILESIZEBITS +#endif + +#if defined(_LARGE_FILES) || (_FILE_OFFSET_BITS > 32) || (FILESIZEBITS > 32) \ + || defined(_LARGEFILE_SOURCE) || defined(_LARGEFILE64_SOURCE) + /* For now, we assume at least one of these to be set for large files to + work! */ +#define CURL_FORMAT_OFF_T "%lld" +#else /* LARGE_FILE support */ +#define CURL_FORMAT_OFF_T "%ld" +#endif +#endif /* GCC or Watcom on Windows */ +#endif /* _MSC_VER || __LCC__ */ + +#ifdef UNDEF_FILE_OFFSET_BITS +/* this was defined above for our checks, undefine it again */ +#undef _FILE_OFFSET_BITS +#endif + +#ifdef UNDEF_FILESIZEBITS +/* this was defined above for our checks, undefine it again */ +#undef FILESIZEBITS +#endif + +struct curl_httppost { + struct curl_httppost *next; /* next entry in the list */ + char *name; /* pointer to allocated name */ + long namelength; /* length of name length */ + char *contents; /* pointer to allocated data contents */ + long contentslength; /* length of contents field */ + char *buffer; /* pointer to allocated buffer contents */ + long bufferlength; /* length of buffer field */ + char *contenttype; /* Content-Type */ + struct curl_slist* contentheader; /* list of extra headers for this form */ + struct curl_httppost *more; /* if one field name has more than one + file, this link should link to following + files */ + long flags; /* as defined below */ +#define HTTPPOST_FILENAME (1<<0) /* specified content is a file name */ +#define HTTPPOST_READFILE (1<<1) /* specified content is a file name */ +#define HTTPPOST_PTRNAME (1<<2) /* name is only stored pointer + do not free in formfree */ +#define HTTPPOST_PTRCONTENTS (1<<3) /* contents is only stored pointer + do not free in formfree */ +#define HTTPPOST_BUFFER (1<<4) /* upload file from buffer */ +#define HTTPPOST_PTRBUFFER (1<<5) /* upload file from pointer contents */ + + char *showfilename; /* The file name to show. If not set, the + actual file name will be used (if this + is a file part) */ +}; + +typedef int (*curl_progress_callback)(void *clientp, + double dltotal, + double dlnow, + double ultotal, + double ulnow); + + /* Tests have proven that 20K is a very bad buffer size for uploads on + Windows, while 16K for some odd reason performed a lot better. */ +#define CURL_MAX_WRITE_SIZE 16384 + +typedef size_t (*curl_write_callback)(char *buffer, + size_t size, + size_t nitems, + void *outstream); + +/* This is a brand new return code for the read callback that will signal + the caller to immediately abort the current transfer. */ +#define CURL_READFUNC_ABORT 0x10000000 +typedef size_t (*curl_read_callback)(char *buffer, + size_t size, + size_t nitems, + void *instream); + + /* not used since 7.10.8, will be removed in a future release */ +typedef int (*curl_passwd_callback)(void *clientp, + const char *prompt, + char *buffer, + int buflen); + +/* + * The following typedef's are signatures of malloc, free, realloc, strdup and + * calloc respectively. Function pointers of these types can be passed to the + * curl_global_init_mem() function to set user defined memory management + * callback routines. + */ +typedef void *(*curl_malloc_callback)(size_t size); +typedef void (*curl_free_callback)(void *ptr); +typedef void *(*curl_realloc_callback)(void *ptr, size_t size); +typedef char *(*curl_strdup_callback)(const char *str); +typedef void *(*curl_calloc_callback)(size_t nmemb, size_t size); + +/* the kind of data that is passed to information_callback*/ +typedef enum { + CURLINFO_TEXT = 0, + CURLINFO_HEADER_IN, /* 1 */ + CURLINFO_HEADER_OUT, /* 2 */ + CURLINFO_DATA_IN, /* 3 */ + CURLINFO_DATA_OUT, /* 4 */ + CURLINFO_SSL_DATA_IN, /* 5 */ + CURLINFO_SSL_DATA_OUT, /* 6 */ + CURLINFO_END +} curl_infotype; + +typedef int (*curl_debug_callback) + (CURL *handle, /* the handle/transfer this concerns */ + curl_infotype type, /* what kind of data */ + char *data, /* points to the data */ + size_t size, /* size of the data pointed to */ + void *userptr); /* whatever the user please */ + +/* All possible error codes from all sorts of curl functions. Future versions + may return other values, stay prepared. + + Always add new return codes last. Never *EVER* remove any. The return + codes must remain the same! + */ + +typedef enum { + CURLE_OK = 0, + CURLE_UNSUPPORTED_PROTOCOL, /* 1 */ + CURLE_FAILED_INIT, /* 2 */ + CURLE_URL_MALFORMAT, /* 3 */ + CURLE_URL_MALFORMAT_USER, /* 4 (NOT USED) */ + CURLE_COULDNT_RESOLVE_PROXY, /* 5 */ + CURLE_COULDNT_RESOLVE_HOST, /* 6 */ + CURLE_COULDNT_CONNECT, /* 7 */ + CURLE_FTP_WEIRD_SERVER_REPLY, /* 8 */ + CURLE_FTP_ACCESS_DENIED, /* 9 */ + CURLE_FTP_USER_PASSWORD_INCORRECT, /* 10 */ + CURLE_FTP_WEIRD_PASS_REPLY, /* 11 */ + CURLE_FTP_WEIRD_USER_REPLY, /* 12 */ + CURLE_FTP_WEIRD_PASV_REPLY, /* 13 */ + CURLE_FTP_WEIRD_227_FORMAT, /* 14 */ + CURLE_FTP_CANT_GET_HOST, /* 15 */ + CURLE_FTP_CANT_RECONNECT, /* 16 */ + CURLE_FTP_COULDNT_SET_BINARY, /* 17 */ + CURLE_PARTIAL_FILE, /* 18 */ + CURLE_FTP_COULDNT_RETR_FILE, /* 19 */ + CURLE_FTP_WRITE_ERROR, /* 20 */ + CURLE_FTP_QUOTE_ERROR, /* 21 */ + CURLE_HTTP_RETURNED_ERROR, /* 22 */ + CURLE_WRITE_ERROR, /* 23 */ + CURLE_MALFORMAT_USER, /* 24 - NOT USED */ + CURLE_FTP_COULDNT_STOR_FILE, /* 25 - failed FTP upload */ + CURLE_READ_ERROR, /* 26 - could open/read from file */ + CURLE_OUT_OF_MEMORY, /* 27 */ + CURLE_OPERATION_TIMEOUTED, /* 28 - the timeout time was reached */ + CURLE_FTP_COULDNT_SET_ASCII, /* 29 - TYPE A failed */ + CURLE_FTP_PORT_FAILED, /* 30 - FTP PORT operation failed */ + CURLE_FTP_COULDNT_USE_REST, /* 31 - the REST command failed */ + CURLE_FTP_COULDNT_GET_SIZE, /* 32 - the SIZE command failed */ + CURLE_HTTP_RANGE_ERROR, /* 33 - RANGE "command" didn't work */ + CURLE_HTTP_POST_ERROR, /* 34 */ + CURLE_SSL_CONNECT_ERROR, /* 35 - wrong when connecting with SSL */ + CURLE_BAD_DOWNLOAD_RESUME, /* 36 - couldn't resume download */ + CURLE_FILE_COULDNT_READ_FILE, /* 37 */ + CURLE_LDAP_CANNOT_BIND, /* 38 */ + CURLE_LDAP_SEARCH_FAILED, /* 39 */ + CURLE_LIBRARY_NOT_FOUND, /* 40 */ + CURLE_FUNCTION_NOT_FOUND, /* 41 */ + CURLE_ABORTED_BY_CALLBACK, /* 42 */ + CURLE_BAD_FUNCTION_ARGUMENT, /* 43 */ + CURLE_BAD_CALLING_ORDER, /* 44 - NOT USED */ + CURLE_INTERFACE_FAILED, /* 45 - CURLOPT_INTERFACE failed */ + CURLE_BAD_PASSWORD_ENTERED, /* 46 - NOT USED */ + CURLE_TOO_MANY_REDIRECTS , /* 47 - catch endless re-direct loops */ + CURLE_UNKNOWN_TELNET_OPTION, /* 48 - User specified an unknown option */ + CURLE_TELNET_OPTION_SYNTAX , /* 49 - Malformed telnet option */ + CURLE_OBSOLETE, /* 50 - NOT USED */ + CURLE_SSL_PEER_CERTIFICATE, /* 51 - peer's certificate wasn't ok */ + CURLE_GOT_NOTHING, /* 52 - when this is a specific error */ + CURLE_SSL_ENGINE_NOTFOUND, /* 53 - SSL crypto engine not found */ + CURLE_SSL_ENGINE_SETFAILED, /* 54 - can not set SSL crypto engine as + default */ + CURLE_SEND_ERROR, /* 55 - failed sending network data */ + CURLE_RECV_ERROR, /* 56 - failure in receiving network data */ + CURLE_SHARE_IN_USE, /* 57 - share is in use */ + CURLE_SSL_CERTPROBLEM, /* 58 - problem with the local certificate */ + CURLE_SSL_CIPHER, /* 59 - couldn't use specified cipher */ + CURLE_SSL_CACERT, /* 60 - problem with the CA cert (path?) */ + CURLE_BAD_CONTENT_ENCODING, /* 61 - Unrecognized transfer encoding */ + CURLE_LDAP_INVALID_URL, /* 62 - Invalid LDAP URL */ + CURLE_FILESIZE_EXCEEDED, /* 63 - Maximum file size exceeded */ + CURLE_FTP_SSL_FAILED, /* 64 - Requested FTP SSL level failed */ + + CURL_LAST /* never use! */ +} CURLcode; + +typedef CURLcode (*curl_ssl_ctx_callback)(CURL *curl, /* easy handle */ + void *ssl_ctx, /* actually an + OpenSSL SSL_CTX */ + void *userptr); + +/* Make a spelling correction for the operation timed-out define */ +#define CURLE_OPERATION_TIMEDOUT CURLE_OPERATION_TIMEOUTED + +/* backwards compatibility with older names */ +#define CURLE_HTTP_NOT_FOUND CURLE_HTTP_RETURNED_ERROR +#define CURLE_HTTP_PORT_FAILED CURLE_INTERFACE_FAILED + +typedef enum { + CURLPROXY_HTTP = 0, + CURLPROXY_SOCKS4 = 4, + CURLPROXY_SOCKS5 = 5 +} curl_proxytype; + +#define CURLAUTH_NONE 0 /* nothing */ +#define CURLAUTH_BASIC (1<<0) /* Basic (default) */ +#define CURLAUTH_DIGEST (1<<1) /* Digest */ +#define CURLAUTH_GSSNEGOTIATE (1<<2) /* GSS-Negotiate */ +#define CURLAUTH_NTLM (1<<3) /* NTLM */ +#define CURLAUTH_ANY ~0 /* all types set */ +#define CURLAUTH_ANYSAFE (~CURLAUTH_BASIC) + +/* this was the error code 50 in 7.7.3 and a few earlier versions, this + is no longer used by libcurl but is instead #defined here only to not + make programs break */ +#define CURLE_ALREADY_COMPLETE 99999 + +/* This is just to make older programs not break: */ +#define CURLE_FTP_PARTIAL_FILE CURLE_PARTIAL_FILE +#define CURLE_FTP_BAD_DOWNLOAD_RESUME CURLE_BAD_DOWNLOAD_RESUME + +#define CURL_ERROR_SIZE 256 + +typedef enum { + CURLFTPSSL_NONE, /* do not attempt to use SSL */ + CURLFTPSSL_TRY, /* try using SSL, proceed anyway otherwise */ + CURLFTPSSL_CONTROL, /* SSL for the control connection or fail */ + CURLFTPSSL_ALL, /* SSL for all communication or fail */ + CURLFTPSSL_LAST /* not an option, never use */ +} curl_ftpssl; + +/* long may be 32 or 64 bits, but we should never depend on anything else + but 32 */ +#define CURLOPTTYPE_LONG 0 +#define CURLOPTTYPE_OBJECTPOINT 10000 +#define CURLOPTTYPE_FUNCTIONPOINT 20000 +#define CURLOPTTYPE_OFF_T 30000 + +/* name is uppercase CURLOPT_, + type is one of the defined CURLOPTTYPE_ + number is unique identifier */ +#ifdef CINIT +#undef CINIT +#endif +/* + * Figure out if we can use the ## operator, which is supported by ISO/ANSI C + * and C++. Some compilers support it without setting __STDC__ or __cplusplus + * so we need to carefully check for them too. We don't use configure-checks + * for these since we want these headers to remain generic and working for all + * platforms. + */ +#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \ + defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) + /* This compiler is believed to have an ISO compatible preprocessor */ +#define CURL_ISOCPP +#else + /* This compiler is believed NOT to have an ISO compatible preprocessor */ +#undef CURL_ISOCPP +#endif + +#ifdef CURL_ISOCPP +#define CINIT(name,type,number) CURLOPT_ ## name = CURLOPTTYPE_ ## type + number +#else +/* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */ +#define LONG CURLOPTTYPE_LONG +#define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT +#define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT +#define OFF_T CURLOPTTYPE_OFF_T +#define CINIT(name,type,number) CURLOPT_/**/name = type + number +#endif + +/* + * This macro-mania below setups the CURLOPT_[what] enum, to be used with + * curl_easy_setopt(). The first argument in the CINIT() macro is the [what] + * word. + */ + +typedef enum { + /* This is the FILE * or void * the regular output should be written to. */ + CINIT(FILE, OBJECTPOINT, 1), + + /* The full URL to get/put */ + CINIT(URL, OBJECTPOINT, 2), + + /* Port number to connect to, if other than default. */ + CINIT(PORT, LONG, 3), + + /* Name of proxy to use. */ + CINIT(PROXY, OBJECTPOINT, 4), + + /* "name:password" to use when fetching. */ + CINIT(USERPWD, OBJECTPOINT, 5), + + /* "name:password" to use with proxy. */ + CINIT(PROXYUSERPWD, OBJECTPOINT, 6), + + /* Range to get, specified as an ASCII string. */ + CINIT(RANGE, OBJECTPOINT, 7), + + /* not used */ + + /* Specified file stream to upload from (use as input): */ + CINIT(INFILE, OBJECTPOINT, 9), + + /* Buffer to receive error messages in, must be at least CURL_ERROR_SIZE + * bytes big. If this is not used, error messages go to stderr instead: */ + CINIT(ERRORBUFFER, OBJECTPOINT, 10), + + /* Function that will be called to store the output (instead of fwrite). The + * parameters will use fwrite() syntax, make sure to follow them. */ + CINIT(WRITEFUNCTION, FUNCTIONPOINT, 11), + + /* Function that will be called to read the input (instead of fread). The + * parameters will use fread() syntax, make sure to follow them. */ + CINIT(READFUNCTION, FUNCTIONPOINT, 12), + + /* Time-out the read operation after this amount of seconds */ + CINIT(TIMEOUT, LONG, 13), + + /* If the CURLOPT_INFILE is used, this can be used to inform libcurl about + * how large the file being sent really is. That allows better error + * checking and better verifies that the upload was succcessful. -1 means + * unknown size. + * + * For large file support, there is also a _LARGE version of the key + * which takes an off_t type, allowing platforms with larger off_t + * sizes to handle larger files. See below for INFILESIZE_LARGE. + */ + CINIT(INFILESIZE, LONG, 14), + + /* POST input fields. */ + CINIT(POSTFIELDS, OBJECTPOINT, 15), + + /* Set the referer page (needed by some CGIs) */ + CINIT(REFERER, OBJECTPOINT, 16), + + /* Set the FTP PORT string (interface name, named or numerical IP address) + Use i.e '-' to use default address. */ + CINIT(FTPPORT, OBJECTPOINT, 17), + + /* Set the User-Agent string (examined by some CGIs) */ + CINIT(USERAGENT, OBJECTPOINT, 18), + + /* If the download receives less than "low speed limit" bytes/second + * during "low speed time" seconds, the operations is aborted. + * You could i.e if you have a pretty high speed connection, abort if + * it is less than 2000 bytes/sec during 20 seconds. + */ + + /* Set the "low speed limit" */ + CINIT(LOW_SPEED_LIMIT, LONG , 19), + + /* Set the "low speed time" */ + CINIT(LOW_SPEED_TIME, LONG, 20), + + /* Set the continuation offset. + * + * Note there is also a _LARGE version of this key which uses + * off_t types, allowing for large file offsets on platforms which + * use larger-than-32-bit off_t's. Look below for RESUME_FROM_LARGE. + */ + CINIT(RESUME_FROM, LONG, 21), + + /* Set cookie in request: */ + CINIT(COOKIE, OBJECTPOINT, 22), + + /* This points to a linked list of headers, struct curl_slist kind */ + CINIT(HTTPHEADER, OBJECTPOINT, 23), + + /* This points to a linked list of post entries, struct HttpPost */ + CINIT(HTTPPOST, OBJECTPOINT, 24), + + /* name of the file keeping your private SSL-certificate */ + CINIT(SSLCERT, OBJECTPOINT, 25), + + /* password for the SSL-private key, keep this for compatibility */ + CINIT(SSLCERTPASSWD, OBJECTPOINT, 26), + /* password for the SSL private key */ + CINIT(SSLKEYPASSWD, OBJECTPOINT, 26), + + /* send TYPE parameter? */ + CINIT(CRLF, LONG, 27), + + /* send linked-list of QUOTE commands */ + CINIT(QUOTE, OBJECTPOINT, 28), + + /* send FILE * or void * to store headers to, if you use a callback it + is simply passed to the callback unmodified */ + CINIT(WRITEHEADER, OBJECTPOINT, 29), + + /* point to a file to read the initial cookies from, also enables + "cookie awareness" */ + CINIT(COOKIEFILE, OBJECTPOINT, 31), + + /* What version to specifly try to use. + See CURL_SSLVERSION defines below. */ + CINIT(SSLVERSION, LONG, 32), + + /* What kind of HTTP time condition to use, see defines */ + CINIT(TIMECONDITION, LONG, 33), + + /* Time to use with the above condition. Specified in number of seconds + since 1 Jan 1970 */ + CINIT(TIMEVALUE, LONG, 34), + + /* 35 = OBSOLETE */ + + /* Custom request, for customizing the get command like + HTTP: DELETE, TRACE and others + FTP: to use a different list command + */ + CINIT(CUSTOMREQUEST, OBJECTPOINT, 36), + + /* HTTP request, for odd commands like DELETE, TRACE and others */ + CINIT(STDERR, OBJECTPOINT, 37), + + /* 38 is not used */ + + /* send linked-list of post-transfer QUOTE commands */ + CINIT(POSTQUOTE, OBJECTPOINT, 39), + + /* Pass a pointer to string of the output using full variable-replacement + as described elsewhere. */ + CINIT(WRITEINFO, OBJECTPOINT, 40), + + CINIT(VERBOSE, LONG, 41), /* talk a lot */ + CINIT(HEADER, LONG, 42), /* throw the header out too */ + CINIT(NOPROGRESS, LONG, 43), /* shut off the progress meter */ + CINIT(NOBODY, LONG, 44), /* use HEAD to get http document */ + CINIT(FAILONERROR, LONG, 45), /* no output on http error codes >= 300 */ + CINIT(UPLOAD, LONG, 46), /* this is an upload */ + CINIT(POST, LONG, 47), /* HTTP POST method */ + CINIT(FTPLISTONLY, LONG, 48), /* Use NLST when listing ftp dir */ + + CINIT(FTPAPPEND, LONG, 50), /* Append instead of overwrite on upload! */ + + /* Specify whether to read the user+password from the .netrc or the URL. + * This must be one of the CURL_NETRC_* enums below. */ + CINIT(NETRC, LONG, 51), + + CINIT(FOLLOWLOCATION, LONG, 52), /* use Location: Luke! */ + + CINIT(TRANSFERTEXT, LONG, 53), /* transfer data in text/ASCII format */ + CINIT(PUT, LONG, 54), /* HTTP PUT */ + + /* 55 = OBSOLETE */ + + /* Function that will be called instead of the internal progress display + * function. This function should be defined as the curl_progress_callback + * prototype defines. */ + CINIT(PROGRESSFUNCTION, FUNCTIONPOINT, 56), + + /* Data passed to the progress callback */ + CINIT(PROGRESSDATA, OBJECTPOINT, 57), + + /* We want the referer field set automatically when following locations */ + CINIT(AUTOREFERER, LONG, 58), + + /* Port of the proxy, can be set in the proxy string as well with: + "[host]:[port]" */ + CINIT(PROXYPORT, LONG, 59), + + /* size of the POST input data, if strlen() is not good to use */ + CINIT(POSTFIELDSIZE, LONG, 60), + + /* tunnel non-http operations through a HTTP proxy */ + CINIT(HTTPPROXYTUNNEL, LONG, 61), + + /* Set the interface string to use as outgoing network interface */ + CINIT(INTERFACE, OBJECTPOINT, 62), + + /* Set the krb4 security level, this also enables krb4 awareness. This is a + * string, 'clear', 'safe', 'confidential' or 'private'. If the string is + * set but doesn't match one of these, 'private' will be used. */ + CINIT(KRB4LEVEL, OBJECTPOINT, 63), + + /* Set if we should verify the peer in ssl handshake, set 1 to verify. */ + CINIT(SSL_VERIFYPEER, LONG, 64), + + /* The CApath or CAfile used to validate the peer certificate + this option is used only if SSL_VERIFYPEER is true */ + CINIT(CAINFO, OBJECTPOINT, 65), + + /* 66 = OBSOLETE */ + /* 67 = OBSOLETE */ + + /* Maximum number of http redirects to follow */ + CINIT(MAXREDIRS, LONG, 68), + + /* Pass a long set to 1 to get the date of the requested document (if + possible)! Pass a zero to shut it off. */ + CINIT(FILETIME, LONG, 69), + + /* This points to a linked list of telnet options */ + CINIT(TELNETOPTIONS, OBJECTPOINT, 70), + + /* Max amount of cached alive connections */ + CINIT(MAXCONNECTS, LONG, 71), + + /* What policy to use when closing connections when the cache is filled + up */ + CINIT(CLOSEPOLICY, LONG, 72), + + /* 73 = OBSOLETE */ + + /* Set to explicitly use a new connection for the upcoming transfer. + Do not use this unless you're absolutely sure of this, as it makes the + operation slower and is less friendly for the network. */ + CINIT(FRESH_CONNECT, LONG, 74), + + /* Set to explicitly forbid the upcoming transfer's connection to be re-used + when done. Do not use this unless you're absolutely sure of this, as it + makes the operation slower and is less friendly for the network. */ + CINIT(FORBID_REUSE, LONG, 75), + + /* Set to a file name that contains random data for libcurl to use to + seed the random engine when doing SSL connects. */ + CINIT(RANDOM_FILE, OBJECTPOINT, 76), + + /* Set to the Entropy Gathering Daemon socket pathname */ + CINIT(EGDSOCKET, OBJECTPOINT, 77), + + /* Time-out connect operations after this amount of seconds, if connects + are OK within this time, then fine... This only aborts the connect + phase. [Only works on unix-style/SIGALRM operating systems] */ + CINIT(CONNECTTIMEOUT, LONG, 78), + + /* Function that will be called to store headers (instead of fwrite). The + * parameters will use fwrite() syntax, make sure to follow them. */ + CINIT(HEADERFUNCTION, FUNCTIONPOINT, 79), + + /* Set this to force the HTTP request to get back to GET. Only really usable + if POST, PUT or a custom request have been used first. + */ + CINIT(HTTPGET, LONG, 80), + + /* Set if we should verify the Common name from the peer certificate in ssl + * handshake, set 1 to check existence, 2 to ensure that it matches the + * provided hostname. */ + CINIT(SSL_VERIFYHOST, LONG, 81), + + /* Specify which file name to write all known cookies in after completed + operation. Set file name to "-" (dash) to make it go to stdout. */ + CINIT(COOKIEJAR, OBJECTPOINT, 82), + + /* Specify which SSL ciphers to use */ + CINIT(SSL_CIPHER_LIST, OBJECTPOINT, 83), + + /* Specify which HTTP version to use! This must be set to one of the + CURL_HTTP_VERSION* enums set below. */ + CINIT(HTTP_VERSION, LONG, 84), + + /* Specificly switch on or off the FTP engine's use of the EPSV command. By + default, that one will always be attempted before the more traditional + PASV command. */ + CINIT(FTP_USE_EPSV, LONG, 85), + + /* type of the file keeping your SSL-certificate ("DER", "PEM", "ENG") */ + CINIT(SSLCERTTYPE, OBJECTPOINT, 86), + + /* name of the file keeping your private SSL-key */ + CINIT(SSLKEY, OBJECTPOINT, 87), + + /* type of the file keeping your private SSL-key ("DER", "PEM", "ENG") */ + CINIT(SSLKEYTYPE, OBJECTPOINT, 88), + + /* crypto engine for the SSL-sub system */ + CINIT(SSLENGINE, OBJECTPOINT, 89), + + /* set the crypto engine for the SSL-sub system as default + the param has no meaning... + */ + CINIT(SSLENGINE_DEFAULT, LONG, 90), + + /* Non-zero value means to use the global dns cache */ + CINIT(DNS_USE_GLOBAL_CACHE, LONG, 91), /* To become OBSOLETE soon */ + + /* DNS cache timeout */ + CINIT(DNS_CACHE_TIMEOUT, LONG, 92), + + /* send linked-list of pre-transfer QUOTE commands (Wesley Laxton)*/ + CINIT(PREQUOTE, OBJECTPOINT, 93), + + /* set the debug function */ + CINIT(DEBUGFUNCTION, FUNCTIONPOINT, 94), + + /* set the data for the debug function */ + CINIT(DEBUGDATA, OBJECTPOINT, 95), + + /* mark this as start of a cookie session */ + CINIT(COOKIESESSION, LONG, 96), + + /* The CApath directory used to validate the peer certificate + this option is used only if SSL_VERIFYPEER is true */ + CINIT(CAPATH, OBJECTPOINT, 97), + + /* Instruct libcurl to use a smaller receive buffer */ + CINIT(BUFFERSIZE, LONG, 98), + + /* Instruct libcurl to not use any signal/alarm handlers, even when using + timeouts. This option is useful for multi-threaded applications. + See libcurl-the-guide for more background information. */ + CINIT(NOSIGNAL, LONG, 99), + + /* Provide a CURLShare for mutexing non-ts data */ + CINIT(SHARE, OBJECTPOINT, 100), + + /* indicates type of proxy. accepted values are CURLPROXY_HTTP (default), + CURLPROXY_SOCKS4 and CURLPROXY_SOCKS5. */ + CINIT(PROXYTYPE, LONG, 101), + + /* Set the Accept-Encoding string. Use this to tell a server you would like + the response to be compressed. */ + CINIT(ENCODING, OBJECTPOINT, 102), + + /* Set pointer to private data */ + CINIT(PRIVATE, OBJECTPOINT, 103), + + /* Set aliases for HTTP 200 in the HTTP Response header */ + CINIT(HTTP200ALIASES, OBJECTPOINT, 104), + + /* Continue to send authentication (user+password) when following locations, + even when hostname changed. This can potentionally send off the name + and password to whatever host the server decides. */ + CINIT(UNRESTRICTED_AUTH, LONG, 105), + + /* Specificly switch on or off the FTP engine's use of the EPRT command ( it + also disables the LPRT attempt). By default, those ones will always be + attempted before the good old traditional PORT command. */ + CINIT(FTP_USE_EPRT, LONG, 106), + + /* Set this to a bitmask value to enable the particular authentications + methods you like. Use this in combination with CURLOPT_USERPWD. + Note that setting multiple bits may cause extra network round-trips. */ + CINIT(HTTPAUTH, LONG, 107), + + /* Set the ssl context callback function, currently only for OpenSSL ssl_ctx + in second argument. The function must be matching the + curl_ssl_ctx_callback proto. */ + CINIT(SSL_CTX_FUNCTION, FUNCTIONPOINT, 108), + + /* Set the userdata for the ssl context callback function's third + argument */ + CINIT(SSL_CTX_DATA, OBJECTPOINT, 109), + + /* FTP Option that causes missing dirs to be created on the remote server */ + CINIT(FTP_CREATE_MISSING_DIRS, LONG, 110), + + /* Set this to a bitmask value to enable the particular authentications + methods you like. Use this in combination with CURLOPT_PROXYUSERPWD. + Note that setting multiple bits may cause extra network round-trips. */ + CINIT(PROXYAUTH, LONG, 111), + + /* FTP option that changes the timeout, in seconds, associated with + getting a response. This is different from transfer timeout time and + essentially places a demand on the FTP server to acknowledge commands + in a timely manner. */ + CINIT(FTP_RESPONSE_TIMEOUT, LONG , 112), + + /* Set this option to one of the CURL_IPRESOLVE_* defines (see below) to + tell libcurl to resolve names to those IP versions only. This only has + affect on systems with support for more than one, i.e IPv4 _and_ IPv6. */ + CINIT(IPRESOLVE, LONG, 113), + + /* Set this option to limit the size of a file that will be downloaded from + an HTTP or FTP server. + + Note there is also _LARGE version which adds large file support for + platforms which have larger off_t sizes. See MAXFILESIZE_LARGE below. */ + CINIT(MAXFILESIZE, LONG, 114), + + /* See the comment for INFILESIZE above, but in short, specifies + * the size of the file being uploaded. -1 means unknown. + */ + CINIT(INFILESIZE_LARGE, OFF_T, 115), + + /* Sets the continuation offset. There is also a LONG version of this; + * look above for RESUME_FROM. + */ + CINIT(RESUME_FROM_LARGE, OFF_T, 116), + + /* Sets the maximum size of data that will be downloaded from + * an HTTP or FTP server. See MAXFILESIZE above for the LONG version. + */ + CINIT(MAXFILESIZE_LARGE, OFF_T, 117), + + /* Set this option to the file name of your .netrc file you want libcurl + to parse (using the CURLOPT_NETRC option). If not set, libcurl will do + a poor attempt to find the user's home directory and check for a .netrc + file in there. */ + CINIT(NETRC_FILE, OBJECTPOINT, 118), + + /* Enable SSL/TLS for FTP, pick one of: + CURLFTPSSL_TRY - try using SSL, proceed anyway otherwise + CURLFTPSSL_CONTROL - SSL for the control connection or fail + CURLFTPSSL_ALL - SSL for all communication or fail + */ + CINIT(FTP_SSL, LONG, 119), + + /* The _LARGE version of the standard POSTFIELDSIZE option */ + CINIT(POSTFIELDSIZE_LARGE, OFF_T, 120), + + /* Enable/disable the TCP Nagle algorithm */ + CINIT(TCP_NODELAY, LONG, 121), + + /* When doing 3rd party transfer, set the source host name with this */ + CINIT(SOURCE_HOST, OBJECTPOINT, 122), + + /* When doing 3rd party transfer, set the source user and password with + this */ + CINIT(SOURCE_USERPWD, OBJECTPOINT, 123), + + /* When doing 3rd party transfer, set the source file path with this */ + CINIT(SOURCE_PATH, OBJECTPOINT, 124), + + /* When doing 3rd party transfer, set the source server's port number + with this */ + CINIT(SOURCE_PORT, LONG, 125), + + /* When doing 3rd party transfer, decide which server that should get the + PASV command (and the other gets the PORT). + 0 (default) - The target host issues PASV. + 1 - The source host issues PASV */ + CINIT(PASV_HOST, LONG, 126), + + /* When doing 3rd party transfer, set the source pre-quote linked list + of commands with this */ + CINIT(SOURCE_PREQUOTE, OBJECTPOINT, 127), + + /* When doing 3rd party transfer, set the source post-quote linked list + of commands with this */ + CINIT(SOURCE_POSTQUOTE, OBJECTPOINT, 128), + + CURLOPT_LASTENTRY /* the last unused */ +} CURLoption; + + /* Below here follows defines for the CURLOPT_IPRESOLVE option. If a host + name resolves addresses using more than one IP protocol version, this + option might be handy to force libcurl to use a specific IP version. */ +#define CURL_IPRESOLVE_WHATEVER 0 /* default, resolves addresses to all IP + versions that your system allows */ +#define CURL_IPRESOLVE_V4 1 /* resolve to ipv4 addresses */ +#define CURL_IPRESOLVE_V6 2 /* resolve to ipv6 addresses */ + + /* three convenient "aliases" that follow the name scheme better */ +#define CURLOPT_WRITEDATA CURLOPT_FILE +#define CURLOPT_READDATA CURLOPT_INFILE +#define CURLOPT_HEADERDATA CURLOPT_WRITEHEADER + +#ifndef CURL_NO_OLDIES /* define this to test if your app builds with all + the obsolete stuff removed! */ +#define CURLOPT_HTTPREQUEST -1 +#define CURLOPT_FTPASCII CURLOPT_TRANSFERTEXT +#define CURLOPT_MUTE -2 +#define CURLOPT_PASSWDFUNCTION -3 +#define CURLOPT_PASSWDDATA -4 +#define CURLOPT_CLOSEFUNCTION -5 + +#else +/* This is set if CURL_NO_OLDIES is defined at compile-time */ +#undef CURLOPT_DNS_USE_GLOBAL_CACHE /* soon obsolete */ +#endif + + + /* These enums are for use with the CURLOPT_HTTP_VERSION option. */ +enum { + CURL_HTTP_VERSION_NONE, /* setting this means we don't care, and that we'd + like the library to choose the best possible + for us! */ + CURL_HTTP_VERSION_1_0, /* please use HTTP 1.0 in the request */ + CURL_HTTP_VERSION_1_1, /* please use HTTP 1.1 in the request */ + + CURL_HTTP_VERSION_LAST /* *ILLEGAL* http version */ +}; + + /* These enums are for use with the CURLOPT_NETRC option. */ +enum CURL_NETRC_OPTION { + CURL_NETRC_IGNORED, /* The .netrc will never be read. + * This is the default. */ + CURL_NETRC_OPTIONAL, /* A user:password in the URL will be preferred + * to one in the .netrc. */ + CURL_NETRC_REQUIRED, /* A user:password in the URL will be ignored. + * Unless one is set programmatically, the .netrc + * will be queried. */ + CURL_NETRC_LAST +}; + +enum { + CURL_SSLVERSION_DEFAULT, + CURL_SSLVERSION_TLSv1, + CURL_SSLVERSION_SSLv2, + CURL_SSLVERSION_SSLv3, + + CURL_SSLVERSION_LAST /* never use, keep last */ +}; + + +typedef enum { + CURL_TIMECOND_NONE, + + CURL_TIMECOND_IFMODSINCE, + CURL_TIMECOND_IFUNMODSINCE, + CURL_TIMECOND_LASTMOD, + + CURL_TIMECOND_LAST +} curl_TimeCond; + +#ifdef __BEOS__ +#include +#endif + + +/* curl_strequal() and curl_strnequal() are subject for removal in a future + libcurl, see lib/README.curlx for details */ +extern int (curl_strequal)(const char *s1, const char *s2); +extern int (curl_strnequal)(const char *s1, const char *s2, size_t n); + +/* name is uppercase CURLFORM_ */ +#ifdef CFINIT +#undef CFINIT +#endif + +#ifdef CURL_ISOCPP +#define CFINIT(name) CURLFORM_ ## name +#else +/* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */ +#define CFINIT(name) CURLFORM_/**/name +#endif + +typedef enum { + CFINIT(NOTHING), /********* the first one is unused ************/ + + /* */ + CFINIT(COPYNAME), + CFINIT(PTRNAME), + CFINIT(NAMELENGTH), + CFINIT(COPYCONTENTS), + CFINIT(PTRCONTENTS), + CFINIT(CONTENTSLENGTH), + CFINIT(FILECONTENT), + CFINIT(ARRAY), + CFINIT(OBSOLETE), + CFINIT(FILE), + + CFINIT(BUFFER), + CFINIT(BUFFERPTR), + CFINIT(BUFFERLENGTH), + + CFINIT(CONTENTTYPE), + CFINIT(CONTENTHEADER), + CFINIT(FILENAME), + CFINIT(END), + CFINIT(OBSOLETE2), + + CURLFORM_LASTENTRY /* the last unusued */ +} CURLformoption; + +#undef CFINIT /* done */ + +/* structure to be used as parameter for CURLFORM_ARRAY */ +struct curl_forms { + CURLformoption option; + const char *value; +}; + +/* use this for multipart formpost building */ +/* Returns code for curl_formadd() + * + * Returns: + * CURL_FORMADD_OK on success + * CURL_FORMADD_MEMORY if the FormInfo allocation fails + * CURL_FORMADD_OPTION_TWICE if one option is given twice for one Form + * CURL_FORMADD_NULL if a null pointer was given for a char + * CURL_FORMADD_MEMORY if the allocation of a FormInfo struct failed + * CURL_FORMADD_UNKNOWN_OPTION if an unknown option was used + * CURL_FORMADD_INCOMPLETE if the some FormInfo is not complete (or error) + * CURL_FORMADD_MEMORY if a HttpPost struct cannot be allocated + * CURL_FORMADD_MEMORY if some allocation for string copying failed. + * CURL_FORMADD_ILLEGAL_ARRAY if an illegal option is used in an array + * + ***************************************************************************/ +typedef enum { + CURL_FORMADD_OK, /* first, no error */ + + CURL_FORMADD_MEMORY, + CURL_FORMADD_OPTION_TWICE, + CURL_FORMADD_NULL, + CURL_FORMADD_UNKNOWN_OPTION, + CURL_FORMADD_INCOMPLETE, + CURL_FORMADD_ILLEGAL_ARRAY, + CURL_FORMADD_DISABLED, /* libcurl was built with this disabled */ + + CURL_FORMADD_LAST /* last */ +} CURLFORMcode; + +/* + * NAME curl_formadd() + * + * DESCRIPTION + * + * Pretty advanved function for building multi-part formposts. Each invoke + * adds one part that together construct a full post. Then use + * CURLOPT_HTTPPOST to send it off to libcurl. + */ +CURLFORMcode curl_formadd(struct curl_httppost **httppost, + struct curl_httppost **last_post, + ...); + +/* + * NAME curl_formfree() + * + * DESCRIPTION + * + * Free a multipart formpost previously built with curl_formadd(). + */ +void curl_formfree(struct curl_httppost *form); + +/* + * NAME curl_getenv() + * + * DESCRIPTION + * + * Returns a malloc()'ed string that MUST be curl_free()ed after usage is + * complete. DEPRECATED - see lib/README.curlx + */ +char *curl_getenv(const char *variable); + +/* + * NAME curl_version() + * + * DESCRIPTION + * + * Returns a static ascii string of the libcurl version. + */ +char *curl_version(void); + +/* + * NAME curl_escape() + * + * DESCRIPTION + * + * Escapes URL strings (converts all letters consider illegal in URLs to their + * %XX versions). This function returns a new allocated string or NULL if an + * error occurred. + */ +char *curl_escape(const char *string, int length); + +/* + * NAME curl_unescape() + * + * DESCRIPTION + * + * Unescapes URL encoding in strings (converts all %XX codes to their 8bit + * versions). This function returns a new allocated string or NULL if an error + * occurred. + */ +char *curl_unescape(const char *string, int length); + +/* + * NAME curl_free() + * + * DESCRIPTION + * + * Provided for de-allocation in the same translation unit that did the + * allocation. Added in libcurl 7.10 + */ +void curl_free(void *p); + +/* + * NAME curl_global_init() + * + * DESCRIPTION + * + * curl_global_init() should be invoked exactly once for each application that + * uses libcurl + */ +CURLcode curl_global_init(long flags); + +/* + * NAME curl_global_init_mem() + * + * DESCRIPTION + * + * curl_global_init() or curl_global_init_mem() should be invoked exactly once + * for each application that uses libcurl. This function can be used to + * initialize libcurl and set user defined memory management callback + * functions. Users can implement memory management routines to check for + * memory leaks, check for mis-use of the curl library etc. User registered + * callback routines with be invoked by this library instead of the system + * memory management routines like malloc, free etc. + */ +CURLcode curl_global_init_mem(long flags, + curl_malloc_callback m, + curl_free_callback f, + curl_realloc_callback r, + curl_strdup_callback s, + curl_calloc_callback c); + +/* + * NAME curl_global_cleanup() + * + * DESCRIPTION + * + * curl_global_cleanup() should be invoked exactly once for each application + * that uses libcurl + */ +void curl_global_cleanup(void); + +/* linked-list structure for the CURLOPT_QUOTE option (and other) */ +struct curl_slist { + char *data; + struct curl_slist *next; +}; + +/* + * NAME curl_slist_append() + * + * DESCRIPTION + * + * Appends a string to a linked list. If no list exists, it will be created + * first. Returns the new list, after appending. + */ +struct curl_slist *curl_slist_append(struct curl_slist *, const char *); + +/* + * NAME curl_slist_free_all() + * + * DESCRIPTION + * + * free a previously built curl_slist. + */ +void curl_slist_free_all(struct curl_slist *); + +/* + * NAME curl_getdate() + * + * DESCRIPTION + * + * Returns the time, in seconds since 1 Jan 1970 of the time string given in + * the first argument. The time argument in the second parameter is for cases + * where the specified time is relative now, like 'two weeks' or 'tomorrow' + * etc. + */ +time_t curl_getdate(const char *p, const time_t *now); + +#define CURLINFO_STRING 0x100000 +#define CURLINFO_LONG 0x200000 +#define CURLINFO_DOUBLE 0x300000 +#define CURLINFO_MASK 0x0fffff +#define CURLINFO_TYPEMASK 0xf00000 + +typedef enum { + CURLINFO_NONE, /* first, never use this */ + CURLINFO_EFFECTIVE_URL = CURLINFO_STRING + 1, + CURLINFO_RESPONSE_CODE = CURLINFO_LONG + 2, + CURLINFO_TOTAL_TIME = CURLINFO_DOUBLE + 3, + CURLINFO_NAMELOOKUP_TIME = CURLINFO_DOUBLE + 4, + CURLINFO_CONNECT_TIME = CURLINFO_DOUBLE + 5, + CURLINFO_PRETRANSFER_TIME = CURLINFO_DOUBLE + 6, + CURLINFO_SIZE_UPLOAD = CURLINFO_DOUBLE + 7, + CURLINFO_SIZE_DOWNLOAD = CURLINFO_DOUBLE + 8, + CURLINFO_SPEED_DOWNLOAD = CURLINFO_DOUBLE + 9, + CURLINFO_SPEED_UPLOAD = CURLINFO_DOUBLE + 10, + CURLINFO_HEADER_SIZE = CURLINFO_LONG + 11, + CURLINFO_REQUEST_SIZE = CURLINFO_LONG + 12, + CURLINFO_SSL_VERIFYRESULT = CURLINFO_LONG + 13, + CURLINFO_FILETIME = CURLINFO_LONG + 14, + CURLINFO_CONTENT_LENGTH_DOWNLOAD = CURLINFO_DOUBLE + 15, + CURLINFO_CONTENT_LENGTH_UPLOAD = CURLINFO_DOUBLE + 16, + CURLINFO_STARTTRANSFER_TIME = CURLINFO_DOUBLE + 17, + CURLINFO_CONTENT_TYPE = CURLINFO_STRING + 18, + CURLINFO_REDIRECT_TIME = CURLINFO_DOUBLE + 19, + CURLINFO_REDIRECT_COUNT = CURLINFO_LONG + 20, + CURLINFO_PRIVATE = CURLINFO_STRING + 21, + CURLINFO_HTTP_CONNECTCODE = CURLINFO_LONG + 22, + CURLINFO_HTTPAUTH_AVAIL = CURLINFO_LONG + 23, + CURLINFO_PROXYAUTH_AVAIL = CURLINFO_LONG + 24, + /* Fill in new entries below here! */ + + CURLINFO_LASTONE = 23 +} CURLINFO; + +/* CURLINFO_RESPONSE_CODE is the new name for the option previously known as + CURLINFO_HTTP_CODE */ +#define CURLINFO_HTTP_CODE CURLINFO_RESPONSE_CODE + +typedef enum { + CURLCLOSEPOLICY_NONE, /* first, never use this */ + + CURLCLOSEPOLICY_OLDEST, + CURLCLOSEPOLICY_LEAST_RECENTLY_USED, + CURLCLOSEPOLICY_LEAST_TRAFFIC, + CURLCLOSEPOLICY_SLOWEST, + CURLCLOSEPOLICY_CALLBACK, + + CURLCLOSEPOLICY_LAST /* last, never use this */ +} curl_closepolicy; + +#define CURL_GLOBAL_SSL (1<<0) +#define CURL_GLOBAL_WIN32 (1<<1) +#define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32) +#define CURL_GLOBAL_NOTHING 0 +#define CURL_GLOBAL_DEFAULT CURL_GLOBAL_ALL + + +/***************************************************************************** + * Setup defines, protos etc for the sharing stuff. + */ + +/* Different data locks for a single share */ +typedef enum { + CURL_LOCK_DATA_NONE = 0, + /* CURL_LOCK_DATA_SHARE is used internaly to say that + * the locking is just made to change the internal state of the share + * itself. + */ + CURL_LOCK_DATA_SHARE, + CURL_LOCK_DATA_COOKIE, + CURL_LOCK_DATA_DNS, + CURL_LOCK_DATA_SSL_SESSION, + CURL_LOCK_DATA_CONNECT, + CURL_LOCK_DATA_LAST +} curl_lock_data; + +/* Different lock access types */ +typedef enum { + CURL_LOCK_ACCESS_NONE = 0, /* unspecified action */ + CURL_LOCK_ACCESS_SHARED = 1, /* for read perhaps */ + CURL_LOCK_ACCESS_SINGLE = 2, /* for write perhaps */ + CURL_LOCK_ACCESS_LAST /* never use */ +} curl_lock_access; + +typedef void (*curl_lock_function)(CURL *handle, + curl_lock_data data, + curl_lock_access locktype, + void *userptr); +typedef void (*curl_unlock_function)(CURL *handle, + curl_lock_data data, + void *userptr); + +typedef void CURLSH; + +typedef enum { + CURLSHE_OK, /* all is fine */ + CURLSHE_BAD_OPTION, /* 1 */ + CURLSHE_IN_USE, /* 2 */ + CURLSHE_INVALID, /* 3 */ + CURLSHE_NOMEM, /* out of memory */ + CURLSHE_LAST /* never use */ +} CURLSHcode; + +typedef enum { + CURLSHOPT_NONE, /* don't use */ + CURLSHOPT_SHARE, /* specify a data type to share */ + CURLSHOPT_UNSHARE, /* specify shich data type to stop sharing */ + CURLSHOPT_LOCKFUNC, /* pass in a 'curl_lock_function' pointer */ + CURLSHOPT_UNLOCKFUNC, /* pass in a 'curl_unlock_function' pointer */ + CURLSHOPT_USERDATA, /* pass in a user data pointer used in the lock/unlock + callback functions */ + CURLSHOPT_LAST /* never use */ +} CURLSHoption; + +CURLSH *curl_share_init(void); +CURLSHcode curl_share_setopt(CURLSH *, CURLSHoption option, ...); +CURLSHcode curl_share_cleanup(CURLSH *); + +/**************************************************************************** + * Structures for querying information about the curl library at runtime. + */ + +typedef enum { + CURLVERSION_FIRST, + CURLVERSION_SECOND, + CURLVERSION_THIRD, + CURLVERSION_LAST /* never actually use this */ +} CURLversion; + +/* The 'CURLVERSION_NOW' is the symbolic name meant to be used by + basicly all programs ever, that want to get version information. It is + meant to be a built-in version number for what kind of struct the caller + expects. If the struct ever changes, we redfine the NOW to another enum + from above. */ +#define CURLVERSION_NOW CURLVERSION_THIRD + +typedef struct { + CURLversion age; /* age of the returned struct */ + const char *version; /* LIBCURL_VERSION */ + unsigned int version_num; /* LIBCURL_VERSION_NUM */ + const char *host; /* OS/host/cpu/machine when configured */ + int features; /* bitmask, see defines below */ + char *ssl_version; /* human readable string */ + long ssl_version_num; /* number */ + const char *libz_version; /* human readable string */ + /* protocols is terminated by an entry with a NULL protoname */ + const char **protocols; + + /* The fields below this were added in CURLVERSION_SECOND */ + const char *ares; + int ares_num; + + /* This field was aded in CURLVERSION_THIRD */ + const char *libidn; +} curl_version_info_data; + +#define CURL_VERSION_IPV6 (1<<0) /* IPv6-enabled */ +#define CURL_VERSION_KERBEROS4 (1<<1) /* kerberos auth is supported */ +#define CURL_VERSION_SSL (1<<2) /* SSL options are present */ +#define CURL_VERSION_LIBZ (1<<3) /* libz features are present */ +#define CURL_VERSION_NTLM (1<<4) /* NTLM auth is supported */ +#define CURL_VERSION_GSSNEGOTIATE (1<<5) /* Negotiate auth support */ +#define CURL_VERSION_DEBUG (1<<6) /* built with debug capabilities */ +#define CURL_VERSION_ASYNCHDNS (1<<7) /* asynchronous dns resolves */ +#define CURL_VERSION_SPNEGO (1<<8) /* SPNEGO auth */ +#define CURL_VERSION_LARGEFILE (1<<9) /* supports files bigger than 2GB */ +#define CURL_VERSION_IDN (1<<10) /* International Domain Names support */ + +/* + * NAME curl_version_info() + * + * DESCRIPTION + * + * This function returns a pointer to a static copy of the version info + * struct. See above. + */ +curl_version_info_data *curl_version_info(CURLversion); + +/* + * NAME curl_easy_strerror() + * + * DESCRIPTION + * + * The curl_easy_strerror function may be used to turn a CURLcode value + * into the equivalent human readable error string. This is useful + * for printing meaningful error messages. + */ +const char *curl_easy_strerror(CURLcode); + +/* + * NAME curl_share_strerror() + * + * DESCRIPTION + * + * The curl_share_strerror function may be used to turn a CURLSHcode value + * into the equivalent human readable error string. This is useful + * for printing meaningful error messages. + */ +const char *curl_share_strerror(CURLSHcode); + +#ifdef __cplusplus +} +#endif + +/* unfortunately, the easy.h and multi.h include files need options and info + stuff before they can be included! */ +#include "easy.h" /* nothing in curl is fun without the easy stuff */ +#include "multi.h" + +#endif /* __CURL_CURL_H */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/curl/curlver.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/curl/curlver.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/curl/curlver.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/curl/curlver.h 2004-10-05 21:34:20.000000000 +0800 @@ -0,0 +1,55 @@ +#ifndef __CURL_CURLVER_H +#define __CURL_CURLVER_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: curlver.h,v 1.1 2004/10/05 13:34:20 andy Exp $ + ***************************************************************************/ + +/* This header file contains nothing but libcurl version info, generated by + a script at release-time. This was made its own header file in 7.11.2 */ + +/* This is the version number of the libcurl package from which this header + file origins: */ +#define LIBCURL_VERSION "7.12.1" + +/* This is the numeric version of the libcurl version number, meant for easier + parsing and comparions by programs. The LIBCURL_VERSION_NUM define will + always follow this syntax: + + 0xXXYYZZ + + Where XX, YY and ZZ are the main version, release and patch numbers in + hexadecimal. All three numbers are always represented using two digits. 1.2 + would appear as "0x010200" while version 9.11.7 appears as "0x090b07". + + This 6-digit hexadecimal number does not show pre-release number, and it is + always a greater number in a more recent release. It makes comparisons with + greater than and less than work. +*/ +#define LIBCURL_VERSION_NUM 0x70C01 + +/* The numeric version number is also available "in parts" by using these + defines: */ +#define LIBCURL_VERSION_MAJOR 7 +#define LIBCURL_VERSION_MINOR 12 +#define LIBCURL_VERSION_PATCH 1 + +#endif /* __CURL_CURLVER_H */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/curl/easy.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/curl/easy.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/curl/easy.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/curl/easy.h 2004-10-05 21:34:20.000000000 +0800 @@ -0,0 +1,81 @@ +#ifndef __CURL_EASY_H +#define __CURL_EASY_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: easy.h,v 1.4 2004/10/05 13:34:20 andy Exp $ + ***************************************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + +CURL *curl_easy_init(void); +CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...); +CURLcode curl_easy_perform(CURL *curl); +void curl_easy_cleanup(CURL *curl); + +/* + * NAME curl_easy_getinfo() + * + * DESCRIPTION + * + * Request internal information from the curl session with this function. The + * third argument MUST be a pointer to a long, a pointer to a char * or a + * pointer to a double (as the documentation describes elsewhere). The data + * pointed to will be filled in accordingly and can be relied upon only if the + * function returns CURLE_OK. This function is intended to get used *AFTER* a + * performed transfer, all results from this function are undefined until the + * transfer is completed. + */ +CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...); + + +/* + * NAME curl_easy_duphandle() + * + * DESCRIPTION + * + * Creates a new curl session handle with the same options set for the handle + * passed in. Duplicating a handle could only be a matter of cloning data and + * options, internal state info and things like persistant connections cannot + * be transfered. It is useful in multithreaded applications when you can run + * curl_easy_duphandle() for each new thread to avoid a series of identical + * curl_easy_setopt() invokes in every thread. + */ +CURL* curl_easy_duphandle(CURL *curl); + +/* + * NAME curl_easy_reset() + * + * DESCRIPTION + * + * Re-initializes a CURL handle to the default values. This puts back the + * handle to the same state as it was in when it was just created. + * + * It does keep: live connections, the Session ID cache, the DNS cache and the + * cookies. + */ +void curl_easy_reset(CURL *curl); + +#ifdef __cplusplus +} +#endif + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/curl/mprintf.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/curl/mprintf.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/curl/mprintf.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/curl/mprintf.h 2004-10-05 21:34:20.000000000 +0800 @@ -0,0 +1,54 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: mprintf.h,v 1.4 2004/10/05 13:34:20 andy Exp $ + ***************************************************************************/ + +#ifndef H_MPRINTF +#define H_MPRINTF + +#include +#include /* needed for FILE */ + +int curl_mprintf(const char *format, ...); +int curl_mfprintf(FILE *fd, const char *format, ...); +int curl_msprintf(char *buffer, const char *format, ...); +int curl_msnprintf(char *buffer, size_t maxlength, const char *format, ...); +int curl_mvprintf(const char *format, va_list args); +int curl_mvfprintf(FILE *fd, const char *format, va_list args); +int curl_mvsprintf(char *buffer, const char *format, va_list args); +int curl_mvsnprintf(char *buffer, size_t maxlength, const char *format, va_list args); +char *curl_maprintf(const char *format, ...); +char *curl_mvaprintf(const char *format, va_list args); + +#ifdef _MPRINTF_REPLACE +# define printf curl_mprintf +# define fprintf curl_mfprintf +# define sprintf curl_msprintf +# define snprintf curl_msnprintf +# define vprintf curl_mvprintf +# define vfprintf curl_mvfprintf +# define vsprintf curl_mvsprintf +# define vsnprintf curl_mvsnprintf +# define aprintf curl_maprintf +# define vaprintf curl_mvaprintf +#endif + +#endif /* H_MPRINTF */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/curl/multi.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/curl/multi.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/curl/multi.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/curl/multi.h 2004-10-05 21:34:20.000000000 +0800 @@ -0,0 +1,221 @@ +#ifndef __CURL_MULTI_H +#define __CURL_MULTI_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: multi.h,v 1.3 2004/10/05 13:34:20 andy Exp $ + ***************************************************************************/ +/* + This is meant to be the "external" header file. Don't give away any + internals here! + + This document presents a mixture of ideas from at least: + - Daniel Stenberg + - Steve Dekorte + - Sterling Hughes + - Ben Greear + + ------------------------------------------- + GOALS + + o Enable a "pull" interface. The application that uses libcurl decides where + and when to ask libcurl to get/send data. + + o Enable multiple simultaneous transfers in the same thread without making it + complicated for the application. + + o Enable the application to select() on its own file descriptors and curl's + file descriptors simultaneous easily. + +*/ +#if defined(_WIN32) && !defined(WIN32) +/* Chris Lewis mentioned that he doesn't get WIN32 defined, only _WIN32 so we + make this adjustment to catch this. */ +#define WIN32 1 +#endif + +#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__) +#include +#else + +/* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish + libc5-based Linux systems. Only include it on system that are known to + require it! */ +#if defined(_AIX) || defined(NETWARE) +#include +#endif + +#include +#include +#include +#endif + +#include "curl.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void CURLM; + +typedef enum { + CURLM_CALL_MULTI_PERFORM=-1, /* please call curl_multi_perform() soon */ + CURLM_OK, + CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */ + CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */ + CURLM_OUT_OF_MEMORY, /* if you ever get this, you're in deep sh*t */ + CURLM_INTERNAL_ERROR, /* this is a libcurl bug */ + CURLM_LAST +} CURLMcode; + +typedef enum { + CURLMSG_NONE, /* first, not used */ + CURLMSG_DONE, /* This easy handle has completed. 'result' contains + the CURLcode of the transfer */ + CURLMSG_LAST /* last, not used */ +} CURLMSG; + +struct CURLMsg { + CURLMSG msg; /* what this message means */ + CURL *easy_handle; /* the handle it concerns */ + union { + void *whatever; /* message-specific data */ + CURLcode result; /* return code for transfer */ + } data; +}; +typedef struct CURLMsg CURLMsg; + +/* + * Name: curl_multi_init() + * + * Desc: inititalize multi-style curl usage + * Returns: a new CURLM handle to use in all 'curl_multi' functions. + */ +CURLM *curl_multi_init(void); + +/* + * Name: curl_multi_add_handle() + * + * Desc: add a standard curl handle to the multi stack + * Returns: CURLMcode type, general multi error code. + */ +CURLMcode curl_multi_add_handle(CURLM *multi_handle, + CURL *curl_handle); + + /* + * Name: curl_multi_remove_handle() + * + * Desc: removes a curl handle from the multi stack again + * Returns: CURLMcode type, general multi error code. + */ +CURLMcode curl_multi_remove_handle(CURLM *multi_handle, + CURL *curl_handle); + + /* + * Name: curl_multi_fdset() + * + * Desc: Ask curl for its fd_set sets. The app can use these to select() or + * poll() on. We want curl_multi_perform() called as soon as one of + * them are ready. + * Returns: CURLMcode type, general multi error code. + */ +CURLMcode curl_multi_fdset(CURLM *multi_handle, + fd_set *read_fd_set, + fd_set *write_fd_set, + fd_set *exc_fd_set, + int *max_fd); + + /* + * Name: curl_multi_perform() + * + * Desc: When the app thinks there's data available for curl it calls this + * function to read/write whatever there is right now. This returns + * as soon as the reads and writes are done. This function does not + * require that there actually is data available for reading or that + * data can be written, it can be called just in case. It returns + * the number of handles that still transfer data in the second + * argument's integer-pointer. + * + * Returns: CURLMcode type, general multi error code. *NOTE* that this only + * returns errors etc regarding the whole multi stack. There might + * still have occurred problems on invidual transfers even when this + * returns OK. + */ +CURLMcode curl_multi_perform(CURLM *multi_handle, + int *running_handles); + + /* + * Name: curl_multi_cleanup() + * + * Desc: Cleans up and removes a whole multi stack. It does not free or + * touch any individual easy handles in any way. We need to define + * in what state those handles will be if this function is called + * in the middle of a transfer. + * Returns: CURLMcode type, general multi error code. + */ +CURLMcode curl_multi_cleanup(CURLM *multi_handle); + +/* + * Name: curl_multi_info_read() + * + * Desc: Ask the multi handle if there's any messages/informationals from + * the individual transfers. Messages include informationals such as + * error code from the transfer or just the fact that a transfer is + * completed. More details on these should be written down as well. + * + * Repeated calls to this function will return a new struct each + * time, until a special "end of msgs" struct is returned as a signal + * that there is no more to get at this point. + * + * The data the returned pointer points to will not survive calling + * curl_multi_cleanup(). + * + * The 'CURLMsg' struct is meant to be very simple and only contain + * very basic informations. If more involved information is wanted, + * we will provide the particular "transfer handle" in that struct + * and that should/could/would be used in subsequent + * curl_easy_getinfo() calls (or similar). The point being that we + * must never expose complex structs to applications, as then we'll + * undoubtably get backwards compatibility problems in the future. + * + * Returns: A pointer to a filled-in struct, or NULL if it failed or ran out + * of structs. It also writes the number of messages left in the + * queue (after this read) in the integer the second argument points + * to. + */ +CURLMsg *curl_multi_info_read(CURLM *multi_handle, + int *msgs_in_queue); + +/* + * NAME curl_multi_strerror() + * + * DESCRIPTION + * + * The curl_multi_strerror function may be used to turn a CURLMcode value + * into the equivalent human readable error string. This is useful + * for printing meaningful error messages. + */ +const char *curl_multi_strerror(CURLMcode); + +#ifdef __cplusplus +} /* end of extern "C" */ +#endif + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/curl/stdcheaders.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/curl/stdcheaders.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/curl/stdcheaders.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/curl/stdcheaders.h 2004-10-05 21:34:20.000000000 +0800 @@ -0,0 +1,34 @@ +#ifndef __STDC_HEADERS_H +#define __STDC_HEADERS_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: stdcheaders.h,v 1.4 2004/10/05 13:34:20 andy Exp $ + ***************************************************************************/ + +#include + +size_t fread (void *, size_t, size_t, FILE *); +size_t fwrite (const void *, size_t, size_t, FILE *); + +int strcasecmp(const char *, const char *); +int strncasecmp(const char *, const char *, size_t); + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/curl/types.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/curl/types.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/curl/types.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/curl/types.h 2004-10-05 21:34:20.000000000 +0800 @@ -0,0 +1 @@ +/* not used */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/curl.copyright /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/curl.copyright --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/curl.copyright 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/curl.copyright 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,25 @@ +This package was cmakified by Andy Cedilnik + +It was downloaded from http://curl.haxx.se + +COPYRIGHT AND PERMISSION NOTICE + +Copyright (c) 1996 - 2004, Daniel Stenberg, . + +All rights reserved. + +Permission to use, copy, modify, and distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright +notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. 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. + +Except as contained in this notice, the name of a copyright holder shall not +be used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization of the copyright holder. diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/curl_memory.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/curl_memory.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/curl_memory.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/curl_memory.h 2004-10-06 00:42:37.000000000 +0800 @@ -0,0 +1,50 @@ +#ifndef _CURL_MEMORY_H +#define _CURL_MEMORY_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: curl_memory.h,v 1.1 2004/10/05 16:42:37 hoffman Exp $ + ***************************************************************************/ + +#include /* for the typedefs */ + +extern curl_malloc_callback Curl_cmalloc; +extern curl_free_callback Curl_cfree; +extern curl_realloc_callback Curl_crealloc; +extern curl_strdup_callback Curl_cstrdup; +extern curl_calloc_callback Curl_ccalloc; + +#ifndef CURLDEBUG +/* Only do this define-mania if we're not using the memdebug system, as that + has preference on this magic. */ +#undef strdup +#define strdup(ptr) Curl_cstrdup(ptr) +#undef malloc +#define malloc(size) Curl_cmalloc(size) +#undef calloc +#define calloc(nbelem,size) Curl_ccalloc(nbelem, size) +#undef realloc +#define realloc(ptr,size) Curl_crealloc(ptr, size) +#undef free +#define free(ptr) Curl_cfree(ptr) + +#endif + +#endif /* _CURL_MEMORY_H */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/curlx.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/curlx.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/curlx.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/curlx.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,95 @@ +#ifndef __CURLX_H +#define __CURLX_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: curlx.h,v 1.1 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +/* + * Defines protos and includes all header files that provide the curlx_* + * functions. The curlx_* functions are not part of the libcurl API, but are + * stand-alone functions whose sources can be built and linked by apps if need + * be. + */ + +#include +/* this is still a public header file that provides the curl_mprintf() + functions while they still are offered publicly. They will be made library- + private one day */ + +#include "strequal.h" +/* "strequal.h" provides the strequal protos */ + +#include "strtoofft.h" +/* "strtoofft.h" provides this function: curlx_strtoofft(), returns a + curl_off_t number from a given string. +*/ + +#include "timeval.h" +/* + "timeval.h" sets up a 'struct timeval' even for platforms that otherwise + don't have one and has protos for these functions: + + curlx_tvnow() + curlx_tvdiff() + curlx_tvdiff_secs() +*/ + +/* Now setup curlx_ * names for the functions that are to become curlx_ and + be removed from a future libcurl official API: + curlx_getenv + curlx_mprintf (and its variations) + curlx_strequal + curlx_strnequal + +*/ + +#define curlx_getenv curl_getenv +#define curlx_strequal curl_strequal +#define curlx_strnequal curl_strnequal +#define curlx_mvsnprintf curl_mvsnprintf +#define curlx_msnprintf curl_msnprintf +#define curlx_maprintf curl_maprintf +#define curlx_mvaprintf curl_mvaprintf +#define curlx_msprintf curl_msprintf +#define curlx_mprintf curl_mprintf +#define curlx_mfprintf curl_mfprintf +#define curlx_mvsprintf curl_mvsprintf +#define curlx_mvprintf curl_mvprintf +#define curlx_mvfprintf curl_mvfprintf + +#ifdef ENABLE_CURLX_PRINTF +/* If this define is set, we define all "standard" printf() functions to use + the curlx_* version instead. It makes the source code transparant and + easier to understand/patch. */ +# define printf curlx_mprintf +# define fprintf curlx_mfprintf +# define sprintf curlx_msprintf +# define snprintf curlx_msnprintf +# define vprintf curlx_mvprintf +# define vfprintf curlx_mvfprintf +# define vsprintf curlx_mvsprintf +# define vsnprintf curlx_mvsnprintf +# define aprintf curlx_maprintf +# define vaprintf curlx_mvaprintf +#endif /* ENABLE_CURLX_PRINTF */ + +#endif /* __CURLX_H */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/dict.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/dict.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/dict.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/dict.c 2004-10-13 22:45:30.000000000 +0800 @@ -0,0 +1,221 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: dict.c,v 1.7 2004/10/13 14:45:30 andy Exp $ + ***************************************************************************/ + +#include "setup.h" + +/* -- WIN32 approved -- */ +#include +#include +#include +#include +#include +#include +#include + +#include + +#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__) +#include +#include +#else +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#include +#ifdef HAVE_ARPA_INET_H +#include +#endif +#ifdef HAVE_NET_IF_H +#include +#endif +#include +#include + +#ifdef HAVE_SYS_PARAM_H +#include +#endif + +#ifdef HAVE_SYS_SELECT_H +#include +#endif + + +#endif + +#include "urldata.h" +#include +#include "transfer.h" +#include "sendf.h" + +#include "progress.h" +#include "strequal.h" +#include "dict.h" + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +CURLcode Curl_dict(struct connectdata *conn) +{ + char *word; + char *ppath; + char *database = NULL; + char *strategy = NULL; + char *nthdef = NULL; /* This is not part of the protocol, but required + by RFC 2229 */ + CURLcode result; + struct SessionHandle *data=conn->data; + curl_socket_t sockfd = conn->sock[FIRSTSOCKET]; + + char *path = conn->path; + curl_off_t *bytecount = &conn->bytecount; + + if(conn->bits.user_passwd) { + /* AUTH is missing */ + } + + if (strnequal(path, DICT_MATCH, sizeof(DICT_MATCH)-1) || + strnequal(path, DICT_MATCH2, sizeof(DICT_MATCH2)-1) || + strnequal(path, DICT_MATCH3, sizeof(DICT_MATCH3)-1)) { + + word = strchr(path, ':'); + if (word) { + word++; + database = strchr(word, ':'); + if (database) { + *database++ = (char)0; + strategy = strchr(database, ':'); + if (strategy) { + *strategy++ = (char)0; + nthdef = strchr(strategy, ':'); + if (nthdef) { + *nthdef++ = (char)0; + } + } + } + } + + if ((word == NULL) || (*word == (char)0)) { + failf(data, "lookup word is missing"); + } + if ((database == NULL) || (*database == (char)0)) { + database = (char *)"!"; + } + if ((strategy == NULL) || (*strategy == (char)0)) { + strategy = (char *)"."; + } + + result = Curl_sendf(sockfd, conn, + "CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\n" + "MATCH " + "%s " /* database */ + "%s " /* strategy */ + "%s\n" /* word */ + "QUIT\n", + + database, + strategy, + word + ); + if(result) + failf(data, "Failed sending DICT request"); + else + result = Curl_Transfer(conn, FIRSTSOCKET, -1, FALSE, bytecount, + -1, NULL); /* no upload */ + if(result) + return result; + } + else if (strnequal(path, DICT_DEFINE, sizeof(DICT_DEFINE)-1) || + strnequal(path, DICT_DEFINE2, sizeof(DICT_DEFINE2)-1) || + strnequal(path, DICT_DEFINE3, sizeof(DICT_DEFINE3)-1)) { + + word = strchr(path, ':'); + if (word) { + word++; + database = strchr(word, ':'); + if (database) { + *database++ = (char)0; + nthdef = strchr(database, ':'); + if (nthdef) { + *nthdef++ = (char)0; + } + } + } + + if ((word == NULL) || (*word == (char)0)) { + failf(data, "lookup word is missing"); + } + if ((database == NULL) || (*database == (char)0)) { + database = (char *)"!"; + } + + result = Curl_sendf(sockfd, conn, + "CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\n" + "DEFINE " + "%s " /* database */ + "%s\n" /* word */ + "QUIT\n", + database, + word); + if(result) + failf(data, "Failed sending DICT request"); + else + result = Curl_Transfer(conn, FIRSTSOCKET, -1, FALSE, bytecount, + -1, NULL); /* no upload */ + + if(result) + return result; + + } + else { + + ppath = strchr(path, '/'); + if (ppath) { + int i; + + ppath++; + for (i = 0; ppath[i]; i++) { + if (ppath[i] == ':') + ppath[i] = ' '; + } + result = Curl_sendf(sockfd, conn, + "CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\n" + "%s\n" + "QUIT\n", ppath); + if(result) + failf(data, "Failed sending DICT request"); + else + result = Curl_Transfer(conn, FIRSTSOCKET, -1, FALSE, bytecount, + -1, NULL); + if(result) + return result; + } + } + (void)nthdef; + + return CURLE_OK; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/dict.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/dict.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/dict.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/dict.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,30 @@ +#ifndef __DICT_H +#define __DICT_H + +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: dict.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ +#ifndef CURL_DISABLE_DICT +CURLcode Curl_dict(struct connectdata *conn); +CURLcode Curl_dict_done(struct connectdata *conn); +#endif +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/easy.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/easy.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/easy.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/easy.c 2004-10-13 22:01:04.000000000 +0800 @@ -0,0 +1,583 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: easy.c,v 1.6 2004/10/13 14:01:04 andy Exp $ + ***************************************************************************/ + +#include "setup.h" + +/* -- WIN32 approved -- */ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "strequal.h" + +#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__) +#include +#include +#else +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#include +#ifdef HAVE_ARPA_INET_H +#include +#endif +#ifdef HAVE_NET_IF_H +#include +#endif +#include +#include + +#ifdef HAVE_SYS_PARAM_H +#include +#endif + +#ifdef HAVE_SYS_SELECT_H +#include +#endif + +#endif /* WIN32 ... */ + +#include "urldata.h" +#include +#include "transfer.h" +#include "ssluse.h" +#include "url.h" +#include "getinfo.h" +#include "hostip.h" +#include "share.h" +#include "curl_memory.h" + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +/* The last #include file should be: */ +#include "memdebug.h" + +#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__) +/* win32_cleanup() is for win32 socket cleanup functionality, the opposite + of win32_init() */ +static void win32_cleanup(void) +{ + WSACleanup(); +} + +/* win32_init() performs win32 socket initialization to properly setup the + stack to allow networking */ +static CURLcode win32_init(void) +{ + WORD wVersionRequested; + WSADATA wsaData; + int err; + +#ifdef ENABLE_IPV6 + wVersionRequested = MAKEWORD(2, 0); +#else + wVersionRequested = MAKEWORD(1, 1); +#endif + + err = WSAStartup(wVersionRequested, &wsaData); + + if (err != 0) + /* Tell the user that we couldn't find a useable */ + /* winsock.dll. */ + return CURLE_FAILED_INIT; + + /* Confirm that the Windows Sockets DLL supports what we need.*/ + /* Note that if the DLL supports versions greater */ + /* than wVersionRequested, it will still return */ + /* wVersionRequested in wVersion. wHighVersion contains the */ + /* highest supported version. */ + + if ( LOBYTE( wsaData.wVersion ) != LOBYTE(wVersionRequested) || + HIBYTE( wsaData.wVersion ) != HIBYTE(wVersionRequested) ) { + /* Tell the user that we couldn't find a useable */ + + /* winsock.dll. */ + WSACleanup(); + return CURLE_FAILED_INIT; + } + /* The Windows Sockets DLL is acceptable. Proceed. */ + return CURLE_OK; +} + +#else +/* These functions exist merely to prevent compiler warnings */ +static CURLcode win32_init(void) { return CURLE_OK; } +static void win32_cleanup(void) { } +#endif + +#ifdef USE_LIBIDN +/* + * Initialise use of IDNA library. + * It falls back to ASCII if $CHARSET isn't defined. This doesn't work for + * idna_to_ascii_lz(). + */ +static void idna_init (void) +{ +#ifdef WIN32 + char buf[60]; + UINT cp = GetACP(); + + if (!getenv("CHARSET") && cp > 0) { + snprintf(buf, sizeof(buf), "CHARSET=cp%u", cp); + putenv(buf); + } +#else + /* to do? */ +#endif +} +#endif /* USE_LIBIDN */ + +/* true globals -- for curl_global_init() and curl_global_cleanup() */ +static unsigned int initialized = 0; +static long init_flags = 0; + +/* + * If a memory-using function (like curl_getenv) is used before + * curl_global_init() is called, we need to have these pointers set already. + */ +curl_malloc_callback Curl_cmalloc = (curl_malloc_callback)malloc; +curl_free_callback Curl_cfree = (curl_free_callback)free; +curl_realloc_callback Curl_crealloc = (curl_realloc_callback)realloc; +curl_strdup_callback Curl_cstrdup = (curl_strdup_callback)strdup; +curl_calloc_callback Curl_ccalloc = (curl_calloc_callback)calloc; + +/** + * curl_global_init() globally initializes cURL given a bitwise set of the + * different features of what to initialize. + */ +CURLcode curl_global_init(long flags) +{ + if (initialized) + return CURLE_OK; + + /* Setup the default memory functions here (again) */ + Curl_cmalloc = (curl_malloc_callback)malloc; + Curl_cfree = (curl_free_callback)free; + Curl_crealloc = (curl_realloc_callback)realloc; + Curl_cstrdup = (curl_strdup_callback)strdup; + Curl_ccalloc = (curl_calloc_callback)calloc; + + if (flags & CURL_GLOBAL_SSL) + Curl_SSL_init(); + + if (flags & CURL_GLOBAL_WIN32) + if (win32_init() != CURLE_OK) + return CURLE_FAILED_INIT; + +#ifdef _AMIGASF + if(!amiga_init()) + return CURLE_FAILED_INIT; +#endif + +#ifdef USE_LIBIDN + idna_init(); +#endif + + initialized = 1; + init_flags = flags; + + return CURLE_OK; +} + +/* + * curl_global_init_mem() globally initializes cURL and also registers the + * user provided callback routines. + */ +CURLcode curl_global_init_mem(long flags, curl_malloc_callback m, + curl_free_callback f, curl_realloc_callback r, + curl_strdup_callback s, curl_calloc_callback c) +{ + CURLcode code; + + /* Invalid input, return immediately */ + if (!m || !f || !r || !s || !c) + return CURLE_FAILED_INIT; + + /* Already initialized, don't do it again */ + if ( initialized ) + return CURLE_OK; + + /* Call the actual init function first */ + code = curl_global_init(flags); + if (code == CURLE_OK) { + Curl_cmalloc = m; + Curl_cfree = f; + Curl_cstrdup = s; + Curl_crealloc = r; + Curl_ccalloc = c; + } + + return code; +} + +/** + * curl_global_cleanup() globally cleanups cURL, uses the value of + * "init_flags" to determine what needs to be cleaned up and what doesn't. + */ +void curl_global_cleanup(void) +{ + if (!initialized) + return; + + Curl_global_host_cache_dtor(); + + if (init_flags & CURL_GLOBAL_SSL) + Curl_SSL_cleanup(); + + if (init_flags & CURL_GLOBAL_WIN32) + win32_cleanup(); + +#ifdef _AMIGASF + amiga_cleanup(); +#endif + + initialized = 0; + init_flags = 0; +} + +/* + * curl_easy_init() is the external interface to alloc, setup and init an + * easy handle that is returned. If anything goes wrong, NULL is returned. + */ +CURL *curl_easy_init(void) +{ + CURLcode res; + struct SessionHandle *data; + + /* Make sure we inited the global SSL stuff */ + if (!initialized) { + res = curl_global_init(CURL_GLOBAL_DEFAULT); + if(res) + /* something in the global init failed, return nothing */ + return NULL; + } + + /* We use curl_open() with undefined URL so far */ + res = Curl_open(&data); + if(res != CURLE_OK) + return NULL; + + return data; +} + +/* + * curl_easy_setopt() is the external interface for setting options on an + * easy handle. + */ +typedef int (*func_T)(void); +CURLcode curl_easy_setopt(CURL *curl, CURLoption tag, ...) +{ + va_list arg; + func_T param_func; + long param_long; + void *param_obj; + curl_off_t param_offset; + struct SessionHandle *data = curl; + CURLcode ret; + + if(!curl) + return CURLE_BAD_FUNCTION_ARGUMENT; + + va_start(arg, tag); + + /* PORTING NOTE: + Object pointers can't necessarily be casted to function pointers and + therefore we need to know what type it is and read the correct type + at once. This should also correct problems with different sizes of + the types. + */ + + if(tag < CURLOPTTYPE_OBJECTPOINT) { + /* This is a LONG type */ + param_long = va_arg(arg, long); + ret = Curl_setopt(data, tag, param_long); + } + else if(tag < CURLOPTTYPE_FUNCTIONPOINT) { + /* This is a object pointer type */ + param_obj = va_arg(arg, void *); + ret = Curl_setopt(data, tag, param_obj); + } + else if(tag < CURLOPTTYPE_OFF_T) { + /* This is a function pointer type */ + param_func = va_arg(arg, func_T ); + ret = Curl_setopt(data, tag, param_func); + } + else { + /* This is a curl_off_t type */ + param_offset = va_arg(arg, curl_off_t); + ret = Curl_setopt(data, tag, param_offset); + } + + va_end(arg); + return ret; +} + +/* + * curl_easy_perform() is the external interface that performs a transfer + * previously setup. + */ +CURLcode curl_easy_perform(CURL *curl) +{ + struct SessionHandle *data = (struct SessionHandle *)curl; + + if(!data) + return CURLE_BAD_FUNCTION_ARGUMENT; + + if ( ! (data->share && data->share->hostcache) ) { + + if (Curl_global_host_cache_use(data) && + data->hostcache != Curl_global_host_cache_get()) { + if (data->hostcache) + Curl_hash_destroy(data->hostcache); + data->hostcache = Curl_global_host_cache_get(); + } + + if (!data->hostcache) { + data->hostcache = Curl_mk_dnscache(); + + if(!data->hostcache) + /* While we possibly could survive and do good without a host cache, + the fact that creating it failed indicates that things are truly + screwed up and we should bail out! */ + return CURLE_OUT_OF_MEMORY; + } + + } + + return Curl_perform(data); +} + +/* + * curl_easy_cleanup() is the external interface to cleaning/freeing the given + * easy handle. + */ +void curl_easy_cleanup(CURL *curl) +{ + struct SessionHandle *data = (struct SessionHandle *)curl; + + if(!data) + return; + + if ( ! (data->share && data->share->hostcache) ) { + if ( !Curl_global_host_cache_use(data)) { + Curl_hash_destroy(data->hostcache); + } + } + Curl_close(data); +} + +/* + * curl_easy_getinfo() is an external interface that allows an app to retrieve + * information from a performed transfer and similar. + */ +CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...) +{ + va_list arg; + void *paramp; + struct SessionHandle *data = (struct SessionHandle *)curl; + + va_start(arg, info); + paramp = va_arg(arg, void *); + + return Curl_getinfo(data, info, paramp); +} + +/* + * curl_easy_duphandle() is an external interface to allow duplication of a + * given input easy handle. The returned handle will be a new working handle + * with all options set exactly as the input source handle. + */ +CURL *curl_easy_duphandle(CURL *incurl) +{ + bool fail = TRUE; + struct SessionHandle *data=(struct SessionHandle *)incurl; + + struct SessionHandle *outcurl = (struct SessionHandle *) + calloc(sizeof(struct SessionHandle), 1); + + if(NULL == outcurl) + return NULL; /* failure */ + + do { + + /* + * We setup a few buffers we need. We should probably make them + * get setup on-demand in the code, as that would probably decrease + * the likeliness of us forgetting to init a buffer here in the future. + */ + outcurl->state.headerbuff=(char*)malloc(HEADERSIZE); + if(!outcurl->state.headerbuff) { + break; + } + outcurl->state.headersize=HEADERSIZE; + + /* copy all userdefined values */ + outcurl->set = data->set; + outcurl->state.numconnects = data->state.numconnects; + outcurl->state.connects = (struct connectdata **) + malloc(sizeof(struct connectdata *) * outcurl->state.numconnects); + + if(!outcurl->state.connects) { + break; + } + + memset(outcurl->state.connects, 0, + sizeof(struct connectdata *)*outcurl->state.numconnects); + + outcurl->progress.flags = data->progress.flags; + outcurl->progress.callback = data->progress.callback; + +#ifndef CURL_DISABLE_HTTP + if(data->cookies) { + /* If cookies are enabled in the parent handle, we enable them + in the clone as well! */ + outcurl->cookies = Curl_cookie_init(data, + data->cookies->filename, + outcurl->cookies, + data->set.cookiesession); + if(!outcurl->cookies) { + break; + } + } +#endif /* CURL_DISABLE_HTTP */ + + /* duplicate all values in 'change' */ + if(data->change.url) { + outcurl->change.url = strdup(data->change.url); + if(!outcurl->change.url) + break; + outcurl->change.url_alloc = TRUE; + } + if(data->change.proxy) { + outcurl->change.proxy = strdup(data->change.proxy); + if(!outcurl->change.proxy) + break; + outcurl->change.proxy_alloc = TRUE; + } + if(data->change.referer) { + outcurl->change.referer = strdup(data->change.referer); + if(!outcurl->change.referer) + break; + outcurl->change.referer_alloc = TRUE; + } + +#ifdef USE_ARES + /* If we use ares, we setup a new ares channel for the new handle */ + if(ARES_SUCCESS != ares_init(&outcurl->state.areschannel)) + break; +#endif + + fail = FALSE; /* we reach this point and thus we are OK */ + + } while(0); + + if(fail) { + if(outcurl) { + if(outcurl->state.connects) + free(outcurl->state.connects); + if(outcurl->state.headerbuff) + free(outcurl->state.headerbuff); + if(outcurl->change.proxy) + free(outcurl->change.proxy); + if(outcurl->change.url) + free(outcurl->change.url); + if(outcurl->change.referer) + free(outcurl->change.referer); + free(outcurl); /* free the memory again */ + outcurl = NULL; + } + } + + return outcurl; +} + +/* + * curl_easy_reset() is an external interface that allows an app to re- + * initialize a session handle to the default values. + */ +void curl_easy_reset(CURL *curl) +{ + struct SessionHandle *data = (struct SessionHandle *)curl; + + /* zero out UserDefined data: */ + memset(&data->set, 0, sizeof(struct UserDefined)); + + /* zero out Progress data: */ + memset(&data->progress, 0, sizeof(struct Progress)); + + /* The remainder of these calls have been taken from Curl_open() */ + + data->set.out = stdout; /* default output to stdout */ + data->set.in = stdin; /* default input from stdin */ + data->set.err = stderr; /* default stderr to stderr */ + + /* use fwrite as default function to store output */ + data->set.fwrite = (curl_write_callback)fwrite; + + /* use fread as default function to read input */ + data->set.fread = (curl_read_callback)fread; + + data->set.infilesize = -1; /* we don't know any size */ + + data->state.current_speed = -1; /* init to negative == impossible */ + + data->set.httpreq = HTTPREQ_GET; /* Default HTTP request */ + data->set.ftp_use_epsv = TRUE; /* FTP defaults to EPSV operations */ + data->set.ftp_use_eprt = TRUE; /* FTP defaults to EPRT operations */ + + data->set.dns_cache_timeout = 60; /* Timeout every 60 seconds by default */ + + /* make libcurl quiet by default: */ + data->set.hide_progress = TRUE; /* CURLOPT_NOPROGRESS changes these */ + + /* Set the default size of the SSL session ID cache */ + data->set.ssl.numsessions = 5; + + data->set.proxyport = 1080; + data->set.proxytype = CURLPROXY_HTTP; /* defaults to HTTP proxy */ + data->set.httpauth = CURLAUTH_BASIC; /* defaults to basic */ + data->set.proxyauth = CURLAUTH_BASIC; /* defaults to basic */ + + /* + * libcurl 7.10 introduced SSL verification *by default*! This needs to be + * switched off unless wanted. + */ + data->set.ssl.verifypeer = TRUE; + data->set.ssl.verifyhost = 2; +#ifdef CURL_CA_BUNDLE + /* This is our prefered CA cert bundle since install time */ + data->set.ssl.CAfile = (char *)CURL_CA_BUNDLE; +#endif +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/escape.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/escape.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/escape.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/escape.c 2004-10-13 22:01:04.000000000 +0800 @@ -0,0 +1,135 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: escape.c,v 1.7 2004/10/13 14:01:04 andy Exp $ + ***************************************************************************/ + +/* Escape and unescape URL encoding in strings. The functions return a new + * allocated string or NULL if an error occurred. */ + +#include "setup.h" +#include +#include + +#include +#include +#include +#include "curl_memory.h" + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +/* The last #include file should be: */ +#include "memdebug.h" + +char *curl_escape(const char *string, int inlength) +{ + size_t alloc = (inlength?(size_t)inlength:strlen(string))+1; + char *ns; + char *testing_ptr; + unsigned char in; + size_t newlen = alloc; + int strindex=0; + size_t length; + + ns = malloc(alloc); + if(!ns) + return NULL; + + length = alloc-1; + while(length--) { + in = *string; + if(!(in >= 'a' && in <= 'z') && + !(in >= 'A' && in <= 'Z') && + !(in >= '0' && in <= '9')) { + /* encode it */ + newlen += 2; /* the size grows with two, since this'll become a %XX */ + if(newlen > alloc) { + alloc *= 2; + testing_ptr = realloc(ns, alloc); + if(!testing_ptr) { + free( ns ); + return NULL; + } + else { + ns = testing_ptr; + } + } + snprintf(&ns[strindex], 4, "%%%02X", in); + + strindex+=3; + } + else { + /* just copy this */ + ns[strindex++]=in; + } + string++; + } + ns[strindex]=0; /* terminate it */ + return ns; +} + +#define ishex(in) ((in >= 'a' && in <= 'f') || \ + (in >= 'A' && in <= 'F') || \ + (in >= '0' && in <= '9')) + +char *curl_unescape(const char *string, int length) +{ + int alloc = (length?length:(int)strlen(string))+1; + char *ns = malloc(alloc); + unsigned char in; + int strindex=0; + long hex; + + if( !ns ) + return NULL; + + while(--alloc > 0) { + in = *string; + if(('%' == in) && ishex(string[1]) && ishex(string[2])) { + /* this is two hexadecimal digits following a '%' */ + char hexstr[3]; + char *ptr; + hexstr[0] = string[1]; + hexstr[1] = string[2]; + hexstr[2] = 0; + + hex = strtol(hexstr, &ptr, 16); + + in = (unsigned char)hex; /* this long is never bigger than 255 anyway */ + string+=2; + alloc-=2; + } + + ns[strindex++] = in; + string++; + } + ns[strindex]=0; /* terminate it */ + return ns; +} + +/* For operating systems/environments that use different malloc/free + ssystems for the app and for this library, we provide a free that uses + the library's memory system */ +void curl_free(void *p) +{ + if(p) + free(p); +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/escape.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/escape.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/escape.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/escape.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,32 @@ +#ifndef __ESCAPE_H +#define __ESCAPE_H + +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: escape.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ +/* Escape and unescape URL encoding in strings. The functions return a new + * allocated string or NULL if an error occurred. */ + +char *curl_escape(const char *string, int length); +char *curl_unescape(const char *string, int length); + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/file.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/file.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/file.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/file.c 2005-02-28 06:36:00.000000000 +0800 @@ -0,0 +1,390 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: file.c,v 1.7 2005/02/27 22:36:00 andy Exp $ + ***************************************************************************/ + +#include "setup.h" + +#ifndef CURL_DISABLE_FILE +/* -- WIN32 approved -- */ +#include +#include +#include +#include +#include +#include +#include + +#include + +#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__) +#include +#include +#include +#else +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_NETDB_H +#include +#endif +#ifdef HAVE_ARPA_INET_H +#include +#endif +#ifdef HAVE_NET_IF_H +#include +#endif +#include +#include + +#ifdef HAVE_SYS_PARAM_H +#include +#endif + +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif + +#endif + +#include "urldata.h" +#include +#include "progress.h" +#include "sendf.h" +#include "escape.h" +#include "file.h" +#include "speedcheck.h" +#include "getinfo.h" +#include "transfer.h" +#include "url.h" +#include "curl_memory.h" + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +/* The last #include file should be: */ +#include "memdebug.h" + +/* + * Curl_file_connect() gets called from Curl_protocol_connect() to allow us to + * do protocol-specific actions at connect-time. We emulate a + * connect-then-transfer protocol and "connect" to the file here + */ +CURLcode Curl_file_connect(struct connectdata *conn) +{ + char *real_path = curl_unescape(conn->path, 0); + struct FILEPROTO *file; + int fd; +#if defined(WIN32) || defined(__EMX__) + int i; + char *actual_path; +#endif + + if(!real_path) + return CURLE_OUT_OF_MEMORY; + + file = (struct FILEPROTO *)calloc(sizeof(struct FILEPROTO), 1); + if(!file) { + free(real_path); + return CURLE_OUT_OF_MEMORY; + } + + conn->proto.file = file; + +#if defined(WIN32) || defined(__EMX__) + /* If the first character is a slash, and there's + something that looks like a drive at the beginning of + the path, skip the slash. If we remove the initial + slash in all cases, paths without drive letters end up + relative to the current directory which isn't how + browsers work. + + Some browsers accept | instead of : as the drive letter + separator, so we do too. + + On other platforms, we need the slash to indicate an + absolute pathname. On Windows, absolute paths start + with a drive letter. + */ + actual_path = real_path; + if ((actual_path[0] == '/') && + actual_path[1] && + (actual_path[2] == ':' || actual_path[2] == '|')) + { + actual_path[2] = ':'; + actual_path++; + } + + /* change path separators from '/' to '\\' for Windows and OS/2 */ + for (i=0; actual_path[i] != '\0'; ++i) + if (actual_path[i] == '/') + actual_path[i] = '\\'; + + fd = open(actual_path, O_RDONLY | O_BINARY); /* no CR/LF translation! */ + file->path = actual_path; +#else + fd = open(real_path, O_RDONLY); + file->path = real_path; +#endif + file->freepath = real_path; /* free this when done */ + + if(!conn->data->set.upload && (fd == -1)) { + failf(conn->data, "Couldn't open file %s", conn->path); + Curl_file_done(conn, CURLE_FILE_COULDNT_READ_FILE); + return CURLE_FILE_COULDNT_READ_FILE; + } + file->fd = fd; + + return CURLE_OK; +} + +#if defined(WIN32) && (SIZEOF_CURL_OFF_T > 4) +#define lseek(x,y,z) _lseeki64(x, y, z) +#endif + +CURLcode Curl_file_done(struct connectdata *conn, + CURLcode status) +{ + struct FILEPROTO *file = conn->proto.file; + (void)status; /* not used */ + Curl_safefree(file->freepath); + + return CURLE_OK; +} + +#if defined(WIN32) || defined(__EMX__) +#define DIRSEP '\\' +#else +#define DIRSEP '/' +#endif + +static CURLcode file_upload(struct connectdata *conn) +{ + struct FILEPROTO *file = conn->proto.file; + char *dir = strchr(file->path, DIRSEP); + FILE *fp; + CURLcode res=CURLE_OK; + struct SessionHandle *data = conn->data; + char *buf = data->state.buffer; + size_t nread; + size_t nwrite; + curl_off_t bytecount = 0; + struct timeval now = Curl_tvnow(); + + /* + * Since FILE: doesn't do the full init, we need to provide some extra + * assignments here. + */ + conn->fread = data->set.fread; + conn->fread_in = data->set.in; + conn->upload_fromhere = buf; + + if(!dir) + return CURLE_FILE_COULDNT_READ_FILE; /* fix: better error code */ + + if(!dir[1]) + return CURLE_FILE_COULDNT_READ_FILE; /* fix: better error code */ + + fp = fopen(file->path, "wb"); + if(!fp) { + failf(data, "Can't open %s for writing", file->path); + return CURLE_WRITE_ERROR; + } + + if(-1 != data->set.infilesize) + /* known size of data to "upload" */ + Curl_pgrsSetUploadSize(data, data->set.infilesize); + + while (res == CURLE_OK) { + int readcount; + res = Curl_fillreadbuffer(conn, BUFSIZE, &readcount); + if(res) + return res; + + nread = (size_t)readcount; + + if (nread <= 0) + break; + + /* write the data to the target */ + nwrite = fwrite(buf, 1, nread, fp); + if(nwrite != nread) { + res = CURLE_SEND_ERROR; + break; + } + + bytecount += nread; + + Curl_pgrsSetUploadCounter(data, bytecount); + + if(Curl_pgrsUpdate(conn)) + res = CURLE_ABORTED_BY_CALLBACK; + else + res = Curl_speedcheck(data, now); + } + if(!res && Curl_pgrsUpdate(conn)) + res = CURLE_ABORTED_BY_CALLBACK; + + fclose(fp); + + return res; +} + +/* + * Curl_file() is the protocol-specific function for the do-phase, separated + * from the connect-phase above. Other protocols merely setup the transfer in + * the do-phase, to have it done in the main transfer loop but since some + * platforms we support don't allow select()ing etc on file handles (as + * opposed to sockets) we instead perform the whole do-operation in this + * function. + */ +CURLcode Curl_file(struct connectdata *conn) +{ + /* This implementation ignores the host name in conformance with + RFC 1738. Only local files (reachable via the standard file system) + are supported. This means that files on remotely mounted directories + (via NFS, Samba, NT sharing) can be accessed through a file:// URL + */ + CURLcode res = CURLE_OK; + struct stat statbuf; + curl_off_t expected_size=0; + bool fstated=FALSE; + ssize_t nread; + struct SessionHandle *data = conn->data; + char *buf = data->state.buffer; + curl_off_t bytecount = 0; + int fd; + struct timeval now = Curl_tvnow(); + + Curl_readwrite_init(conn); + Curl_initinfo(data); + Curl_pgrsStartNow(data); + + if(data->set.upload) + return file_upload(conn); + + /* get the fd from the connection phase */ + fd = conn->proto.file->fd; + + /* VMS: This only works reliable for STREAMLF files */ + if( -1 != fstat(fd, &statbuf)) { + /* we could stat it, then read out the size */ + expected_size = statbuf.st_size; + fstated = TRUE; + } + + /* If we have selected NOBODY and HEADER, it means that we only want file + information. Which for FILE can't be much more than the file size and + date. */ + if(conn->bits.no_body && data->set.include_header && fstated) { + CURLcode result; + snprintf(buf, sizeof(data->state.buffer), + "Content-Length: %" FORMAT_OFF_T "\r\n", expected_size); + result = Curl_client_write(data, CLIENTWRITE_BOTH, buf, 0); + if(result) + return result; + + result = Curl_client_write(data, CLIENTWRITE_BOTH, + (char *)"Accept-ranges: bytes\r\n", 0); + if(result) + return result; + +#ifdef HAVE_STRFTIME + if(fstated) { + struct tm *tm; + time_t cuClock = (time_t)statbuf.st_mtime; +#ifdef HAVE_GMTIME_R + struct tm buffer; + tm = (struct tm *)gmtime_r(&cuClock, &buffer); +#else + tm = gmtime(&cuClock); +#endif + /* format: "Tue, 15 Nov 1994 12:45:26 GMT" */ + strftime(buf, BUFSIZE-1, "Last-Modified: %a, %d %b %Y %H:%M:%S GMT\r\n", + tm); + result = Curl_client_write(data, CLIENTWRITE_BOTH, buf, 0); + } +#endif + return result; + } + + /* Added by Dolbneff A.V & Spiridonoff A.V */ + if (conn->resume_from <= expected_size) + expected_size -= conn->resume_from; + else + /* Is this error code suitable in such situation? */ + return CURLE_FTP_BAD_DOWNLOAD_RESUME; + + if (fstated && (expected_size == 0)) + return CURLE_OK; + + /* The following is a shortcut implementation of file reading + this is both more efficient than the former call to download() and + it avoids problems with select() and recv() on file descriptors + in Winsock */ + if(fstated) + Curl_pgrsSetDownloadSize(data, expected_size); + + if(conn->resume_from) + lseek(fd, conn->resume_from, SEEK_SET); + + Curl_pgrsTime(data, TIMER_STARTTRANSFER); + + while (res == CURLE_OK) { + nread = read(fd, buf, BUFSIZE-1); + + if ( nread > 0) + buf[nread] = 0; + + if (nread <= 0) + break; + + bytecount += nread; + + res = Curl_client_write(data, CLIENTWRITE_BODY, buf, nread); + if(res) + return res; + + Curl_pgrsSetDownloadCounter(data, bytecount); + + if(Curl_pgrsUpdate(conn)) + res = CURLE_ABORTED_BY_CALLBACK; + else + res = Curl_speedcheck(data, now); + } + if(Curl_pgrsUpdate(conn)) + res = CURLE_ABORTED_BY_CALLBACK; + + close(fd); + + return res; +} +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/file.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/file.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/file.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/file.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,31 @@ +#ifndef __FILE_H +#define __FILE_H + +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: file.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ +#ifndef CURL_DISABLE_FILE +CURLcode Curl_file(struct connectdata *); +CURLcode Curl_file_done(struct connectdata *, CURLcode); +CURLcode Curl_file_connect(struct connectdata *); +#endif +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/formdata.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/formdata.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/formdata.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/formdata.c 2004-10-13 22:45:30.000000000 +0800 @@ -0,0 +1,1484 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: formdata.c,v 1.11 2004/10/13 14:45:30 andy Exp $ + ***************************************************************************/ + +/* + Debug the form generator stand-alone by compiling this source file with: + + gcc -DHAVE_CONFIG_H -I../ -g -D_FORM_DEBUG -o formdata -I../include formdata.c strequal.c + + run the 'formdata' executable the output should end with: + All Tests seem to have worked ... + and the following parts should be there: + +Content-Disposition: form-data; name="simple_COPYCONTENTS" +value for simple COPYCONTENTS + +Content-Disposition: form-data; name="COPYCONTENTS_+_CONTENTTYPE" +Content-Type: image/gif +value for COPYCONTENTS + CONTENTTYPE + +Content-Disposition: form-data; name="PRNAME_+_NAMELENGTH_+_COPYNAME_+_CONTENTSLENGTH" +vlue for PTRNAME + NAMELENGTH + COPYNAME + CONTENTSLENGTH +(or you might see P^@RNAME and v^@lue at the start) + +Content-Disposition: form-data; name="simple_PTRCONTENTS" +value for simple PTRCONTENTS + +Content-Disposition: form-data; name="PTRCONTENTS_+_CONTENTSLENGTH" +vlue for PTRCONTENTS + CONTENTSLENGTH +(or you might see v^@lue at the start) + +Content-Disposition: form-data; name="PTRCONTENTS_+_CONTENTSLENGTH_+_CONTENTTYPE" +Content-Type: text/plain +vlue for PTRCOTNENTS + CONTENTSLENGTH + CONTENTTYPE +(or you might see v^@lue at the start) + +Content-Disposition: form-data; name="FILE1_+_CONTENTTYPE"; filename="inet_ntoa_r.h" +Content-Type: text/html +... + +Content-Disposition: form-data; name="FILE1_+_FILE2" +Content-Type: multipart/mixed, boundary=curlz1s0dkticx49MV1KGcYP5cvfSsz +... +Content-Disposition: attachment; filename="inet_ntoa_r.h" +Content-Type: text/plain +... +Content-Disposition: attachment; filename="Makefile.b32.resp" +Content-Type: text/plain +... + +Content-Disposition: form-data; name="FILE1_+_FILE2_+_FILE3" +Content-Type: multipart/mixed, boundary=curlirkYPmPwu6FrJ1vJ1u1BmtIufh1 +... +Content-Disposition: attachment; filename="inet_ntoa_r.h" +Content-Type: text/plain +... +Content-Disposition: attachment; filename="Makefile.b32.resp" +Content-Type: text/plain +... +Content-Disposition: attachment; filename="inet_ntoa_r.h" +Content-Type: text/plain +... + + +Content-Disposition: form-data; name="ARRAY: FILE1_+_FILE2_+_FILE3" +Content-Type: multipart/mixed, boundary=curlirkYPmPwu6FrJ1vJ1u1BmtIufh1 +... +Content-Disposition: attachment; filename="inet_ntoa_r.h" +Content-Type: text/plain +... +Content-Disposition: attachment; filename="Makefile.b32.resp" +Content-Type: text/plain +... +Content-Disposition: attachment; filename="inet_ntoa_r.h" +Content-Type: text/plain +... + +Content-Disposition: form-data; name="FILECONTENT" +... + + */ + +#include "setup.h" +#include + +/* Length of the random boundary string. */ +#define BOUNDARY_LENGTH 40 + +#ifndef CURL_DISABLE_HTTP + +#include +#include +#include +#include +#include +#include +#include "formdata.h" +#include "strequal.h" +#include "curl_memory.h" + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +/* The last #include file should be: */ +#include "memdebug.h" + +/* What kind of Content-Type to use on un-specified files with unrecognized + extensions. */ +#define HTTPPOST_CONTENTTYPE_DEFAULT "application/octet-stream" + +#define FORM_FILE_SEPARATOR ',' +#define FORM_TYPE_SEPARATOR ';' + +/*************************************************************************** + * + * AddHttpPost() + * + * Adds a HttpPost structure to the list, if parent_post is given becomes + * a subpost of parent_post instead of a direct list element. + * + * Returns newly allocated HttpPost on success and NULL if malloc failed. + * + ***************************************************************************/ +static struct curl_httppost * +AddHttpPost(char * name, size_t namelength, + char * value, size_t contentslength, + char * buffer, size_t bufferlength, + char *contenttype, + long flags, + struct curl_slist* contentHeader, + char *showfilename, + struct curl_httppost *parent_post, + struct curl_httppost **httppost, + struct curl_httppost **last_post) +{ + struct curl_httppost *post; + post = (struct curl_httppost *)calloc(sizeof(struct curl_httppost), 1); + if(post) { + post->name = name; + post->namelength = (long)(name?(namelength?namelength:strlen(name)):0); + post->contents = value; + post->contentslength = (long)contentslength; + post->buffer = buffer; + post->bufferlength = (long)bufferlength; + post->contenttype = contenttype; + post->contentheader = contentHeader; + post->showfilename = showfilename; + post->flags = flags; + } + else + return NULL; + + if (parent_post) { + /* now, point our 'more' to the original 'more' */ + post->more = parent_post->more; + + /* then move the original 'more' to point to ourselves */ + parent_post->more = post; + } + else { + /* make the previous point to this */ + if(*last_post) + (*last_post)->next = post; + else + (*httppost) = post; + + (*last_post) = post; + } + return post; +} + +/*************************************************************************** + * + * AddFormInfo() + * + * Adds a FormInfo structure to the list presented by parent_form_info. + * + * Returns newly allocated FormInfo on success and NULL if malloc failed/ + * parent_form_info is NULL. + * + ***************************************************************************/ +static FormInfo * AddFormInfo(char *value, + char *contenttype, + FormInfo *parent_form_info) +{ + FormInfo *form_info; + form_info = (FormInfo *)malloc(sizeof(FormInfo)); + if(form_info) { + memset(form_info, 0, sizeof(FormInfo)); + if (value) + form_info->value = value; + if (contenttype) + form_info->contenttype = contenttype; + form_info->flags = HTTPPOST_FILENAME; + } + else + return NULL; + + if (parent_form_info) { + /* now, point our 'more' to the original 'more' */ + form_info->more = parent_form_info->more; + + /* then move the original 'more' to point to ourselves */ + parent_form_info->more = form_info; + } + else + return NULL; + + return form_info; +} + +/*************************************************************************** + * + * ContentTypeForFilename() + * + * Provides content type for filename if one of the known types (else + * (either the prevtype or the default is returned). + * + * Returns some valid contenttype for filename. + * + ***************************************************************************/ +static const char * ContentTypeForFilename (const char *filename, + const char *prevtype) +{ + const char *contenttype; + unsigned int i; + /* + * No type was specified, we scan through a few well-known + * extensions and pick the first we match! + */ + struct ContentType { + const char *extension; + const char *type; + }; + static struct ContentType ctts[]={ + {".gif", "image/gif"}, + {".jpg", "image/jpeg"}, + {".jpeg", "image/jpeg"}, + {".txt", "text/plain"}, + {".html", "text/html"} + }; + + if(prevtype) + /* default to the previously set/used! */ + contenttype = prevtype; + else + /* It seems RFC1867 defines no Content-Type to default to + text/plain so we don't actually need to set this: */ + contenttype = HTTPPOST_CONTENTTYPE_DEFAULT; + + for(i=0; i= strlen(ctts[i].extension)) { + if(strequal(filename + + strlen(filename) - strlen(ctts[i].extension), + ctts[i].extension)) { + contenttype = ctts[i].type; + break; + } + } + } + /* we have a contenttype by now */ + return contenttype; +} + +/*************************************************************************** + * + * memdup() + * + * Copies the 'source' data to a newly allocated buffer buffer (that is + * returned). Uses buffer_length if not null, else uses strlen to determine + * the length of the buffer to be copied + * + * Returns the new pointer or NULL on failure. + * + ***************************************************************************/ +static char *memdup(const char *src, size_t buffer_length) +{ + size_t length; + bool add = FALSE; + char *buffer; + + if (buffer_length) + length = buffer_length; + else { + length = strlen(src); + add = TRUE; + } + buffer = (char*)malloc(length+add); + if (!buffer) + return NULL; /* fail */ + + memcpy(buffer, src, length); + + /* if length unknown do null termination */ + if (add) + buffer[length] = '\0'; + + return buffer; +} + +/*************************************************************************** + * + * FormAdd() + * + * Stores a formpost parameter and builds the appropriate linked list. + * + * Has two principal functionalities: using files and byte arrays as + * post parts. Byte arrays are either copied or just the pointer is stored + * (as the user requests) while for files only the filename and not the + * content is stored. + * + * While you may have only one byte array for each name, multiple filenames + * are allowed (and because of this feature CURLFORM_END is needed after + * using CURLFORM_FILE). + * + * Examples: + * + * Simple name/value pair with copied contents: + * curl_formadd (&post, &last, CURLFORM_COPYNAME, "name", + * CURLFORM_COPYCONTENTS, "value", CURLFORM_END); + * + * name/value pair where only the content pointer is remembered: + * curl_formadd (&post, &last, CURLFORM_COPYNAME, "name", + * CURLFORM_PTRCONTENTS, ptr, CURLFORM_CONTENTSLENGTH, 10, CURLFORM_END); + * (if CURLFORM_CONTENTSLENGTH is missing strlen () is used) + * + * storing a filename (CONTENTTYPE is optional!): + * curl_formadd (&post, &last, CURLFORM_COPYNAME, "name", + * CURLFORM_FILE, "filename1", CURLFORM_CONTENTTYPE, "plain/text", + * CURLFORM_END); + * + * storing multiple filenames: + * curl_formadd (&post, &last, CURLFORM_COPYNAME, "name", + * CURLFORM_FILE, "filename1", CURLFORM_FILE, "filename2", CURLFORM_END); + * + * Returns: + * CURL_FORMADD_OK on success + * CURL_FORMADD_MEMORY if the FormInfo allocation fails + * CURL_FORMADD_OPTION_TWICE if one option is given twice for one Form + * CURL_FORMADD_NULL if a null pointer was given for a char + * CURL_FORMADD_MEMORY if the allocation of a FormInfo struct failed + * CURL_FORMADD_UNKNOWN_OPTION if an unknown option was used + * CURL_FORMADD_INCOMPLETE if the some FormInfo is not complete (or an error) + * CURL_FORMADD_MEMORY if a HttpPost struct cannot be allocated + * CURL_FORMADD_MEMORY if some allocation for string copying failed. + * CURL_FORMADD_ILLEGAL_ARRAY if an illegal option is used in an array + * + ***************************************************************************/ + +static +CURLFORMcode FormAdd(struct curl_httppost **httppost, + struct curl_httppost **last_post, + va_list params) +{ + FormInfo *first_form, *current_form, *form = NULL; + CURLFORMcode return_value = CURL_FORMADD_OK; + const char *prevtype = NULL; + struct curl_httppost *post; + CURLformoption option; + struct curl_forms *forms = NULL; + char *array_value=NULL; /* value read from an array */ + + /* This is a state variable, that if TRUE means that we're parsing an + array that we got passed to us. If FALSE we're parsing the input + va_list arguments. */ + bool array_state = FALSE; + + /* + * We need to allocate the first struct to fill in. + */ + first_form = (FormInfo *)calloc(sizeof(struct FormInfo), 1); + if(!first_form) + return CURL_FORMADD_MEMORY; + + current_form = first_form; + + /* + * Loop through all the options set. Break if we have an error to report. + */ + while (return_value == CURL_FORMADD_OK) { + + /* first see if we have more parts of the array param */ + if ( array_state ) { + /* get the upcoming option from the given array */ + option = forms->option; + array_value = (char *)forms->value; + + forms++; /* advance this to next entry */ + if (CURLFORM_END == option) { + /* end of array state */ + array_state = FALSE; + continue; + } + } + else { + /* This is not array-state, get next option */ + option = va_arg(params, CURLformoption); + if (CURLFORM_END == option) + break; + } + + switch (option) { + case CURLFORM_ARRAY: + if(array_state) + /* we don't support an array from within an array */ + return_value = CURL_FORMADD_ILLEGAL_ARRAY; + else { + forms = va_arg(params, struct curl_forms *); + if (forms) + array_state = TRUE; + else + return_value = CURL_FORMADD_NULL; + } + break; + + /* + * Set the Name property. + */ + case CURLFORM_PTRNAME: + current_form->flags |= HTTPPOST_PTRNAME; /* fall through */ + case CURLFORM_COPYNAME: + if (current_form->name) + return_value = CURL_FORMADD_OPTION_TWICE; + else { + char *name = array_state? + array_value:va_arg(params, char *); + if (name) + current_form->name = name; /* store for the moment */ + else + return_value = CURL_FORMADD_NULL; + } + break; + case CURLFORM_NAMELENGTH: + if (current_form->namelength) + return_value = CURL_FORMADD_OPTION_TWICE; + else + current_form->namelength = + array_state?(long)array_value:va_arg(params, long); + break; + + /* + * Set the contents property. + */ + case CURLFORM_PTRCONTENTS: + current_form->flags |= HTTPPOST_PTRCONTENTS; /* fall through */ + case CURLFORM_COPYCONTENTS: + if (current_form->value) + return_value = CURL_FORMADD_OPTION_TWICE; + else { + char *value = + array_state?array_value:va_arg(params, char *); + if (value) + current_form->value = value; /* store for the moment */ + else + return_value = CURL_FORMADD_NULL; + } + break; + case CURLFORM_CONTENTSLENGTH: + if (current_form->contentslength) + return_value = CURL_FORMADD_OPTION_TWICE; + else + current_form->contentslength = + array_state?(long)array_value:va_arg(params, long); + break; + + /* Get contents from a given file name */ + case CURLFORM_FILECONTENT: + if (current_form->flags != 0) + return_value = CURL_FORMADD_OPTION_TWICE; + else { + char *filename = array_state? + array_value:va_arg(params, char *); + if (filename) { + current_form->value = strdup(filename); + if(!current_form->value) + return_value = CURL_FORMADD_MEMORY; + else { + current_form->flags |= HTTPPOST_READFILE; + current_form->value_alloc = TRUE; + } + } + else + return_value = CURL_FORMADD_NULL; + } + break; + + /* We upload a file */ + case CURLFORM_FILE: + { + char *filename = array_state?array_value: + va_arg(params, char *); + + if (current_form->value) { + if (current_form->flags & HTTPPOST_FILENAME) { + if (filename) { + if (!(current_form = AddFormInfo(strdup(filename), + NULL, current_form))) + return_value = CURL_FORMADD_MEMORY; + } + else + return_value = CURL_FORMADD_NULL; + } + else + return_value = CURL_FORMADD_OPTION_TWICE; + } + else { + if (filename) { + current_form->value = strdup(filename); + if(!current_form->value) + return_value = CURL_FORMADD_MEMORY; + else { + current_form->flags |= HTTPPOST_FILENAME; + current_form->value_alloc = TRUE; + } + } + else + return_value = CURL_FORMADD_NULL; + } + break; + } + + case CURLFORM_BUFFER: + { + char *filename = array_state?array_value: + va_arg(params, char *); + + if (current_form->value) { + if (current_form->flags & HTTPPOST_BUFFER) { + if (filename) { + if (!(current_form = AddFormInfo(strdup(filename), + NULL, current_form))) + return_value = CURL_FORMADD_MEMORY; + } + else + return_value = CURL_FORMADD_NULL; + } + else + return_value = CURL_FORMADD_OPTION_TWICE; + } + else { + if (filename) { + current_form->value = strdup(filename); + if(!current_form->value) + return_value = CURL_FORMADD_MEMORY; + } + else + return_value = CURL_FORMADD_NULL; + current_form->flags |= HTTPPOST_BUFFER; + } + break; + } + + case CURLFORM_BUFFERPTR: + current_form->flags |= HTTPPOST_PTRBUFFER; + if (current_form->buffer) + return_value = CURL_FORMADD_OPTION_TWICE; + else { + char *buffer = + array_state?array_value:va_arg(params, char *); + if (buffer) + current_form->buffer = buffer; /* store for the moment */ + else + return_value = CURL_FORMADD_NULL; + } + break; + + case CURLFORM_BUFFERLENGTH: + if (current_form->bufferlength) + return_value = CURL_FORMADD_OPTION_TWICE; + else + current_form->bufferlength = + array_state?(long)array_value:va_arg(params, long); + break; + + case CURLFORM_CONTENTTYPE: + { + char *contenttype = + array_state?array_value:va_arg(params, char *); + if (current_form->contenttype) { + if (current_form->flags & HTTPPOST_FILENAME) { + if (contenttype) { + if (!(current_form = AddFormInfo(NULL, + strdup(contenttype), + current_form))) + return_value = CURL_FORMADD_MEMORY; + } + else + return_value = CURL_FORMADD_NULL; + } + else + return_value = CURL_FORMADD_OPTION_TWICE; + } + else { + if (contenttype) { + current_form->contenttype = strdup(contenttype); + if(!current_form->contenttype) + return_value = CURL_FORMADD_MEMORY; + else + current_form->contenttype_alloc = TRUE; + } + else + return_value = CURL_FORMADD_NULL; + } + break; + } + case CURLFORM_CONTENTHEADER: + { + /* this "cast increases required alignment of target type" but + we consider it OK anyway */ + struct curl_slist* list = 0; + if ( array_state ) + { + memcpy(&list, &array_value, sizeof(struct curl_slist*)); + } + else + { + list = va_arg(params, struct curl_slist*); + } + + if( current_form->contentheader ) + return_value = CURL_FORMADD_OPTION_TWICE; + else + current_form->contentheader = list; + + break; + } + case CURLFORM_FILENAME: + { + char *filename = array_state?array_value: + va_arg(params, char *); + if( current_form->showfilename ) + return_value = CURL_FORMADD_OPTION_TWICE; + else { + current_form->showfilename = strdup(filename); + if(!current_form->showfilename) + return_value = CURL_FORMADD_MEMORY; + else + current_form->showfilename_alloc = TRUE; + } + break; + } + default: + return_value = CURL_FORMADD_UNKNOWN_OPTION; + } + } + + if(CURL_FORMADD_OK == return_value) { + /* go through the list, check for copleteness and if everything is + * alright add the HttpPost item otherwise set return_value accordingly */ + + post = NULL; + for(form = first_form; + form != NULL; + form = form->more) { + if ( ((!form->name || !form->value) && !post) || + ( (form->contentslength) && + (form->flags & HTTPPOST_FILENAME) ) || + ( (form->flags & HTTPPOST_FILENAME) && + (form->flags & HTTPPOST_PTRCONTENTS) ) || + + ( (!form->buffer) && + (form->flags & HTTPPOST_BUFFER) && + (form->flags & HTTPPOST_PTRBUFFER) ) || + + ( (form->flags & HTTPPOST_READFILE) && + (form->flags & HTTPPOST_PTRCONTENTS) ) + ) { + return_value = CURL_FORMADD_INCOMPLETE; + break; + } + else { + if ( ((form->flags & HTTPPOST_FILENAME) || + (form->flags & HTTPPOST_BUFFER)) && + !form->contenttype ) { + /* our contenttype is missing */ + form->contenttype + = strdup(ContentTypeForFilename(form->value, prevtype)); + if(!form->contenttype) { + return_value = CURL_FORMADD_MEMORY; + break; + } + form->contenttype_alloc = TRUE; + } + if ( !(form->flags & HTTPPOST_PTRNAME) && + (form == first_form) ) { + /* copy name (without strdup; possibly contains null characters) */ + form->name = memdup(form->name, form->namelength); + if (!form->name) { + return_value = CURL_FORMADD_MEMORY; + break; + } + form->name_alloc = TRUE; + } + if ( !(form->flags & HTTPPOST_FILENAME) && + !(form->flags & HTTPPOST_READFILE) && + !(form->flags & HTTPPOST_PTRCONTENTS) && + !(form->flags & HTTPPOST_PTRBUFFER) ) { + /* copy value (without strdup; possibly contains null characters) */ + form->value = memdup(form->value, form->contentslength); + if (!form->value) { + return_value = CURL_FORMADD_MEMORY; + break; + } + form->value_alloc = TRUE; + } + post = AddHttpPost(form->name, form->namelength, + form->value, form->contentslength, + form->buffer, form->bufferlength, + form->contenttype, form->flags, + form->contentheader, form->showfilename, + post, httppost, + last_post); + + if(!post) { + return_value = CURL_FORMADD_MEMORY; + break; + } + + if (form->contenttype) + prevtype = form->contenttype; + } + } + } + + if(return_value) { + /* we return on error, free possibly allocated fields */ + if(!form) + form = current_form; + if(form) { + if(form->name_alloc) + free(form->name); + if(form->value_alloc) + free(form->value); + if(form->contenttype_alloc) + free(form->contenttype); + if(form->showfilename_alloc) + free(form->showfilename); + } + } + + /* always delete the allocated memory before returning */ + form = first_form; + while (form != NULL) { + FormInfo *delete_form; + + delete_form = form; + form = form->more; + free (delete_form); + } + + return return_value; +} + +/* + * curl_formadd() is a public API to add a section to the multipart formpost. + */ + +CURLFORMcode curl_formadd(struct curl_httppost **httppost, + struct curl_httppost **last_post, + ...) +{ + va_list arg; + CURLFORMcode result; + va_start(arg, last_post); + result = FormAdd(httppost, last_post, arg); + va_end(arg); + return result; +} + +/* + * AddFormData() adds a chunk of data to the FormData linked list. + * + * size is incremented by the chunk length, unless it is NULL + */ +static CURLcode AddFormData(struct FormData **formp, + enum formtype type, + const void *line, + size_t length, + curl_off_t *size) +{ + struct FormData *newform = (struct FormData *) + malloc(sizeof(struct FormData)); + if (!newform) + return CURLE_OUT_OF_MEMORY; + newform->next = NULL; + + /* we make it easier for plain strings: */ + if(!length) + length = strlen((char *)line); + + newform->line = (char *)malloc(length+1); + if (!newform->line) { + free(newform); + return CURLE_OUT_OF_MEMORY; + } + memcpy(newform->line, line, length); + newform->length = length; + newform->line[length]=0; /* zero terminate for easier debugging */ + newform->type = type; + + if(*formp) { + (*formp)->next = newform; + *formp = newform; + } + else + *formp = newform; + + if (size) { + if(type == FORM_DATA) + *size += length; + else { + /* Since this is a file to be uploaded here, add the size of the actual + file */ + if(!strequal("-", newform->line)) { + struct stat file; + if(!stat(newform->line, &file)) { + *size += file.st_size; + } + } + } + } + return CURLE_OK; +} + +/* + * AddFormDataf() adds printf()-style formatted data to the formdata chain. + */ + +static CURLcode AddFormDataf(struct FormData **formp, + curl_off_t *size, + const char *fmt, ...) +{ + char s[4096]; + va_list ap; + va_start(ap, fmt); + vsnprintf(s, sizeof(s), fmt, ap); + va_end(ap); + + return AddFormData(formp, FORM_DATA, s, 0, size); +} + +/* + * Curl_formclean() is used from http.c, this cleans a built FormData linked + * list + */ +void Curl_formclean(struct FormData *form) +{ + struct FormData *next; + + if(!form) + return; + + do { + next=form->next; /* the following form line */ + free(form->line); /* free the line */ + free(form); /* free the struct */ + + } while((form=next)); /* continue */ +} + +/* + * curl_formfree() is an external function to free up a whole form post + * chain + */ +void curl_formfree(struct curl_httppost *form) +{ + struct curl_httppost *next; + + if(!form) + /* no form to free, just get out of this */ + return; + + do { + next=form->next; /* the following form line */ + + /* recurse to sub-contents */ + if(form->more) + curl_formfree(form->more); + + if( !(form->flags & HTTPPOST_PTRNAME) && form->name) + free(form->name); /* free the name */ + if( !(form->flags & HTTPPOST_PTRCONTENTS) && form->contents) + free(form->contents); /* free the contents */ + if(form->contenttype) + free(form->contenttype); /* free the content type */ + if(form->showfilename) + free(form->showfilename); /* free the faked file name */ + free(form); /* free the struct */ + + } while((form=next)); /* continue */ +} + +/* + * Curl_getFormData() converts a linked list of "meta data" into a complete + * (possibly huge) multipart formdata. The input list is in 'post', while the + * output resulting linked lists gets stored in '*finalform'. *sizep will get + * the total size of the whole POST. + */ + +CURLcode Curl_getFormData(struct FormData **finalform, + struct curl_httppost *post, + curl_off_t *sizep) +{ + struct FormData *form = NULL; + struct FormData *firstform; + struct curl_httppost *file; + CURLcode result = CURLE_OK; + + curl_off_t size=0; /* support potentially ENORMOUS formposts */ + char *boundary; + char *fileboundary=NULL; + struct curl_slist* curList; + + *finalform=NULL; /* default form is empty */ + + if(!post) + return result; /* no input => no output! */ + + boundary = Curl_FormBoundary(); + if(!boundary) + return CURLE_OUT_OF_MEMORY; + + /* Make the first line of the output */ + result = AddFormDataf(&form, NULL, + "Content-Type: multipart/form-data;" + " boundary=%s\r\n", + boundary); + if (result) { + free(boundary); + return result; + } + /* we DO NOT include that line in the total size of the POST, since it'll be + part of the header! */ + + firstform = form; + + do { + + if(size) { + result = AddFormDataf(&form, &size, "\r\n"); + if (result) + break; + } + + /* boundary */ + result = AddFormDataf(&form, &size, "--%s\r\n", boundary); + if (result) + break; + + result = AddFormDataf(&form, &size, + "Content-Disposition: form-data; name=\""); + if (result) + break; + + result = AddFormData(&form, FORM_DATA, post->name, post->namelength, + &size); + if (result) + break; + + result = AddFormDataf(&form, &size, "\""); + if (result) + break; + + if(post->more) { + /* If used, this is a link to more file names, we must then do + the magic to include several files with the same field name */ + + fileboundary = Curl_FormBoundary(); + + result = AddFormDataf(&form, &size, + "\r\nContent-Type: multipart/mixed," + " boundary=%s\r\n", + fileboundary); + if (result) + break; + } + + file = post; + + do { + + /* If 'showfilename' is set, that is a faked name passed on to us + to use to in the formpost. If that is not set, the actually used + local file name should be added. */ + + if(post->more) { + /* if multiple-file */ + result = AddFormDataf(&form, &size, + "\r\n--%s\r\nContent-Disposition: " + "attachment; filename=\"%s\"", + fileboundary, + (file->showfilename?file->showfilename: + file->contents)); + if (result) + break; + } + else if((post->flags & HTTPPOST_FILENAME) || + (post->flags & HTTPPOST_BUFFER)) { + + result = AddFormDataf(&form, &size, + "; filename=\"%s\"", + (post->showfilename?post->showfilename: + post->contents)); + if (result) + break; + } + + if(file->contenttype) { + /* we have a specified type */ + result = AddFormDataf(&form, &size, + "\r\nContent-Type: %s", + file->contenttype); + if (result) + break; + } + + curList = file->contentheader; + while( curList ) { + /* Process the additional headers specified for this form */ + result = AddFormDataf( &form, &size, "\r\n%s", curList->data ); + if (result) + break; + curList = curList->next; + } + if (result) { + Curl_formclean(firstform); + free(boundary); + return result; + } + +#if 0 + /* The header Content-Transfer-Encoding: seems to confuse some receivers + * (like the built-in PHP engine). While I can't see any reason why it + * should, I can just as well skip this to the benefit of the users who + * are using such confused receivers. + */ + + if(file->contenttype && + !checkprefix("text/", file->contenttype)) { + /* this is not a text content, mention our binary encoding */ + size += AddFormData(&form, "\r\nContent-Transfer-Encoding: binary", 0); + } +#endif + + result = AddFormDataf(&form, &size, "\r\n\r\n"); + if (result) + break; + + if((post->flags & HTTPPOST_FILENAME) || + (post->flags & HTTPPOST_READFILE)) { + /* we should include the contents from the specified file */ + FILE *fileread; + + fileread = strequal("-", file->contents)? + stdin:fopen(file->contents, "rb"); /* binary read for win32 */ + + /* + * VMS: This only allows for stream files on VMS. Stream files are + * OK, as are FIXED & VAR files WITHOUT implied CC For implied CC, + * every record needs to have a \n appended & 1 added to SIZE + */ + + if(fileread) { + if(fileread != stdin) { + /* close the file again */ + fclose(fileread); + /* add the file name only - for later reading from this */ + result = AddFormData(&form, FORM_FILE, file->contents, 0, &size); + } + else { + /* When uploading from stdin, we can't know the size of the file, + * thus must read the full file as before. We *could* use chunked + * transfer-encoding, but that only works for HTTP 1.1 and we + * can't be sure we work with such a server. + */ + size_t nread; + char buffer[512]; + while((nread = fread(buffer, 1, sizeof(buffer), fileread))) { + result = AddFormData(&form, FORM_DATA, buffer, nread, &size); + if (result) + break; + } + } + + if (result) { + Curl_formclean(firstform); + free(boundary); + return result; + } + + } + else { + Curl_formclean(firstform); + free(boundary); + *finalform = NULL; + return CURLE_READ_ERROR; + } + + } + else if (post->flags & HTTPPOST_BUFFER) { + /* include contents of buffer */ + result = AddFormData(&form, FORM_DATA, post->buffer, + post->bufferlength, &size); + if (result) + break; + } + + else { + /* include the contents we got */ + result = AddFormData(&form, FORM_DATA, post->contents, + post->contentslength, &size); + if (result) + break; + } + } while((file = file->more)); /* for each specified file for this field */ + if (result) { + Curl_formclean(firstform); + free(boundary); + return result; + } + + if(post->more) { + /* this was a multiple-file inclusion, make a termination file + boundary: */ + result = AddFormDataf(&form, &size, + "\r\n--%s--", + fileboundary); + free(fileboundary); + if (result) + break; + } + + } while((post=post->next)); /* for each field */ + if (result) { + Curl_formclean(firstform); + free(boundary); + return result; + } + + /* end-boundary for everything */ + result = AddFormDataf(&form, &size, + "\r\n--%s--\r\n", + boundary); + if (result) { + Curl_formclean(firstform); + free(boundary); + return result; + } + + *sizep = size; + + free(boundary); + + *finalform=firstform; + + return result; +} + +/* + * Curl_FormInit() inits the struct 'form' points to with the 'formdata' + * and resets the 'sent' counter. + */ +int Curl_FormInit(struct Form *form, struct FormData *formdata ) +{ + if(!formdata) + return 1; /* error */ + + form->data = formdata; + form->sent = 0; + form->fp = NULL; + + return 0; +} + +static size_t readfromfile(struct Form *form, char *buffer, size_t size) +{ + size_t nread; + if(!form->fp) { + /* this file hasn't yet been opened */ + form->fp = fopen(form->data->line, "rb"); /* b is for binary */ + if(!form->fp) + return -1; /* failure */ + } + nread = fread(buffer, 1, size, form->fp); + + if(nread != size) { + /* this is the last chunk form the file, move on */ + fclose(form->fp); + form->fp = NULL; + form->data = form->data->next; + } + + return nread; +} + +/* + * Curl_FormReader() is the fread() emulation function that will be used to + * deliver the formdata to the transfer loop and then sent away to the peer. + */ +size_t Curl_FormReader(char *buffer, + size_t size, + size_t nitems, + FILE *mydata) +{ + struct Form *form; + size_t wantedsize; + size_t gotsize = 0; + + form=(struct Form *)mydata; + + wantedsize = size * nitems; + + if(!form->data) + return 0; /* nothing, error, empty */ + + if(form->data->type == FORM_FILE) + return readfromfile(form, buffer, wantedsize); + + do { + + if( (form->data->length - form->sent ) > wantedsize - gotsize) { + + memcpy(buffer + gotsize , form->data->line + form->sent, + wantedsize - gotsize); + + form->sent += wantedsize-gotsize; + + return wantedsize; + } + + memcpy(buffer+gotsize, + form->data->line + form->sent, + (form->data->length - form->sent) ); + gotsize += form->data->length - form->sent; + + form->sent = 0; + + form->data = form->data->next; /* advance */ + + } while(form->data && (form->data->type == FORM_DATA)); + /* If we got an empty line and we have more data, we proceed to the next + line immediately to avoid returning zero before we've reached the end. + This is the bug reported November 22 1999 on curl 6.3. (Daniel) */ + + return gotsize; +} + +/* + * Curl_formpostheader() returns the first line of the formpost, the + * request-header part (which is not part of the request-body like the rest of + * the post). + */ +char *Curl_formpostheader(void *formp, size_t *len) +{ + char *header; + struct Form *form=(struct Form *)formp; + + if(!form->data) + return 0; /* nothing, ERROR! */ + + header = form->data->line; + *len = form->data->length; + + form->data = form->data->next; /* advance */ + + return header; +} + + +#ifdef _FORM_DEBUG +int FormAddTest(const char * errormsg, + struct curl_httppost **httppost, + struct curl_httppost **last_post, + ...) +{ + int result; + va_list arg; + va_start(arg, last_post); + if ((result = FormAdd(httppost, last_post, arg))) + fprintf (stderr, "ERROR doing FormAdd ret: %d action: %s\n", result, + errormsg); + va_end(arg); + return result; +} + + +int main() +{ + char name1[] = "simple_COPYCONTENTS"; + char name2[] = "COPYCONTENTS_+_CONTENTTYPE"; + char name3[] = "PTRNAME_+_NAMELENGTH_+_COPYNAME_+_CONTENTSLENGTH"; + char name4[] = "simple_PTRCONTENTS"; + char name5[] = "PTRCONTENTS_+_CONTENTSLENGTH"; + char name6[] = "PTRCONTENTS_+_CONTENTSLENGTH_+_CONTENTTYPE"; + char name7[] = "FILE1_+_CONTENTTYPE"; + char name8[] = "FILE1_+_FILE2"; + char name9[] = "FILE1_+_FILE2_+_FILE3"; + char name10[] = "ARRAY: FILE1_+_FILE2_+_FILE3"; + char name11[] = "FILECONTENT"; + char value1[] = "value for simple COPYCONTENTS"; + char value2[] = "value for COPYCONTENTS + CONTENTTYPE"; + char value3[] = "value for PTRNAME + NAMELENGTH + COPYNAME + CONTENTSLENGTH"; + char value4[] = "value for simple PTRCONTENTS"; + char value5[] = "value for PTRCONTENTS + CONTENTSLENGTH"; + char value6[] = "value for PTRCOTNENTS + CONTENTSLENGTH + CONTENTTYPE"; + char value7[] = "inet_ntoa_r.h"; + char value8[] = "Makefile.b32.resp"; + char type2[] = "image/gif"; + char type6[] = "text/plain"; + char type7[] = "text/html"; + int name3length = strlen(name3); + int value3length = strlen(value3); + int value5length = strlen(value4); + int value6length = strlen(value5); + int errors = 0; + int size; + size_t nread; + char buffer[4096]; + struct curl_httppost *httppost=NULL; + struct curl_httppost *last_post=NULL; + struct curl_forms forms[4]; + + struct FormData *form; + struct Form formread; + + if (FormAddTest("simple COPYCONTENTS test", &httppost, &last_post, + CURLFORM_COPYNAME, name1, CURLFORM_COPYCONTENTS, value1, + CURLFORM_END)) + ++errors; + if (FormAddTest("COPYCONTENTS + CONTENTTYPE test", &httppost, &last_post, + CURLFORM_COPYNAME, name2, CURLFORM_COPYCONTENTS, value2, + CURLFORM_CONTENTTYPE, type2, CURLFORM_END)) + ++errors; + /* make null character at start to check that contentslength works + correctly */ + name3[1] = '\0'; + value3[1] = '\0'; + if (FormAddTest("PTRNAME + NAMELENGTH + COPYNAME + CONTENTSLENGTH test", + &httppost, &last_post, + CURLFORM_PTRNAME, name3, CURLFORM_COPYCONTENTS, value3, + CURLFORM_CONTENTSLENGTH, value3length, + CURLFORM_NAMELENGTH, name3length, CURLFORM_END)) + ++errors; + if (FormAddTest("simple PTRCONTENTS test", &httppost, &last_post, + CURLFORM_COPYNAME, name4, CURLFORM_PTRCONTENTS, value4, + CURLFORM_END)) + ++errors; + /* make null character at start to check that contentslength works + correctly */ + value5[1] = '\0'; + if (FormAddTest("PTRCONTENTS + CONTENTSLENGTH test", &httppost, &last_post, + CURLFORM_COPYNAME, name5, CURLFORM_PTRCONTENTS, value5, + CURLFORM_CONTENTSLENGTH, value5length, CURLFORM_END)) + ++errors; + /* make null character at start to check that contentslength works + correctly */ + value6[1] = '\0'; + if (FormAddTest("PTRCONTENTS + CONTENTSLENGTH + CONTENTTYPE test", + &httppost, &last_post, + CURLFORM_COPYNAME, name6, CURLFORM_PTRCONTENTS, value6, + CURLFORM_CONTENTSLENGTH, value6length, + CURLFORM_CONTENTTYPE, type6, CURLFORM_END)) + ++errors; + if (FormAddTest("FILE + CONTENTTYPE test", &httppost, &last_post, + CURLFORM_COPYNAME, name7, CURLFORM_FILE, value7, + CURLFORM_CONTENTTYPE, type7, CURLFORM_END)) + ++errors; + if (FormAddTest("FILE1 + FILE2 test", &httppost, &last_post, + CURLFORM_COPYNAME, name8, CURLFORM_FILE, value7, + CURLFORM_FILE, value8, CURLFORM_END)) + ++errors; + if (FormAddTest("FILE1 + FILE2 + FILE3 test", &httppost, &last_post, + CURLFORM_COPYNAME, name9, CURLFORM_FILE, value7, + CURLFORM_FILE, value8, CURLFORM_FILE, value7, CURLFORM_END)) + ++errors; + forms[0].option = CURLFORM_FILE; + forms[0].value = value7; + forms[1].option = CURLFORM_FILE; + forms[1].value = value8; + forms[2].option = CURLFORM_FILE; + forms[2].value = value7; + forms[3].option = CURLFORM_END; + if (FormAddTest("FILE1 + FILE2 + FILE3 ARRAY test", &httppost, &last_post, + CURLFORM_COPYNAME, name10, CURLFORM_ARRAY, forms, + CURLFORM_END)) + ++errors; + if (FormAddTest("FILECONTENT test", &httppost, &last_post, + CURLFORM_COPYNAME, name11, CURLFORM_FILECONTENT, value7, + CURLFORM_END)) + ++errors; + + form=Curl_getFormData(httppost, &size); + + Curl_FormInit(&formread, form); + + do { + nread = Curl_FormReader(buffer, 1, sizeof(buffer), + (FILE *)&formread); + + if(-1 == nread) + break; + fwrite(buffer, nread, 1, stdout); + } while(1); + + fprintf(stdout, "size: %d\n", size); + if (errors) + fprintf(stdout, "\n==> %d Test(s) failed!\n", errors); + else + fprintf(stdout, "\nAll Tests seem to have worked (please check output)\n"); + + return 0; +} + +#endif + +#else /* CURL_DISABLE_HTTP */ +CURLFORMcode curl_formadd(struct curl_httppost **httppost, + struct curl_httppost **last_post, + ...) +{ + (void)httppost; + (void)last_post; + return CURL_FORMADD_DISABLED; +} + +void curl_formfree(struct curl_httppost *form) +{ + (void)form; + /* does nothing HTTP is disabled */ +} + +#endif /* CURL_DISABLE_HTTP */ + +/* + * Curl_FormBoundary() creates a suitable boundary string and returns an + * allocated one. This is also used by SSL-code so it must be present even + * if HTTP is disabled! + */ +char *Curl_FormBoundary(void) +{ + char *retstring; + static int randomizer=0; /* this is just so that two boundaries within + the same form won't be identical */ + size_t i; + + static char table16[]="abcdef0123456789"; + + retstring = (char *)malloc(BOUNDARY_LENGTH+1); + + if(!retstring) + return NULL; /* failed */ + + srand(time(NULL)+randomizer++); /* seed */ + + strcpy(retstring, "----------------------------"); + + for(i=strlen(retstring); i, et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: formdata.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +enum formtype { + FORM_DATA, /* regular data */ + FORM_FILE /* 'line' points to a file name we should read from */ +}; + +/* plain and simple linked list with lines to send */ +struct FormData { + struct FormData *next; + enum formtype type; + char *line; + size_t length; +}; + +struct Form { + struct FormData *data; /* current form line to send */ + size_t sent; /* number of bytes of the current line that has + already been sent in a previous invoke */ + FILE *fp; /* file to read from */ +}; + +/* used by FormAdd for temporary storage */ +typedef struct FormInfo { + char *name; + bool name_alloc; + size_t namelength; + char *value; + bool value_alloc; + size_t contentslength; + char *contenttype; + bool contenttype_alloc; + long flags; + char *buffer; /* pointer to existing buffer used for file upload */ + size_t bufferlength; + char *showfilename; /* The file name to show. If not set, the actual + file name will be used */ + bool showfilename_alloc; + struct curl_slist* contentheader; + struct FormInfo *more; +} FormInfo; + +int Curl_FormInit(struct Form *form, struct FormData *formdata ); + +CURLcode +Curl_getFormData(struct FormData **, + struct curl_httppost *post, + curl_off_t *size); + +/* fread() emulation */ +size_t Curl_FormReader(char *buffer, + size_t size, + size_t nitems, + FILE *mydata); + +/* + * Curl_formpostheader() returns the first line of the formpost, the + * request-header part (which is not part of the request-body like the rest of + * the post). + */ +char *Curl_formpostheader(void *formp, size_t *len); + +char *Curl_FormBoundary(void); + +void Curl_formclean(struct FormData *); + +#endif + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/ftp.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/ftp.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/ftp.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/ftp.c 2005-02-28 06:36:00.000000000 +0800 @@ -0,0 +1,2774 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: ftp.c,v 1.14 2005/02/27 22:36:00 andy Exp $ + ***************************************************************************/ + +#include "setup.h" + +#ifndef CURL_DISABLE_FTP +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_SYS_SELECT_H +#include +#endif + +#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__) + +#else /* some kind of unix */ +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#include +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_ARPA_INET_H +#include +#endif +#include +#ifdef HAVE_NETDB_H +#include +#endif +#ifdef VMS +#include +#include +#endif +#endif + +#if defined(WIN32) && defined(__GNUC__) || defined(__MINGW32__) +#include +#endif + +#if (defined(NETWARE) && defined(__NOVELL_LIBC__)) +#undef in_addr_t +#define in_addr_t unsigned long +#endif + +#include +#include "urldata.h" +#include "sendf.h" + +#include "if2ip.h" +#include "hostip.h" +#include "progress.h" +#include "transfer.h" +#include "escape.h" +#include "http.h" /* for HTTP proxy tunnel stuff */ +#include "ftp.h" + +#ifdef HAVE_KRB4 +#include "security.h" +#include "krb4.h" +#endif + +#include "strtoofft.h" +#include "strequal.h" +#include "ssluse.h" +#include "connect.h" +#include "strerror.h" +#include "curl_memory.h" +#include "inet_ntop.h" + +#if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL) +#include "inet_ntoa_r.h" +#endif + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +/* The last #include file should be: */ +#ifdef CURLDEBUG +#include "memdebug.h" +#endif + +#ifdef HAVE_NI_WITHSCOPEID +#define NIFLAGS NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID +#else +#define NIFLAGS NI_NUMERICHOST | NI_NUMERICSERV +#endif + +/* Local API functions */ +static CURLcode ftp_sendquote(struct connectdata *conn, + struct curl_slist *quote); +static CURLcode ftp_cwd(struct connectdata *conn, char *path); +static CURLcode ftp_mkd(struct connectdata *conn, char *path); +static CURLcode ftp_cwd_and_mkd(struct connectdata *conn, char *path); +static CURLcode ftp_quit(struct connectdata *conn); +static CURLcode ftp_3rdparty_pretransfer(struct connectdata *conn); +static CURLcode ftp_3rdparty_transfer(struct connectdata *conn); +static CURLcode ftp_regular_transfer(struct connectdata *conn); +static CURLcode ftp_3rdparty(struct connectdata *conn); + +/* easy-to-use macro: */ +#define FTPSENDF(x,y,z) if((result = Curl_ftpsendf(x,y,z))) return result + +static void freedirs(struct FTP *ftp) +{ + int i; + if(ftp->dirs) { + for (i=0; i < ftp->dirdepth; i++){ + if(ftp->dirs[i]) { + free(ftp->dirs[i]); + ftp->dirs[i]=NULL; + } + } + free(ftp->dirs); + ftp->dirs = NULL; + } + if(ftp->file) { + free(ftp->file); + ftp->file = NULL; + } +} + +/*********************************************************************** + * + * AllowServerConnect() + * + * When we've issue the PORT command, we have told the server to connect + * to us. This function will sit and wait here until the server has + * connected. + * + */ +static CURLcode AllowServerConnect(struct connectdata *conn) +{ + fd_set rdset; + struct timeval dt; + struct SessionHandle *data = conn->data; + curl_socket_t sock = conn->sock[SECONDARYSOCKET]; + struct timeval now = Curl_tvnow(); + long timespent = Curl_tvdiff(Curl_tvnow(), now)/1000; + long timeout = data->set.connecttimeout?data->set.connecttimeout: + (data->set.timeout?data->set.timeout: 0); + + FD_ZERO(&rdset); + + FD_SET(sock, &rdset); + + if(timeout) { + timeout -= timespent; + if(timeout<=0) { + failf(data, "Timed out before server could connect to us"); + return CURLE_OPERATION_TIMEDOUT; + } + } + + /* we give the server 60 seconds to connect to us, or a custom timeout */ + dt.tv_sec = (int)(timeout?timeout:60); + dt.tv_usec = 0; + + switch (select(sock+1, &rdset, NULL, NULL, &dt)) { + case -1: /* error */ + /* let's die here */ + failf(data, "Error while waiting for server connect"); + return CURLE_FTP_PORT_FAILED; + case 0: /* timeout */ + /* let's die here */ + failf(data, "Timeout while waiting for server connect"); + return CURLE_FTP_PORT_FAILED; + default: + /* we have received data here */ + { + curl_socket_t s; +#ifdef __hpux + int size = sizeof(struct sockaddr_in); +#else + socklen_t size = sizeof(struct sockaddr_in); +#endif + struct sockaddr_in add; + + getsockname(sock, (struct sockaddr *) &add, &size); + s=accept(sock, (struct sockaddr *) &add, &size); + + sclose(sock); /* close the first socket */ + + if (CURL_SOCKET_BAD == s) { + /* DIE! */ + failf(data, "Error accept()ing server connect"); + return CURLE_FTP_PORT_FAILED; + } + infof(data, "Connection accepted from server\n"); + + conn->sock[SECONDARYSOCKET] = s; + Curl_nonblock(s, TRUE); /* enable non-blocking */ + } + break; + } + + return CURLE_OK; +} + + +/* --- parse FTP server responses --- */ + +/* + * Curl_GetFTPResponse() is supposed to be invoked after each command sent to + * a remote FTP server. This function will wait and read all lines of the + * response and extract the relevant return code for the invoking function. + */ + +CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */ + struct connectdata *conn, + int *ftpcode) /* return the ftp-code */ +{ + /* Brand new implementation. + * We cannot read just one byte per read() and then go back to select() + * as it seems that the OpenSSL read() stuff doesn't grok that properly. + * + * Alas, read as much as possible, split up into lines, use the ending + * line in a response or continue reading. */ + + curl_socket_t sockfd = conn->sock[FIRSTSOCKET]; + int perline; /* count bytes per line */ + bool keepon=TRUE; + ssize_t gotbytes; + char *ptr; + long timeout; /* timeout in seconds */ + struct timeval interval; + fd_set rkeepfd; + fd_set readfd; + struct SessionHandle *data = conn->data; + char *line_start; + int code=0; /* default ftp "error code" to return */ + char *buf = data->state.buffer; + CURLcode result = CURLE_OK; + struct FTP *ftp = conn->proto.ftp; + struct timeval now = Curl_tvnow(); + + if (ftpcode) + *ftpcode = 0; /* 0 for errors */ + + FD_ZERO (&readfd); /* clear it */ + FD_SET (sockfd, &readfd); /* read socket */ + + /* get this in a backup variable to be able to restore it on each lap in the + select() loop */ + rkeepfd = readfd; + + ptr=buf; + line_start = buf; + + *nreadp=0; + perline=0; + + while((*nreadpset.ftp_response_timeout ) + /* if CURLOPT_FTP_RESPONSE_TIMEOUT is set, use that to determine + remaining time. Also, use "now" as opposed to "conn->now" + because ftp_response_timeout is only supposed to govern + the response for any given ftp response, not for the time + from connect to the given ftp response. */ + timeout = data->set.ftp_response_timeout - /* timeout time */ + Curl_tvdiff(Curl_tvnow(), now)/1000; /* spent time */ + else if(data->set.timeout) + /* if timeout is requested, find out how much remaining time we have */ + timeout = data->set.timeout - /* timeout time */ + Curl_tvdiff(Curl_tvnow(), conn->now)/1000; /* spent time */ + else + /* Even without a requested timeout, we only wait response_time + seconds for the full response to arrive before we bail out */ + timeout = ftp->response_time - + Curl_tvdiff(Curl_tvnow(), now)/1000; /* spent time */ + + if(timeout <=0 ) { + failf(data, "FTP response timeout"); + return CURLE_OPERATION_TIMEDOUT; /* already too little time */ + } + + if(!ftp->cache) { + readfd = rkeepfd; /* set every lap */ + interval.tv_sec = 1; /* use 1 second timeout intervals */ + interval.tv_usec = 0; + + switch (select (sockfd+1, &readfd, NULL, NULL, &interval)) { + case -1: /* select() error, stop reading */ + result = CURLE_RECV_ERROR; + failf(data, "FTP response aborted due to select() error: %d", errno); + break; + case 0: /* timeout */ + if(Curl_pgrsUpdate(conn)) + return CURLE_ABORTED_BY_CALLBACK; + continue; /* just continue in our loop for the timeout duration */ + + default: + break; + } + } + if(CURLE_OK == result) { + /* + * This code previously didn't use the kerberos sec_read() code + * to read, but when we use Curl_read() it may do so. Do confirm + * that this is still ok and then remove this comment! + */ + if(ftp->cache) { + /* we had data in the "cache", copy that instead of doing an actual + * read + * + * Dave Meyer, December 2003: + * ftp->cache_size is cast to int here. This should be safe, + * because it would have been populated with something of size + * int to begin with, even though its datatype may be larger + * than an int. + */ + memcpy(ptr, ftp->cache, (int)ftp->cache_size); + gotbytes = (int)ftp->cache_size; + free(ftp->cache); /* free the cache */ + ftp->cache = NULL; /* clear the pointer */ + ftp->cache_size = 0; /* zero the size just in case */ + } + else { + int res = Curl_read(conn, sockfd, ptr, BUFSIZE-*nreadp, &gotbytes); + if(res < 0) + /* EWOULDBLOCK */ + continue; /* go looping again */ + + if(CURLE_OK != res) + keepon = FALSE; + } + + if(!keepon) + ; + else if(gotbytes <= 0) { + keepon = FALSE; + result = CURLE_RECV_ERROR; + failf(data, "FTP response reading failed"); + } + else { + /* we got a whole chunk of data, which can be anything from one + * byte to a set of lines and possible just a piece of the last + * line */ + int i; + + conn->headerbytecount += gotbytes; + + *nreadp += gotbytes; + for(i = 0; i < gotbytes; ptr++, i++) { + perline++; + if(*ptr=='\n') { + /* a newline is CRLF in ftp-talk, so the CR is ignored as + the line isn't really terminated until the LF comes */ + + /* output debug output if that is requested */ + if(data->set.verbose) + Curl_debug(data, CURLINFO_HEADER_IN, line_start, perline, conn->host.dispname); + + /* + * We pass all response-lines to the callback function registered + * for "headers". The response lines can be seen as a kind of + * headers. + */ + result = Curl_client_write(data, CLIENTWRITE_HEADER, + line_start, perline); + if(result) + return result; + +#define lastline(line) (isdigit((int)line[0]) && isdigit((int)line[1]) && \ + isdigit((int)line[2]) && (' ' == line[3])) + + if(perline>3 && lastline(line_start)) { + /* This is the end of the last line, copy the last + * line to the start of the buffer and zero terminate, + * for old times sake (and krb4)! */ + char *meow; + int n; + for(meow=line_start, n=0; meowcache_size = gotbytes - i; + ftp->cache = (char *)malloc((int)ftp->cache_size); + if(ftp->cache) + memcpy(ftp->cache, line_start, (int)ftp->cache_size); + else + return CURLE_OUT_OF_MEMORY; /**BANG**/ + } + } /* there was data */ + } /* if(no error) */ + } /* while there's buffer left and loop is requested */ + + if(!result) + code = atoi(buf); + +#ifdef HAVE_KRB4 + /* handle the security-oriented responses 6xx ***/ + /* FIXME: some errorchecking perhaps... ***/ + switch(code) { + case 631: + Curl_sec_read_msg(conn, buf, prot_safe); + break; + case 632: + Curl_sec_read_msg(conn, buf, prot_private); + break; + case 633: + Curl_sec_read_msg(conn, buf, prot_confidential); + break; + default: + /* normal ftp stuff we pass through! */ + break; + } +#endif + + if(ftpcode) + *ftpcode=code; /* return the initial number like this */ + + /* store the latest code for later retrieval */ + conn->data->info.httpcode=code; + + return result; +} + +static const char *ftpauth[]= { + "SSL", "TLS", NULL +}; + +/* + * Curl_ftp_connect() should do everything that is to be considered a part of + * the connection phase. + */ +CURLcode Curl_ftp_connect(struct connectdata *conn) +{ + /* this is FTP and no proxy */ + ssize_t nread; + struct SessionHandle *data=conn->data; + char *buf = data->state.buffer; /* this is our buffer */ + struct FTP *ftp; + CURLcode result; + int ftpcode, try; + + ftp = (struct FTP *)malloc(sizeof(struct FTP)); + if(!ftp) + return CURLE_OUT_OF_MEMORY; + + memset(ftp, 0, sizeof(struct FTP)); + conn->proto.ftp = ftp; + + /* We always support persistant connections on ftp */ + conn->bits.close = FALSE; + + /* get some initial data into the ftp struct */ + ftp->bytecountp = &conn->bytecount; + + /* no need to duplicate them, this connectdata struct won't change */ + ftp->user = conn->user; + ftp->passwd = conn->passwd; + ftp->response_time = 3600; /* set default response time-out */ + +#ifndef CURL_DISABLE_HTTP + if (conn->bits.tunnel_proxy) { + /* We want "seamless" FTP operations through HTTP proxy tunnel */ + result = Curl_ConnectHTTPProxyTunnel(conn, FIRSTSOCKET, + conn->host.name, conn->remote_port); + if(CURLE_OK != result) + return result; + } +#endif /* CURL_DISABLE_HTTP */ + + if(conn->protocol & PROT_FTPS) { + /* FTPS is simply ftp with SSL for the control channel */ + /* now, perform the SSL initialization for this socket */ + result = Curl_SSLConnect(conn, FIRSTSOCKET); + if(result) + return result; + } + + /* The first thing we do is wait for the "220*" line: */ + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + if(result) + return result; + + if(ftpcode != 220) { + failf(data, "This doesn't seem like a nice ftp-server response"); + return CURLE_FTP_WEIRD_SERVER_REPLY; + } + +#ifdef HAVE_KRB4 + /* if not anonymous login, try a secure login */ + if(data->set.krb4) { + + /* request data protection level (default is 'clear') */ + Curl_sec_request_prot(conn, "private"); + + /* We set private first as default, in case the line below fails to + set a valid level */ + Curl_sec_request_prot(conn, data->set.krb4_level); + + if(Curl_sec_login(conn) != 0) + infof(data, "Logging in with password in cleartext!\n"); + else + infof(data, "Authentication successful\n"); + } +#endif + + if(data->set.ftp_ssl && !conn->ssl[FIRSTSOCKET].use) { + /* we don't have a SSL/TLS connection, try a FTPS connection now */ + + for (try = 0; ftpauth[try]; try++) { + + FTPSENDF(conn, "AUTH %s", ftpauth[try]); + + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + + if(result) + return result; + + /* RFC2228 (page 5) says: + * + * If the server is willing to accept the named security mechanism, and + * does not require any security data, it must respond with reply code + * 234/334. + */ + + if((ftpcode == 234) || (ftpcode == 334)) { + result = Curl_SSLConnect(conn, FIRSTSOCKET); + if(result) + return result; + conn->protocol |= PROT_FTPS; + conn->ssl[SECONDARYSOCKET].use = FALSE; /* clear-text data */ + break; + } + } + } + + /* send USER */ + FTPSENDF(conn, "USER %s", ftp->user?ftp->user:""); + + /* wait for feedback */ + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + if(result) + return result; + + if(ftpcode == 530) { + /* 530 User ... access denied + (the server denies to log the specified user) */ + failf(data, "Access denied: %s", &buf[4]); + return CURLE_FTP_ACCESS_DENIED; + } + else if(ftpcode == 331) { + /* 331 Password required for ... + (the server requires to send the user's password too) */ + FTPSENDF(conn, "PASS %s", ftp->passwd?ftp->passwd:""); + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + if(result) + return result; + + if(ftpcode == 530) { + /* 530 Login incorrect. + (the username and/or the password are incorrect) */ + failf(data, "the username and/or the password are incorrect"); + return CURLE_FTP_USER_PASSWORD_INCORRECT; + } + else if(ftpcode == 230) { + /* 230 User ... logged in. + (user successfully logged in) */ + + infof(data, "We have successfully logged in\n"); + } + else { + failf(data, "Odd return code after PASS"); + return CURLE_FTP_WEIRD_PASS_REPLY; + } + } + else if(buf[0] == '2') { + /* 230 User ... logged in. + (the user logged in without password) */ + infof(data, "We have successfully logged in\n"); + if (conn->ssl[FIRSTSOCKET].use) { +#ifdef HAVE_KRB4 + /* We are logged in with Kerberos, now set the requested protection + * level + */ + if(conn->sec_complete) + Curl_sec_set_protection_level(conn); + + /* We may need to issue a KAUTH here to have access to the files + * do it if user supplied a password + */ + if(conn->passwd && *conn->passwd) { + result = Curl_krb_kauth(conn); + if(result) + return result; + } +#endif + } + } + else { + failf(data, "Odd return code after USER"); + return CURLE_FTP_WEIRD_USER_REPLY; + } + + if(conn->ssl[FIRSTSOCKET].use) { + /* PBSZ = PROTECTION BUFFER SIZE. + + The 'draft-murray-auth-ftp-ssl' (draft 12, page 7) says: + + Specifically, the PROT command MUST be preceded by a PBSZ command + and a PBSZ command MUST be preceded by a successful security data + exchange (the TLS negotiation in this case) + + ... (and on page 8): + + Thus the PBSZ command must still be issued, but must have a parameter + of '0' to indicate that no buffering is taking place and the data + connection should not be encapsulated. + */ + FTPSENDF(conn, "PBSZ %d", 0); + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + if(result) + return result; + + /* For TLS, the data connection can have one of two security levels. + + 1)Clear (requested by 'PROT C') + + 2)Private (requested by 'PROT P') + */ + if(!conn->ssl[SECONDARYSOCKET].use) { + FTPSENDF(conn, "PROT %c", 'P'); + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + if(result) + return result; + + if(ftpcode == 200) + /* We have enabled SSL for the data connection! */ + conn->ssl[SECONDARYSOCKET].use = TRUE; + + /* FTP servers typically responds with 500 if they decide to reject + our 'P' request */ + } + } + + /* send PWD to discover our entry point */ + FTPSENDF(conn, "PWD", NULL); + + /* wait for feedback */ + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + if(result) + return result; + + if(ftpcode == 257) { + char *dir = (char *)malloc(nread+1); + char *store=dir; + char *ptr=&buf[4]; /* start on the first letter */ + + if(!dir) + return CURLE_OUT_OF_MEMORY; + + /* Reply format is like + 257"" and the RFC959 says + + The directory name can contain any character; embedded double-quotes + should be escaped by double-quotes (the "quote-doubling" convention). + */ + if('\"' == *ptr) { + /* it started good */ + ptr++; + while(ptr && *ptr) { + if('\"' == *ptr) { + if('\"' == ptr[1]) { + /* "quote-doubling" */ + *store = ptr[1]; + ptr++; + } + else { + /* end of path */ + *store = '\0'; /* zero terminate */ + break; /* get out of this loop */ + } + } + else + *store = *ptr; + store++; + ptr++; + } + ftp->entrypath =dir; /* remember this */ + infof(data, "Entry path is '%s'\n", ftp->entrypath); + } + else { + /* couldn't get the path */ + free(dir); + infof(data, "Failed to figure out path\n"); + } + + } + else { + /* We couldn't read the PWD response! */ + } + + return CURLE_OK; +} + +/*********************************************************************** + * + * Curl_ftp_done() + * + * The DONE function. This does what needs to be done after a single DO has + * performed. + * + * Input argument is already checked for validity. + */ +CURLcode Curl_ftp_done(struct connectdata *conn, CURLcode status) +{ + struct SessionHandle *data = conn->data; + struct FTP *ftp = conn->proto.ftp; + ssize_t nread; + int ftpcode; + CURLcode result=CURLE_OK; + + bool was_ctl_valid = ftp->ctl_valid; + + /* free the dir tree and file parts */ + freedirs(ftp); + + ftp->ctl_valid = FALSE; + + if(data->set.upload) { + if((-1 != data->set.infilesize) && + (data->set.infilesize != *ftp->bytecountp) && + !data->set.crlf) { + failf(data, "Uploaded unaligned file size (%" FORMAT_OFF_T + " out of %" FORMAT_OFF_T " bytes)", + *ftp->bytecountp, data->set.infilesize); + conn->bits.close = TRUE; /* close this connection since we don't + know what state this error leaves us in */ + return CURLE_PARTIAL_FILE; + } + } + else { + if((-1 != conn->size) && (conn->size != *ftp->bytecountp) && + (conn->maxdownload != *ftp->bytecountp)) { + failf(data, "Received only partial file: %" FORMAT_OFF_T " bytes", + *ftp->bytecountp); + conn->bits.close = TRUE; /* close this connection since we don't + know what state this error leaves us in */ + return CURLE_PARTIAL_FILE; + } + else if(!ftp->dont_check && + !*ftp->bytecountp && + (conn->size>0)) { + /* We consider this an error, but there's no true FTP error received + why we need to continue to "read out" the server response too. + We don't want to leave a "waiting" server reply if we'll get told + to make a second request on this same connection! */ + failf(data, "No data was received!"); + result = CURLE_FTP_COULDNT_RETR_FILE; + } + } + + switch(status) { + case CURLE_BAD_DOWNLOAD_RESUME: + case CURLE_FTP_WEIRD_PASV_REPLY: + case CURLE_FTP_PORT_FAILED: + case CURLE_FTP_COULDNT_SET_BINARY: + case CURLE_FTP_COULDNT_RETR_FILE: + case CURLE_FTP_ACCESS_DENIED: + /* the connection stays alive fine even though this happened */ + /* fall-through */ + case CURLE_OK: /* doesn't affect the control connection's status */ + ftp->ctl_valid = was_ctl_valid; + break; + default: /* by default, an error means the control connection is + wedged and should not be used anymore */ + ftp->ctl_valid = FALSE; + break; + } + +#ifdef HAVE_KRB4 + Curl_sec_fflush_fd(conn, conn->sock[SECONDARYSOCKET]); +#endif + /* shut down the socket to inform the server we're done */ + sclose(conn->sock[SECONDARYSOCKET]); + conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD; + + if(!ftp->no_transfer && !status) { + /* Let's see what the server says about the transfer we just performed, + * but lower the timeout as sometimes this connection has died while the + * data has been transfered. This happens when doing through NATs etc that + * abandon old silent connections. + */ + ftp->response_time = 60; /* give it only a minute for now */ + + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + + ftp->response_time = 3600; /* set this back to one hour waits */ + + if(!nread && (CURLE_OPERATION_TIMEDOUT == result)) { + failf(data, "control connection looks dead"); + return result; + } + + if(result) + return result; + + if(!ftp->dont_check) { + /* 226 Transfer complete, 250 Requested file action okay, completed. */ + if((ftpcode != 226) && (ftpcode != 250)) { + failf(data, "server did not report OK, got %d", ftpcode); + return CURLE_FTP_WRITE_ERROR; + } + } + } + + /* clear these for next connection */ + ftp->no_transfer = FALSE; + ftp->dont_check = FALSE; + + if (!result && conn->sec_conn) { /* 3rd party transfer */ + /* "done" with the secondary connection */ + result = Curl_ftp_done(conn->sec_conn, status); + } + + /* Send any post-transfer QUOTE strings? */ + if(!status && !result && data->set.postquote) + result = ftp_sendquote(conn, data->set.postquote); + + return result; +} + +/*********************************************************************** + * + * ftp_sendquote() + * + * Where a 'quote' means a list of custom commands to send to the server. + * The quote list is passed as an argument. + */ + +static +CURLcode ftp_sendquote(struct connectdata *conn, struct curl_slist *quote) +{ + struct curl_slist *item; + ssize_t nread; + int ftpcode; + CURLcode result; + + item = quote; + while (item) { + if (item->data) { + FTPSENDF(conn, "%s", item->data); + + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + if (result) + return result; + + if (ftpcode >= 400) { + failf(conn->data, "QUOT string not accepted: %s", item->data); + return CURLE_FTP_QUOTE_ERROR; + } + } + + item = item->next; + } + + return CURLE_OK; +} + +/*********************************************************************** + * + * ftp_getfiletime() + * + * Get the timestamp of the given file. + */ +static +CURLcode ftp_getfiletime(struct connectdata *conn, char *file) +{ + CURLcode result; + int ftpcode; /* for ftp status */ + ssize_t nread; + char *buf = conn->data->state.buffer; + + /* we have requested to get the modified-time of the file, this is yet + again a grey area as the MDTM is not kosher RFC959 */ + FTPSENDF(conn, "MDTM %s", file); + + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + if(result) + return result; + + switch(ftpcode) { + case 213: + { + /* we got a time. Format should be: "YYYYMMDDHHMMSS[.sss]" where the + last .sss part is optional and means fractions of a second */ + int year, month, day, hour, minute, second; + if(6 == sscanf(buf+4, "%04d%02d%02d%02d%02d%02d", + &year, &month, &day, &hour, &minute, &second)) { + /* we have a time, reformat it */ + time_t secs=time(NULL); + snprintf(buf, sizeof(conn->data->state.buffer), + "%04d%02d%02d %02d:%02d:%02d GMT", + year, month, day, hour, minute, second); + /* now, convert this into a time() value: */ + conn->data->info.filetime = curl_getdate(buf, &secs); + } + } + break; + default: + infof(conn->data, "unsupported MDTM reply format\n"); + break; + case 550: /* "No such file or directory" */ + failf(conn->data, "Given file does not exist"); + result = CURLE_FTP_COULDNT_RETR_FILE; + break; + } + return result; +} + +/*********************************************************************** + * + * ftp_transfertype() + * + * Set transfer type. We only deal with ASCII or BINARY so this function + * sets one of them. + */ +static CURLcode ftp_transfertype(struct connectdata *conn, + bool ascii) +{ + struct SessionHandle *data = conn->data; + int ftpcode; + ssize_t nread; + CURLcode result; + + FTPSENDF(conn, "TYPE %s", ascii?"A":"I"); + + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + if(result) + return result; + + if(ftpcode != 200) { + failf(data, "Couldn't set %s mode", + ascii?"ASCII":"binary"); + return ascii? CURLE_FTP_COULDNT_SET_ASCII:CURLE_FTP_COULDNT_SET_BINARY; + } + + return CURLE_OK; +} + +/*********************************************************************** + * + * ftp_getsize() + * + * Returns the file size (in bytes) of the given remote file. + */ + +static +CURLcode ftp_getsize(struct connectdata *conn, char *file, + curl_off_t *size) +{ + struct SessionHandle *data = conn->data; + int ftpcode; + ssize_t nread; + char *buf=data->state.buffer; + CURLcode result; + + FTPSENDF(conn, "SIZE %s", file); + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + if(result) + return result; + + if(ftpcode == 213) { + /* get the size from the ascii string: */ + *size = curlx_strtoofft(buf+4, NULL, 0); + } + else + return CURLE_FTP_COULDNT_GET_SIZE; + + return CURLE_OK; +} + +/*************************************************************************** + * + * ftp_pasv_verbose() + * + * This function only outputs some informationals about this second connection + * when we've issued a PASV command before and thus we have connected to a + * possibly new IP address. + * + */ +static void +ftp_pasv_verbose(struct connectdata *conn, + Curl_addrinfo *ai, + char *newhost, /* ascii version */ + int port) +{ + char buf[256]; + Curl_printable_address(ai, buf, sizeof(buf)); + infof(conn->data, "Connecting to %s (%s) port %d\n", newhost, buf, port); +} + +/*********************************************************************** + * + * ftp_use_port() + * + * Send the proper PORT command. PORT is the ftp client's way of telling the + * server that *WE* open a port that we listen on an awaits the server to + * connect to. This is the opposite of PASV. + */ + +static +CURLcode ftp_use_port(struct connectdata *conn) +{ + struct SessionHandle *data=conn->data; + curl_socket_t portsock; + ssize_t nread; + int ftpcode; /* receive FTP response codes in this */ + CURLcode result; + +#ifdef ENABLE_IPV6 + /****************************************************************** + * + * Here's a piece of IPv6-specific code coming up + * + */ + + struct addrinfo hints, *res, *ai; + struct sockaddr_storage ss; + socklen_t sslen; + char hbuf[NI_MAXHOST]; + + struct sockaddr *sa=(struct sockaddr *)&ss; + unsigned char *ap; + unsigned char *pp; + char portmsgbuf[1024], tmp[1024]; + + const char *mode[] = { "EPRT", "LPRT", "PORT", NULL }; + char **modep; + int rc; + int error; + + /* + * we should use Curl_if2ip? given pickiness of recent ftpd, + * I believe we should use the same address as the control connection. + */ + sslen = sizeof(ss); + rc = getsockname(conn->sock[FIRSTSOCKET], (struct sockaddr *)&ss, &sslen); + if(rc < 0) { + failf(data, "getsockname() returned %d\n", rc); + return CURLE_FTP_PORT_FAILED; + } + + rc = getnameinfo((struct sockaddr *)&ss, sslen, hbuf, sizeof(hbuf), NULL, 0, + NIFLAGS); + if(rc) { + failf(data, "getnameinfo() returned %d\n", rc); + return CURLE_FTP_PORT_FAILED; + } + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = sa->sa_family; + /*hints.ai_family = ss.ss_family; + this way can be used if sockaddr_storage is properly defined, as glibc + 2.1.X doesn't do*/ + hints.ai_socktype = SOCK_STREAM; + hints.ai_flags = AI_PASSIVE; + + rc = getaddrinfo(hbuf, NULL, &hints, &res); + if(rc) { + failf(data, "getaddrinfo() returned %d\n", rc); + return CURLE_FTP_PORT_FAILED; + } + + portsock = CURL_SOCKET_BAD; + error = 0; + for (ai = res; ai; ai = ai->ai_next) { + /* + * Workaround for AIX5 getaddrinfo() problem (it doesn't set ai_socktype): + */ + if (ai->ai_socktype == 0) + ai->ai_socktype = hints.ai_socktype; + + portsock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); + if (portsock == CURL_SOCKET_BAD) { + error = Curl_ourerrno(); + continue; + } + + if (bind(portsock, ai->ai_addr, ai->ai_addrlen) < 0) { + error = Curl_ourerrno(); + sclose(portsock); + portsock = CURL_SOCKET_BAD; + continue; + } + + if (listen(portsock, 1) < 0) { + error = Curl_ourerrno(); + sclose(portsock); + portsock = CURL_SOCKET_BAD; + continue; + } + + break; + } + freeaddrinfo(res); + if (portsock == CURL_SOCKET_BAD) { + failf(data, "%s", Curl_strerror(conn,error)); + return CURLE_FTP_PORT_FAILED; + } + + sslen = sizeof(ss); + if (getsockname(portsock, sa, &sslen) < 0) { + failf(data, "%s", Curl_strerror(conn,Curl_ourerrno())); + return CURLE_FTP_PORT_FAILED; + } + + for (modep = (char **)(data->set.ftp_use_eprt?&mode[0]:&mode[2]); + modep && *modep; modep++) { + int lprtaf, eprtaf; + int alen=0, plen=0; + + switch (sa->sa_family) { + case AF_INET: + ap = (unsigned char *)&((struct sockaddr_in *)&ss)->sin_addr; + alen = sizeof(((struct sockaddr_in *)&ss)->sin_addr); + pp = (unsigned char *)&((struct sockaddr_in *)&ss)->sin_port; + plen = sizeof(((struct sockaddr_in *)&ss)->sin_port); + lprtaf = 4; + eprtaf = 1; + break; + case AF_INET6: + ap = (unsigned char *)&((struct sockaddr_in6 *)&ss)->sin6_addr; + alen = sizeof(((struct sockaddr_in6 *)&ss)->sin6_addr); + pp = (unsigned char *)&((struct sockaddr_in6 *)&ss)->sin6_port; + plen = sizeof(((struct sockaddr_in6 *)&ss)->sin6_port); + lprtaf = 6; + eprtaf = 2; + break; + default: + ap = pp = NULL; + lprtaf = eprtaf = -1; + break; + } + + if (strcmp(*modep, "EPRT") == 0) { + if (eprtaf < 0) + continue; + if (getnameinfo((struct sockaddr *)&ss, sslen, + portmsgbuf, sizeof(portmsgbuf), tmp, sizeof(tmp), + NIFLAGS)) + continue; + + /* do not transmit IPv6 scope identifier to the wire */ + if (sa->sa_family == AF_INET6) { + char *q = strchr(portmsgbuf, '%'); + if (q) + *q = '\0'; + } + + result = Curl_ftpsendf(conn, "%s |%d|%s|%s|", *modep, eprtaf, + portmsgbuf, tmp); + if(result) + return result; + } + else if (strcmp(*modep, "LPRT") == 0 || + strcmp(*modep, "PORT") == 0) { + int i; + + if (strcmp(*modep, "LPRT") == 0 && lprtaf < 0) + continue; + if (strcmp(*modep, "PORT") == 0 && sa->sa_family != AF_INET) + continue; + + portmsgbuf[0] = '\0'; + if (strcmp(*modep, "LPRT") == 0) { + snprintf(tmp, sizeof(tmp), "%d,%d", lprtaf, alen); + if (strlcat(portmsgbuf, tmp, sizeof(portmsgbuf)) >= + sizeof(portmsgbuf)) { + continue; + } + } + + for (i = 0; i < alen; i++) { + if (portmsgbuf[0]) + snprintf(tmp, sizeof(tmp), ",%u", ap[i]); + else + snprintf(tmp, sizeof(tmp), "%u", ap[i]); + + if (strlcat(portmsgbuf, tmp, sizeof(portmsgbuf)) >= + sizeof(portmsgbuf)) { + continue; + } + } + + if (strcmp(*modep, "LPRT") == 0) { + snprintf(tmp, sizeof(tmp), ",%d", plen); + + if (strlcat(portmsgbuf, tmp, sizeof(portmsgbuf)) >= sizeof(portmsgbuf)) + continue; + } + + for (i = 0; i < plen; i++) { + snprintf(tmp, sizeof(tmp), ",%u", pp[i]); + + if (strlcat(portmsgbuf, tmp, sizeof(portmsgbuf)) >= + sizeof(portmsgbuf)) { + continue; + } + } + + result = Curl_ftpsendf(conn, "%s %s", *modep, portmsgbuf); + if(result) + return result; + } + + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + if(result) + return result; + + if (ftpcode != 200) { + continue; + } + else + break; + } + + if (!*modep) { + sclose(portsock); + failf(data, "PORT command attempts failed"); + return CURLE_FTP_PORT_FAILED; + } + /* we set the secondary socket variable to this for now, it + is only so that the cleanup function will close it in case + we fail before the true secondary stuff is made */ + conn->sock[SECONDARYSOCKET] = portsock; + +#else + /****************************************************************** + * + * Here's a piece of IPv4-specific code coming up + * + */ + struct sockaddr_in sa; + unsigned short porttouse; + char myhost[256] = ""; + bool sa_filled_in = FALSE; + Curl_addrinfo *addr = NULL; + unsigned short ip[4]; + + if(data->set.ftpport) { + in_addr_t in; + + /* First check if the given name is an IP address */ + in=inet_addr(data->set.ftpport); + + if(in != CURL_INADDR_NONE) + /* this is an IPv4 address */ + addr = Curl_ip2addr(in, data->set.ftpport, 0); + else { + if(Curl_if2ip(data->set.ftpport, myhost, sizeof(myhost))) { + /* The interface to IP conversion provided a dotted address */ + in=inet_addr(myhost); + addr = Curl_ip2addr(in, myhost, 0); + } + else if(strlen(data->set.ftpport)> 1) { + /* might be a host name! */ + struct Curl_dns_entry *h=NULL; + int rc = Curl_resolv(conn, myhost, 0, &h); + if(rc == CURLRESOLV_PENDING) + rc = Curl_wait_for_resolv(conn, &h); + (void)rc; + if(h) { + addr = h->addr; + /* when we return from this function, we can forget about this entry + to we can unlock it now already */ + Curl_resolv_unlock(data, h); + } /* (h) */ + } /* strlen */ + } /* CURL_INADDR_NONE */ + } /* data->set.ftpport */ + + if(!addr) { + /* pick a suitable default here */ + +#ifdef __hpux + int sslen; +#else + socklen_t sslen; +#endif + + sslen = sizeof(sa); + if (getsockname(conn->sock[FIRSTSOCKET], + (struct sockaddr *)&sa, &sslen) < 0) { + failf(data, "getsockname() failed"); + return CURLE_FTP_PORT_FAILED; + } + + sa_filled_in = TRUE; /* the sa struct is filled in */ + } + + if (addr || sa_filled_in) { + portsock = socket(AF_INET, SOCK_STREAM, 0); + if(CURL_SOCKET_BAD != portsock) { + socklen_t size; + + /* we set the secondary socket variable to this for now, it + is only so that the cleanup function will close it in case + we fail before the true secondary stuff is made */ + conn->sock[SECONDARYSOCKET] = portsock; + + if(!sa_filled_in) { + memcpy(&sa, addr->ai_addr, sizeof(sa)); + sa.sin_addr.s_addr = INADDR_ANY; + } + + sa.sin_port = 0; + size = sizeof(sa); + + if(bind(portsock, (struct sockaddr *)&sa, size) >= 0) { + /* we succeeded to bind */ + struct sockaddr_in add; +#ifdef __hpux + int socksize = sizeof(add); +#else + socklen_t socksize = sizeof(add); +#endif + + if(getsockname(portsock, (struct sockaddr *) &add, + &socksize)<0) { + failf(data, "getsockname() failed"); + return CURLE_FTP_PORT_FAILED; + } + porttouse = ntohs(add.sin_port); + + if ( listen(portsock, 1) < 0 ) { + failf(data, "listen(2) failed on socket"); + return CURLE_FTP_PORT_FAILED; + } + } + else { + failf(data, "bind(2) failed on socket"); + return CURLE_FTP_PORT_FAILED; + } + } + else { + failf(data, "socket(2) failed (%s)"); + return CURLE_FTP_PORT_FAILED; + } + } + else { + failf(data, "could't find IP address to use"); + return CURLE_FTP_PORT_FAILED; + } + + if(sa_filled_in) + Curl_inet_ntop(AF_INET, &((struct sockaddr_in *)&sa)->sin_addr, + myhost, sizeof(myhost)); + else + Curl_printable_address(addr, myhost, sizeof(myhost)); + + if(4 == sscanf(myhost, "%hu.%hu.%hu.%hu", + &ip[0], &ip[1], &ip[2], &ip[3])) { + + infof(data, "Telling server to connect to %d.%d.%d.%d:%d\n", + ip[0], ip[1], ip[2], ip[3], porttouse); + + result=Curl_ftpsendf(conn, "PORT %d,%d,%d,%d,%d,%d", + ip[0], ip[1], ip[2], ip[3], + porttouse >> 8, + porttouse & 255); + if(result) + return result; + + } + else + return CURLE_FTP_PORT_FAILED; + + Curl_freeaddrinfo(addr); + + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + if(result) + return result; + + if(ftpcode != 200) { + failf(data, "Server does not grok PORT, try without it!"); + return CURLE_FTP_PORT_FAILED; + } +#endif /* end of ipv4-specific code */ + + return CURLE_OK; +} + +/*********************************************************************** + * + * ftp_use_pasv() + * + * Send the PASV command. PASV is the ftp client's way of asking the server to + * open a second port that we can connect to (for the data transfer). This is + * the opposite of PORT. + */ + +static +CURLcode ftp_use_pasv(struct connectdata *conn, + bool *connected) +{ + struct SessionHandle *data = conn->data; + ssize_t nread; + char *buf = data->state.buffer; /* this is our buffer */ + int ftpcode; /* receive FTP response codes in this */ + CURLcode result; + struct Curl_dns_entry *addr=NULL; + Curl_addrinfo *conninfo; + int rc; + + /* + Here's the excecutive summary on what to do: + + PASV is RFC959, expect: + 227 Entering Passive Mode (a1,a2,a3,a4,p1,p2) + + LPSV is RFC1639, expect: + 228 Entering Long Passive Mode (4,4,a1,a2,a3,a4,2,p1,p2) + + EPSV is RFC2428, expect: + 229 Entering Extended Passive Mode (|||port|) + + */ + + const char *mode[] = { "EPSV", "PASV", NULL }; + int results[] = { 229, 227, 0 }; + int modeoff; + unsigned short connectport; /* the local port connect() should use! */ + unsigned short newport=0; /* remote port, not necessary the local one */ + + /* newhost must be able to hold a full IP-style address in ASCII, which + in the IPv6 case means 5*8-1 = 39 letters */ + char newhost[48]; + char *newhostp=NULL; + + for (modeoff = (data->set.ftp_use_epsv?0:1); + mode[modeoff]; modeoff++) { + result = Curl_ftpsendf(conn, "%s", mode[modeoff]); + if(result) + return result; + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + if(result) + return result; + if (ftpcode == results[modeoff]) + break; + } + + if (!mode[modeoff]) { + failf(data, "Odd return code after PASV"); + return CURLE_FTP_WEIRD_PASV_REPLY; + } + else if (227 == results[modeoff]) { + int ip[4]; + int port[2]; + char *str=buf; + + /* + * New 227-parser June 3rd 1999. + * It now scans for a sequence of six comma-separated numbers and + * will take them as IP+port indicators. + * + * Found reply-strings include: + * "227 Entering Passive Mode (127,0,0,1,4,51)" + * "227 Data transfer will passively listen to 127,0,0,1,4,51" + * "227 Entering passive mode. 127,0,0,1,4,51" + */ + + while(*str) { + if (6 == sscanf(str, "%d,%d,%d,%d,%d,%d", + &ip[0], &ip[1], &ip[2], &ip[3], + &port[0], &port[1])) + break; + str++; + } + + if(!*str) { + failf(data, "Couldn't interpret this 227-reply: %s", buf); + return CURLE_FTP_WEIRD_227_FORMAT; + } + + snprintf(newhost, sizeof(newhost), + "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); + newhostp = newhost; + newport = (port[0]<<8) + port[1]; + } + else if (229 == results[modeoff]) { + char *ptr = strchr(buf, '('); + if(ptr) { + unsigned int num; + char separator[4]; + ptr++; + if(5 == sscanf(ptr, "%c%c%c%u%c", + &separator[0], + &separator[1], + &separator[2], + &num, + &separator[3])) { + char sep1 = separator[0]; + int i; + + /* The four separators should be identical, or else this is an oddly + formatted reply and we bail out immediately. */ + for(i=1; i<4; i++) { + if(separator[i] != sep1) { + ptr=NULL; /* set to NULL to signal error */ + break; + } + } + if(ptr) { + newport = num; + + /* we should use the same host we already are connected to */ + newhostp = conn->host.name; + } + } + else + ptr=NULL; + } + if(!ptr) { + failf(data, "Weirdly formatted EPSV reply"); + return CURLE_FTP_WEIRD_PASV_REPLY; + } + } + else + return CURLE_FTP_CANT_RECONNECT; + + if(data->change.proxy && *data->change.proxy) { + /* + * This is a tunnel through a http proxy and we need to connect to the + * proxy again here. + * + * We don't want to rely on a former host lookup that might've expired + * now, instead we remake the lookup here and now! + */ + rc = Curl_resolv(conn, conn->proxy.name, (int)conn->port, &addr); + if(rc == CURLRESOLV_PENDING) + rc = Curl_wait_for_resolv(conn, &addr); + + connectport = + (unsigned short)conn->port; /* we connect to the proxy's port */ + + } + else { + /* normal, direct, ftp connection */ + rc = Curl_resolv(conn, newhostp, newport, &addr); + if(rc == CURLRESOLV_PENDING) + rc = Curl_wait_for_resolv(conn, &addr); + + if(!addr) { + failf(data, "Can't resolve new host %s:%d", newhostp, newport); + return CURLE_FTP_CANT_GET_HOST; + } + connectport = newport; /* we connect to the remote port */ + } + + result = Curl_connecthost(conn, + addr, + &conn->sock[SECONDARYSOCKET], + &conninfo, + connected); + + Curl_resolv_unlock(data, addr); /* we're done using this address */ + + if(result) + return result; + + /* + * When this is used from the multi interface, this might've returned with + * the 'connected' set to FALSE and thus we are now awaiting a non-blocking + * connect to connect and we should not be "hanging" here waiting. + */ + + if(data->set.verbose) + /* this just dumps information about this second connection */ + ftp_pasv_verbose(conn, conninfo, newhostp, connectport); + +#ifndef CURL_DISABLE_HTTP + if(conn->bits.tunnel_proxy) { + /* We want "seamless" FTP operations through HTTP proxy tunnel */ + result = Curl_ConnectHTTPProxyTunnel(conn, SECONDARYSOCKET, + newhostp, newport); + if(CURLE_OK != result) + return result; + } +#endif /* CURL_DISABLE_HTTP */ + + (void)rc; + return CURLE_OK; +} + +/* + * Curl_ftp_nextconnect() + * + * This function shall be called when the second FTP connection has been + * established and is confirmed connected. + */ + +CURLcode Curl_ftp_nextconnect(struct connectdata *conn) +{ + struct SessionHandle *data=conn->data; + char *buf = data->state.buffer; /* this is our buffer */ + CURLcode result; + ssize_t nread; + int ftpcode; /* for ftp status */ + + /* the ftp struct is already inited in Curl_ftp_connect() */ + struct FTP *ftp = conn->proto.ftp; + curl_off_t *bytecountp = ftp->bytecountp; + + if(data->set.upload) { + + /* Set type to binary (unless specified ASCII) */ + result = ftp_transfertype(conn, data->set.ftp_ascii); + if(result) + return result; + + /* Send any PREQUOTE strings after transfer type is set? (Wesley Laxton)*/ + if(data->set.prequote) { + if ((result = ftp_sendquote(conn, data->set.prequote)) != CURLE_OK) + return result; + } + + if(conn->resume_from) { + /* we're about to continue the uploading of a file */ + /* 1. get already existing file's size. We use the SIZE + command for this which may not exist in the server! + The SIZE command is not in RFC959. */ + + /* 2. This used to set REST. But since we can do append, we + don't another ftp command. We just skip the source file + offset and then we APPEND the rest on the file instead */ + + /* 3. pass file-size number of bytes in the source file */ + /* 4. lower the infilesize counter */ + /* => transfer as usual */ + + if(conn->resume_from < 0 ) { + /* we could've got a specified offset from the command line, + but now we know we didn't */ + curl_off_t gottensize; + + if(CURLE_OK != ftp_getsize(conn, ftp->file, &gottensize)) { + failf(data, "Couldn't get remote file size"); + return CURLE_FTP_COULDNT_GET_SIZE; + } + conn->resume_from = gottensize; + } + + if(conn->resume_from) { + /* do we still game? */ + curl_off_t passed=0; + /* enable append instead */ + data->set.ftp_append = 1; + + /* Now, let's read off the proper amount of bytes from the + input. If we knew it was a proper file we could've just + fseek()ed but we only have a stream here */ + do { + curl_off_t readthisamountnow = (conn->resume_from - passed); + curl_off_t actuallyread; + + if(readthisamountnow > BUFSIZE) + readthisamountnow = BUFSIZE; + + actuallyread = (curl_off_t) + conn->fread(data->state.buffer, 1, (size_t)readthisamountnow, + conn->fread_in); + + passed += actuallyread; + if(actuallyread != readthisamountnow) { + failf(data, "Could only read %" FORMAT_OFF_T + " bytes from the input", passed); + return CURLE_FTP_COULDNT_USE_REST; + } + } + while(passed != conn->resume_from); + + /* now, decrease the size of the read */ + if(data->set.infilesize>0) { + data->set.infilesize -= conn->resume_from; + + if(data->set.infilesize <= 0) { + infof(data, "File already completely uploaded\n"); + + /* no data to transfer */ + result=Curl_Transfer(conn, -1, -1, FALSE, NULL, -1, NULL); + (void)result; + + /* Set no_transfer so that we won't get any error in + * Curl_ftp_done() because we didn't transfer anything! */ + ftp->no_transfer = TRUE; + + return CURLE_OK; + } + } + /* we've passed, proceed as normal */ + } + } + + /* Send everything on data->state.in to the socket */ + if(data->set.ftp_append) { + /* we append onto the file instead of rewriting it */ + FTPSENDF(conn, "APPE %s", ftp->file); + } + else { + FTPSENDF(conn, "STOR %s", ftp->file); + } + + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + if(result) + return result; + + if(ftpcode>=400) { + failf(data, "Failed FTP upload:%s", buf+3); + /* oops, we never close the sockets! */ + return CURLE_FTP_COULDNT_STOR_FILE; + } + + if(data->set.ftp_use_port) { + /* PORT means we are now awaiting the server to connect to us. */ + result = AllowServerConnect(conn); + if( result ) + return result; + } + + if(conn->ssl[SECONDARYSOCKET].use) { + /* since we only have a plaintext TCP connection here, we must now + do the TLS stuff */ + infof(data, "Doing the SSL/TLS handshake on the data stream\n"); + result = Curl_SSLConnect(conn, SECONDARYSOCKET); + if(result) + return result; + } + + *bytecountp=0; + + /* When we know we're uploading a specified file, we can get the file + size prior to the actual upload. */ + + Curl_pgrsSetUploadSize(data, data->set.infilesize); + + result = Curl_Transfer(conn, -1, -1, FALSE, NULL, /* no download */ + SECONDARYSOCKET, bytecountp); + if(result) + return result; + + } + else if(!conn->bits.no_body) { + /* Retrieve file or directory */ + bool dirlist=FALSE; + curl_off_t downloadsize=-1; + + if(conn->bits.use_range && conn->range) { + curl_off_t from, to; + curl_off_t totalsize; + char *ptr; + char *ptr2; + + from=curlx_strtoofft(conn->range, &ptr, 0); + while(ptr && *ptr && (isspace((int)*ptr) || (*ptr=='-'))) + ptr++; + to=curlx_strtoofft(ptr, &ptr2, 0); + if(ptr == ptr2) { + /* we didn't get any digit */ + to=-1; + } + if((-1 == to) && (from>=0)) { + /* X - */ + conn->resume_from = from; + infof(data, "FTP RANGE %" FORMAT_OFF_T " to end of file\n", from); + } + else if(from < 0) { + /* -Y */ + totalsize = -from; + conn->maxdownload = -from; + conn->resume_from = from; + infof(data, "FTP RANGE the last %" FORMAT_OFF_T " bytes\n", totalsize); + } + else { + /* X-Y */ + totalsize = to-from; + conn->maxdownload = totalsize+1; /* include the last mentioned byte */ + conn->resume_from = from; + infof(data, "FTP RANGE from %" FORMAT_OFF_T + " getting %" FORMAT_OFF_T " bytes\n", from, conn->maxdownload); + } + infof(data, "range-download from %" FORMAT_OFF_T + " to %" FORMAT_OFF_T ", totally %" FORMAT_OFF_T " bytes\n", + from, to, conn->maxdownload); + ftp->dont_check = TRUE; /* dont check for successful transfer */ + } + + if((data->set.ftp_list_only) || !ftp->file) { + /* The specified path ends with a slash, and therefore we think this + is a directory that is requested, use LIST. But before that we + need to set ASCII transfer mode. */ + dirlist = TRUE; + + /* Set type to ASCII */ + result = ftp_transfertype(conn, TRUE /* ASCII enforced */); + if(result) + return result; + + /* if this output is to be machine-parsed, the NLST command will be + better used since the LIST command output is not specified or + standard in any way */ + + FTPSENDF(conn, "%s", + data->set.customrequest?data->set.customrequest: + (data->set.ftp_list_only?"NLST":"LIST")); + } + else { + curl_off_t foundsize; + + /* Set type to binary (unless specified ASCII) */ + result = ftp_transfertype(conn, data->set.ftp_ascii); + if(result) + return result; + + /* Send any PREQUOTE strings after transfer type is set? */ + if(data->set.prequote) { + if ((result = ftp_sendquote(conn, data->set.prequote)) != CURLE_OK) + return result; + } + + /* Attempt to get the size, it'll be useful in some cases: for resumed + downloads and when talking to servers that don't give away the size + in the RETR response line. */ + result = ftp_getsize(conn, ftp->file, &foundsize); + if(CURLE_OK == result) { + if (data->set.max_filesize && foundsize > data->set.max_filesize) { + failf(data, "Maximum file size exceeded"); + return CURLE_FILESIZE_EXCEEDED; + } + downloadsize = foundsize; + } + + if(conn->resume_from) { + + /* Daniel: (August 4, 1999) + * + * We start with trying to use the SIZE command to figure out the size + * of the file we're gonna get. If we can get the size, this is by far + * the best way to know if we're trying to resume beyond the EOF. + * + * Daniel, November 28, 2001. We *always* get the size on downloads + * now, so it is done before this even when not doing resumes. I saved + * the comment above for nostalgical reasons! ;-) + */ + if(CURLE_OK != result) { + infof(data, "ftp server doesn't support SIZE\n"); + /* We couldn't get the size and therefore we can't know if there + really is a part of the file left to get, although the server + will just close the connection when we start the connection so it + won't cause us any harm, just not make us exit as nicely. */ + } + else { + /* We got a file size report, so we check that there actually is a + part of the file left to get, or else we go home. */ + if(conn->resume_from< 0) { + /* We're supposed to download the last abs(from) bytes */ + if(foundsize < -conn->resume_from) { + failf(data, "Offset (%" FORMAT_OFF_T + ") was beyond file size (%" FORMAT_OFF_T ")", + conn->resume_from, foundsize); + return CURLE_FTP_BAD_DOWNLOAD_RESUME; + } + /* convert to size to download */ + downloadsize = -conn->resume_from; + /* download from where? */ + conn->resume_from = foundsize - downloadsize; + } + else { + if(foundsize < conn->resume_from) { + failf(data, "Offset (%" FORMAT_OFF_T + ") was beyond file size (%" FORMAT_OFF_T ")", + conn->resume_from, foundsize); + return CURLE_FTP_BAD_DOWNLOAD_RESUME; + } + /* Now store the number of bytes we are expected to download */ + downloadsize = foundsize-conn->resume_from; + } + } + + if (downloadsize == 0) { + /* no data to transfer */ + result=Curl_Transfer(conn, -1, -1, FALSE, NULL, -1, NULL); + (void)result; + infof(data, "File already completely downloaded\n"); + + /* Set no_transfer so that we won't get any error in Curl_ftp_done() + * because we didn't transfer the any file */ + ftp->no_transfer = TRUE; + return CURLE_OK; + } + + /* Set resume file transfer offset */ + infof(data, "Instructs server to resume from offset %" FORMAT_OFF_T + "\n", + conn->resume_from); + + FTPSENDF(conn, "REST %" FORMAT_OFF_T, conn->resume_from); + + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + if(result) + return result; + + if(ftpcode != 350) { + failf(data, "Couldn't use REST: %s", buf+4); + return CURLE_FTP_COULDNT_USE_REST; + } + } + + FTPSENDF(conn, "RETR %s", ftp->file); + } + + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + if(result) + return result; + + if((ftpcode == 150) || (ftpcode == 125)) { + + /* + A; + 150 Opening BINARY mode data connection for /etc/passwd (2241 + bytes). (ok, the file is being transfered) + + B: + 150 Opening ASCII mode data connection for /bin/ls + + C: + 150 ASCII data connection for /bin/ls (137.167.104.91,37445) (0 bytes). + + D: + 150 Opening ASCII mode data connection for /linux/fisk/kpanelrc (0.0.0.0,0) (545 bytes). + + E: + 125 Data connection already open; Transfer starting. */ + + curl_off_t size=-1; /* default unknown size */ + + + /* + * It appears that there are FTP-servers that return size 0 for files + * when SIZE is used on the file while being in BINARY mode. To work + * around that (stupid) behavior, we attempt to parse the RETR response + * even if the SIZE returned size zero. + * + * Debugging help from Salvatore Sorrentino on February 26, 2003. + */ + + if(!dirlist && + !data->set.ftp_ascii && + (downloadsize < 1)) { + /* + * It seems directory listings either don't show the size or very + * often uses size 0 anyway. ASCII transfers may very well turn out + * that the transfered amount of data is not the same as this line + * tells, why using this number in those cases only confuses us. + * + * Example D above makes this parsing a little tricky */ + char *bytes; + bytes=strstr(buf, " bytes"); + if(bytes--) { + long in=bytes-buf; + /* this is a hint there is size information in there! ;-) */ + while(--in) { + /* scan for the parenthesis and break there */ + if('(' == *bytes) + break; + /* if only skip digits, or else we're in deep trouble */ + if(!isdigit((int)*bytes)) { + bytes=NULL; + break; + } + /* one more estep backwards */ + bytes--; + } + /* only if we have nothing but digits: */ + if(bytes++) { + /* get the number! */ + size = curlx_strtoofft(bytes, NULL, 0); + } + + } + } + else if(downloadsize > -1) + size = downloadsize; + + if(data->set.ftp_use_port) { + result = AllowServerConnect(conn); + if( result ) + return result; + } + + if(conn->ssl[SECONDARYSOCKET].use) { + /* since we only have a plaintext TCP connection here, we must now + do the TLS stuff */ + infof(data, "Doing the SSL/TLS handshake on the data stream\n"); + result = Curl_SSLConnect(conn, SECONDARYSOCKET); + if(result) + return result; + } + + if(size > conn->maxdownload && conn->maxdownload > 0) + size = conn->size = conn->maxdownload; + + infof(data, "Getting file with size: %" FORMAT_OFF_T "\n", size); + + /* FTP download: */ + result=Curl_Transfer(conn, SECONDARYSOCKET, size, FALSE, + bytecountp, + -1, NULL); /* no upload here */ + if(result) + return result; + } + else { + if(dirlist && (ftpcode == 450)) { + /* simply no matching files */ + ftp->no_transfer = TRUE; /* don't think we should download anything */ + } + else { + failf(data, "%s", buf+4); + return CURLE_FTP_COULDNT_RETR_FILE; + } + } + + } + /* end of transfer */ + + return CURLE_OK; +} + +/*********************************************************************** + * + * ftp_perform() + * + * This is the actual DO function for FTP. Get a file/directory according to + * the options previously setup. + */ + +static +CURLcode ftp_perform(struct connectdata *conn, + bool *connected) /* for the TCP connect status after + PASV / PORT */ +{ + /* this is FTP and no proxy */ + CURLcode result=CURLE_OK; + struct SessionHandle *data=conn->data; + char *buf = data->state.buffer; /* this is our buffer */ + + /* the ftp struct is already inited in Curl_ftp_connect() */ + struct FTP *ftp = conn->proto.ftp; + + /* Send any QUOTE strings? */ + if(data->set.quote) { + if ((result = ftp_sendquote(conn, data->set.quote)) != CURLE_OK) + return result; + } + + /* This is a re-used connection. Since we change directory to where the + transfer is taking place, we must now get back to the original dir + where we ended up after login: */ + if (conn->bits.reuse && ftp->entrypath) { + if ((result = ftp_cwd_and_mkd(conn, ftp->entrypath)) != CURLE_OK) + return result; + } + + { + int i; /* counter for loop */ + for (i=0; i < ftp->dirdepth; i++) { + /* RFC 1738 says empty components should be respected too, but + that is plain stupid since CWD can't be used with an empty argument */ + if ((result = ftp_cwd_and_mkd(conn, ftp->dirs[i])) != CURLE_OK) + return result; + } + } + + /* Requested time of file or time-depended transfer? */ + if((data->set.get_filetime || data->set.timecondition) && + ftp->file) { + result = ftp_getfiletime(conn, ftp->file); + switch( result ) + { + case CURLE_FTP_COULDNT_RETR_FILE: + case CURLE_OK: + if(data->set.timecondition) { + if((data->info.filetime > 0) && (data->set.timevalue > 0)) { + switch(data->set.timecondition) { + case CURL_TIMECOND_IFMODSINCE: + default: + if(data->info.filetime < data->set.timevalue) { + infof(data, "The requested document is not new enough\n"); + ftp->no_transfer = TRUE; /* mark this to not transfer data */ + return CURLE_OK; + } + break; + case CURL_TIMECOND_IFUNMODSINCE: + if(data->info.filetime > data->set.timevalue) { + infof(data, "The requested document is not old enough\n"); + ftp->no_transfer = TRUE; /* mark this to not transfer data */ + return CURLE_OK; + } + break; + } /* switch */ + } + else { + infof(data, "Skipping time comparison\n"); + } + } + break; + default: + return result; + } /* switch */ + } + + /* If we have selected NOBODY and HEADER, it means that we only want file + information. Which in FTP can't be much more than the file size and + date. */ + if(conn->bits.no_body && data->set.include_header && ftp->file) { + /* The SIZE command is _not_ RFC 959 specified, and therefor many servers + may not support it! It is however the only way we have to get a file's + size! */ + curl_off_t filesize; + ssize_t nread; + int ftpcode; + + ftp->no_transfer = TRUE; /* this means no actual transfer is made */ + + /* Some servers return different sizes for different modes, and thus we + must set the proper type before we check the size */ + result = ftp_transfertype(conn, data->set.ftp_ascii); + if(result) + return result; + + /* failing to get size is not a serious error */ + result = ftp_getsize(conn, ftp->file, &filesize); + + if(CURLE_OK == result) { + snprintf(buf, sizeof(data->state.buffer), + "Content-Length: %" FORMAT_OFF_T "\r\n", filesize); + result = Curl_client_write(data, CLIENTWRITE_BOTH, buf, 0); + if(result) + return result; + } + + /* Determine if server can respond to REST command and therefore + whether it can do a range */ + FTPSENDF(conn, "REST 0", NULL); + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + + if ((CURLE_OK == result) && (ftpcode == 350)) { + result = Curl_client_write(data, CLIENTWRITE_BOTH, + (char *)"Accept-ranges: bytes\r\n", 0); + if(result) + return result; + } + + /* If we asked for a time of the file and we actually got one as + well, we "emulate" a HTTP-style header in our output. */ + +#ifdef HAVE_STRFTIME + if(data->set.get_filetime && (data->info.filetime>=0) ) { + struct tm *tm; + time_t cuClock = (time_t)data->info.filetime; +#ifdef HAVE_GMTIME_R + struct tm buffer; + tm = (struct tm *)gmtime_r(&cuClock, &buffer); +#else + tm = gmtime(&cuClock); +#endif + /* format: "Tue, 15 Nov 1994 12:45:26" */ + strftime(buf, BUFSIZE-1, "Last-Modified: %a, %d %b %Y %H:%M:%S GMT\r\n", + tm); + result = Curl_client_write(data, CLIENTWRITE_BOTH, buf, 0); + if(result) + return result; + } +#endif + + return CURLE_OK; + } + + if(conn->bits.no_body) + /* doesn't really transfer any data */ + ftp->no_transfer = TRUE; + /* Get us a second connection up and connected */ + else if(data->set.ftp_use_port) { + /* We have chosen to use the PORT command */ + result = ftp_use_port(conn); + if(CURLE_OK == result) { + /* we have the data connection ready */ + infof(data, "Ordered connect of the data stream with PORT!\n"); + *connected = TRUE; /* mark us "still connected" */ + } + } + else { + /* We have chosen (this is default) to use the PASV command */ + result = ftp_use_pasv(conn, connected); + if(CURLE_OK == result && *connected) + infof(data, "Connected the data stream with PASV!\n"); + } + + return result; +} + +/*********************************************************************** + * + * Curl_ftp() + * + * This function is registered as 'curl_do' function. It decodes the path + * parts etc as a wrapper to the actual DO function (ftp_perform). + * + * The input argument is already checked for validity. + */ +CURLcode Curl_ftp(struct connectdata *conn) +{ + CURLcode retcode; + + if (conn->sec_conn) /* 3rd party transfer */ + retcode = ftp_3rdparty(conn); + else + retcode = ftp_regular_transfer(conn); + + return retcode; +} + +/*********************************************************************** + * + * Curl_ftpsendf() + * + * Sends the formated string as a ftp command to a ftp server + * + * NOTE: we build the command in a fixed-length buffer, which sets length + * restrictions on the command! + */ +CURLcode Curl_ftpsendf(struct connectdata *conn, + const char *fmt, ...) +{ + ssize_t bytes_written; + char s[256]; + size_t write_len; + char *sptr=s; + CURLcode res; + + va_list ap; + va_start(ap, fmt); + vsnprintf(s, 250, fmt, ap); + va_end(ap); + + strcat(s, "\r\n"); /* append a trailing CRLF */ + + bytes_written=0; + write_len = strlen(s); + + while(1) { + res = Curl_write(conn, conn->sock[FIRSTSOCKET], sptr, write_len, + &bytes_written); + + if(CURLE_OK != res) + break; + + if(conn->data->set.verbose) + Curl_debug(conn->data, CURLINFO_HEADER_OUT, sptr, bytes_written, conn->host.dispname); + + if(bytes_written != (ssize_t)write_len) { + write_len -= bytes_written; + sptr += bytes_written; + } + else + break; + } + + return res; +} + +/*********************************************************************** + * + * ftp_quit() + * + * This should be called before calling sclose() on an ftp control connection + * (not data connections). We should then wait for the response from the + * server before returning. The calling code should then try to close the + * connection. + * + */ +static CURLcode ftp_quit(struct connectdata *conn) +{ + ssize_t nread; + int ftpcode; + CURLcode ret = CURLE_OK; + + if(conn->proto.ftp->ctl_valid) { + ret = Curl_ftpsendf(conn, "%s", "QUIT"); + if(CURLE_OK == ret) + ret = Curl_GetFTPResponse(&nread, conn, &ftpcode); + } + + return ret; +} + +/*********************************************************************** + * + * Curl_ftp_disconnect() + * + * Disconnect from an FTP server. Cleanup protocol-specific per-connection + * resources + */ +CURLcode Curl_ftp_disconnect(struct connectdata *conn) +{ + struct FTP *ftp= conn->proto.ftp; + + /* We cannot send quit unconditionally. If this connection is stale or + bad in any way, sending quit and waiting around here will make the + disconnect wait in vain and cause more problems than we need to. + + ftp_quit() will check the state of ftp->ctl_valid. If it's ok it + will try to send the QUIT command, otherwise it will just return. + */ + + /* The FTP session may or may not have been allocated/setup at this point! */ + if(ftp) { + (void)ftp_quit(conn); /* ignore errors on the QUIT */ + + if(ftp->entrypath) + free(ftp->entrypath); + if(ftp->cache) { + free(ftp->cache); + ftp->cache = NULL; + } + freedirs(ftp); + } + return CURLE_OK; +} + +/*********************************************************************** + * + * ftp_mkd() + * + * Makes a directory on the FTP server. + * + * Calls failf() + */ +static CURLcode ftp_mkd(struct connectdata *conn, char *path) +{ + CURLcode result; + int ftpcode; /* for ftp status */ + ssize_t nread; + + /* Create a directory on the remote server */ + FTPSENDF(conn, "MKD %s", path); + + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + if(result) + return result; + + switch(ftpcode) { + case 257: + /* success! */ + infof( conn->data , "Created remote directory %s\n" , path ); + break; + case 550: + failf(conn->data, "Permission denied to make directory %s", path); + result = CURLE_FTP_ACCESS_DENIED; + break; + default: + failf(conn->data, "unrecognized MKD response: %d", ftpcode ); + result = CURLE_FTP_ACCESS_DENIED; + break; + } + return result; +} + +/*********************************************************************** + * + * ftp_cwd() + * + * Send 'CWD' to the remote server to Change Working Directory. It is the ftp + * version of the unix 'cd' command. This function is only called from the + * ftp_cwd_and_mkd() function these days. + * + * This function does NOT call failf(). + */ +static +CURLcode ftp_cwd(struct connectdata *conn, char *path) +{ + ssize_t nread; + int ftpcode; + CURLcode result; + + FTPSENDF(conn, "CWD %s", path); + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + if (!result) { + /* According to RFC959, CWD is supposed to return 250 on success, but + there seem to be non-compliant FTP servers out there that return 200, + so we accept any '2xy' code here. */ + if (ftpcode/100 != 2) + result = CURLE_FTP_ACCESS_DENIED; + } + + return result; +} + +/*********************************************************************** + * + * ftp_cwd_and_mkd() + * + * Change to the given directory. If the directory is not present, and we + * have been told to allow it, then create the directory and cd to it. + * + */ +static CURLcode ftp_cwd_and_mkd(struct connectdata *conn, char *path) +{ + CURLcode result; + + result = ftp_cwd(conn, path); + if (result) { + if(conn->data->set.ftp_create_missing_dirs) { + result = ftp_mkd(conn, path); + if (result) + /* ftp_mkd() calls failf() itself */ + return result; + result = ftp_cwd(conn, path); + } + if(result) + failf(conn->data, "Couldn't cd to %s", path); + } + return result; +} + + + +/*********************************************************************** + * + * ftp_3rdparty_pretransfer() + * + * Preparation for 3rd party transfer. + * + */ +static CURLcode ftp_3rdparty_pretransfer(struct connectdata *conn) +{ + CURLcode result; + struct SessionHandle *data = conn->data; + struct connectdata *sec_conn = conn->sec_conn; + + /* sets transfer type */ + result = ftp_transfertype(conn, data->set.ftp_ascii); + if (result) + return result; + + result = ftp_transfertype(sec_conn, data->set.ftp_ascii); + if (result) + return result; + + /* Send any PREQUOTE strings after transfer type is set? */ + if (data->set.source_prequote) { + /* sends command(s) to source server before file transfer */ + result = ftp_sendquote(sec_conn, data->set.source_prequote); + } + if (!result && data->set.prequote) + result = ftp_sendquote(conn, data->set.prequote); + + return result; +} + + + +/*********************************************************************** + * + * ftp_3rdparty_transfer() + * + * Performs 3rd party transfer. + * + */ +static CURLcode ftp_3rdparty_transfer(struct connectdata *conn) +{ + CURLcode result; + ssize_t nread; + int ftpcode, ip[4], port[2]; + struct SessionHandle *data = conn->data; + struct connectdata *sec_conn = conn->sec_conn; + char *buf = data->state.buffer; /* this is our buffer */ + char *str = buf; + char pasv_port[50]; + const char *stor_cmd; + struct connectdata *pasv_conn; + struct connectdata *port_conn; + + if (data->set.pasvHost == CURL_TARGET_PASV) { + pasv_conn = conn; + port_conn = sec_conn; + } + else { + pasv_conn = sec_conn; + port_conn = conn; + } + + /* sets the passive mode */ + FTPSENDF(pasv_conn, "%s", "PASV"); + result = Curl_GetFTPResponse(&nread, pasv_conn, &ftpcode); + if (result) return result; + if (ftpcode != 227) { + failf(data, "Odd return code after PASV:%s", buf + 3); + return CURLE_FTP_WEIRD_PASV_REPLY; + } + + while (*str) { + if (6 == sscanf(str, "%d,%d,%d,%d,%d,%d", + &ip[0], &ip[1], &ip[2], &ip[3], &port[0], &port[1])) + break; + str++; + } + + if (!*str) { + failf(pasv_conn->data, "Couldn't interpret this 227-reply: %s", buf); + return CURLE_FTP_WEIRD_227_FORMAT; + } + + snprintf(pasv_port, sizeof(pasv_port), "%d,%d,%d,%d,%d,%d", ip[0], ip[1], + ip[2], ip[3], port[0], port[1]); + + /* sets data connection between remote hosts */ + FTPSENDF(port_conn, "PORT %s", pasv_port); + result = Curl_GetFTPResponse(&nread, port_conn, &ftpcode); + if (result) + return result; + + if (ftpcode != 200) { + failf(data, "PORT command attempts failed:%s", buf + 3); + return CURLE_FTP_PORT_FAILED; + } + + /* we might append onto the file instead of overwriting it */ + stor_cmd = data->set.ftp_append?"APPE":"STOR"; + + /* transfers file between remote hosts */ + FTPSENDF(sec_conn, "RETR %s", data->set.source_path); + + if(data->set.pasvHost == CURL_TARGET_PASV) { + + result = Curl_GetFTPResponse(&nread, sec_conn, &ftpcode); + if (result) + return result; + + if (ftpcode != 150) { + failf(data, "Failed RETR: %s", buf + 4); + return CURLE_FTP_COULDNT_RETR_FILE; + } + + result = Curl_ftpsendf(conn, "%s %s", stor_cmd, conn->path); + if(CURLE_OK == result) + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + if (result) + return result; + + if (ftpcode != 150) { + failf(data, "Failed FTP upload: %s", buf + 4); + return CURLE_FTP_COULDNT_STOR_FILE; + } + + } + else { + + result = Curl_ftpsendf(conn, "%s %s", stor_cmd, conn->path); + if(CURLE_OK == result) + result = Curl_GetFTPResponse(&nread, sec_conn, &ftpcode); + if (result) + return result; + + if (ftpcode != 150) { + failf(data, "Failed FTP upload: %s", buf + 4); + return CURLE_FTP_COULDNT_STOR_FILE; + } + + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + if (result) + return result; + + if (ftpcode != 150) { + failf(data, "Failed FTP upload: %s", buf + 4); + return CURLE_FTP_COULDNT_STOR_FILE; + } + } + + return CURLE_OK; +} + + + +/*********************************************************************** + * + * ftp_regular_transfer() + * + * The input argument is already checked for validity. + * Performs a regular transfer between local and remote hosts. + * + * ftp->ctl_valid starts out as FALSE, and gets set to TRUE if we reach the + * Curl_ftp_done() function without finding any major problem. + */ +static +CURLcode ftp_regular_transfer(struct connectdata *conn) +{ + CURLcode retcode=CURLE_OK; + bool connected=0; + struct SessionHandle *data = conn->data; + struct FTP *ftp; + + char *slash_pos; /* position of the first '/' char in curpos */ + char *cur_pos=conn->path; /* current position in ppath. point at the begin + of next path component */ + + /* the ftp struct is already inited in ftp_connect() */ + ftp = conn->proto.ftp; + ftp->ctl_valid = FALSE; + conn->size = -1; /* make sure this is unknown at this point */ + + Curl_pgrsSetUploadCounter(data, 0); + Curl_pgrsSetDownloadCounter(data, 0); + Curl_pgrsSetUploadSize(data, 0); + Curl_pgrsSetDownloadSize(data, 0); + + ftp->dirdepth = 0; + ftp->diralloc = 5; /* default dir depth to allocate */ + ftp->dirs = (char **)malloc(ftp->diralloc * sizeof(ftp->dirs[0])); + if(!ftp->dirs) + return CURLE_OUT_OF_MEMORY; + ftp->dirs[0] = NULL; /* to start with */ + + /* parse the URL path into separate path components */ + while((slash_pos=strchr(cur_pos, '/'))) { + /* 1 or 0 to indicate absolute directory */ + bool absolute_dir = (cur_pos - conn->path > 0) && (ftp->dirdepth == 0); + + /* seek out the next path component */ + if (slash_pos-cur_pos) { + /* we skip empty path components, like "x//y" since the FTP command CWD + requires a parameter and a non-existant parameter a) doesn't work on + many servers and b) has no effect on the others. */ + int len = (int)(slash_pos - cur_pos + absolute_dir); + ftp->dirs[ftp->dirdepth] = curl_unescape(cur_pos - absolute_dir, len); + + if (!ftp->dirs[ftp->dirdepth]) { /* run out of memory ... */ + failf(data, "no memory"); + freedirs(ftp); + return CURLE_OUT_OF_MEMORY; + } + } + else { + cur_pos = slash_pos + 1; /* jump to the rest of the string */ + continue; + } + + if(!retcode) { + cur_pos = slash_pos + 1; /* jump to the rest of the string */ + if(++ftp->dirdepth >= ftp->diralloc) { + /* enlarge array */ + char **bigger; + ftp->diralloc *= 2; /* double the size each time */ + bigger = realloc(ftp->dirs, ftp->diralloc * sizeof(ftp->dirs[0])); + if(!bigger) { + freedirs(ftp); + return CURLE_OUT_OF_MEMORY; + } + ftp->dirs = (char **)bigger; + } + } + } + + ftp->file = cur_pos; /* the rest is the file name */ + + if(*ftp->file) { + ftp->file = curl_unescape(ftp->file, 0); + if(NULL == ftp->file) { + freedirs(ftp); + failf(data, "no memory"); + return CURLE_OUT_OF_MEMORY; + } + } + else + ftp->file=NULL; /* instead of point to a zero byte, we make it a NULL + pointer */ + + retcode = ftp_perform(conn, &connected); + + if(CURLE_OK == retcode) { + if(connected) + retcode = Curl_ftp_nextconnect(conn); + + if(retcode && (conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD)) { + /* Failure detected, close the second socket if it was created already */ + sclose(conn->sock[SECONDARYSOCKET]); + conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD; + } + + if(ftp->no_transfer) + /* no data to transfer */ + retcode=Curl_Transfer(conn, -1, -1, FALSE, NULL, -1, NULL); + else if(!connected) + /* since we didn't connect now, we want do_more to get called */ + conn->bits.do_more = TRUE; + } + else + freedirs(ftp); + + ftp->ctl_valid = TRUE; /* seems good */ + + return retcode; +} + + + +/*********************************************************************** + * + * ftp_3rdparty() + * + * The input argument is already checked for validity. + * Performs a 3rd party transfer between two remote hosts. + */ +static CURLcode ftp_3rdparty(struct connectdata *conn) +{ + CURLcode retcode; + + conn->proto.ftp->ctl_valid = conn->sec_conn->proto.ftp->ctl_valid = TRUE; + conn->size = conn->sec_conn->size = -1; + + retcode = ftp_3rdparty_pretransfer(conn); + if (!retcode) + retcode = ftp_3rdparty_transfer(conn); + + return retcode; +} + +#endif /* CURL_DISABLE_FTP */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/ftp.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/ftp.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/ftp.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/ftp.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,37 @@ +#ifndef __FTP_H +#define __FTP_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: ftp.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +#ifndef CURL_DISABLE_FTP +CURLcode Curl_ftp(struct connectdata *conn); +CURLcode Curl_ftp_done(struct connectdata *conn, CURLcode); +CURLcode Curl_ftp_connect(struct connectdata *conn); +CURLcode Curl_ftp_disconnect(struct connectdata *conn); +CURLcode Curl_ftpsendf(struct connectdata *, const char *fmt, ...); +CURLcode Curl_GetFTPResponse(ssize_t *nread, struct connectdata *conn, + int *ftpcode); +CURLcode Curl_ftp_nextconnect(struct connectdata *conn); +#endif + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/getdate.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/getdate.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/getdate.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/getdate.c 2004-10-26 22:25:58.000000000 +0800 @@ -0,0 +1,2471 @@ +/* A Bison parser, made by GNU Bison 1.875a. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Written by Richard Stallman by simplifying the original so called + ``semantic'' parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + tAGO = 258, + tDAY = 259, + tDAY_UNIT = 260, + tDAYZONE = 261, + tDST = 262, + tHOUR_UNIT = 263, + tID = 264, + tMERIDIAN = 265, + tMINUTE_UNIT = 266, + tMONTH = 267, + tMONTH_UNIT = 268, + tSEC_UNIT = 269, + tSNUMBER = 270, + tUNUMBER = 271, + tYEAR_UNIT = 272, + tZONE = 273 + }; +#endif +#define tAGO 258 +#define tDAY 259 +#define tDAY_UNIT 260 +#define tDAYZONE 261 +#define tDST 262 +#define tHOUR_UNIT 263 +#define tID 264 +#define tMERIDIAN 265 +#define tMINUTE_UNIT 266 +#define tMONTH 267 +#define tMONTH_UNIT 268 +#define tSEC_UNIT 269 +#define tSNUMBER 270 +#define tUNUMBER 271 +#define tYEAR_UNIT 272 +#define tZONE 273 + + + + +/* Copy the first part of user declarations. */ +#line 1 "getdate.y" + +/* +** Originally written by Steven M. Bellovin while +** at the University of North Carolina at Chapel Hill. Later tweaked by +** a couple of people on Usenet. Completely overhauled by Rich $alz +** and Jim Berets in August, 1990. +** +** This code has been modified since it was included in curl, to make it +** thread-safe and to make compilers complain less about it. +** +** This code is in the public domain and has no copyright. +*/ + +#include "setup.h" + +# ifdef HAVE_ALLOCA_H +# include +# endif + +# ifdef HAVE_TIME_H +# include +# endif + +#ifndef YYDEBUG + /* to satisfy gcc -Wundef, we set this to 0 */ +#define YYDEBUG 0 +#endif + +#ifndef YYSTACK_USE_ALLOCA + /* to satisfy gcc -Wundef, we set this to 0 */ +#define YYSTACK_USE_ALLOCA 0 +#endif + +/* Since the code of getdate.y is not included in the Emacs executable + itself, there is no need to #define static in this file. Even if + the code were included in the Emacs executable, it probably + wouldn't do any harm to #undef it here; this will only cause + problems if we try to write to a static variable, which I don't + think this code needs to do. */ +#ifdef emacs +# undef static +#endif + +#ifdef __APPLE__ +#include +#include +#else + +#endif +#include +#include +#include + +#if HAVE_STDLIB_H +# include /* for `free'; used by Bison 1.27 */ +#else + +#ifdef HAVE_MALLOC_H +#include +#endif + +#endif + +#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) +# define IN_CTYPE_DOMAIN(c) 1 +#else +# define IN_CTYPE_DOMAIN(c) isascii(c) +#endif + +#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c)) +#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c)) +#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c)) +#define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (c)) + +/* ISDIGIT differs from ISDIGIT_LOCALE, as follows: + - Its arg may be any int or unsigned int; it need not be an unsigned char. + - It's guaranteed to evaluate its argument exactly once. + - It's typically faster. + Posix 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that + only '0' through '9' are digits. Prefer ISDIGIT to ISDIGIT_LOCALE unless + it's important to use the locale's definition of `digit' even when the + host does not conform to Posix. */ +#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9) + +#if defined (STDC_HEADERS) || defined (USG) +# include +#endif + +#include "curl_memory.h" +/* The last #include file should be: */ +#include "memdebug.h" + +#ifndef YYMAXDEPTH +#define YYMAXDEPTH 0 +#endif + +#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) +# define __attribute__(x) +#endif + +#ifndef ATTRIBUTE_UNUSED +# define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +#endif + +/* Some old versions of bison generate parsers that use bcopy. + That loses on systems that don't provide the function, so we have + to redefine it here. */ +#if !defined (HAVE_BCOPY) && defined (HAVE_MEMCPY) && !defined (bcopy) +# define bcopy(from, to, len) memcpy ((to), (from), (len)) +#endif + +/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), + as well as gratuitiously global symbol names, so we can have multiple + yacc generated parsers in the same program. Note that these are only + the variables produced by yacc. If other parser generators (bison, + byacc, etc) produce additional global names that conflict at link time, + then those parser generators need to be fixed instead of adding those + names to this list. */ + +#define yymaxdepth Curl_gd_maxdepth +#define yyparse Curl_gd_parse +#define yylex Curl_gd_lex +#define yyerror Curl_gd_error +#define yylval Curl_gd_lval +#define yychar Curl_gd_char +#define yydebug Curl_gd_debug +#define yypact Curl_gd_pact +#define yyr1 Curl_gd_r1 +#define yyr2 Curl_gd_r2 +#define yydef Curl_gd_def +#define yychk Curl_gd_chk +#define yypgo Curl_gd_pgo +#define yyact Curl_gd_act +#define yyexca Curl_gd_exca +#define yyerrflag Curl_gd_errflag +#define yynerrs Curl_gd_nerrs +#define yyps Curl_gd_ps +#define yypv Curl_gd_pv +#define yys Curl_gd_s +#define yy_yys Curl_gd_yys +#define yystate Curl_gd_state +#define yytmp Curl_gd_tmp +#define yyv Curl_gd_v +#define yy_yyv Curl_gd_yyv +#define yyval Curl_gd_val +#define yylloc Curl_gd_lloc +#define yyreds Curl_gd_reds /* With YYDEBUG defined */ +#define yytoks Curl_gd_toks /* With YYDEBUG defined */ +#define yylhs Curl_gd_yylhs +#define yylen Curl_gd_yylen +#define yydefred Curl_gd_yydefred +#define yydgoto Curl_gd_yydgoto +#define yysindex Curl_gd_yysindex +#define yyrindex Curl_gd_yyrindex +#define yygindex Curl_gd_yygindex +#define yytable Curl_gd_yytable +#define yycheck Curl_gd_yycheck + +#define EPOCH 1970 +#define HOUR(x) ((x) * 60) + +#define MAX_BUFF_LEN 128 /* size of buffer to read the date into */ + +/* +** An entry in the lexical lookup table. +*/ +typedef struct _TABLE { + const char *name; + int type; + int value; +} TABLE; + + +/* +** Meridian: am, pm, or 24-hour style. +*/ +typedef enum _MERIDIAN { + MERam, MERpm, MER24 +} MERIDIAN; + +/* parse results and input string */ +typedef struct _CURL_CONTEXT { + const char *yyInput; + int yyDayOrdinal; + int yyDayNumber; + int yyHaveDate; + int yyHaveDay; + int yyHaveRel; + int yyHaveTime; + int yyHaveZone; + int yyTimezone; + int yyDay; + int yyHour; + int yyMinutes; + int yyMonth; + int yySeconds; + int yyYear; + MERIDIAN yyMeridian; + int yyRelDay; + int yyRelHour; + int yyRelMinutes; + int yyRelMonth; + int yyRelSeconds; + int yyRelYear; +} CURL_CONTEXT; + +/* enable use of extra argument to yyparse and yylex which can be used to pass +** in a user defined value (CURL_CONTEXT struct in our case) +*/ +#define YYPARSE_PARAM cookie +#define YYLEX_PARAM cookie +#define context ((CURL_CONTEXT *) cookie) + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +#line 223 "getdate.y" +typedef union YYSTYPE { + int Number; + enum _MERIDIAN Meridian; +} YYSTYPE; +/* Line 191 of yacc.c. */ +#line 331 "y.tab.c" +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ +#line 228 "getdate.y" + +static int yylex (YYSTYPE *yylval, void *cookie); +static int yyerror (const char *s); + + +/* Line 214 of yacc.c. */ +#line 347 "y.tab.c" + +#if ! defined (yyoverflow) || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# if YYSTACK_USE_ALLOCA +# define YYSTACK_ALLOC alloca +# else +# ifndef YYSTACK_USE_ALLOCA +# if defined (alloca) || defined (_ALLOCA_H) +# define YYSTACK_ALLOC alloca +# else +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# else +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# define YYSTACK_ALLOC malloc +# define YYSTACK_FREE free +# endif +#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ + + +#if (! defined (yyoverflow) \ + && (! defined (__cplusplus) \ + || (YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + short yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + register YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (0) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + (void)yyptr; \ + } \ + while (0) + +#endif + +#if defined (__STDC__) || defined (__cplusplus) + typedef signed char yysigned_char; +#else + typedef short yysigned_char; +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 2 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 50 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 22 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 11 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 51 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 61 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 273 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const unsigned char yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 20, 2, 2, 21, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 19, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const unsigned char yyprhs[] = +{ + 0, 0, 3, 4, 7, 9, 11, 13, 15, 17, + 19, 22, 27, 32, 39, 46, 48, 50, 53, 55, + 58, 61, 65, 71, 75, 79, 82, 87, 90, 94, + 97, 99, 102, 105, 107, 110, 113, 115, 118, 121, + 123, 126, 129, 131, 134, 137, 139, 142, 145, 147, + 149, 150 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yysigned_char yyrhs[] = +{ + 23, 0, -1, -1, 23, 24, -1, 25, -1, 26, + -1, 28, -1, 27, -1, 29, -1, 31, -1, 16, + 10, -1, 16, 19, 16, 32, -1, 16, 19, 16, + 15, -1, 16, 19, 16, 19, 16, 32, -1, 16, + 19, 16, 19, 16, 15, -1, 18, -1, 6, -1, + 18, 7, -1, 4, -1, 4, 20, -1, 16, 4, + -1, 16, 21, 16, -1, 16, 21, 16, 21, 16, + -1, 16, 15, 15, -1, 16, 12, 15, -1, 12, + 16, -1, 12, 16, 20, 16, -1, 16, 12, -1, + 16, 12, 16, -1, 30, 3, -1, 30, -1, 16, + 17, -1, 15, 17, -1, 17, -1, 16, 13, -1, + 15, 13, -1, 13, -1, 16, 5, -1, 15, 5, + -1, 5, -1, 16, 8, -1, 15, 8, -1, 8, + -1, 16, 11, -1, 15, 11, -1, 11, -1, 16, + 14, -1, 15, 14, -1, 14, -1, 16, -1, -1, + 10, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const unsigned short yyrline[] = +{ + 0, 244, 244, 245, 248, 251, 254, 257, 260, 263, + 266, 272, 278, 287, 293, 305, 308, 312, 317, 321, + 325, 331, 335, 353, 359, 365, 369, 374, 378, 385, + 393, 396, 399, 402, 405, 408, 411, 414, 417, 420, + 423, 426, 429, 432, 435, 438, 441, 444, 447, 452, + 487, 490 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE +/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "tAGO", "tDAY", "tDAY_UNIT", "tDAYZONE", + "tDST", "tHOUR_UNIT", "tID", "tMERIDIAN", "tMINUTE_UNIT", "tMONTH", + "tMONTH_UNIT", "tSEC_UNIT", "tSNUMBER", "tUNUMBER", "tYEAR_UNIT", + "tZONE", "':'", "','", "'/'", "$accept", "spec", "item", "time", "zone", + "day", "date", "rel", "relunit", "number", "o_merid", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const unsigned short yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 58, + 44, 47 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const unsigned char yyr1[] = +{ + 0, 22, 23, 23, 24, 24, 24, 24, 24, 24, + 25, 25, 25, 25, 25, 26, 26, 26, 27, 27, + 27, 28, 28, 28, 28, 28, 28, 28, 28, 29, + 29, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 31, + 32, 32 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const unsigned char yyr2[] = +{ + 0, 2, 0, 2, 1, 1, 1, 1, 1, 1, + 2, 4, 4, 6, 6, 1, 1, 2, 1, 2, + 2, 3, 5, 3, 3, 2, 4, 2, 3, 2, + 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, + 2, 2, 1, 2, 2, 1, 2, 2, 1, 1, + 0, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const unsigned char yydefact[] = +{ + 2, 0, 1, 18, 39, 16, 42, 45, 0, 36, + 48, 0, 49, 33, 15, 3, 4, 5, 7, 6, + 8, 30, 9, 19, 25, 38, 41, 44, 35, 47, + 32, 20, 37, 40, 10, 43, 27, 34, 46, 0, + 31, 0, 0, 17, 29, 0, 24, 28, 23, 50, + 21, 26, 51, 12, 0, 11, 0, 50, 22, 14, + 13 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yysigned_char yydefgoto[] = +{ + -1, 1, 15, 16, 17, 18, 19, 20, 21, 22, + 55 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -20 +static const yysigned_char yypact[] = +{ + -20, 0, -20, -19, -20, -20, -20, -20, -13, -20, + -20, 30, 15, -20, 14, -20, -20, -20, -20, -20, + -20, 19, -20, -20, 4, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -6, -20, -20, 16, + -20, 17, 23, -20, -20, 24, -20, -20, -20, 27, + 28, -20, -20, -20, 29, -20, 32, -8, -20, -20, + -20 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yysigned_char yypgoto[] = +{ + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -7 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const unsigned char yytable[] = +{ + 2, 23, 52, 24, 3, 4, 5, 59, 6, 46, + 47, 7, 8, 9, 10, 11, 12, 13, 14, 31, + 32, 43, 44, 33, 45, 34, 35, 36, 37, 38, + 39, 48, 40, 49, 41, 25, 42, 52, 26, 50, + 51, 27, 53, 28, 29, 57, 54, 30, 58, 56, + 60 +}; + +static const unsigned char yycheck[] = +{ + 0, 20, 10, 16, 4, 5, 6, 15, 8, 15, + 16, 11, 12, 13, 14, 15, 16, 17, 18, 4, + 5, 7, 3, 8, 20, 10, 11, 12, 13, 14, + 15, 15, 17, 16, 19, 5, 21, 10, 8, 16, + 16, 11, 15, 13, 14, 16, 19, 17, 16, 21, + 57 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const unsigned char yystos[] = +{ + 0, 23, 0, 4, 5, 6, 8, 11, 12, 13, + 14, 15, 16, 17, 18, 24, 25, 26, 27, 28, + 29, 30, 31, 20, 16, 5, 8, 11, 13, 14, + 17, 4, 5, 8, 10, 11, 12, 13, 14, 15, + 17, 19, 21, 7, 3, 20, 15, 16, 15, 16, + 16, 16, 10, 15, 19, 32, 21, 16, 16, 15, + 32 +}; + +#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) +# define YYSIZE_T __SIZE_TYPE__ +#endif +#if ! defined (YYSIZE_T) && defined (size_t) +# define YYSIZE_T size_t +#endif +#if ! defined (YYSIZE_T) +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int +#endif + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrlab1 + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror ("syntax error: cannot back up");\ + YYERROR; \ + } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +/* YYLLOC_DEFAULT -- Compute the default location (before the actions + are run). */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + Current.first_line = Rhs[1].first_line; \ + Current.first_column = Rhs[1].first_column; \ + Current.last_line = Rhs[N].last_line; \ + Current.last_column = Rhs[N].last_column; +#endif + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +# define YYDSYMPRINT(Args) \ +do { \ + if (yydebug) \ + yysymprint Args; \ +} while (0) + +# define YYDSYMPRINTF(Title, Token, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yysymprint (stderr, \ + Token, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (cinluded). | +`------------------------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_stack_print (short *bottom, short *top) +#else +static void +yy_stack_print (bottom, top) + short *bottom; + short *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (/* Nothing. */; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_reduce_print (int yyrule) +#else +static void +yy_reduce_print (yyrule) + int yyrule; +#endif +{ + int yyi; + unsigned int yylineno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", + yyrule - 1, yylineno); + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) + YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YYDSYMPRINT(Args) +# define YYDSYMPRINTF(Title, Token, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#if YYMAXDEPTH == 0 +# undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined (__GLIBC__) && defined (_STRING_H) +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +# if defined (__STDC__) || defined (__cplusplus) +yystrlen (const char *yystr) +# else +yystrlen (yystr) + const char *yystr; +# endif +{ + register const char *yys = yystr; + + while (*yys++ != '\0') + continue; + + return yys - yystr - 1; +} +# endif +# endif + +# ifndef yystpcpy +# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +# if defined (__STDC__) || defined (__cplusplus) +yystpcpy (char *yydest, const char *yysrc) +# else +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +# endif +{ + register char *yyd = yydest; + register const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +#endif /* !YYERROR_VERBOSE */ + + + +#if YYDEBUG +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) +#else +static void +yysymprint (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + if (yytype < YYNTOKENS) + { + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); +# ifdef YYPRINT + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + } + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + switch (yytype) + { + default: + break; + } + YYFPRINTF (yyoutput, ")"); +} + +#endif /* ! YYDEBUG */ +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yydestruct (int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yytype, yyvaluep) + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM); +# else +int yyparse (); +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM) +# else +int yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + /* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + register int yystate; + register int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + short yyssa[YYINITDEPTH]; + short *yyss = yyssa; + register short *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + register YYSTYPE *yyvsp; + + + +#define YYPOPSTACK (yyvsp--, yyssp--) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* When reducing, the number of symbols on the RHS of the reduced + rule. */ + int yylen; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. + */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow ("parser stack overflow", + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyoverflowlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyoverflowlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + short *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyoverflowlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; + + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + yystate = yyn; + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 4: +#line 248 "getdate.y" + { + context->yyHaveTime++; + } + break; + + case 5: +#line 251 "getdate.y" + { + context->yyHaveZone++; + } + break; + + case 6: +#line 254 "getdate.y" + { + context->yyHaveDate++; + } + break; + + case 7: +#line 257 "getdate.y" + { + context->yyHaveDay++; + } + break; + + case 8: +#line 260 "getdate.y" + { + context->yyHaveRel++; + } + break; + + case 10: +#line 266 "getdate.y" + { + context->yyHour = yyvsp[-1].Number; + context->yyMinutes = 0; + context->yySeconds = 0; + context->yyMeridian = yyvsp[0].Meridian; + } + break; + + case 11: +#line 272 "getdate.y" + { + context->yyHour = yyvsp[-3].Number; + context->yyMinutes = yyvsp[-1].Number; + context->yySeconds = 0; + context->yyMeridian = yyvsp[0].Meridian; + } + break; + + case 12: +#line 278 "getdate.y" + { + context->yyHour = yyvsp[-3].Number; + context->yyMinutes = yyvsp[-1].Number; + context->yyMeridian = MER24; + context->yyHaveZone++; + context->yyTimezone = (yyvsp[0].Number < 0 + ? -yyvsp[0].Number % 100 + (-yyvsp[0].Number / 100) * 60 + : - (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60)); + } + break; + + case 13: +#line 287 "getdate.y" + { + context->yyHour = yyvsp[-5].Number; + context->yyMinutes = yyvsp[-3].Number; + context->yySeconds = yyvsp[-1].Number; + context->yyMeridian = yyvsp[0].Meridian; + } + break; + + case 14: +#line 293 "getdate.y" + { + context->yyHour = yyvsp[-5].Number; + context->yyMinutes = yyvsp[-3].Number; + context->yySeconds = yyvsp[-1].Number; + context->yyMeridian = MER24; + context->yyHaveZone++; + context->yyTimezone = (yyvsp[0].Number < 0 + ? -yyvsp[0].Number % 100 + (-yyvsp[0].Number / 100) * 60 + : - (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60)); + } + break; + + case 15: +#line 305 "getdate.y" + { + context->yyTimezone = yyvsp[0].Number; + } + break; + + case 16: +#line 308 "getdate.y" + { + context->yyTimezone = yyvsp[0].Number - 60; + } + break; + + case 17: +#line 312 "getdate.y" + { + context->yyTimezone = yyvsp[-1].Number - 60; + } + break; + + case 18: +#line 317 "getdate.y" + { + context->yyDayOrdinal = 1; + context->yyDayNumber = yyvsp[0].Number; + } + break; + + case 19: +#line 321 "getdate.y" + { + context->yyDayOrdinal = 1; + context->yyDayNumber = yyvsp[-1].Number; + } + break; + + case 20: +#line 325 "getdate.y" + { + context->yyDayOrdinal = yyvsp[-1].Number; + context->yyDayNumber = yyvsp[0].Number; + } + break; + + case 21: +#line 331 "getdate.y" + { + context->yyMonth = yyvsp[-2].Number; + context->yyDay = yyvsp[0].Number; + } + break; + + case 22: +#line 335 "getdate.y" + { + /* Interpret as YYYY/MM/DD if $1 >= 1000, otherwise as MM/DD/YY. + The goal in recognizing YYYY/MM/DD is solely to support legacy + machine-generated dates like those in an RCS log listing. If + you want portability, use the ISO 8601 format. */ + if (yyvsp[-4].Number >= 1000) + { + context->yyYear = yyvsp[-4].Number; + context->yyMonth = yyvsp[-2].Number; + context->yyDay = yyvsp[0].Number; + } + else + { + context->yyMonth = yyvsp[-4].Number; + context->yyDay = yyvsp[-2].Number; + context->yyYear = yyvsp[0].Number; + } + } + break; + + case 23: +#line 353 "getdate.y" + { + /* ISO 8601 format. yyyy-mm-dd. */ + context->yyYear = yyvsp[-2].Number; + context->yyMonth = -yyvsp[-1].Number; + context->yyDay = -yyvsp[0].Number; + } + break; + + case 24: +#line 359 "getdate.y" + { + /* e.g. 17-JUN-1992. */ + context->yyDay = yyvsp[-2].Number; + context->yyMonth = yyvsp[-1].Number; + context->yyYear = -yyvsp[0].Number; + } + break; + + case 25: +#line 365 "getdate.y" + { + context->yyMonth = yyvsp[-1].Number; + context->yyDay = yyvsp[0].Number; + } + break; + + case 26: +#line 369 "getdate.y" + { + context->yyMonth = yyvsp[-3].Number; + context->yyDay = yyvsp[-2].Number; + context->yyYear = yyvsp[0].Number; + } + break; + + case 27: +#line 374 "getdate.y" + { + context->yyMonth = yyvsp[0].Number; + context->yyDay = yyvsp[-1].Number; + } + break; + + case 28: +#line 378 "getdate.y" + { + context->yyMonth = yyvsp[-1].Number; + context->yyDay = yyvsp[-2].Number; + context->yyYear = yyvsp[0].Number; + } + break; + + case 29: +#line 385 "getdate.y" + { + context->yyRelSeconds = -context->yyRelSeconds; + context->yyRelMinutes = -context->yyRelMinutes; + context->yyRelHour = -context->yyRelHour; + context->yyRelDay = -context->yyRelDay; + context->yyRelMonth = -context->yyRelMonth; + context->yyRelYear = -context->yyRelYear; + } + break; + + case 31: +#line 396 "getdate.y" + { + context->yyRelYear += yyvsp[-1].Number * yyvsp[0].Number; + } + break; + + case 32: +#line 399 "getdate.y" + { + context->yyRelYear += yyvsp[-1].Number * yyvsp[0].Number; + } + break; + + case 33: +#line 402 "getdate.y" + { + context->yyRelYear += yyvsp[0].Number; + } + break; + + case 34: +#line 405 "getdate.y" + { + context->yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number; + } + break; + + case 35: +#line 408 "getdate.y" + { + context->yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number; + } + break; + + case 36: +#line 411 "getdate.y" + { + context->yyRelMonth += yyvsp[0].Number; + } + break; + + case 37: +#line 414 "getdate.y" + { + context->yyRelDay += yyvsp[-1].Number * yyvsp[0].Number; + } + break; + + case 38: +#line 417 "getdate.y" + { + context->yyRelDay += yyvsp[-1].Number * yyvsp[0].Number; + } + break; + + case 39: +#line 420 "getdate.y" + { + context->yyRelDay += yyvsp[0].Number; + } + break; + + case 40: +#line 423 "getdate.y" + { + context->yyRelHour += yyvsp[-1].Number * yyvsp[0].Number; + } + break; + + case 41: +#line 426 "getdate.y" + { + context->yyRelHour += yyvsp[-1].Number * yyvsp[0].Number; + } + break; + + case 42: +#line 429 "getdate.y" + { + context->yyRelHour += yyvsp[0].Number; + } + break; + + case 43: +#line 432 "getdate.y" + { + context->yyRelMinutes += yyvsp[-1].Number * yyvsp[0].Number; + } + break; + + case 44: +#line 435 "getdate.y" + { + context->yyRelMinutes += yyvsp[-1].Number * yyvsp[0].Number; + } + break; + + case 45: +#line 438 "getdate.y" + { + context->yyRelMinutes += yyvsp[0].Number; + } + break; + + case 46: +#line 441 "getdate.y" + { + context->yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number; + } + break; + + case 47: +#line 444 "getdate.y" + { + context->yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number; + } + break; + + case 48: +#line 447 "getdate.y" + { + context->yyRelSeconds += yyvsp[0].Number; + } + break; + + case 49: +#line 453 "getdate.y" + { + if (context->yyHaveTime && context->yyHaveDate && + !context->yyHaveRel) + context->yyYear = yyvsp[0].Number; + else + { + if (yyvsp[0].Number>10000) + { + context->yyHaveDate++; + context->yyDay= (yyvsp[0].Number)%100; + context->yyMonth= (yyvsp[0].Number/100)%100; + context->yyYear = yyvsp[0].Number/10000; + } + else + { + context->yyHaveTime++; + if (yyvsp[0].Number < 100) + { + context->yyHour = yyvsp[0].Number; + context->yyMinutes = 0; + } + else + { + context->yyHour = yyvsp[0].Number / 100; + context->yyMinutes = yyvsp[0].Number % 100; + } + context->yySeconds = 0; + context->yyMeridian = MER24; + } + } + } + break; + + case 50: +#line 487 "getdate.y" + { + yyval.Meridian = MER24; + } + break; + + case 51: +#line 491 "getdate.y" + { + yyval.Meridian = yyvsp[0].Meridian; + } + break; + + + } + +/* Line 999 of yacc.c. */ +#line 1688 "y.tab.c" + + yyvsp -= yylen; + yyssp -= yylen; + + + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (YYPACT_NINF < yyn && yyn < YYLAST) + { + YYSIZE_T yysize = 0; + int yytype = YYTRANSLATE (yychar); + char *yymsg; + int yyx, yycount; + + yycount = 0; + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + for (yyx = yyn < 0 ? -yyn : 0; + yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + yysize += yystrlen (yytname[yyx]) + 15, yycount++; + yysize += yystrlen ("syntax error, unexpected ") + 1; + yysize += yystrlen (yytname[yytype]); + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg != 0) + { + char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); + yyp = yystpcpy (yyp, yytname[yytype]); + + if (yycount < 5) + { + yycount = 0; + for (yyx = yyn < 0 ? -yyn : 0; + yyx < (int) (sizeof (yytname) / sizeof (char *)); + yyx++) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + const char *yyq = ! yycount ? ", expecting " : " or "; + yyp = yystpcpy (yyp, yyq); + yyp = yystpcpy (yyp, yytname[yyx]); + yycount++; + } + } + yyerror (yymsg); + YYSTACK_FREE (yymsg); + } + else + yyerror ("syntax error; also virtual memory exhausted"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror ("syntax error"); + } + (void)yynerrs; + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + /* Return failure if at end of input. */ + if (yychar == YYEOF) + { + /* Pop the error token. */ + YYPOPSTACK; + /* Pop the rest of the stack. */ + while (yyss < yyssp) + { + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[*yyssp], yyvsp); + YYPOPSTACK; + } + YYABORT; + } + + YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); + yydestruct (yytoken, &yylval); + yychar = YYEMPTY; + + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*----------------------------------------------------. +| yyerrlab1 -- error raised explicitly by an action. | +`----------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[yystate], yyvsp); + yyvsp--; + yystate = *--yyssp; + + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + YYDPRINTF ((stderr, "Shifting error token, ")); + + *++yyvsp = yylval; + + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*----------------------------------------------. +| yyoverflowlab -- parser overflow comes here. | +`----------------------------------------------*/ +yyoverflowlab: + yyerror ("parser stack overflow"); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif + return yyresult; +} + + +#line 496 "getdate.y" + + +/* Include this file down here because bison inserts code above which + may define-away `const'. We want the prototype for get_date to have + the same signature as the function definition does. */ +#include "getdate.h" + +#ifndef WIN32 /* the windows dudes don't need these, does anyone really? */ +extern struct tm *gmtime (const time_t *); +extern struct tm *localtime (const time_t *); +extern time_t mktime (struct tm *); +#endif + +/* Month and day table. */ +static TABLE const MonthDayTable[] = { + { "january", tMONTH, 1 }, + { "february", tMONTH, 2 }, + { "march", tMONTH, 3 }, + { "april", tMONTH, 4 }, + { "may", tMONTH, 5 }, + { "june", tMONTH, 6 }, + { "july", tMONTH, 7 }, + { "august", tMONTH, 8 }, + { "september", tMONTH, 9 }, + { "sept", tMONTH, 9 }, + { "october", tMONTH, 10 }, + { "november", tMONTH, 11 }, + { "december", tMONTH, 12 }, + { "sunday", tDAY, 0 }, + { "monday", tDAY, 1 }, + { "tuesday", tDAY, 2 }, + { "tues", tDAY, 2 }, + { "wednesday", tDAY, 3 }, + { "wednes", tDAY, 3 }, + { "thursday", tDAY, 4 }, + { "thur", tDAY, 4 }, + { "thurs", tDAY, 4 }, + { "friday", tDAY, 5 }, + { "saturday", tDAY, 6 }, + { NULL, 0, 0 } +}; + +/* Time units table. */ +static TABLE const UnitsTable[] = { + { "year", tYEAR_UNIT, 1 }, + { "month", tMONTH_UNIT, 1 }, + { "fortnight", tDAY_UNIT, 14 }, + { "week", tDAY_UNIT, 7 }, + { "day", tDAY_UNIT, 1 }, + { "hour", tHOUR_UNIT, 1 }, + { "minute", tMINUTE_UNIT, 1 }, + { "min", tMINUTE_UNIT, 1 }, + { "second", tSEC_UNIT, 1 }, + { "sec", tSEC_UNIT, 1 }, + { NULL, 0, 0 } +}; + +/* Assorted relative-time words. */ +static TABLE const OtherTable[] = { + { "tomorrow", tMINUTE_UNIT, 1 * 24 * 60 }, + { "yesterday", tMINUTE_UNIT, -1 * 24 * 60 }, + { "today", tMINUTE_UNIT, 0 }, + { "now", tMINUTE_UNIT, 0 }, + { "last", tUNUMBER, -1 }, + { "this", tMINUTE_UNIT, 0 }, + { "next", tUNUMBER, 1 }, + { "first", tUNUMBER, 1 }, +/* { "second", tUNUMBER, 2 }, */ + { "third", tUNUMBER, 3 }, + { "fourth", tUNUMBER, 4 }, + { "fifth", tUNUMBER, 5 }, + { "sixth", tUNUMBER, 6 }, + { "seventh", tUNUMBER, 7 }, + { "eighth", tUNUMBER, 8 }, + { "ninth", tUNUMBER, 9 }, + { "tenth", tUNUMBER, 10 }, + { "eleventh", tUNUMBER, 11 }, + { "twelfth", tUNUMBER, 12 }, + { "ago", tAGO, 1 }, + { NULL, 0, 0 } +}; + +/* The timezone table. */ +static TABLE const TimezoneTable[] = { + { "gmt", tZONE, HOUR ( 0) }, /* Greenwich Mean */ + { "ut", tZONE, HOUR ( 0) }, /* Universal (Coordinated) */ + { "utc", tZONE, HOUR ( 0) }, + { "wet", tZONE, HOUR ( 0) }, /* Western European */ + { "bst", tDAYZONE, HOUR ( 0) }, /* British Summer */ + { "wat", tZONE, HOUR ( 1) }, /* West Africa */ + { "at", tZONE, HOUR ( 2) }, /* Azores */ +#if 0 + /* For completeness. BST is also British Summer, and GST is + * also Guam Standard. */ + { "bst", tZONE, HOUR ( 3) }, /* Brazil Standard */ + { "gst", tZONE, HOUR ( 3) }, /* Greenland Standard */ +#endif +#if 0 + { "nft", tZONE, HOUR (3.5) }, /* Newfoundland */ + { "nst", tZONE, HOUR (3.5) }, /* Newfoundland Standard */ + { "ndt", tDAYZONE, HOUR (3.5) }, /* Newfoundland Daylight */ +#endif + { "ast", tZONE, HOUR ( 4) }, /* Atlantic Standard */ + { "adt", tDAYZONE, HOUR ( 4) }, /* Atlantic Daylight */ + { "est", tZONE, HOUR ( 5) }, /* Eastern Standard */ + { "edt", tDAYZONE, HOUR ( 5) }, /* Eastern Daylight */ + { "cst", tZONE, HOUR ( 6) }, /* Central Standard */ + { "cdt", tDAYZONE, HOUR ( 6) }, /* Central Daylight */ + { "mst", tZONE, HOUR ( 7) }, /* Mountain Standard */ + { "mdt", tDAYZONE, HOUR ( 7) }, /* Mountain Daylight */ + { "pst", tZONE, HOUR ( 8) }, /* Pacific Standard */ + { "pdt", tDAYZONE, HOUR ( 8) }, /* Pacific Daylight */ + { "yst", tZONE, HOUR ( 9) }, /* Yukon Standard */ + { "ydt", tDAYZONE, HOUR ( 9) }, /* Yukon Daylight */ + { "hst", tZONE, HOUR (10) }, /* Hawaii Standard */ + { "hdt", tDAYZONE, HOUR (10) }, /* Hawaii Daylight */ + { "cat", tZONE, HOUR (10) }, /* Central Alaska */ + { "ahst", tZONE, HOUR (10) }, /* Alaska-Hawaii Standard */ + { "nt", tZONE, HOUR (11) }, /* Nome */ + { "idlw", tZONE, HOUR (12) }, /* International Date Line West */ + { "cet", tZONE, -HOUR (1) }, /* Central European */ + { "met", tZONE, -HOUR (1) }, /* Middle European */ + { "mewt", tZONE, -HOUR (1) }, /* Middle European Winter */ + { "mest", tDAYZONE, -HOUR (1) }, /* Middle European Summer */ + { "mesz", tDAYZONE, -HOUR (1) }, /* Middle European Summer */ + { "swt", tZONE, -HOUR (1) }, /* Swedish Winter */ + { "sst", tDAYZONE, -HOUR (1) }, /* Swedish Summer */ + { "fwt", tZONE, -HOUR (1) }, /* French Winter */ + { "fst", tDAYZONE, -HOUR (1) }, /* French Summer */ + { "eet", tZONE, -HOUR (2) }, /* Eastern Europe, USSR Zone 1 */ + { "bt", tZONE, -HOUR (3) }, /* Baghdad, USSR Zone 2 */ +#if 0 + { "it", tZONE, -HOUR (3.5) },/* Iran */ +#endif + { "zp4", tZONE, -HOUR (4) }, /* USSR Zone 3 */ + { "zp5", tZONE, -HOUR (5) }, /* USSR Zone 4 */ +#if 0 + { "ist", tZONE, -HOUR (5.5) },/* Indian Standard */ +#endif + { "zp6", tZONE, -HOUR (6) }, /* USSR Zone 5 */ +#if 0 + /* For completeness. NST is also Newfoundland Standard, and SST is + * also Swedish Summer. */ + { "nst", tZONE, -HOUR (6.5) },/* North Sumatra */ + { "sst", tZONE, -HOUR (7) }, /* South Sumatra, USSR Zone 6 */ +#endif /* 0 */ + { "wast", tZONE, -HOUR (7) }, /* West Australian Standard */ + { "wadt", tDAYZONE, -HOUR (7) }, /* West Australian Daylight */ +#if 0 + { "jt", tZONE, -HOUR (7.5) },/* Java (3pm in Cronusland!) */ +#endif + { "cct", tZONE, -HOUR (8) }, /* China Coast, USSR Zone 7 */ + { "jst", tZONE, -HOUR (9) }, /* Japan Standard, USSR Zone 8 */ +#if 0 + { "cast", tZONE, -HOUR (9.5) },/* Central Australian Standard */ + { "cadt", tDAYZONE, -HOUR (9.5) },/* Central Australian Daylight */ +#endif + { "east", tZONE, -HOUR (10) }, /* Eastern Australian Standard */ + { "eadt", tDAYZONE, -HOUR (10) }, /* Eastern Australian Daylight */ + { "gst", tZONE, -HOUR (10) }, /* Guam Standard, USSR Zone 9 */ + { "nzt", tZONE, -HOUR (12) }, /* New Zealand */ + { "nzst", tZONE, -HOUR (12) }, /* New Zealand Standard */ + { "nzdt", tDAYZONE, -HOUR (12) }, /* New Zealand Daylight */ + { "idle", tZONE, -HOUR (12) }, /* International Date Line East */ + { NULL, 0, 0 } +}; + +/* Military timezone table. */ +static TABLE const MilitaryTable[] = { + { "a", tZONE, HOUR ( 1) }, + { "b", tZONE, HOUR ( 2) }, + { "c", tZONE, HOUR ( 3) }, + { "d", tZONE, HOUR ( 4) }, + { "e", tZONE, HOUR ( 5) }, + { "f", tZONE, HOUR ( 6) }, + { "g", tZONE, HOUR ( 7) }, + { "h", tZONE, HOUR ( 8) }, + { "i", tZONE, HOUR ( 9) }, + { "k", tZONE, HOUR ( 10) }, + { "l", tZONE, HOUR ( 11) }, + { "m", tZONE, HOUR ( 12) }, + { "n", tZONE, HOUR (- 1) }, + { "o", tZONE, HOUR (- 2) }, + { "p", tZONE, HOUR (- 3) }, + { "q", tZONE, HOUR (- 4) }, + { "r", tZONE, HOUR (- 5) }, + { "s", tZONE, HOUR (- 6) }, + { "t", tZONE, HOUR (- 7) }, + { "u", tZONE, HOUR (- 8) }, + { "v", tZONE, HOUR (- 9) }, + { "w", tZONE, HOUR (-10) }, + { "x", tZONE, HOUR (-11) }, + { "y", tZONE, HOUR (-12) }, + { "z", tZONE, HOUR ( 0) }, + { NULL, 0, 0 } +}; + + + + +/* ARGSUSED */ +static int +yyerror (const char *s ATTRIBUTE_UNUSED) +{ + return 0; +} + +static int +ToHour (int Hours, MERIDIAN Meridian) +{ + switch (Meridian) + { + case MER24: + if (Hours < 0 || Hours > 23) + return -1; + return Hours; + case MERam: + if (Hours < 1 || Hours > 12) + return -1; + if (Hours == 12) + Hours = 0; + return Hours; + case MERpm: + if (Hours < 1 || Hours > 12) + return -1; + if (Hours == 12) + Hours = 0; + return Hours + 12; + default: + break; /* used to do abort() here */ + } + /* NOTREACHED - but make gcc happy! */ + return -1; +} + +static int +ToYear (int Year) +{ + if (Year < 0) + Year = -Year; + + /* XPG4 suggests that years 00-68 map to 2000-2068, and + years 69-99 map to 1969-1999. */ + if (Year < 69) + Year += 2000; + else if (Year < 100) + Year += 1900; + + return Year; +} + +static int +LookupWord (YYSTYPE *yylval, char *buff) +{ + char *p; + char *q; + const TABLE *tp; + size_t i; + int abbrev; + + /* Make it lowercase. */ + for (p = buff; *p; p++) + if (ISUPPER ((unsigned char) *p)) + *p = tolower ((int)*p); + + if (strcmp (buff, "am") == 0 || strcmp (buff, "a.m.") == 0) + { + yylval->Meridian = MERam; + return tMERIDIAN; + } + if (strcmp (buff, "pm") == 0 || strcmp (buff, "p.m.") == 0) + { + yylval->Meridian = MERpm; + return tMERIDIAN; + } + + /* See if we have an abbreviation for a month. */ + if (strlen (buff) == 3) + abbrev = 1; + else if (strlen (buff) == 4 && buff[3] == '.') + { + abbrev = 1; + buff[3] = '\0'; + } + else + abbrev = 0; + + for (tp = MonthDayTable; tp->name; tp++) + { + if (abbrev) + { + if (strncmp (buff, tp->name, 3) == 0) + { + yylval->Number = tp->value; + return tp->type; + } + } + else if (strcmp (buff, tp->name) == 0) + { + yylval->Number = tp->value; + return tp->type; + } + } + + for (tp = TimezoneTable; tp->name; tp++) + if (strcmp (buff, tp->name) == 0) + { + yylval->Number = tp->value; + return tp->type; + } + + if (strcmp (buff, "dst") == 0) + return tDST; + + for (tp = UnitsTable; tp->name; tp++) + if (strcmp (buff, tp->name) == 0) + { + yylval->Number = tp->value; + return tp->type; + } + + /* Strip off any plural and try the units table again. */ + i = strlen (buff) - 1; + if (buff[i] == 's') + { + buff[i] = '\0'; + for (tp = UnitsTable; tp->name; tp++) + if (strcmp (buff, tp->name) == 0) + { + yylval->Number = tp->value; + return tp->type; + } + buff[i] = 's'; /* Put back for "this" in OtherTable. */ + } + + for (tp = OtherTable; tp->name; tp++) + if (strcmp (buff, tp->name) == 0) + { + yylval->Number = tp->value; + return tp->type; + } + + /* Military timezones. */ + if (buff[1] == '\0' && ISALPHA ((unsigned char) *buff)) + { + for (tp = MilitaryTable; tp->name; tp++) + if (strcmp (buff, tp->name) == 0) + { + yylval->Number = tp->value; + return tp->type; + } + } + + /* Drop out any periods and try the timezone table again. */ + for (i = 0, p = q = buff; *q; q++) + if (*q != '.') + *p++ = *q; + else + i++; + *p = '\0'; + if (i) + for (tp = TimezoneTable; tp->name; tp++) + if (strcmp (buff, tp->name) == 0) + { + yylval->Number = tp->value; + return tp->type; + } + + return tID; +} + +static int +yylex (YYSTYPE *yylval, void *cookie) +{ + register unsigned char c; + register char *p; + char buff[20]; + int Count; + int sign; + + for (;;) + { + while (ISSPACE ((unsigned char) *context->yyInput)) + context->yyInput++; + + if (ISDIGIT (c = *context->yyInput) || c == '-' || c == '+') + { + if (c == '-' || c == '+') + { + sign = c == '-' ? -1 : 1; + if (!ISDIGIT (*++context->yyInput)) + /* skip the '-' sign */ + continue; + } + else + sign = 0; + for (yylval->Number = 0; ISDIGIT (c = *context->yyInput++);) + yylval->Number = 10 * yylval->Number + c - '0'; + context->yyInput--; + if (sign < 0) + yylval->Number = -yylval->Number; + return sign ? tSNUMBER : tUNUMBER; + } + if (ISALPHA (c)) + { + for (p = buff; (c = *context->yyInput++, ISALPHA (c)) || c == '.';) + if (p < &buff[sizeof buff - 1]) + *p++ = c; + *p = '\0'; + context->yyInput--; + return LookupWord (yylval, buff); + } + if (c != '(') + return *context->yyInput++; + Count = 0; + do + { + c = *context->yyInput++; + if (c == '\0') + return c; + if (c == '(') + Count++; + else if (c == ')') + Count--; + } + while (Count > 0); + } +} + +#define TM_YEAR_ORIGIN 1900 + +/* Yield A - B, measured in seconds. */ +static long +difftm (struct tm *a, struct tm *b) +{ + int ay = a->tm_year + (TM_YEAR_ORIGIN - 1); + int by = b->tm_year + (TM_YEAR_ORIGIN - 1); + long days = ( + /* difference in day of year */ + a->tm_yday - b->tm_yday + /* + intervening leap days */ + + ((ay >> 2) - (by >> 2)) + - (ay / 100 - by / 100) + + ((ay / 100 >> 2) - (by / 100 >> 2)) + /* + difference in years * 365 */ + + (long) (ay - by) * 365 + ); + return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour)) + + (a->tm_min - b->tm_min)) + + (a->tm_sec - b->tm_sec)); +} + +time_t +curl_getdate (const char *p, const time_t *now) +{ + struct tm tm, tm0, *tmp; + time_t Start; + CURL_CONTEXT cookie; +#ifdef HAVE_LOCALTIME_R + struct tm keeptime; +#endif + cookie.yyInput = p; + Start = now ? *now : time ((time_t *) NULL); +#ifdef HAVE_LOCALTIME_R + tmp = (struct tm *)localtime_r(&Start, &keeptime); +#else + tmp = localtime (&Start); +#endif + if (!tmp) + return -1; + cookie.yyYear = tmp->tm_year + TM_YEAR_ORIGIN; + cookie.yyMonth = tmp->tm_mon + 1; + cookie.yyDay = tmp->tm_mday; + cookie.yyHour = tmp->tm_hour; + cookie.yyMinutes = tmp->tm_min; + cookie.yySeconds = tmp->tm_sec; + tm.tm_isdst = tmp->tm_isdst; + cookie.yyMeridian = MER24; + cookie.yyRelSeconds = 0; + cookie.yyRelMinutes = 0; + cookie.yyRelHour = 0; + cookie.yyRelDay = 0; + cookie.yyRelMonth = 0; + cookie.yyRelYear = 0; + cookie.yyHaveDate = 0; + cookie.yyHaveDay = 0; + cookie.yyHaveRel = 0; + cookie.yyHaveTime = 0; + cookie.yyHaveZone = 0; + + if (yyparse ((void*)&cookie) + || cookie.yyHaveTime > 1 || cookie.yyHaveZone > 1 || + cookie.yyHaveDate > 1 || cookie.yyHaveDay > 1) + return -1; + + tm.tm_year = ToYear (cookie.yyYear) - TM_YEAR_ORIGIN + cookie.yyRelYear; + tm.tm_mon = cookie.yyMonth - 1 + cookie.yyRelMonth; + tm.tm_mday = cookie.yyDay + cookie.yyRelDay; + if (cookie.yyHaveTime || + (cookie.yyHaveRel && !cookie.yyHaveDate && !cookie.yyHaveDay)) + { + tm.tm_hour = ToHour (cookie.yyHour, cookie.yyMeridian); + if (tm.tm_hour < 0) + return -1; + tm.tm_min = cookie.yyMinutes; + tm.tm_sec = cookie.yySeconds; + } + else + { + tm.tm_hour = tm.tm_min = tm.tm_sec = 0; + } + tm.tm_hour += cookie.yyRelHour; + tm.tm_min += cookie.yyRelMinutes; + tm.tm_sec += cookie.yyRelSeconds; + + /* Let mktime deduce tm_isdst if we have an absolute timestamp, + or if the relative timestamp mentions days, months, or years. */ + if (cookie.yyHaveDate | cookie.yyHaveDay | cookie.yyHaveTime | + cookie.yyRelDay | cookie.yyRelMonth | cookie.yyRelYear) + tm.tm_isdst = -1; + + tm0 = tm; + + Start = mktime (&tm); + + if (Start == (time_t) -1) + { + + /* Guard against falsely reporting errors near the time_t boundaries + when parsing times in other time zones. For example, if the min + time_t value is 1970-01-01 00:00:00 UTC and we are 8 hours ahead + of UTC, then the min localtime value is 1970-01-01 08:00:00; if + we apply mktime to 1970-01-01 00:00:00 we will get an error, so + we apply mktime to 1970-01-02 08:00:00 instead and adjust the time + zone by 24 hours to compensate. This algorithm assumes that + there is no DST transition within a day of the time_t boundaries. */ + if (cookie.yyHaveZone) + { + tm = tm0; + if (tm.tm_year <= EPOCH - TM_YEAR_ORIGIN) + { + tm.tm_mday++; + cookie.yyTimezone -= 24 * 60; + } + else + { + tm.tm_mday--; + cookie.yyTimezone += 24 * 60; + } + Start = mktime (&tm); + } + + if (Start == (time_t) -1) + return Start; + } + + if (cookie.yyHaveDay && !cookie.yyHaveDate) + { + tm.tm_mday += ((cookie.yyDayNumber - tm.tm_wday + 7) % 7 + + 7 * (cookie.yyDayOrdinal - (0 < cookie.yyDayOrdinal))); + Start = mktime (&tm); + if (Start == (time_t) -1) + return Start; + } + + if (cookie.yyHaveZone) + { + long delta; + struct tm *gmt; +#ifdef HAVE_GMTIME_R + /* thread-safe version */ + struct tm keeptime2; + gmt = (struct tm *)gmtime_r(&Start, &keeptime2); +#else + gmt = gmtime(&Start); +#endif + if (!gmt) + return -1; + delta = cookie.yyTimezone * 60L + difftm (&tm, gmt); + if ((Start + delta < Start) != (delta < 0)) + return -1; /* time_t overflow */ + Start += delta; + } + + return Start; +} + + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/getdate.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/getdate.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/getdate.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/getdate.h 2003-01-07 10:13:39.000000000 +0800 @@ -0,0 +1,37 @@ +/* +** Originally written by Steven M. Bellovin while +** at the University of North Carolina at Chapel Hill. Later tweaked by +** a couple of people on Usenet. Completely overhauled by Rich $alz +** and Jim Berets in August, 1990. +** +** This code is in the public domain and has no copyright. +*/ + +# include "setup.h" + +#ifndef PARAMS +# if defined PROTOTYPES || (defined __STDC__ && __STDC__) +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +#endif + +#ifdef vms +# include +# include +#else +# include +# if TIME_WITH_SYS_TIME +# include +# include +# else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +# endif +#endif /* defined (vms) */ + +time_t curl_getdate PARAMS ((const char *p, const time_t *now)); diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/getenv.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/getenv.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/getenv.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/getenv.c 2004-10-06 00:42:37.000000000 +0800 @@ -0,0 +1,70 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: getenv.c,v 1.6 2004/10/05 16:42:37 hoffman Exp $ + ***************************************************************************/ + +#include "setup.h" + +#include +#include +#include + +#ifdef WIN32 +#include +#endif + +#ifdef VMS +#include +#endif + +#include +#include "curl_memory.h" + +#include "memdebug.h" + +static +char *GetEnv(const char *variable) +{ +#ifdef WIN32 + /* This shit requires windows.h (HUGE) to be included */ + char env[MAX_PATH]; /* MAX_PATH is from windef.h */ + char *temp = getenv(variable); + env[0] = '\0'; + if (temp != NULL) + ExpandEnvironmentStrings(temp, env, sizeof(env)); +#else +#ifdef VMS + char *env = getenv(variable); + if (env && strcmp("HOME",variable) == 0) { + env = decc$translate_vms(env); + } +#else + /* no length control */ + char *env = getenv(variable); +#endif +#endif + return (env && env[0])?strdup(env):NULL; +} + +char *curl_getenv(const char *v) +{ + return GetEnv(v); +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/getinfo.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/getinfo.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/getinfo.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/getinfo.c 2004-10-06 00:42:38.000000000 +0800 @@ -0,0 +1,174 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: getinfo.c,v 1.6 2004/10/05 16:42:38 hoffman Exp $ + ***************************************************************************/ + +#include "setup.h" + +#include + +#include "urldata.h" +#include "getinfo.h" + +#include +#include +#include +#include +#include "curl_memory.h" + +/* Make this the last #include */ +#include "memdebug.h" + +/* + * This is supposed to be called in the beginning of a permform() session + * and should reset all session-info variables + */ +CURLcode Curl_initinfo(struct SessionHandle *data) +{ + struct Progress *pro = &data->progress; + struct PureInfo *info =&data->info; + + pro->t_nslookup = 0; + pro->t_connect = 0; + pro->t_pretransfer = 0; + pro->t_starttransfer = 0; + pro->timespent = 0; + pro->t_redirect = 0; + + info->httpcode = 0; + info->httpversion=0; + info->filetime=-1; /* -1 is an illegal time and thus means unknown */ + + if (info->contenttype) + free(info->contenttype); + info->contenttype = NULL; + + info->header_size = 0; + info->request_size = 0; + return CURLE_OK; +} + +CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...) +{ + va_list arg; + long *param_longp=NULL; + double *param_doublep=NULL; + char **param_charp=NULL; + va_start(arg, info); + + switch(info&CURLINFO_TYPEMASK) { + default: + return CURLE_BAD_FUNCTION_ARGUMENT; + case CURLINFO_STRING: + param_charp = va_arg(arg, char **); + if(NULL == param_charp) + return CURLE_BAD_FUNCTION_ARGUMENT; + break; + case CURLINFO_LONG: + param_longp = va_arg(arg, long *); + if(NULL == param_longp) + return CURLE_BAD_FUNCTION_ARGUMENT; + break; + case CURLINFO_DOUBLE: + param_doublep = va_arg(arg, double *); + if(NULL == param_doublep) + return CURLE_BAD_FUNCTION_ARGUMENT; + break; + } + + switch(info) { + case CURLINFO_EFFECTIVE_URL: + *param_charp = data->change.url?data->change.url:(char *)""; + break; + case CURLINFO_RESPONSE_CODE: + *param_longp = data->info.httpcode; + break; + case CURLINFO_HTTP_CONNECTCODE: + *param_longp = data->info.httpproxycode; + break; + case CURLINFO_FILETIME: + *param_longp = data->info.filetime; + break; + case CURLINFO_HEADER_SIZE: + *param_longp = data->info.header_size; + break; + case CURLINFO_REQUEST_SIZE: + *param_longp = data->info.request_size; + break; + case CURLINFO_TOTAL_TIME: + *param_doublep = data->progress.timespent; + break; + case CURLINFO_NAMELOOKUP_TIME: + *param_doublep = data->progress.t_nslookup; + break; + case CURLINFO_CONNECT_TIME: + *param_doublep = data->progress.t_connect; + break; + case CURLINFO_PRETRANSFER_TIME: + *param_doublep = data->progress.t_pretransfer; + break; + case CURLINFO_STARTTRANSFER_TIME: + *param_doublep = data->progress.t_starttransfer; + break; + case CURLINFO_SIZE_UPLOAD: + *param_doublep = (double)data->progress.uploaded; + break; + case CURLINFO_SIZE_DOWNLOAD: + *param_doublep = (double)data->progress.downloaded; + break; + case CURLINFO_SPEED_DOWNLOAD: + *param_doublep = (double)data->progress.dlspeed; + break; + case CURLINFO_SPEED_UPLOAD: + *param_doublep = (double)data->progress.ulspeed; + break; + case CURLINFO_SSL_VERIFYRESULT: + *param_longp = data->set.ssl.certverifyresult; + break; + case CURLINFO_CONTENT_LENGTH_DOWNLOAD: + *param_doublep = (double)data->progress.size_dl; + break; + case CURLINFO_CONTENT_LENGTH_UPLOAD: + *param_doublep = (double)data->progress.size_ul; + break; + case CURLINFO_REDIRECT_TIME: + *param_doublep = data->progress.t_redirect; + break; + case CURLINFO_REDIRECT_COUNT: + *param_longp = data->set.followlocation; + break; + case CURLINFO_CONTENT_TYPE: + *param_charp = data->info.contenttype; + break; + case CURLINFO_PRIVATE: + *param_charp = data->set.private; + break; + case CURLINFO_HTTPAUTH_AVAIL: + *param_longp = data->info.httpauthavail; + break; + case CURLINFO_PROXYAUTH_AVAIL: + *param_longp = data->info.proxyauthavail; + break; + default: + return CURLE_BAD_FUNCTION_ARGUMENT; + } + return CURLE_OK; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/getinfo.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/getinfo.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/getinfo.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/getinfo.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,28 @@ +#ifndef __GETINFO_H +#define __GETINFO_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: getinfo.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ +CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...); +CURLcode Curl_initinfo(struct SessionHandle *data); + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/hash.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/hash.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/hash.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/hash.c 2004-10-06 00:42:38.000000000 +0800 @@ -0,0 +1,267 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: hash.c,v 1.6 2004/10/05 16:42:38 hoffman Exp $ + ***************************************************************************/ + +#include "setup.h" + +#include +#include + +#include "hash.h" +#include "llist.h" +#include "curl_memory.h" + +/* this must be the last include file */ +#include "memdebug.h" + +static unsigned long +hash_str(const char *key, size_t key_length) +{ + char *end = (char *) key + key_length; + unsigned long h = 5381; + + while (key < end) { + h += h << 5; + h ^= (unsigned long) *key++; + } + + return h; +} + +static void +hash_element_dtor(void *user, void *element) +{ + curl_hash *h = (curl_hash *) user; + curl_hash_element *e = (curl_hash_element *) element; + + if (e->key) { + free(e->key); + } + + h->dtor(e->ptr); + + free(e); +} + +/* return 1 on error, 0 is fine */ +int +Curl_hash_init(curl_hash *h, int slots, curl_hash_dtor dtor) +{ + int i; + + h->dtor = dtor; + h->size = 0; + h->slots = slots; + + h->table = (curl_llist **) malloc(slots * sizeof(curl_llist *)); + if(h->table) { + for (i = 0; i < slots; ++i) { + h->table[i] = Curl_llist_alloc((curl_llist_dtor) hash_element_dtor); + if(!h->table[i]) { + while(i--) + Curl_llist_destroy(h->table[i], NULL); + free(h->table); + return 1; /* failure */ + } + } + return 0; /* fine */ + } + else + return 1; /* failure */ +} + +curl_hash * +Curl_hash_alloc(int slots, curl_hash_dtor dtor) +{ + curl_hash *h; + + h = (curl_hash *) malloc(sizeof(curl_hash)); + if (h) { + if(Curl_hash_init(h, slots, dtor)) { + /* failure */ + free(h); + h = NULL; + } + } + + return h; +} + +static int +hash_key_compare(char *key1, size_t key1_len, char *key2, size_t key2_len) +{ + if (key1_len == key2_len && + *key1 == *key2 && + memcmp(key1, key2, key1_len) == 0) { + return 1; + } + + return 0; +} + +static curl_hash_element * +mk_hash_element(char *key, size_t key_len, const void *p) +{ + curl_hash_element *he = + (curl_hash_element *) malloc(sizeof(curl_hash_element)); + + if(he) { + char *dup = strdup(key); + if(dup) { + he->key = dup; + he->key_len = key_len; + he->ptr = (void *) p; + } + else { + /* failed to duplicate the key, free memory and fail */ + free(he); + he = NULL; + } + } + return he; +} + +#define find_slot(__h, __k, __k_len) (hash_str(__k, __k_len) % (__h)->slots) + +#define FETCH_LIST(x,y,z) x->table[find_slot(x, y, z)] + +/* Return the data in the hash. If there already was a match in the hash, + that data is returned. */ +void * +Curl_hash_add(curl_hash *h, char *key, size_t key_len, void *p) +{ + curl_hash_element *he; + curl_llist_element *le; + curl_llist *l = FETCH_LIST(h, key, key_len); + + for (le = l->head; le; le = le->next) { + he = (curl_hash_element *) le->ptr; + if (hash_key_compare(he->key, he->key_len, key, key_len)) { + h->dtor(p); /* remove the NEW entry */ + return he->ptr; /* return the EXISTING entry */ + } + } + + he = mk_hash_element(key, key_len, p); + if (he) { + if(Curl_llist_insert_next(l, l->tail, he)) { + ++h->size; + return p; /* return the new entry */ + } + /* + * Couldn't insert it, destroy the 'he' element and the key again. We + * don't call hash_element_dtor() since that would also call the + * "destructor" for the actual data 'p'. When we fail, we shall not touch + * that data. + */ + free(he->key); + free(he); + } + + return NULL; /* failure */ +} + +void * +Curl_hash_pick(curl_hash *h, char *key, size_t key_len) +{ + curl_llist_element *le; + curl_hash_element *he; + curl_llist *l = FETCH_LIST(h, key, key_len); + + for (le = l->head; + le; + le = le->next) { + he = le->ptr; + if (hash_key_compare(he->key, he->key_len, key, key_len)) { + return he->ptr; + } + } + + return NULL; +} + +#if defined(CURLDEBUG) && defined(AGGRESIVE_TEST) +void +Curl_hash_apply(curl_hash *h, void *user, + void (*cb)(void *user, void *ptr)) +{ + curl_llist_element *le; + int i; + + for (i = 0; i < h->slots; ++i) { + for (le = (h->table[i])->head; + le; + le = le->next) { + curl_hash_element *el = le->ptr; + cb(user, el->ptr); + } + } +} +#endif + +void +Curl_hash_clean(curl_hash *h) +{ + int i; + + for (i = 0; i < h->slots; ++i) { + Curl_llist_destroy(h->table[i], (void *) h); + } + + free(h->table); +} + +void +Curl_hash_clean_with_criterium(curl_hash *h, void *user, + int (*comp)(void *, void *)) +{ + curl_llist_element *le; + curl_llist_element *lnext; + curl_llist *list; + int i; + + for (i = 0; i < h->slots; ++i) { + list = h->table[i]; + le = list->head; /* get first list entry */ + while(le) { + curl_hash_element *he = le->ptr; + lnext = le->next; + /* ask the callback function if we shall remove this entry or not */ + if (comp(user, he->ptr)) { + Curl_llist_remove(list, le, (void *) h); + --h->size; /* one less entry in the hash now */ + } + le = lnext; + } + } +} + +void +Curl_hash_destroy(curl_hash *h) +{ + if (!h) + return; + + Curl_hash_clean(h); + free(h); +} + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/hash.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/hash.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/hash.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/hash.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,60 @@ +#ifndef __HASH_H +#define __HASH_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: hash.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +#include "setup.h" + +#include + +#include "llist.h" + +typedef void (*curl_hash_dtor)(void *); + +typedef struct _curl_hash { + curl_llist **table; + curl_hash_dtor dtor; + int slots; + size_t size; +} curl_hash; + +typedef struct _curl_hash_element { + void *ptr; + char *key; + size_t key_len; +} curl_hash_element; + + +int Curl_hash_init(curl_hash *, int, curl_hash_dtor); +curl_hash *Curl_hash_alloc(int, curl_hash_dtor); +void *Curl_hash_add(curl_hash *, char *, size_t, void *); +int Curl_hash_delete(curl_hash *h, char *key, size_t key_len); +void *Curl_hash_pick(curl_hash *, char *, size_t); +void Curl_hash_apply(curl_hash *h, void *user, + void (*cb)(void *user, void *ptr)); +int Curl_hash_count(curl_hash *h); +void Curl_hash_clean(curl_hash *h); +void Curl_hash_clean_with_criterium(curl_hash *h, void *user, int (*comp)(void *, void *)); +void Curl_hash_destroy(curl_hash *h); + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/hostares.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/hostares.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/hostares.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/hostares.c 2004-10-06 00:42:38.000000000 +0800 @@ -0,0 +1,301 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: hostares.c,v 1.2 2004/10/05 16:42:38 hoffman Exp $ + ***************************************************************************/ + +#include "setup.h" + +#include +#include + +#define _REENTRANT + +#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__) +#include +#else +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_NETDB_H +#include +#endif +#ifdef HAVE_ARPA_INET_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include /* required for free() prototypes */ +#endif +#ifdef HAVE_UNISTD_H +#include /* for the close() proto */ +#endif +#ifdef VMS +#include +#include +#include +#endif +#endif + +#ifdef HAVE_SETJMP_H +#include +#endif + +#ifdef WIN32 +#include +#endif + +#if (defined(NETWARE) && defined(__NOVELL_LIBC__)) +#undef in_addr_t +#define in_addr_t unsigned long +#endif + +#include "urldata.h" +#include "sendf.h" +#include "hostip.h" +#include "hash.h" +#include "share.h" +#include "strerror.h" +#include "url.h" + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +#if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL) +#include "inet_ntoa_r.h" +#endif + +#include "curl_memory.h" + +/* The last #include file should be: */ +#include "memdebug.h" + +/*********************************************************************** + * Only for ares-enabled builds + **********************************************************************/ + +#ifdef CURLRES_ARES + +/* + * Curl_fdset() is called when someone from the outside world (using + * curl_multi_fdset()) wants to get our fd_set setup and we're talking with + * ares. The caller must make sure that this function is only called when we + * have a working ares channel. + * + * Returns: CURLE_OK always! + */ + +CURLcode Curl_fdset(struct connectdata *conn, + fd_set *read_fd_set, + fd_set *write_fd_set, + int *max_fdp) + +{ + int max = ares_fds(conn->data->state.areschannel, + read_fd_set, write_fd_set); + *max_fdp = max; + + return CURLE_OK; +} + +/* + * Curl_is_resolved() is called repeatedly to check if a previous name resolve + * request has completed. It should also make sure to time-out if the + * operation seems to take too long. + * + * Returns normal CURLcode errors. + */ +CURLcode Curl_is_resolved(struct connectdata *conn, + struct Curl_dns_entry **dns) +{ + fd_set read_fds, write_fds; + struct timeval tv={0,0}; + struct SessionHandle *data = conn->data; + int nfds; + + FD_ZERO(&read_fds); + FD_ZERO(&write_fds); + + nfds = ares_fds(data->state.areschannel, &read_fds, &write_fds); + + (void)select(nfds, &read_fds, &write_fds, NULL, + (struct timeval *)&tv); + + /* Call ares_process() unconditonally here, even if we simply timed out + above, as otherwise the ares name resolve won't timeout! */ + ares_process(data->state.areschannel, &read_fds, &write_fds); + + *dns = NULL; + + if(conn->async.done) { + /* we're done, kill the ares handle */ + if(!conn->async.dns) { + failf(data, "Could not resolve host: %s (%s)", conn->host.dispname, + ares_strerror(conn->async.status)); + return CURLE_COULDNT_RESOLVE_HOST; + } + *dns = conn->async.dns; + } + + return CURLE_OK; +} + +/* + * Curl_wait_for_resolv() waits for a resolve to finish. This function should + * be avoided since using this risk getting the multi interface to "hang". + * + * If 'entry' is non-NULL, make it point to the resolved dns entry + * + * Returns CURLE_COULDNT_RESOLVE_HOST if the host was not resolved, and + * CURLE_OPERATION_TIMEDOUT if a time-out occurred. + */ +CURLcode Curl_wait_for_resolv(struct connectdata *conn, + struct Curl_dns_entry **entry) +{ + CURLcode rc=CURLE_OK; + struct SessionHandle *data = conn->data; + long timeout = CURL_TIMEOUT_RESOLVE; /* default name resolve timeout */ + + /* now, see if there's a connect timeout or a regular timeout to + use instead of the default one */ + if(conn->data->set.connecttimeout) + timeout = conn->data->set.connecttimeout; + else if(conn->data->set.timeout) + timeout = conn->data->set.timeout; + + /* We convert the number of seconds into number of milliseconds here: */ + if(timeout < 2147483) + /* maximum amount of seconds that can be multiplied with 1000 and + still fit within 31 bits */ + timeout *= 1000; + else + timeout = 0x7fffffff; /* ridiculous amount of time anyway */ + + /* Wait for the name resolve query to complete. */ + while (1) { + int nfds=0; + fd_set read_fds, write_fds; + struct timeval *tvp, tv, store; + int count; + struct timeval now = Curl_tvnow(); + long timediff; + + store.tv_sec = (int)timeout/1000; + store.tv_usec = (timeout%1000)*1000; + + FD_ZERO(&read_fds); + FD_ZERO(&write_fds); + nfds = ares_fds(data->state.areschannel, &read_fds, &write_fds); + if (nfds == 0) + /* no file descriptors means we're done waiting */ + break; + tvp = ares_timeout(data->state.areschannel, &store, &tv); + count = select(nfds, &read_fds, &write_fds, NULL, tvp); + if (count < 0 && errno != EINVAL) + break; + + ares_process(data->state.areschannel, &read_fds, &write_fds); + + timediff = Curl_tvdiff(Curl_tvnow(), now); /* spent time */ + timeout -= timediff?timediff:1; /* always deduct at least 1 */ + if (timeout < 0) { + /* our timeout, so we cancel the ares operation */ + ares_cancel(data->state.areschannel); + break; + } + } + + /* Operation complete, if the lookup was successful we now have the entry + in the cache. */ + + if(entry) + *entry = conn->async.dns; + + if(!conn->async.dns) { + /* a name was not resolved */ + if((timeout < 0) || (conn->async.status == ARES_ETIMEOUT)) { + failf(data, "Resolving host timed out: %s", conn->host.dispname); + rc = CURLE_OPERATION_TIMEDOUT; + } + else if(conn->async.done) { + failf(data, "Could not resolve host: %s (%s)", conn->host.dispname, + ares_strerror(conn->async.status)); + rc = CURLE_COULDNT_RESOLVE_HOST; + } + else + rc = CURLE_OPERATION_TIMEDOUT; + + /* close the connection, since we can't return failure here without + cleaning up this connection properly */ + Curl_disconnect(conn); + } + + return rc; +} + +/* + * Curl_getaddrinfo() - when using ares + * + * Returns name information about the given hostname and port number. If + * successful, the 'hostent' is returned and the forth argument will point to + * memory we need to free after use. That memory *MUST* be freed with + * Curl_freeaddrinfo(), nothing else. + */ +Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, + char *hostname, + int port, + int *waitp) +{ + char *bufp; + struct SessionHandle *data = conn->data; + in_addr_t in = inet_addr(hostname); + + *waitp = FALSE; + + if (in != CURL_INADDR_NONE) { + /* This is a dotted IP address 123.123.123.123-style */ + return Curl_ip2addr(in, hostname, port); + } + + bufp = strdup(hostname); + + if(bufp) { + Curl_safefree(conn->async.hostname); + conn->async.hostname = bufp; + conn->async.port = port; + conn->async.done = FALSE; /* not done */ + conn->async.status = 0; /* clear */ + conn->async.dns = NULL; /* clear */ + + /* areschannel is already setup in the Curl_open() function */ + ares_gethostbyname(data->state.areschannel, hostname, PF_INET, + Curl_addrinfo4_callback, conn); + + *waitp = TRUE; /* please wait for the response */ + } + return NULL; /* no struct yet */ +} + +#endif /* CURLRES_ARES */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/hostasyn.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/hostasyn.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/hostasyn.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/hostasyn.c 2004-10-06 00:42:38.000000000 +0800 @@ -0,0 +1,170 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: hostasyn.c,v 1.2 2004/10/05 16:42:38 hoffman Exp $ + ***************************************************************************/ + +#include "setup.h" + +#include +#include + +#define _REENTRANT + +#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__) +#include +#else +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_NETDB_H +#include +#endif +#ifdef HAVE_ARPA_INET_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include /* required for free() prototypes */ +#endif +#ifdef HAVE_UNISTD_H +#include /* for the close() proto */ +#endif +#ifdef VMS +#include +#include +#include +#endif +#endif + +#ifdef HAVE_SETJMP_H +#include +#endif + +#ifdef WIN32 +#include +#endif + +#if (defined(NETWARE) && defined(__NOVELL_LIBC__)) +#undef in_addr_t +#define in_addr_t unsigned long +#endif + +#include "urldata.h" +#include "sendf.h" +#include "hostip.h" +#include "hash.h" +#include "share.h" +#include "strerror.h" +#include "url.h" + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +#if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL) +#include "inet_ntoa_r.h" +#endif + +#include "curl_memory.h" +/* The last #include file should be: */ +#include "memdebug.h" + +/*********************************************************************** + * Only for builds using asynchronous name resolves + **********************************************************************/ +#ifdef CURLRES_ASYNCH +/* + * addrinfo_callback() gets called by ares, gethostbyname_thread() or + * getaddrinfo_thread() when we got the name resolved (or not!). + * + * If the status argument is CURL_ASYNC_SUCCESS, we might need to copy the + * address field since it might be freed when this function returns. This + * operation stores the resolved data in the DNS cache. + * + * NOTE: for IPv6 operations, Curl_addrinfo_copy() returns the same + * pointer it is given as argument! + * + * The storage operation locks and unlocks the DNS cache. + */ +static void addrinfo_callback(void *arg, /* "struct connectdata *" */ + int status, + void *addr) +{ + struct connectdata *conn = (struct connectdata *)arg; + struct Curl_dns_entry *dns = NULL; + + conn->async.done = TRUE; + conn->async.status = status; + + if(CURL_ASYNC_SUCCESS == status) { + + /* + * IPv4: Curl_addrinfo_copy() copies the address and returns an allocated + * version. + * + * IPv6: Curl_addrinfo_copy() returns the input pointer! + */ + Curl_addrinfo *ai = Curl_addrinfo_copy(addr, conn->async.port); + if(ai) { + struct SessionHandle *data = conn->data; + + if(data->share) + Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); + + dns = Curl_cache_addr(data, ai, + conn->async.hostname, + conn->async.port); + if(!dns) + /* failed to store, cleanup and return error */ + Curl_freeaddrinfo(ai); + + if(data->share) + Curl_share_unlock(data, CURL_LOCK_DATA_DNS); + } + } + + conn->async.dns = dns; + + /* ipv4: The input hostent struct will be freed by ares when we return from + this function */ +} + +void Curl_addrinfo4_callback(void *arg, /* "struct connectdata *" */ + int status, + struct hostent *hostent) +{ + addrinfo_callback(arg, status, hostent); +} + +#ifdef CURLRES_IPV6 +void Curl_addrinfo6_callback(void *arg, /* "struct connectdata *" */ + int status, + struct addrinfo *ai) +{ + addrinfo_callback(arg, status, ai); +} +#endif + +#endif /* CURLRES_ASYNC */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/hostip4.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/hostip4.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/hostip4.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/hostip4.c 2004-10-11 23:44:08.000000000 +0800 @@ -0,0 +1,456 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: hostip4.c,v 1.4 2004/10/11 15:44:08 andy Exp $ + ***************************************************************************/ + +#include "setup.h" + +#include +#include + +#define _REENTRANT + +#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__) +#include +#else +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_NETDB_H +#include +#endif +#ifdef HAVE_ARPA_INET_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include /* required for free() prototypes */ +#endif +#ifdef HAVE_UNISTD_H +#include /* for the close() proto */ +#endif +#ifdef VMS +#include +#include +#include +#endif +#endif + +#ifdef HAVE_SETJMP_H +#include +#endif + +#ifdef WIN32 +#include +#endif + +#if (defined(NETWARE) && defined(__NOVELL_LIBC__)) +#undef in_addr_t +#define in_addr_t unsigned long +#endif + +#include "urldata.h" +#include "sendf.h" +#include "hostip.h" +#include "hash.h" +#include "share.h" +#include "strerror.h" +#include "url.h" + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +#if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL) +#include "inet_ntoa_r.h" +#endif + +#include "curl_memory.h" +/* The last #include file should be: */ +#include "memdebug.h" + +/*********************************************************************** + * Only for plain-ipv4 builds + **********************************************************************/ +#ifdef CURLRES_IPV4 /* plain ipv4 code coming up */ + +/* + * This is a function for freeing name information in a protocol independent + * way. + */ +void Curl_freeaddrinfo(Curl_addrinfo *ai) +{ + Curl_addrinfo *next; + + /* walk over the list and free all entries */ + while(ai) { + next = ai->ai_next; + free(ai); + ai = next; + } +} + +/* + * Curl_ipvalid() checks what CURL_IPRESOLVE_* requirements that might've + * been set and returns TRUE if they are OK. + */ +bool Curl_ipvalid(struct SessionHandle *data) +{ + if(data->set.ip_version == CURL_IPRESOLVE_V6) + /* an ipv6 address was requested and we can't get/use one */ + return FALSE; + + return TRUE; /* OK, proceed */ +} + +struct namebuf { + struct hostent hostentry; + char *h_addr_list[2]; + struct in_addr addrentry; + char h_name[16]; /* 123.123.123.123 = 15 letters is maximum */ +}; + +/* + * Curl_ip2addr() takes a 32bit ipv4 internet address as input parameter + * together with a pointer to the string version of the address, and it + * returns a Curl_addrinfo chain filled in correctly with information for this + * address/host. + * + * The input parameters ARE NOT checked for validity but they are expected + * to have been checked already when this is called. + */ +Curl_addrinfo *Curl_ip2addr(in_addr_t num, char *hostname, int port) +{ + Curl_addrinfo *ai; + struct hostent *h; + struct in_addr *addrentry; + struct namebuf buffer; + struct namebuf *buf = &buffer; + + h = &buf->hostentry; + h->h_addr_list = &buf->h_addr_list[0]; + addrentry = &buf->addrentry; + addrentry->s_addr = num; + h->h_addr_list[0] = (char*)addrentry; + h->h_addr_list[1] = NULL; + h->h_addrtype = AF_INET; + h->h_length = sizeof(*addrentry); + h->h_name = &buf->h_name[0]; + h->h_aliases = NULL; + + /* Now store the dotted version of the address */ + snprintf((char*)(h->h_name), 16, "%s", hostname); + + ai = Curl_he2ai(h, port); + + return ai; +} + +#ifdef CURLRES_SYNCH /* the functions below are for synchronous resolves */ + +/* + * Curl_getaddrinfo() - the ipv4 synchronous version. + * + * The original code to this function was once stolen from the Dancer source + * code, written by Bjorn Reese, it has since been patched and modified + * considerably. + * + * gethostbyname_r() is the thread-safe version of the gethostbyname() + * function. When we build for plain IPv4, we attempt to use this + * function. There are _three_ different gethostbyname_r() versions, and we + * detect which one this platform supports in the configure script and set up + * the HAVE_GETHOSTBYNAME_R_3, HAVE_GETHOSTBYNAME_R_5 or + * HAVE_GETHOSTBYNAME_R_6 defines accordingly. Note that HAVE_GETADDRBYNAME + * has the corresponding rules. This is primarily on *nix. Note that some unix + * flavours have thread-safe versions of the plain gethostbyname() etc. + * + */ +Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, + char *hostname, + int port, + int *waitp) +{ + Curl_addrinfo *ai = NULL; + struct hostent *h = NULL; + in_addr_t in; + struct SessionHandle *data = conn->data; + struct hostent *buf = NULL; + + (void)port; /* unused in IPv4 code */ + + *waitp = 0; /* don't wait, we act synchronously */ + + in=inet_addr(hostname); + if (in != CURL_INADDR_NONE) { + /* This is a dotted IP address 123.123.123.123-style */ + return Curl_ip2addr(in, hostname, port); + } + +#if defined(HAVE_GETHOSTBYNAME_R) + /* + * gethostbyname_r() is the preferred resolve function for many platforms. + * Since there are three different versions of it, the following code is + * somewhat #ifdef-ridden. + */ + else { + int h_errnop; + int res=ERANGE; + + buf = (struct hostent *)calloc(CURL_HOSTENT_SIZE, 1); + if(!buf) + return NULL; /* major failure */ + /* + * The clearing of the buffer is a workaround for a gethostbyname_r bug in + * qnx nto and it is also _required_ for some of these functions on some + * platforms. + */ + +#ifdef HAVE_GETHOSTBYNAME_R_5 + /* Solaris, IRIX and more */ + (void)res; /* prevent compiler warning */ + h = gethostbyname_r(hostname, + (struct hostent *)buf, + (char *)buf + sizeof(struct hostent), + CURL_HOSTENT_SIZE - sizeof(struct hostent), + &h_errnop); + + /* If the buffer is too small, it returns NULL and sets errno to + * ERANGE. The errno is thread safe if this is compiled with + * -D_REENTRANT as then the 'errno' variable is a macro defined to get + * used properly for threads. + */ + + if(h) { + ; + } + else +#endif /* HAVE_GETHOSTBYNAME_R_5 */ +#ifdef HAVE_GETHOSTBYNAME_R_6 + /* Linux */ + + res=gethostbyname_r(hostname, + (struct hostent *)buf, + (char *)buf + sizeof(struct hostent), + CURL_HOSTENT_SIZE - sizeof(struct hostent), + &h, /* DIFFERENCE */ + &h_errnop); + /* Redhat 8, using glibc 2.2.93 changed the behavior. Now all of a + * sudden this function returns EAGAIN if the given buffer size is too + * small. Previous versions are known to return ERANGE for the same + * problem. + * + * This wouldn't be such a big problem if older versions wouldn't + * sometimes return EAGAIN on a common failure case. Alas, we can't + * assume that EAGAIN *or* ERANGE means ERANGE for any given version of + * glibc. + * + * For now, we do that and thus we may call the function repeatedly and + * fail for older glibc versions that return EAGAIN, until we run out of + * buffer size (step_size grows beyond CURL_HOSTENT_SIZE). + * + * If anyone has a better fix, please tell us! + * + * ------------------------------------------------------------------- + * + * On October 23rd 2003, Dan C dug up more details on the mysteries of + * gethostbyname_r() in glibc: + * + * In glibc 2.2.5 the interface is different (this has also been + * discovered in glibc 2.1.1-6 as shipped by Redhat 6). What I can't + * explain, is that tests performed on glibc 2.2.4-34 and 2.2.4-32 + * (shipped/upgraded by Redhat 7.2) don't show this behavior! + * + * In this "buggy" version, the return code is -1 on error and 'errno' + * is set to the ERANGE or EAGAIN code. Note that 'errno' is not a + * thread-safe variable. + */ + + if(!h) /* failure */ +#endif/* HAVE_GETHOSTBYNAME_R_6 */ +#ifdef HAVE_GETHOSTBYNAME_R_3 + /* AIX, Digital Unix/Tru64, HPUX 10, more? */ + + /* For AIX 4.3 or later, we don't use gethostbyname_r() at all, because of + * the plain fact that it does not return unique full buffers on each + * call, but instead several of the pointers in the hostent structs will + * point to the same actual data! This have the unfortunate down-side that + * our caching system breaks down horribly. Luckily for us though, AIX 4.3 + * and more recent versions have a "completely thread-safe"[*] libc where + * all the data is stored in thread-specific memory areas making calls to + * the plain old gethostbyname() work fine even for multi-threaded + * programs. + * + * This AIX 4.3 or later detection is all made in the configure script. + * + * Troels Walsted Hansen helped us work this out on March 3rd, 2003. + * + * [*] = much later we've found out that it isn't at all "completely + * thread-safe", but at least the gethostbyname() function is. + */ + + if(CURL_HOSTENT_SIZE >= + (sizeof(struct hostent)+sizeof(struct hostent_data))) { + + /* August 22nd, 2000: Albert Chin-A-Young brought an updated version + * that should work! September 20: Richard Prescott worked on the buffer + * size dilemma. + */ + + res = gethostbyname_r(hostname, + (struct hostent *)buf, + (struct hostent_data *)((char *)buf + + sizeof(struct hostent))); + h_errnop= errno; /* we don't deal with this, but set it anyway */ + } + else + res = -1; /* failure, too smallish buffer size */ + + if(!res) { /* success */ + + h = buf; /* result expected in h */ + + /* This is the worst kind of the different gethostbyname_r() interfaces. + * Since we don't know how big buffer this particular lookup required, + * we can't realloc down the huge alloc without doing closer analysis of + * the returned data. Thus, we always use CURL_HOSTENT_SIZE for every + * name lookup. Fixing this would require an extra malloc() and then + * calling Curl_addrinfo_copy() that subsequent realloc()s down the new + * memory area to the actually used amount. + */ + } + else +#endif /* HAVE_GETHOSTBYNAME_R_3 */ + { + infof(data, "gethostbyname_r(2) failed for %s\n", hostname); + h = NULL; /* set return code to NULL */ + free(buf); + } +#else /* HAVE_GETHOSTBYNAME_R */ + /* + * Here is code for platforms that don't have gethostbyname_r() or for + * which the gethostbyname() is the preferred() function. + */ + else { + h = gethostbyname(hostname); + if (!h) + infof(data, "gethostbyname(2) failed for %s\n", hostname); +#endif /*HAVE_GETHOSTBYNAME_R */ + } + + if(h) { + ai = Curl_he2ai(h, port); + + if (buf) /* used a *_r() function */ + free(buf); + } + + return ai; +} + +#endif /* CURLRES_SYNCH */ + +/* + * Curl_he2ai() translates from a hostent struct to a Curl_addrinfo struct. + * The Curl_addrinfo is meant to work like the addrinfo struct does for IPv6 + * stacks, but for all hosts and environments. + +struct Curl_addrinfo { + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + size_t ai_addrlen; + struct sockaddr *ai_addr; + char *ai_canonname; + struct addrinfo *ai_next; +}; + +struct hostent { + char *h_name; * official name of host * + char **h_aliases; * alias list * + int h_addrtype; * host address type * + int h_length; * length of address * + char **h_addr_list; * list of addresses * +} +#define h_addr h_addr_list[0] * for backward compatibility * + +*/ + +Curl_addrinfo *Curl_he2ai(struct hostent *he, int port) +{ + Curl_addrinfo *ai; + Curl_addrinfo *prevai = NULL; + Curl_addrinfo *firstai = NULL; + int i; + + union { + struct in_addr *addr; + char* list; + } curr; + union { + struct sockaddr_in* addr_in; + struct sockaddr* addr; + } address; + + if(!he) + /* no input == no output! */ + return NULL; + + for(i=0; (curr.list = he->h_addr_list[i]); i++) { + + ai = calloc(1, sizeof(Curl_addrinfo) + sizeof(struct sockaddr_in)); + + if(!ai) + break; + + if(!firstai) + /* store the pointer we want to return from this function */ + firstai = ai; + + if(prevai) + /* make the previous entry point to this */ + prevai->ai_next = ai; + + ai->ai_family = AF_INET; /* we only support this */ + ai->ai_socktype = SOCK_STREAM; /* we only support this */ + ai->ai_addrlen = sizeof(struct sockaddr_in); + /* make the ai_addr point to the address immediately following this struct + and use that area to store the address */ + ai->ai_addr = (struct sockaddr *) (ai + 1); + + /* leave the rest of the struct filled with zero */ + + address.addr = ai->ai_addr; /* storage area for this info */ + + memcpy((char *)&(address.addr_in->sin_addr), curr.addr, sizeof(struct in_addr)); + address.addr_in->sin_family = he->h_addrtype; + address.addr_in->sin_port = htons((unsigned short)port); + + prevai = ai; + } + return firstai; +} + +#endif /* CURLRES_IPV4 */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/hostip6.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/hostip6.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/hostip6.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/hostip6.c 2004-10-06 00:42:38.000000000 +0800 @@ -0,0 +1,263 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: hostip6.c,v 1.2 2004/10/05 16:42:38 hoffman Exp $ + ***************************************************************************/ + +#include "setup.h" + +#include +#include + +#define _REENTRANT + +#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__) +#include +#else +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_NETDB_H +#include +#endif +#ifdef HAVE_ARPA_INET_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include /* required for free() prototypes */ +#endif +#ifdef HAVE_UNISTD_H +#include /* for the close() proto */ +#endif +#ifdef VMS +#include +#include +#include +#endif +#endif + +#ifdef HAVE_SETJMP_H +#include +#endif + +#ifdef WIN32 +#include +#endif + +#if (defined(NETWARE) && defined(__NOVELL_LIBC__)) +#undef in_addr_t +#define in_addr_t unsigned long +#endif + +#include "urldata.h" +#include "sendf.h" +#include "hostip.h" +#include "hash.h" +#include "share.h" +#include "strerror.h" +#include "url.h" + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +#if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL) +#include "inet_ntoa_r.h" +#endif + +#include "curl_memory.h" +/* The last #include file should be: */ +#include "memdebug.h" + +/*********************************************************************** + * Only for ipv6-enabled builds + **********************************************************************/ +#ifdef CURLRES_IPV6 +/* + * This is a wrapper function for freeing name information in a protocol + * independent way. This takes care of using the appropriate underlaying + * function. + */ +void Curl_freeaddrinfo(Curl_addrinfo *p) +{ + freeaddrinfo(p); +} + +#ifdef CURLRES_ASYNCH +/* + * Curl_addrinfo_copy() is used by the asynch callback to copy a given + * address. But this is an ipv6 build and then we don't copy the address, we + * just return the same pointer! + */ +Curl_addrinfo *Curl_addrinfo_copy(void *source, int port) +{ + (void) port; + return source; +} +#endif + +#ifdef CURLDEBUG +/* These are strictly for memory tracing and are using the same style as the + * family otherwise present in memdebug.c. I put these ones here since they + * require a bunch of structs I didn't wanna include in memdebug.c + */ +int curl_dogetaddrinfo(char *hostname, char *service, + struct addrinfo *hints, + struct addrinfo **result, + int line, const char *source) +{ + int res=(getaddrinfo)(hostname, service, hints, result); + if(0 == res) { + /* success */ + if(logfile) + fprintf(logfile, "ADDR %s:%d getaddrinfo() = %p\n", + source, line, (void *)*result); + } + else { + if(logfile) + fprintf(logfile, "ADDR %s:%d getaddrinfo() failed\n", + source, line); + } + return res; +} + +int curl_dogetnameinfo(const struct sockaddr *sa, socklen_t salen, + char *host, size_t hostlen, + char *serv, size_t servlen, int flags, + int line, const char *source) +{ + int res=(getnameinfo)(sa, salen, host, hostlen, serv, servlen, flags); + if(0 == res) { + /* success */ + if(logfile) + fprintf(logfile, "GETNAME %s:%d getnameinfo()\n", + source, line); + } + else { + if(logfile) + fprintf(logfile, "GETNAME %s:%d getnameinfo() failed = %d\n", + source, line, res); + } + return res; +} + +void curl_dofreeaddrinfo(struct addrinfo *freethis, + int line, const char *source) +{ + (freeaddrinfo)(freethis); + if(logfile) + fprintf(logfile, "ADDR %s:%d freeaddrinfo(%p)\n", + source, line, (void *)freethis); +} + +#endif + +/* + * Curl_ipvalid() checks what CURL_IPRESOLVE_* requirements that might've + * been set and returns TRUE if they are OK. + */ +bool Curl_ipvalid(struct SessionHandle *data) +{ + if(data->set.ip_version == CURL_IPRESOLVE_V6) { + /* see if we have an IPv6 stack */ + curl_socket_t s = socket(PF_INET6, SOCK_DGRAM, 0); + if (s == CURL_SOCKET_BAD) + /* an ipv6 address was requested and we can't get/use one */ + return FALSE; + sclose(s); + } + return TRUE; +} + +#ifndef USE_THREADING_GETADDRINFO +/* + * Curl_getaddrinfo() when built ipv6-enabled (non-threading version). + * + * Returns name information about the given hostname and port number. If + * successful, the 'addrinfo' is returned and the forth argument will point to + * memory we need to free after use. That memory *MUST* be freed with + * Curl_freeaddrinfo(), nothing else. + */ +Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, + char *hostname, + int port, + int *waitp) +{ + struct addrinfo hints, *res; + int error; + char sbuf[NI_MAXSERV]; + curl_socket_t s; + int pf; + struct SessionHandle *data = conn->data; + + *waitp=0; /* don't wait, we have the response now */ + + /* see if we have an IPv6 stack */ + s = socket(PF_INET6, SOCK_DGRAM, 0); + if (s < 0) { + /* Some non-IPv6 stacks have been found to make very slow name resolves + * when PF_UNSPEC is used, so thus we switch to a mere PF_INET lookup if + * the stack seems to be a non-ipv6 one. */ + + pf = PF_INET; + } + else { + /* This seems to be an IPv6-capable stack, use PF_UNSPEC for the widest + * possible checks. And close the socket again. + */ + sclose(s); + + /* + * Check if a more limited name resolve has been requested. + */ + switch(data->set.ip_version) { + case CURL_IPRESOLVE_V4: + pf = PF_INET; + break; + case CURL_IPRESOLVE_V6: + pf = PF_INET6; + break; + default: + pf = PF_UNSPEC; + break; + } + } + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = pf; + hints.ai_socktype = SOCK_STREAM; + hints.ai_flags = AI_CANONNAME; + snprintf(sbuf, sizeof(sbuf), "%d", port); + error = getaddrinfo(hostname, sbuf, &hints, &res); + if (error) { + infof(data, "getaddrinfo(3) failed for %s:%d\n", hostname, port); + return NULL; + } + + return res; +} +#endif /* USE_THREADING_GETADDRINFO */ +#endif /* ipv6 */ + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/hostip.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/hostip.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/hostip.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/hostip.c 2004-10-13 22:45:30.000000000 +0800 @@ -0,0 +1,540 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: hostip.c,v 1.14 2004/10/13 14:45:30 andy Exp $ + ***************************************************************************/ + +#include "setup.h" + +#include +#include + +#define _REENTRANT + +#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__) +#include +#else +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_NETDB_H +#include +#endif +#ifdef HAVE_ARPA_INET_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include /* required for free() prototypes */ +#endif +#ifdef HAVE_UNISTD_H +#include /* for the close() proto */ +#endif +#ifdef VMS +#include +#include +#include +#endif +#endif + +#ifdef HAVE_SETJMP_H +#include +#endif + +#ifdef WIN32 +#include +#endif + +#if (defined(NETWARE) && defined(__NOVELL_LIBC__)) +#undef in_addr_t +#define in_addr_t unsigned long +#endif + +#include "urldata.h" +#include "sendf.h" +#include "hostip.h" +#include "hash.h" +#include "share.h" +#include "strerror.h" +#include "url.h" +#include "inet_ntop.h" + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +#if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL) +#include "inet_ntoa_r.h" +#endif + +#include "curl_memory.h" +/* The last #include file should be: */ +#include "memdebug.h" + +/* + * hostip.c explained + * ================== + * + * The main COMPILE-TIME DEFINES to keep in mind when reading the host*.c + * source file are these: + * + * CURLRES_IPV6 - this host has getaddrinfo() and family, and thus we use + * that. The host may not be able to resolve IPv6, but we don't really have to + * take that into account. Hosts that aren't IPv6-enabled have CURLRES_IPV4 + * defined. + * + * CURLRES_ARES - is defined if libcurl is built to use c-ares for + * asynchronous name resolves. It cannot have ENABLE_IPV6 defined at the same + * time, as c-ares has no ipv6 support. This can be Windows or *nix. + * + * CURLRES_THREADED - is defined if libcurl is built to run under (native) + * Windows, and then the name resolve will be done in a new thread, and the + * supported API will be the same as for ares-builds. + * + * If any of the two previous are defined, CURLRES_ASYNCH is defined too. If + * libcurl is not built to use an asynchronous resolver, CURLRES_SYNCH is + * defined. + * + * The host*.c sources files are split up like this: + * + * hostip.c - method-independent resolver functions and utility functions + * hostasyn.c - functions for asynchronous name resolves + * hostsyn.c - functions for synchronous name resolves + * hostares.c - functions for ares-using name resolves + * hostthre.c - functions for threaded name resolves + * hostip4.c - ipv4-specific functions + * hostip6.c - ipv6-specific functions + * + * The hostip.h is the united header file for all this. It defines the + * CURLRES_* defines based on the config*.h and setup.h defines. + */ + +/* These two symbols are for the global DNS cache */ +static curl_hash hostname_cache; +static int host_cache_initialized; + +static void freednsentry(void *freethis); + +/* + * Curl_global_host_cache_init() initializes and sets up a global DNS cache. + * Global DNS cache is general badness. Do not use. This will be removed in + * a future version. Use the share interface instead! + */ +void Curl_global_host_cache_init(void) +{ + if (!host_cache_initialized) { + Curl_hash_init(&hostname_cache, 7, freednsentry); + host_cache_initialized = 1; + } +} + +/* + * Return a pointer to the global cache + */ +curl_hash *Curl_global_host_cache_get(void) +{ + return &hostname_cache; +} + +/* + * Destroy and cleanup the global DNS cache + */ +void Curl_global_host_cache_dtor(void) +{ + if (host_cache_initialized) { + Curl_hash_clean(&hostname_cache); + host_cache_initialized = 0; + } +} + +/* + * Return # of adresses in a Curl_addrinfo struct + */ +int Curl_num_addresses(const Curl_addrinfo *addr) +{ + int i; + for (i = 0; addr; addr = addr->ai_next, i++); + return i; +} + +#define GET_SIN_ADDR_FROM_CURL_ADDRINFO(ai_addr, si, sin, sinaddr, ip) \ + { \ + union { \ + struct si* vsi; \ + struct sin* vsin;\ + } vi; \ + vi.vsi = ai_addr; \ + ip = &(vi.vsin->sinaddr); \ + } + +/* + * Curl_printable_address() returns a printable version of the 1st address + * given in the 'ip' argument. The result will be stored in the buf that is + * bufsize bytes big. + * + * If the conversion fails, it returns NULL. + */ +const char *Curl_printable_address(const Curl_addrinfo *ip, + char *buf, size_t bufsize) +{ + int af = ip->ai_family; + const void *ip4; +#ifdef CURLRES_IPV6 + const void *ip6; + GET_SIN_ADDR_FROM_CURL_ADDRINFO(ip->ai_addr, sockaddr, sockaddr_in6, + sin6_addr, ip6); +#else + const void *ip6 = NULL; +#endif + GET_SIN_ADDR_FROM_CURL_ADDRINFO(ip->ai_addr, sockaddr, sockaddr_in, + sin_addr, ip4); + + return Curl_inet_ntop(af, af == AF_INET ? ip4 : ip6, buf, bufsize); +} + +/* + * Return a hostcache id string for the providing host + port, to be used by + * the DNS caching. + */ +static char * +create_hostcache_id(char *server, int port) +{ + /* create and return the new allocated entry */ + return aprintf("%s:%d", server, port); +} + +struct hostcache_prune_data { + int cache_timeout; + time_t now; +}; + +/* + * This function is set as a callback to be called for every entry in the DNS + * cache when we want to prune old unused entries. + * + * Returning non-zero means remove the entry, return 0 to keep it in the + * cache. + */ +static int +hostcache_timestamp_remove(void *datap, void *hc) +{ + struct hostcache_prune_data *data = + (struct hostcache_prune_data *) datap; + struct Curl_dns_entry *c = (struct Curl_dns_entry *) hc; + + if ((data->now - c->timestamp < data->cache_timeout) || + c->inuse) { + /* please don't remove */ + return 0; + } + + /* fine, remove */ + return 1; +} + +/* + * Prune the DNS cache. This assumes that a lock has already been taken. + */ +static void +hostcache_prune(curl_hash *hostcache, int cache_timeout, time_t now) +{ + struct hostcache_prune_data user; + + user.cache_timeout = cache_timeout; + user.now = now; + + Curl_hash_clean_with_criterium(hostcache, + (void *) &user, + hostcache_timestamp_remove); +} + +/* + * Library-wide function for pruning the DNS cache. This function takes and + * returns the appropriate locks. + */ +void Curl_hostcache_prune(struct SessionHandle *data) +{ + time_t now; + + if(data->set.dns_cache_timeout == -1) + /* cache forever means never prune! */ + return; + + if(data->share) + Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); + + time(&now); + + /* Remove outdated and unused entries from the hostcache */ + hostcache_prune(data->hostcache, + data->set.dns_cache_timeout, + now); + + if(data->share) + Curl_share_unlock(data, CURL_LOCK_DATA_DNS); +} + +#ifdef HAVE_SIGSETJMP +/* Beware this is a global and unique instance. This is used to store the + return address that we can jump back to from inside a signal handler. This + is not thread-safe stuff. */ +sigjmp_buf curl_jmpenv; +#endif + + +/* + * Curl_cache_addr() stores a 'Curl_addrinfo' struct in the DNS cache. + * + * When calling Curl_resolv() has resulted in a response with a returned + * address, we call this function to store the information in the dns + * cache etc + * + * Returns the Curl_dns_entry entry pointer or NULL if the storage failed. + */ +struct Curl_dns_entry * +Curl_cache_addr(struct SessionHandle *data, + Curl_addrinfo *addr, + char *hostname, + int port) +{ + char *entry_id; + size_t entry_len; + struct Curl_dns_entry *dns; + struct Curl_dns_entry *dns2; + time_t now; + + /* Create an entry id, based upon the hostname and port */ + entry_id = create_hostcache_id(hostname, port); + /* If we can't create the entry id, fail */ + if (!entry_id) + return NULL; + entry_len = strlen(entry_id); + + /* Create a new cache entry */ + dns = (struct Curl_dns_entry *) malloc(sizeof(struct Curl_dns_entry)); + if (!dns) { + free(entry_id); + return NULL; + } + + dns->inuse = 0; /* init to not used */ + dns->addr = addr; /* this is the address(es) */ + + /* Store the resolved data in our DNS cache. This function may return a + pointer to an existing struct already present in the hash, and it may + return the same argument we pass in. Make no assumptions. */ + dns2 = Curl_hash_add(data->hostcache, entry_id, entry_len+1, (void *)dns); + if(!dns2) { + /* Major badness, run away. */ + free(dns); + free(entry_id); + return NULL; + } + time(&now); + dns = dns2; + + dns->timestamp = now; /* used now */ + dns->inuse++; /* mark entry as in-use */ + + /* free the allocated entry_id again */ + free(entry_id); + + return dns; +} + +/* + * Curl_resolv() is the main name resolve function within libcurl. It resolves + * a name and returns a pointer to the entry in the 'entry' argument (if one + * is provided). This function might return immediately if we're using asynch + * resolves. See the return codes. + * + * The cache entry we return will get its 'inuse' counter increased when this + * function is used. You MUST call Curl_resolv_unlock() later (when you're + * done using this struct) to decrease the counter again. + * + * Return codes: + * + * CURLRESOLV_ERROR (-1) = error, no pointer + * CURLRESOLV_RESOLVED (0) = OK, pointer provided + * CURLRESOLV_PENDING (1) = waiting for response, no pointer + */ + +int Curl_resolv(struct connectdata *conn, + char *hostname, + int port, + struct Curl_dns_entry **entry) +{ + char *entry_id; + struct Curl_dns_entry *dns = NULL; + size_t entry_len; + int wait; + struct SessionHandle *data = conn->data; + CURLcode result; + + /* default to failure */ + int rc; + *entry = NULL; + +#ifdef HAVE_SIGSETJMP + /* this allows us to time-out from the name resolver, as the timeout + will generate a signal and we will siglongjmp() from that here */ + if(!data->set.no_signal && sigsetjmp(curl_jmpenv, 1)) { + /* this is coming from a siglongjmp() */ + failf(data, "name lookup timed out"); + return CURLRESOLV_ERROR; + } +#endif + rc = CURLRESOLV_ERROR; + + /* Create an entry id, based upon the hostname and port */ + entry_id = create_hostcache_id(hostname, port); + /* If we can't create the entry id, fail */ + if (!entry_id) + return CURLRESOLV_ERROR; + + entry_len = strlen(entry_id); + + if(data->share) + Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); + + /* See if its already in our dns cache */ + dns = Curl_hash_pick(data->hostcache, entry_id, entry_len+1); + + if(data->share) + Curl_share_unlock(data, CURL_LOCK_DATA_DNS); + + /* free the allocated entry_id again */ + free(entry_id); + + if (!dns) { + /* The entry was not in the cache. Resolve it to IP address */ + + Curl_addrinfo *addr; + + /* Check what IP specifics the app has requested and if we can provide it. + * If not, bail out. */ + if(!Curl_ipvalid(data)) + return CURLRESOLV_ERROR; + + /* If Curl_getaddrinfo() returns NULL, 'wait' might be set to a non-zero + value indicating that we need to wait for the response to the resolve + call */ + addr = Curl_getaddrinfo(conn, hostname, port, &wait); + + if (!addr) { + if(wait) { + /* the response to our resolve call will come asynchronously at + a later time, good or bad */ + /* First, check that we haven't received the info by now */ + result = Curl_is_resolved(conn, &dns); + if(result) /* error detected */ + return CURLRESOLV_ERROR; + if(dns) + rc = CURLRESOLV_RESOLVED; /* pointer provided */ + else + rc = CURLRESOLV_PENDING; /* no info yet */ + } + } + else { + if(data->share) + Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); + + /* we got a response, store it in the cache */ + dns = Curl_cache_addr(data, addr, hostname, port); + + if(data->share) + Curl_share_unlock(data, CURL_LOCK_DATA_DNS); + + if(!dns) + /* returned failure, bail out nicely */ + Curl_freeaddrinfo(addr); + else + rc = CURLRESOLV_RESOLVED; + } + } + else { + dns->inuse++; /* we use it! */ + rc = CURLRESOLV_RESOLVED; + } + + *entry = dns; + + return rc; +} + +/* + * Curl_resolv_unlock() unlocks the given cached DNS entry. When this has been + * made, the struct may be destroyed due to pruning. It is important that only + * one unlock is made for each Curl_resolv() call. + */ +void Curl_resolv_unlock(struct SessionHandle *data, struct Curl_dns_entry *dns) +{ + curlassert(dns && (dns->inuse>0)); + + if(data->share) + Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); + + dns->inuse--; + + if(data->share) + Curl_share_unlock(data, CURL_LOCK_DATA_DNS); +} + +/* + * File-internal: free a cache dns entry. + */ +static void freednsentry(void *freethis) +{ + struct Curl_dns_entry *p = (struct Curl_dns_entry *) freethis; + + Curl_freeaddrinfo(p->addr); + + free(p); +} + +/* + * Curl_mk_dnscache() creates a new DNS cache and returns the handle for it. + */ +curl_hash *Curl_mk_dnscache(void) +{ + return Curl_hash_alloc(7, freednsentry); +} + +#ifdef CURLRES_ADDRINFO_COPY + +/* align on even 64bit boundaries */ +#define MEMALIGN(x) ((x)+(8-(((unsigned long)(x))&0x7))) + +/* + * Curl_addrinfo_copy() performs a "deep" copy of a hostent into a buffer and + * returns a pointer to the malloc()ed copy. You need to call free() on the + * returned buffer when you're done with it. + */ +Curl_addrinfo *Curl_addrinfo_copy(void *org, int port) +{ + struct hostent *orig = org; + + return Curl_he2ai(orig, port); +} +#endif /* CURLRES_ADDRINFO_COPY */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/hostip.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/hostip.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/hostip.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/hostip.h 2004-10-07 19:59:09.000000000 +0800 @@ -0,0 +1,255 @@ +#ifndef __HOSTIP_H +#define __HOSTIP_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: hostip.h,v 1.6 2004/10/07 11:59:09 andy Exp $ + ***************************************************************************/ + +#include "setup.h" +#include "hash.h" + +#ifdef HAVE_NETDB_H +#include +#endif + +/* + * Setup comfortable CURLRES_* defines to use in the host*.c sources. + */ + +#ifdef USE_ARES +#define CURLRES_ASYNCH +#define CURLRES_ARES +#endif + +#ifdef USE_THREADING_GETHOSTBYNAME +#define CURLRES_ASYNCH +#define CURLRES_THREADED +#endif + +#ifdef USE_THREADING_GETADDRINFO +#define CURLRES_ASYNCH +#define CURLRES_THREADED +#endif + +#ifdef ENABLE_IPV6 +#define CURLRES_IPV6 +#else +#define CURLRES_IPV4 +#endif + +#ifdef CURLRES_IPV4 +#if !defined(HAVE_GETHOSTBYNAME_R) || defined(CURLRES_ASYNCH) +/* If built for ipv4 and missing gethostbyname_r(), or if using async name + resolve, we need the Curl_addrinfo_copy() function (which itself needs the + Curl_hostent_relocate() function)) */ +#define CURLRES_ADDRINFO_COPY +#endif +#endif /* IPv4-only */ + +#ifndef CURLRES_ASYNCH +#define CURLRES_SYNCH +#endif + +#ifndef USE_LIBIDN +#define CURLRES_IDN +#endif + +/* Allocate enough memory to hold the full name information structs and + * everything. OSF1 is known to require at least 8872 bytes. The buffer + * required for storing all possible aliases and IP numbers is according to + * Stevens' Unix Network Programming 2nd edition, p. 304: 8192 bytes! + */ +#define CURL_HOSTENT_SIZE 9000 + +#define CURL_TIMEOUT_RESOLVE 300 /* when using asynch methods, we allow this + many seconds for a name resolve */ + +#ifdef CURLRES_ARES +#define CURL_ASYNC_SUCCESS ARES_SUCCESS +#else +#define CURL_ASYNC_SUCCESS CURLE_OK +#endif + +/* + * Curl_addrinfo MUST be used for all name resolved info. + */ +#ifdef CURLRES_IPV6 +typedef struct addrinfo Curl_addrinfo; +#else +/* OK, so some ipv4-only include tree probably have the addrinfo struct, but + to work even on those that don't, we provide our own look-alike! */ +struct Curl_addrinfo { + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + size_t ai_addrlen; + struct sockaddr *ai_addr; + char *ai_canonname; + struct Curl_addrinfo *ai_next; +}; +typedef struct Curl_addrinfo Curl_addrinfo; +#endif + +struct addrinfo; +struct SessionHandle; +struct connectdata; + +void Curl_global_host_cache_init(void); +void Curl_global_host_cache_dtor(void); +curl_hash *Curl_global_host_cache_get(void); + +#define Curl_global_host_cache_use(__p) ((__p)->set.global_dns_cache) + +struct Curl_dns_entry { + Curl_addrinfo *addr; + time_t timestamp; + long inuse; /* use-counter, make very sure you decrease this + when you're done using the address you received */ +}; + +/* + * Curl_resolv() returns an entry with the info for the specified host + * and port. + * + * The returned data *MUST* be "unlocked" with Curl_resolv_unlock() after + * use, or we'll leak memory! + */ +/* return codes */ +#define CURLRESOLV_ERROR -1 +#define CURLRESOLV_RESOLVED 0 +#define CURLRESOLV_PENDING 1 +int Curl_resolv(struct connectdata *conn, char *hostname, + int port, struct Curl_dns_entry **dnsentry); + +/* + * Curl_ipvalid() checks what CURL_IPRESOLVE_* requirements that might've + * been set and returns TRUE if they are OK. + */ +bool Curl_ipvalid(struct SessionHandle *data); + +/* + * Curl_getaddrinfo() is the generic low-level name resolve API within this + * source file. There are several versions of this function - for different + * name resolve layers (selected at build-time). They all take this same set + * of arguments + */ +Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, + char *hostname, + int port, + int *waitp); + +CURLcode Curl_is_resolved(struct connectdata *conn, + struct Curl_dns_entry **dns); +CURLcode Curl_wait_for_resolv(struct connectdata *conn, + struct Curl_dns_entry **dnsentry); + +/* Curl_fdset() is a generic function that exists in multiple versions + depending on what name resolve technology we've built to use. The function + is called from the curl_multi_fdset() function */ +CURLcode Curl_fdset(struct connectdata *conn, + fd_set *read_fd_set, + fd_set *write_fd_set, + int *max_fdp); +/* unlock a previously resolved dns entry */ +void Curl_resolv_unlock(struct SessionHandle *data, struct Curl_dns_entry *dns); + +/* for debugging purposes only: */ +void Curl_scan_cache_used(void *user, void *ptr); + +/* free name info */ +void Curl_freeaddrinfo(Curl_addrinfo *freeaddr); + +/* make a new dns cache and return the handle */ +curl_hash *Curl_mk_dnscache(void); + +/* prune old entries from the DNS cache */ +void Curl_hostcache_prune(struct SessionHandle *data); + +/* Return # of adresses in a Curl_addrinfo struct */ +int Curl_num_addresses (const Curl_addrinfo *addr); + +#ifdef CURLDEBUG +void curl_dofreeaddrinfo(struct addrinfo *freethis, + int line, const char *source); +int curl_dogetaddrinfo(char *hostname, char *service, + struct addrinfo *hints, + struct addrinfo **result, + int line, const char *source); +int curl_dogetnameinfo(const struct sockaddr *sa, socklen_t salen, + char *host, size_t hostlen, + char *serv, size_t servlen, int flags, + int line, const char *source); +#endif + +/* This is the callback function that is used when we build with asynch + resolve, ipv4 */ +void Curl_addrinfo4_callback(void *arg, + int status, + struct hostent *hostent); +/* This is the callback function that is used when we build with asynch + resolve, ipv6 */ +void Curl_addrinfo6_callback(void *arg, + int status, + struct addrinfo *ai); + + +/* [ipv4 only] Creates a Curl_addrinfo struct from a numerical-only IP + address */ +Curl_addrinfo *Curl_ip2addr(in_addr_t num, char *hostname, int port); + +/* [ipv4 only] Curl_he2ai() converts a struct hostent to a Curl_addrinfo chain + and returns it */ +Curl_addrinfo *Curl_he2ai(struct hostent *, int port); + +/* relocate a hostent struct */ +void Curl_hostent_relocate(struct hostent *h, long offset); + +/* Clone a Curl_addrinfo struct, works protocol independently */ +Curl_addrinfo *Curl_addrinfo_copy(void *orig, int port); + +/* + * Curl_printable_address() returns a printable version of the 1st address + * given in the 'ip' argument. The result will be stored in the buf that is + * bufsize bytes big. + */ +const char *Curl_printable_address(const Curl_addrinfo *ip, + char *buf, size_t bufsize); + +/* + * Curl_cache_addr() stores a 'Curl_addrinfo' struct in the DNS cache. + * + * Returns the Curl_dns_entry entry pointer or NULL if the storage failed. + */ +struct Curl_dns_entry * +Curl_cache_addr(struct SessionHandle *data, Curl_addrinfo *addr, + char *hostname, int port); + +#ifndef INADDR_NONE +#define CURL_INADDR_NONE (in_addr_t) ~0 +#else +#define CURL_INADDR_NONE INADDR_NONE +#endif + + + + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/hostsyn.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/hostsyn.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/hostsyn.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/hostsyn.c 2004-10-06 00:42:38.000000000 +0800 @@ -0,0 +1,149 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: hostsyn.c,v 1.2 2004/10/05 16:42:38 hoffman Exp $ + ***************************************************************************/ + +#include "setup.h" + +#include +#include + +#define _REENTRANT + +#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__) +#include +#else +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_NETDB_H +#include +#endif +#ifdef HAVE_ARPA_INET_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include /* required for free() prototypes */ +#endif +#ifdef HAVE_UNISTD_H +#include /* for the close() proto */ +#endif +#ifdef VMS +#include +#include +#include +#endif +#endif + +#ifdef HAVE_SETJMP_H +#include +#endif + +#ifdef WIN32 +#include +#endif + +#if (defined(NETWARE) && defined(__NOVELL_LIBC__)) +#undef in_addr_t +#define in_addr_t unsigned long +#endif + +#include "urldata.h" +#include "sendf.h" +#include "hostip.h" +#include "hash.h" +#include "share.h" +#include "strerror.h" +#include "url.h" + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +#if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL) +#include "inet_ntoa_r.h" +#endif + +#include "curl_memory.h" +/* The last #include file should be: */ +#include "memdebug.h" + +/*********************************************************************** + * Only for builds using synchronous name resolves + **********************************************************************/ +#ifdef CURLRES_SYNCH + +/* + * Curl_wait_for_resolv() for synch-builds. Curl_resolv() can never return + * wait==TRUE, so this function will never be called. If it still gets called, + * we return failure at once. + * + * We provide this function only to allow multi.c to remain unaware if we are + * doing asynch resolves or not. + */ +CURLcode Curl_wait_for_resolv(struct connectdata *conn, + struct Curl_dns_entry **entry) +{ + (void)conn; + *entry=NULL; + return CURLE_COULDNT_RESOLVE_HOST; +} + +/* + * This function will never be called when synch-built. If it still gets + * called, we return failure at once. + * + * We provide this function only to allow multi.c to remain unaware if we are + * doing asynch resolves or not. + */ +CURLcode Curl_is_resolved(struct connectdata *conn, + struct Curl_dns_entry **dns) +{ + (void)conn; + *dns = NULL; + + return CURLE_COULDNT_RESOLVE_HOST; +} + +/* + * We just return OK, this function is never actually used for synch builds. + * It is present here to keep #ifdefs out from multi.c + */ + +CURLcode Curl_fdset(struct connectdata *conn, + fd_set *read_fd_set, + fd_set *write_fd_set, + int *max_fdp) +{ + (void)conn; + (void)read_fd_set; + (void)write_fd_set; + (void)max_fdp; + + return CURLE_OK; +} + +#endif /* truly sync */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/hostthre.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/hostthre.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/hostthre.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/hostthre.c 2004-10-13 22:45:30.000000000 +0800 @@ -0,0 +1,551 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: hostthre.c,v 1.4 2004/10/13 14:45:30 andy Exp $ + ***************************************************************************/ + +#include "setup.h" + +#include +#include + +#define _REENTRANT + +#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__) +#include +#else +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_NETDB_H +#include +#endif +#ifdef HAVE_ARPA_INET_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include /* required for free() prototypes */ +#endif +#ifdef HAVE_UNISTD_H +#include /* for the close() proto */ +#endif +#ifdef VMS +#include +#include +#include +#endif +#endif + +#ifdef HAVE_SETJMP_H +#include +#endif + +#ifdef WIN32 +#include +#endif + +#if (defined(NETWARE) && defined(__NOVELL_LIBC__)) +#undef in_addr_t +#define in_addr_t unsigned long +#endif + +#include "urldata.h" +#include "sendf.h" +#include "hostip.h" +#include "hash.h" +#include "share.h" +#include "strerror.h" +#include "url.h" + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +#include "inet_ntop.h" + +#include "curl_memory.h" +/* The last #include file should be: */ +#include "memdebug.h" + +/*********************************************************************** + * Only for Windows threaded name resolves builds + **********************************************************************/ +#ifdef CURLRES_THREADED + +/* This function is used to init a threaded resolve */ +static bool init_resolve_thread(struct connectdata *conn, + const char *hostname, int port, + const Curl_addrinfo *hints); + +#ifdef CURLRES_IPV4 + #define THREAD_FUNC gethostbyname_thread + #define THREAD_NAME "gethostbyname_thread" +#else + #define THREAD_FUNC getaddrinfo_thread + #define THREAD_NAME "getaddrinfo_thread" +#endif + +#if defined(DEBUG_THREADING_GETHOSTBYNAME) || \ + defined(DEBUG_THREADING_GETADDRINFO) +/* If this is defined, provide tracing */ +#define TRACE(args) \ + do { trace_it("%u: ", __LINE__); trace_it args; } while (0) + +static void trace_it (const char *fmt, ...) +{ + static int do_trace = -1; + va_list args; + + if (do_trace == -1) { + const char *env = getenv("CURL_TRACE"); + do_trace = (env && atoi(env) > 0); + } + if (!do_trace) + return; + va_start (args, fmt); + vfprintf (stderr, fmt, args); + fflush (stderr); + va_end (args); +} +#else +#define TRACE(x) +#endif + +#ifdef DEBUG_THREADING_GETADDRINFO +static void dump_addrinfo (struct connectdata *conn, const struct addrinfo *ai) +{ + TRACE(("dump_addrinfo:\n")); + for ( ; ai; ai = ai->ai_next) { + char buf [INET6_ADDRSTRLEN]; + + trace_it(" fam %2d, CNAME %s, ", + ai->ai_family, ai->ai_canonname ? ai->ai_canonname : ""); + if (Curl_printable_address(ai, buf, sizeof(buf))) + trace_it("%s\n", buf); + else + trace_it("failed; %s\n", Curl_strerror(conn,WSAGetLastError())); + } +} +#endif + +struct thread_data { + HANDLE thread_hnd; + unsigned thread_id; + DWORD thread_status; + curl_socket_t dummy_sock; /* dummy for Curl_fdset() */ + FILE *stderr_file; +#ifdef CURLRES_IPV6 + struct addrinfo hints; +#endif +}; + +#if defined(CURLRES_IPV4) +/* + * gethostbyname_thread() resolves a name, calls the Curl_addrinfo4_callback + * and then exits. + * + * For builds without ARES/ENABLE_IPV6, create a resolver thread and wait on + * it. + */ +static unsigned __stdcall gethostbyname_thread (void *arg) +{ + struct connectdata *conn = (struct connectdata*) arg; + struct thread_data *td = (struct thread_data*) conn->async.os_specific; + struct hostent *he; + int rc; + + /* Sharing the same _iob[] element with our parent thread should + * hopefully make printouts synchronised. I'm not sure it works + * with a static runtime lib (MSVC's libc.lib). + */ + *stderr = *td->stderr_file; + + WSASetLastError (conn->async.status = NO_DATA); /* pending status */ + he = gethostbyname (conn->async.hostname); + if (he) { + Curl_addrinfo4_callback(conn, CURL_ASYNC_SUCCESS, he); + rc = 1; + } + else { + Curl_addrinfo4_callback(conn, (int)WSAGetLastError(), NULL); + rc = 0; + } + TRACE(("Winsock-error %d, addr %s\n", conn->async.status, + he ? inet_ntoa(*(struct in_addr*)he->h_addr) : "unknown")); + return (rc); + /* An implicit _endthreadex() here */ +} + +#elif defined(CURLRES_IPV6) + +/* + * getaddrinfo_thread() resolves a name, calls Curl_addrinfo6_callback and then + * exits. + * + * For builds without ARES, but with ENABLE_IPV6, create a resolver thread + * and wait on it. + */ +static unsigned __stdcall getaddrinfo_thread (void *arg) +{ + struct connectdata *conn = (struct connectdata*) arg; + struct thread_data *td = (struct thread_data*) conn->async.os_specific; + struct addrinfo *res; + char service [NI_MAXSERV]; + int rc; + + *stderr = *td->stderr_file; + + itoa(conn->async.port, service, 10); + + WSASetLastError(conn->async.status = NO_DATA); /* pending status */ + + rc = getaddrinfo(conn->async.hostname, service, &td->hints, &res); + + if (rc == 0) { +#ifdef DEBUG_THREADING_GETADDRINFO + dump_addrinfo (conn, res); +#endif + Curl_addrinfo6_callback(conn, CURL_ASYNC_SUCCESS, res); + } + else { + Curl_addrinfo6_callback(conn, (int)WSAGetLastError(), NULL); + TRACE(("Winsock-error %d, no address\n", conn->async.status)); + } + return (rc); + /* An implicit _endthreadex() here */ +} +#endif + +/* + * destroy_thread_data() cleans up async resolver data. + * Complementary of ares_destroy. + */ +static void destroy_thread_data (struct Curl_async *async) +{ + if (async->hostname) + free(async->hostname); + + if (async->os_specific) { + curl_socket_t sock = ((const struct thread_data*)async->os_specific)->dummy_sock; + + if (sock != CURL_SOCKET_BAD) + sclose(sock); + free(async->os_specific); + } + async->hostname = NULL; + async->os_specific = NULL; +} + +/* + * init_resolve_thread() starts a new thread that performs the actual + * resolve. This function returns before the resolve is done. + * + * Returns FALSE in case of failure, otherwise TRUE. + */ +static bool init_resolve_thread (struct connectdata *conn, + const char *hostname, int port, + const Curl_addrinfo *hints) +{ + struct thread_data *td = calloc(sizeof(*td), 1); + + if (!td) { + SetLastError(ENOMEM); + return FALSE; + } + + Curl_safefree(conn->async.hostname); + conn->async.hostname = strdup(hostname); + if (!conn->async.hostname) { + free(td); + SetLastError(ENOMEM); + return FALSE; + } + + conn->async.port = port; + conn->async.done = FALSE; + conn->async.status = 0; + conn->async.dns = NULL; + conn->async.os_specific = (void*) td; + + td->dummy_sock = CURL_SOCKET_BAD; + td->stderr_file = stderr; + td->thread_hnd = (HANDLE) _beginthreadex(NULL, 0, THREAD_FUNC, + conn, 0, &td->thread_id); +#ifdef CURLRES_IPV6 + curlassert(hints); + td->hints = *hints; +#else + (void) hints; +#endif + + if (!td->thread_hnd) { + SetLastError(errno); + TRACE(("_beginthreadex() failed; %s\n", Curl_strerror(conn,errno))); + destroy_thread_data(&conn->async); + return FALSE; + } + /* This socket is only to keep Curl_fdset() and select() happy; should never + * become signalled for read/write since it's unbound but Windows needs + * atleast 1 socket in select(). + */ + td->dummy_sock = socket(AF_INET, SOCK_DGRAM, 0); + return TRUE; +} + + +/* + * Curl_wait_for_resolv() waits for a resolve to finish. This function should + * be avoided since using this risk getting the multi interface to "hang". + * + * If 'entry' is non-NULL, make it point to the resolved dns entry + * + * This is the version for resolves-in-a-thread. + */ +CURLcode Curl_wait_for_resolv(struct connectdata *conn, + struct Curl_dns_entry **entry) +{ + struct thread_data *td = (struct thread_data*) conn->async.os_specific; + struct SessionHandle *data = conn->data; + long timeout; + DWORD status, ticks; + CURLcode rc; + + curlassert (conn && td); + + /* now, see if there's a connect timeout or a regular timeout to + use instead of the default one */ + timeout = + conn->data->set.connecttimeout ? conn->data->set.connecttimeout : + conn->data->set.timeout ? conn->data->set.timeout : + CURL_TIMEOUT_RESOLVE; /* default name resolve timeout */ + ticks = GetTickCount(); + (void)ticks; + + status = WaitForSingleObject(td->thread_hnd, 1000UL*timeout); + if (status == WAIT_OBJECT_0 || status == WAIT_ABANDONED) { + /* Thread finished before timeout; propagate Winsock error to this thread. + * 'conn->async.done = TRUE' is set in Curl_addrinfo4/6_callback(). + */ + WSASetLastError(conn->async.status); + GetExitCodeThread(td->thread_hnd, &td->thread_status); + TRACE(("%s() status %lu, thread retval %lu, ", + THREAD_NAME, status, td->thread_status)); + } + else { + conn->async.done = TRUE; + td->thread_status = (DWORD)-1; + TRACE(("%s() timeout, ", THREAD_NAME)); + } + + TRACE(("elapsed %lu ms\n", GetTickCount()-ticks)); + + CloseHandle(td->thread_hnd); + + if(entry) + *entry = conn->async.dns; + + rc = CURLE_OK; + + if (!conn->async.dns) { + /* a name was not resolved */ + if (td->thread_status == (DWORD)-1 || conn->async.status == NO_DATA) { + failf(data, "Resolving host timed out: %s", conn->host.name); + rc = CURLE_OPERATION_TIMEDOUT; + } + else if(conn->async.done) { + failf(data, "Could not resolve host: %s; %s", + conn->host.name, Curl_strerror(conn,conn->async.status)); + rc = CURLE_COULDNT_RESOLVE_HOST; + } + else + rc = CURLE_OPERATION_TIMEDOUT; + } + + destroy_thread_data(&conn->async); + + if(CURLE_OK != rc) + /* close the connection, since we must not return failure from here + without cleaning up this connection properly */ + Curl_disconnect(conn); + + return (rc); +} + +/* + * Curl_is_resolved() is called repeatedly to check if a previous name resolve + * request has completed. It should also make sure to time-out if the + * operation seems to take too long. + */ +CURLcode Curl_is_resolved(struct connectdata *conn, + struct Curl_dns_entry **entry) +{ + *entry = NULL; + + if (conn->async.done) { + /* we're done */ + destroy_thread_data(&conn->async); + if (!conn->async.dns) { + TRACE(("Curl_is_resolved(): CURLE_COULDNT_RESOLVE_HOST\n")); + return CURLE_COULDNT_RESOLVE_HOST; + } + *entry = conn->async.dns; + TRACE(("resolved okay, dns %p\n", *entry)); + } + else + TRACE(("not yet\n")); + return CURLE_OK; +} + +CURLcode Curl_fdset(struct connectdata *conn, + fd_set *read_fd_set, + fd_set *write_fd_set, + int *max_fdp) +{ + const struct thread_data *td = + (const struct thread_data *) conn->async.os_specific; + + if (td && td->dummy_sock != CURL_SOCKET_BAD) { + FD_SET(td->dummy_sock,write_fd_set); + *max_fdp = td->dummy_sock; + } + (void) read_fd_set; + return CURLE_OK; +} + +#ifdef CURLRES_IPV4 +/* + * Curl_getaddrinfo() - for Windows threading without ENABLE_IPV6. + */ +Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, + char *hostname, + int port, + int *waitp) +{ + struct hostent *h; + struct SessionHandle *data = conn->data; + in_addr_t in; + + *waitp = 0; /* don't wait, we act synchronously */ + + in = inet_addr(hostname); + if (in != CURL_INADDR_NONE) + /* This is a dotted IP address 123.123.123.123-style */ + return Curl_ip2addr(in, hostname, port); + + /* fire up a new resolver thread! */ + if (init_resolve_thread(conn, hostname, port, NULL)) { + *waitp = TRUE; /* please wait for the response */ + return NULL; + } + + /* fall-back to blocking version */ + infof(data, "init_resolve_thread() failed for %s; code %lu\n", + hostname, GetLastError()); + + h = gethostbyname(hostname); + if (!h) { + infof(data, "gethostbyname(2) failed for %s:%d; %s\n", + hostname, port, Curl_strerror(conn,WSAGetLastError())); + return NULL; + } + return Curl_he2ai(h, port); +} +#endif /* CURLRES_IPV4 */ + +#ifdef CURLRES_IPV6 +/* + * Curl_getaddrinfo() - for Windows threading IPv6 enabled + */ +Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, + char *hostname, + int port, + int *waitp) +{ + struct addrinfo hints, *res; + int error; + char sbuf[NI_MAXSERV]; + curl_socket_t s; + int pf; + struct SessionHandle *data = conn->data; + + *waitp = FALSE; /* default to synch response */ + + /* see if we have an IPv6 stack */ + s = socket(PF_INET6, SOCK_DGRAM, 0); + if (s == CURL_SOCKET_BAD) { + /* Some non-IPv6 stacks have been found to make very slow name resolves + * when PF_UNSPEC is used, so thus we switch to a mere PF_INET lookup if + * the stack seems to be a non-ipv6 one. */ + + pf = PF_INET; + } + else { + /* This seems to be an IPv6-capable stack, use PF_UNSPEC for the widest + * possible checks. And close the socket again. + */ + sclose(s); + + /* + * Check if a more limited name resolve has been requested. + */ + switch(data->set.ip_version) { + case CURL_IPRESOLVE_V4: + pf = PF_INET; + break; + case CURL_IPRESOLVE_V6: + pf = PF_INET6; + break; + default: + pf = PF_UNSPEC; + break; + } + } + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = pf; + hints.ai_socktype = SOCK_STREAM; + hints.ai_flags = AI_CANONNAME; + itoa(port, sbuf, 10); + + /* fire up a new resolver thread! */ + if (init_resolve_thread(conn, hostname, port, &hints)) { + *waitp = TRUE; /* please wait for the response */ + return NULL; + } + + /* fall-back to blocking version */ + infof(data, "init_resolve_thread() failed for %s; code %lu\n", + hostname, GetLastError()); + + error = getaddrinfo(hostname, sbuf, &hints, &res); + if (error) { + infof(data, "getaddrinfo() failed for %s:%d; %s\n", + hostname, port, Curl_strerror(conn,WSAGetLastError())); + return NULL; + } + return res; +} +#endif /* CURLRES_IPV6 */ +#endif /* CURLRES_THREADED */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/http.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/http.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/http.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/http.c 2005-02-28 06:36:00.000000000 +0800 @@ -0,0 +1,1996 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: http.c,v 1.10 2005/02/27 22:36:00 andy Exp $ + ***************************************************************************/ + +#include "setup.h" + +#ifndef CURL_DISABLE_HTTP +/* -- WIN32 approved -- */ +#include +#include +#include +#include +#include +#include +#include + +#include + +#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__) +#include +#include +#else +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif +#include + +#ifdef HAVE_TIME_H +#ifdef TIME_WITH_SYS_TIME +#include +#endif +#endif + +#ifdef HAVE_UNISTD_H +#include +#endif +#include +#ifdef HAVE_ARPA_INET_H +#include +#endif +#ifdef HAVE_NET_IF_H +#include +#endif +#include +#include + +#ifdef HAVE_SYS_PARAM_H +#include +#endif + +#ifdef HAVE_SYS_SELECT_H +#include +#endif + +#endif + +#include "urldata.h" +#include +#include "transfer.h" +#include "sendf.h" +#include "formdata.h" +#include "progress.h" +#include "base64.h" +#include "cookie.h" +#include "strequal.h" +#include "ssluse.h" +#include "http_digest.h" +#include "http_ntlm.h" +#include "http_negotiate.h" +#include "url.h" +#include "share.h" +#include "hostip.h" +#include "http.h" +#include "curl_memory.h" + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +/* The last #include file should be: */ +#include "memdebug.h" + +/* + * checkheaders() checks the linked list of custom HTTP headers for a + * particular header (prefix). + * + * Returns a pointer to the first matching header or NULL if none matched. + */ +static char *checkheaders(struct SessionHandle *data, const char *thisheader) +{ + struct curl_slist *head; + size_t thislen = strlen(thisheader); + + for(head = data->set.headers; head; head=head->next) { + if(strnequal(head->data, thisheader, thislen)) + return head->data; + } + return NULL; +} + +/* + * Curl_output_basic() sets up an Authorization: header (or the proxy version) + * for HTTP Basic authentication. + * + * Returns CURLcode. + */ +static CURLcode Curl_output_basic(struct connectdata *conn, bool proxy) +{ + char *authorization; + struct SessionHandle *data=conn->data; + char **userp; + char *user; + char *pwd; + + if(proxy) { + userp = &conn->allocptr.proxyuserpwd; + user = conn->proxyuser; + pwd = conn->proxypasswd; + } + else { + userp = &conn->allocptr.userpwd; + user = conn->user; + pwd = conn->passwd; + } + + snprintf(data->state.buffer, sizeof(data->state.buffer), "%s:%s", user, pwd); + if(Curl_base64_encode(data->state.buffer, + strlen(data->state.buffer), + &authorization) > 0) { + if(*userp) + free(*userp); + *userp = aprintf( "%sAuthorization: Basic %s\015\012", + proxy?"Proxy-":"", + authorization); + free(authorization); + } + else + return CURLE_OUT_OF_MEMORY; + return CURLE_OK; +} + +/* pickoneauth() selects the most favourable authentication method from the + * ones available and the ones we want. + * + * return TRUE if one was picked + */ +static bool pickoneauth(struct auth *pick) +{ + bool picked; + /* only deal with authentication we want */ + long avail = pick->avail & pick->want; + picked = TRUE; + + /* The order of these checks is highly relevant, as this will be the order + of preference in case of the existance of multiple accepted types. */ + if(avail & CURLAUTH_GSSNEGOTIATE) + pick->picked = CURLAUTH_GSSNEGOTIATE; + else if(avail & CURLAUTH_DIGEST) + pick->picked = CURLAUTH_DIGEST; + else if(avail & CURLAUTH_NTLM) + pick->picked = CURLAUTH_NTLM; + else if(avail & CURLAUTH_BASIC) + pick->picked = CURLAUTH_BASIC; + else { + pick->picked = CURLAUTH_PICKNONE; /* we select to use nothing */ + picked = FALSE; + } + pick->avail = CURLAUTH_NONE; /* clear it here */ + + return picked; +} + +/* + * Curl_http_auth_act() gets called when a all HTTP headers have been received + * and it checks what authentication methods that are available and decides + * which one (if any) to use. It will set 'newurl' if an auth metod was + * picked. + */ + +CURLcode Curl_http_auth_act(struct connectdata *conn) +{ + struct SessionHandle *data = conn->data; + bool pickhost = FALSE; + bool pickproxy = FALSE; + CURLcode code = CURLE_OK; + + if(data->state.authproblem) + return data->set.http_fail_on_error?CURLE_HTTP_RETURNED_ERROR:CURLE_OK; + + if(conn->bits.user_passwd && + ((conn->keep.httpcode == 401) || + (conn->bits.authprobe && conn->keep.httpcode < 300))) { + pickhost = pickoneauth(&data->state.authhost); + if(!pickhost) + data->state.authproblem = TRUE; + } + if(conn->bits.proxy_user_passwd && + ((conn->keep.httpcode == 407) || + (conn->bits.authprobe && conn->keep.httpcode < 300))) { + pickproxy = pickoneauth(&data->state.authproxy); + if(!pickproxy) + data->state.authproblem = TRUE; + } + + if(pickhost || pickproxy) + conn->newurl = strdup(data->change.url); /* clone URL */ + + else if((conn->keep.httpcode < 300) && + (!data->state.authhost.done) && + conn->bits.authprobe) { + /* no (known) authentication available, + authentication is not "done" yet and + no authentication seems to be required and + we didn't try HEAD or GET */ + if((data->set.httpreq != HTTPREQ_GET) && + (data->set.httpreq != HTTPREQ_HEAD)) { + conn->newurl = strdup(data->change.url); /* clone URL */ + data->state.authhost.done = TRUE; + } + } + if (Curl_http_should_fail(conn)) { + failf (data, "The requested URL returned error: %d", + conn->keep.httpcode); + code = CURLE_HTTP_RETURNED_ERROR; + } + + return code; +} + +/** + * Curl_http_output_auth() setups the authentication headers for the + * host/proxy and the correct authentication + * method. conn->data->state.authdone is set to TRUE when authentication is + * done. + * + * @param conn all information about the current connection + * @param request pointer to the request keyword + * @param path pointer to the requested path + * @param proxytunnel boolean if this is the request setting up a "proxy + * tunnel" + * + * @returns CURLcode + */ +static CURLcode +Curl_http_output_auth(struct connectdata *conn, + char *request, + char *path, + bool proxytunnel) /* TRUE if this is the request setting + up the proxy tunnel */ +{ + CURLcode result = CURLE_OK; + struct SessionHandle *data = conn->data; + char *auth=NULL; + + curlassert(data); + + if((conn->bits.httpproxy && conn->bits.proxy_user_passwd) || + conn->bits.user_passwd) + /* continue please */ ; + else { + data->state.authhost.done = TRUE; + data->state.authproxy.done = TRUE; + return CURLE_OK; /* no authentication with no user or password */ + } + + if(data->state.authhost.want && !data->state.authhost.picked) + /* The app has selected one or more methods, but none has been picked + so far by a server round-trip. Then we set the picked one to the + want one, and if this is one single bit it'll be used instantly. */ + data->state.authhost.picked = data->state.authhost.want; + + if(data->state.authproxy.want && !data->state.authproxy.picked) + /* The app has selected one or more methods, but none has been picked so + far by a proxy round-trip. Then we set the picked one to the want one, + and if this is one single bit it'll be used instantly. */ + data->state.authproxy.picked = data->state.authproxy.want; + + /* To prevent the user+password to get sent to other than the original + host due to a location-follow, we do some weirdo checks here */ + if(!data->state.this_is_a_follow || + !data->state.auth_host || + curl_strequal(data->state.auth_host, conn->host.name) || + data->set.http_disable_hostname_check_before_authentication) { + + /* Send proxy authentication header if needed */ + if (conn->bits.httpproxy && + (conn->bits.tunnel_proxy == proxytunnel)) { +#ifdef USE_SSLEAY + if(data->state.authproxy.want == CURLAUTH_NTLM) { + auth=(char *)"NTLM"; + result = Curl_output_ntlm(conn, TRUE); + if(result) + return result; + } + else +#endif + if(data->state.authproxy.want == CURLAUTH_BASIC) { + /* Basic */ + if(conn->bits.proxy_user_passwd && + !checkheaders(data, "Proxy-authorization:")) { + auth=(char *)"Basic"; + result = Curl_output_basic(conn, TRUE); + if(result) + return result; + } + data->state.authproxy.done = TRUE; + } + else if(data->state.authproxy.want == CURLAUTH_DIGEST) { + auth=(char *)"Digest"; + result = Curl_output_digest(conn, + TRUE, /* proxy */ + (unsigned char *)request, + (unsigned char *)path); + if(result) + return result; + } + + infof(data, "Proxy auth using %s with user '%s'\n", + auth, conn->proxyuser?conn->proxyuser:""); + } + else + /* we have no proxy so let's pretend we're done authenticating + with it */ + data->state.authproxy.done = TRUE; + + /* Send web authentication header if needed */ + { + auth = NULL; +#ifdef HAVE_GSSAPI + if((data->state.authhost.want == CURLAUTH_GSSNEGOTIATE) && + data->state.negotiate.context && + !GSS_ERROR(data->state.negotiate.status)) { + auth=(char *)"GSS-Negotiate"; + result = Curl_output_negotiate(conn); + if (result) + return result; + data->state.authhost.done = TRUE; + } + else +#endif +#ifdef USE_SSLEAY + if(data->state.authhost.picked == CURLAUTH_NTLM) { + auth=(char *)"NTLM"; + result = Curl_output_ntlm(conn, FALSE); + if(result) + return result; + } + else +#endif + { + if(data->state.authhost.picked == CURLAUTH_DIGEST) { + auth=(char *)"Digest"; + result = Curl_output_digest(conn, + FALSE, /* not a proxy */ + (unsigned char *)request, + (unsigned char *)path); + if(result) + return result; + } + else if(data->state.authhost.picked == CURLAUTH_BASIC) { + if(conn->bits.user_passwd && + !checkheaders(data, "Authorization:")) { + auth=(char *)"Basic"; + result = Curl_output_basic(conn, FALSE); + if(result) + return result; + } + /* basic is always ready */ + data->state.authhost.done = TRUE; + } + } + if(auth) + infof(data, "Server auth using %s with user '%s'\n", + auth, conn->user); + } + } + else + data->state.authhost.done = TRUE; + + return result; +} + + +/* + * Curl_http_input_auth() deals with Proxy-Authenticate: and WWW-Authenticate: + * headers. They are dealt with both in the transfer.c main loop and in the + * proxy CONNECT loop. + */ + +CURLcode Curl_http_input_auth(struct connectdata *conn, + int httpcode, + char *header) /* the first non-space */ +{ + /* + * This resource requires authentication + */ + struct SessionHandle *data = conn->data; + + long *availp; + char *start; + struct auth *authp; + + if (httpcode == 407) { + start = header+strlen("Proxy-authenticate:"); + availp = &data->info.proxyauthavail; + authp = &data->state.authproxy; + } + else { + start = header+strlen("WWW-Authenticate:"); + availp = &data->info.httpauthavail; + authp = &data->state.authhost; + } + + /* pass all white spaces */ + while(*start && isspace((int)*start)) + start++; + + /* + * Here we check if we want the specific single authentiction (using ==) and + * if we do, we initiate usage of it. + * + * If the provided authentication is wanted as one out of several accepted + * types (using &), we OR this authenticaion type to the authavail + * variable. + */ + +#ifdef HAVE_GSSAPI + if (checkprefix("GSS-Negotiate", start) || + checkprefix("Negotiate", start)) { + *availp |= CURLAUTH_GSSNEGOTIATE; + authp->avail |= CURLAUTH_GSSNEGOTIATE; + if(authp->picked == CURLAUTH_GSSNEGOTIATE) { + /* if exactly this is wanted, go */ + int neg = Curl_input_negotiate(conn, start); + if (neg == 0) { + conn->newurl = strdup(data->change.url); + data->state.authproblem = (conn->newurl == NULL); + } + else { + infof(data, "Authentication problem. Ignoring this.\n"); + data->state.authproblem = TRUE; + } + } + } + else +#endif +#ifdef USE_SSLEAY + /* NTLM support requires the SSL crypto libs */ + if(checkprefix("NTLM", start)) { + *availp |= CURLAUTH_NTLM; + authp->avail |= CURLAUTH_NTLM; + if(authp->picked == CURLAUTH_NTLM) { + /* NTLM authentication is picked and activated */ + CURLntlm ntlm = + Curl_input_ntlm(conn, (bool)(httpcode == 407), start); + + if(CURLNTLM_BAD != ntlm) + data->state.authproblem = FALSE; + else { + infof(data, "Authentication problem. Ignoring this.\n"); + data->state.authproblem = TRUE; + } + } + } + else +#endif + if(checkprefix("Digest", start)) { + CURLdigest dig; + *availp |= CURLAUTH_DIGEST; + authp->avail |= CURLAUTH_DIGEST; + + /* We call this function on input Digest headers even if Digest + * authentication isn't activated yet, as we need to store the + * incoming data from this header in case we are gonna use Digest. */ + dig = Curl_input_digest(conn, (bool)(httpcode == 407), start); + + if(CURLDIGEST_FINE != dig) { + infof(data, "Authentication problem. Ignoring this.\n"); + data->state.authproblem = TRUE; + } + } + else if(checkprefix("Basic", start)) { + *availp |= CURLAUTH_BASIC; + authp->avail |= CURLAUTH_BASIC; + if(authp->picked == CURLAUTH_BASIC) { + /* We asked for Basic authentication but got a 40X back + anyway, which basicly means our name+password isn't + valid. */ + authp->avail = CURLAUTH_NONE; + infof(data, "Authentication problem. Ignoring this.\n"); + data->state.authproblem = TRUE; + } + } + + return CURLE_OK; +} + +/** + * Curl_http_should_fail() determines whether an HTTP response has gotten us + * into an error state or not. + * + * @param conn all information about the current connection + * + * @retval 0 communications should continue + * + * @retval 1 communications should not continue + */ +int Curl_http_should_fail(struct connectdata *conn) +{ + struct SessionHandle *data; + struct Curl_transfer_keeper *k; + + curlassert(conn); + data = conn->data; + curlassert(data); + + /* + ** For readability + */ + k = &conn->keep; + + /* + ** If we haven't been asked to fail on error, + ** don't fail. + */ + if (!data->set.http_fail_on_error) + return 0; + + /* + ** Any code < 400 is never terminal. + */ + if (k->httpcode < 400) + return 0; + + /* + ** Any code >= 400 that's not 401 or 407 is always + ** a terminal error + */ + if ((k->httpcode != 401) && + (k->httpcode != 407)) + return 1; + + /* + ** All we have left to deal with is 401 and 407 + */ + curlassert((k->httpcode == 401) || (k->httpcode == 407)); + + /* + ** Examine the current authentication state to see if this + ** is an error. The idea is for this function to get + ** called after processing all the headers in a response + ** message. So, if we've been to asked to authenticate a + ** particular stage, and we've done it, we're OK. But, if + ** we're already completely authenticated, it's not OK to + ** get another 401 or 407. + ** + ** It is possible for authentication to go stale such that + ** the client needs to reauthenticate. Once that info is + ** available, use it here. + */ +#if 0 /* set to 1 when debugging this functionality */ + infof(data,"%s: authstage = %d\n",__FUNCTION__,data->state.authstage); + infof(data,"%s: authwant = 0x%08x\n",__FUNCTION__,data->state.authwant); + infof(data,"%s: authavail = 0x%08x\n",__FUNCTION__,data->state.authavail); + infof(data,"%s: httpcode = %d\n",__FUNCTION__,k->httpcode); + infof(data,"%s: authdone = %d\n",__FUNCTION__,data->state.authdone); + infof(data,"%s: newurl = %s\n",__FUNCTION__,conn->newurl ? conn->newurl : "(null)"); + infof(data,"%s: authproblem = %d\n",__FUNCTION__,data->state.authproblem); +#endif + + /* + ** Either we're not authenticating, or we're supposed to + ** be authenticating something else. This is an error. + */ + if((k->httpcode == 401) && !conn->bits.user_passwd) + return TRUE; + if((k->httpcode == 407) && !conn->bits.proxy_user_passwd) + return TRUE; + + return data->state.authproblem; +} + +/* + * readmoredata() is a "fread() emulation" to provide POST and/or request + * data. It is used when a huge POST is to be made and the entire chunk wasn't + * sent in the first send(). This function will then be called from the + * transfer.c loop when more data is to be sent to the peer. + * + * Returns the amount of bytes it filled the buffer with. + */ +static size_t readmoredata(char *buffer, + size_t size, + size_t nitems, + void *userp) +{ + struct connectdata *conn = (struct connectdata *)userp; + struct HTTP *http = conn->proto.http; + size_t fullsize = size * nitems; + + if(0 == http->postsize) + /* nothing to return */ + return 0; + + /* make sure that a HTTP request is never sent away chunked! */ + conn->bits.forbidchunk= (http->sending == HTTPSEND_REQUEST)?TRUE:FALSE; + + if(http->postsize <= (curl_off_t)fullsize) { + memcpy(buffer, http->postdata, (size_t)http->postsize); + fullsize = (size_t)http->postsize; + + if(http->backup.postsize) { + /* move backup data into focus and continue on that */ + http->postdata = http->backup.postdata; + http->postsize = http->backup.postsize; + conn->fread = http->backup.fread; + conn->fread_in = http->backup.fread_in; + + http->sending++; /* move one step up */ + + http->backup.postsize=0; + } + else + http->postsize = 0; + + return fullsize; + } + + memcpy(buffer, http->postdata, fullsize); + http->postdata += fullsize; + http->postsize -= fullsize; + + return fullsize; +} + +/* ------------------------------------------------------------------------- */ +/* + * The add_buffer series of functions are used to build one large memory chunk + * from repeated function invokes. Used so that the entire HTTP request can + * be sent in one go. + */ + +struct send_buffer { + char *buffer; + size_t size_max; + size_t size_used; +}; +typedef struct send_buffer send_buffer; + +static CURLcode + add_buffer(send_buffer *in, const void *inptr, size_t size); + +/* + * add_buffer_init() sets up and returns a fine buffer struct + */ +static +send_buffer *add_buffer_init(void) +{ + send_buffer *blonk; + blonk=(send_buffer *)malloc(sizeof(send_buffer)); + if(blonk) { + memset(blonk, 0, sizeof(send_buffer)); + return blonk; + } + return NULL; /* failed, go home */ +} + +/* + * add_buffer_send() sends a buffer and frees all associated memory. + * + * Returns CURLcode + */ +static +CURLcode add_buffer_send(send_buffer *in, + struct connectdata *conn, + long *bytes_written) /* add the number of sent + bytes to this counter */ +{ + ssize_t amount; + CURLcode res; + char *ptr; + size_t size; + struct HTTP *http = conn->proto.http; + size_t sendsize; + curl_socket_t sockfd = conn->sock[FIRSTSOCKET]; + + /* The looping below is required since we use non-blocking sockets, but due + to the circumstances we will just loop and try again and again etc */ + + ptr = in->buffer; + size = in->size_used; + + if(conn->protocol & PROT_HTTPS) { + /* We never send more than CURL_MAX_WRITE_SIZE bytes in one single chunk + when we speak HTTPS, as if only a fraction of it is sent now, this data + needs to fit into the normal read-callback buffer later on and that + buffer is using this size. + */ + + sendsize= (size > CURL_MAX_WRITE_SIZE)?CURL_MAX_WRITE_SIZE:size; + + /* OpenSSL is very picky and we must send the SAME buffer pointer to the + library when we attempt to re-send this buffer. Sending the same data + is not enough, we must use the exact same address. For this reason, we + must copy the data to the uploadbuffer first, since that is the buffer + we will be using if this send is retried later. + */ + memcpy(conn->data->state.uploadbuffer, ptr, sendsize); + ptr = conn->data->state.uploadbuffer; + } + else + sendsize = size; + + res = Curl_write(conn, sockfd, ptr, sendsize, &amount); + + if(CURLE_OK == res) { + + if(conn->data->set.verbose) + /* this data _may_ contain binary stuff */ + Curl_debug(conn->data, CURLINFO_HEADER_OUT, ptr, amount, + conn->host.dispname); + + *bytes_written += amount; + + if((size_t)amount != size) { + /* The whole request could not be sent in one system call. We must queue + it up and send it later when we get the chance. We must not loop here + and wait until it might work again. */ + + size -= amount; + + ptr = in->buffer + amount; + + /* backup the currently set pointers */ + http->backup.fread = conn->fread; + http->backup.fread_in = conn->fread_in; + http->backup.postdata = http->postdata; + http->backup.postsize = http->postsize; + + /* set the new pointers for the request-sending */ + conn->fread = (curl_read_callback)readmoredata; + conn->fread_in = (void *)conn; + http->postdata = ptr; + http->postsize = (curl_off_t)size; + + http->send_buffer = in; + http->sending = HTTPSEND_REQUEST; + + return CURLE_OK; + } + http->sending = HTTPSEND_BODY; + /* the full buffer was sent, clean up and return */ + } + if(in->buffer) + free(in->buffer); + free(in); + + return res; +} + + +/* + * add_bufferf() add the formatted input to the buffer. + */ +static +CURLcode add_bufferf(send_buffer *in, const char *fmt, ...) +{ + char *s; + va_list ap; + va_start(ap, fmt); + s = vaprintf(fmt, ap); /* this allocs a new string to append */ + va_end(ap); + + if(s) { + CURLcode result = add_buffer(in, s, strlen(s)); + free(s); + if(CURLE_OK == result) + return CURLE_OK; + } + /* If we failed, we cleanup the whole buffer and return error */ + if(in->buffer) + free(in->buffer); + free(in); + return CURLE_OUT_OF_MEMORY; +} + +/* + * add_buffer() appends a memory chunk to the existing buffer + */ +static +CURLcode add_buffer(send_buffer *in, const void *inptr, size_t size) +{ + char *new_rb; + size_t new_size; + + if(!in->buffer || + ((in->size_used + size) > (in->size_max - 1))) { + new_size = (in->size_used+size)*2; + if(in->buffer) + /* we have a buffer, enlarge the existing one */ + new_rb = (char *)realloc(in->buffer, new_size); + else + /* create a new buffer */ + new_rb = (char *)malloc(new_size); + + if(!new_rb) + return CURLE_OUT_OF_MEMORY; + + in->buffer = new_rb; + in->size_max = new_size; + } + memcpy(&in->buffer[in->size_used], inptr, size); + + in->size_used += size; + + return CURLE_OK; +} + +/* end of the add_buffer functions */ +/* ------------------------------------------------------------------------- */ + +/* + * Curl_compareheader() + * + * Returns TRUE if 'headerline' contains the 'header' with given 'content'. + * Pass headers WITH the colon. + */ +bool +Curl_compareheader(char *headerline, /* line to check */ + const char *header, /* header keyword _with_ colon */ + const char *content) /* content string to find */ +{ + /* RFC2616, section 4.2 says: "Each header field consists of a name followed + * by a colon (":") and the field value. Field names are case-insensitive. + * The field value MAY be preceded by any amount of LWS, though a single SP + * is preferred." */ + + size_t hlen = strlen(header); + size_t clen; + size_t len; + char *start; + char *end; + + if(!strnequal(headerline, header, hlen)) + return FALSE; /* doesn't start with header */ + + /* pass the header */ + start = &headerline[hlen]; + + /* pass all white spaces */ + while(*start && isspace((int)*start)) + start++; + + /* find the end of the header line */ + end = strchr(start, '\r'); /* lines end with CRLF */ + if(!end) { + /* in case there's a non-standard compliant line here */ + end = strchr(start, '\n'); + + if(!end) + /* hm, there's no line ending here, use the zero byte! */ + end = strchr(start, '\0'); + } + + len = end-start; /* length of the content part of the input line */ + clen = strlen(content); /* length of the word to find */ + + /* find the content string in the rest of the line */ + for(;len>=clen;len--, start++) { + if(strnequal(start, content, clen)) + return TRUE; /* match! */ + } + + return FALSE; /* no match */ +} + +/* + * ConnectHTTPProxyTunnel() requires that we're connected to a HTTP proxy. This + * function will issue the necessary commands to get a seamless tunnel through + * this proxy. After that, the socket can be used just as a normal socket. + */ + +CURLcode Curl_ConnectHTTPProxyTunnel(struct connectdata *conn, + int sockindex, + char *hostname, + int remote_port) +{ + int subversion=0; + struct SessionHandle *data=conn->data; + struct Curl_transfer_keeper *k = &conn->keep; + CURLcode result; + int res; + + size_t nread; /* total size read */ + int perline; /* count bytes per line */ + bool keepon=TRUE; + ssize_t gotbytes; + char *ptr; + long timeout; /* default timeout in seconds */ + struct timeval interval; + fd_set rkeepfd; + fd_set readfd; + char *line_start; + char *host_port; + curl_socket_t tunnelsocket = conn->sock[sockindex]; + +#define SELECT_OK 0 +#define SELECT_ERROR 1 +#define SELECT_TIMEOUT 2 + int error = SELECT_OK; + + infof(data, "Establish HTTP proxy tunnel to %s:%d\n", hostname, remote_port); + + do { + if(conn->newurl) { + /* This only happens if we've looped here due to authentication reasons, + and we don't really use the newly cloned URL here then. Just free() + it. */ + free(conn->newurl); + conn->newurl = NULL; + } + + host_port = aprintf("%s:%d", hostname, remote_port); + if(!host_port) + return CURLE_OUT_OF_MEMORY; + + /* Setup the proxy-authorization header, if any */ + result = Curl_http_output_auth(conn, (char *)"CONNECT", host_port, TRUE); + if(CURLE_OK == result) { + + /* OK, now send the connect request to the proxy */ + result = + Curl_sendf(tunnelsocket, conn, + "CONNECT %s:%d HTTP/1.0\015\012" + "%s" + "%s" + "\r\n", + hostname, remote_port, + conn->bits.proxy_user_passwd? + conn->allocptr.proxyuserpwd:"", + data->set.useragent?conn->allocptr.uagent:"" + ); + if(result) + failf(data, "Failed sending CONNECT to proxy"); + } + free(host_port); + if(result) + return result; + + FD_ZERO (&readfd); /* clear it */ + FD_SET (tunnelsocket, &readfd); /* read socket */ + + /* get this in a backup variable to be able to restore it on each lap in + the select() loop */ + rkeepfd = readfd; + + ptr=data->state.buffer; + line_start = ptr; + + nread=0; + perline=0; + + while((nreadset.timeout) { + /* if timeout is requested, find out how much remaining time we have */ + timeout = data->set.timeout - /* timeout time */ + Curl_tvdiff(Curl_tvnow(), conn->now)/1000; /* spent time */ + if(timeout <=0 ) { + failf(data, "Proxy connection aborted due to timeout"); + error = SELECT_TIMEOUT; /* already too little time */ + break; + } + } + + switch (select (tunnelsocket+1, &readfd, NULL, NULL, &interval)) { + case -1: /* select() error, stop reading */ + error = SELECT_ERROR; + failf(data, "Proxy CONNECT aborted due to select() error"); + break; + case 0: /* timeout */ + break; + default: + /* + * This code previously didn't use the kerberos sec_read() code + * to read, but when we use Curl_read() it may do so. Do confirm + * that this is still ok and then remove this comment! + */ + res= Curl_read(conn, tunnelsocket, ptr, BUFSIZE-nread, &gotbytes); + if(res< 0) + /* EWOULDBLOCK */ + continue; /* go loop yourself */ + else if(res) + keepon = FALSE; + else if(gotbytes <= 0) { + keepon = FALSE; + error = SELECT_ERROR; + failf(data, "Proxy CONNECT aborted"); + } + else { + /* + * We got a whole chunk of data, which can be anything from one byte + * to a set of lines and possibly just a piece of the last line. + * + * TODO: To make this code work less error-prone, we need to make + * sure that we read and create full lines before we compare them, + * as there is really nothing that stops the proxy from delivering + * the response lines in multiple parts, each part consisting of + * only a little piece of the line(s). */ + int i; + + nread += gotbytes; + for(i = 0; i < gotbytes; ptr++, i++) { + perline++; /* amount of bytes in this line so far */ + if(*ptr=='\n') { + char letter; + int writetype; + + /* output debug output if that is requested */ + if(data->set.verbose) + Curl_debug(data, CURLINFO_HEADER_IN, line_start, perline, + conn->host.dispname); + + /* send the header to the callback */ + writetype = CLIENTWRITE_HEADER; + if(data->set.include_header) + writetype |= CLIENTWRITE_BODY; + + result = Curl_client_write(data, writetype, line_start, perline); + if(result) + return result; + + /* Newlines are CRLF, so the CR is ignored as the line isn't + really terminated until the LF comes. Treat a following CR + as end-of-headers as well.*/ + + if(('\r' == line_start[0]) || + ('\n' == line_start[0])) { + /* end of response-headers from the proxy */ + keepon=FALSE; + break; /* breaks out of for-loop, not switch() */ + } + + /* keep a backup of the position we are about to blank */ + letter = line_start[perline]; + line_start[perline]=0; /* zero terminate the buffer */ + if((checkprefix("WWW-Authenticate:", line_start) && + (401 == k->httpcode)) || + (checkprefix("Proxy-authenticate:", line_start) && + (407 == k->httpcode))) { + result = Curl_http_input_auth(conn, k->httpcode, line_start); + if(result) + return result; + } + else if(2 == sscanf(line_start, "HTTP/1.%d %d", + &subversion, + &k->httpcode)) { + /* store the HTTP code from the proxy */ + data->info.httpproxycode = k->httpcode; + } + /* put back the letter we blanked out before */ + line_start[perline]= letter; + + perline=0; /* line starts over here */ + line_start = ptr+1; /* this skips the zero byte we wrote */ + } + } + } + break; + } /* switch */ + } /* while there's buffer left and loop is requested */ + + if(error) + return CURLE_RECV_ERROR; + + if(data->info.httpproxycode != 200) + /* Deal with the possibly already received authenticate + headers. 'newurl' is set to a new URL if we must loop. */ + Curl_http_auth_act(conn); + + } while(conn->newurl); + + if(200 != k->httpcode) { + failf(data, "Received HTTP code %d from proxy after CONNECT", + k->httpcode); + return CURLE_RECV_ERROR; + } + + /* If a proxy-authorization header was used for the proxy, then we should + make sure that it isn't accidentally used for the document request + after we've connected. So let's free and clear it here. */ + Curl_safefree(conn->allocptr.proxyuserpwd); + conn->allocptr.proxyuserpwd = NULL; + + data->state.authproxy.done = TRUE; + + infof (data, "Proxy replied OK to CONNECT request\n"); + return CURLE_OK; +} + +/* + * Curl_http_connect() performs HTTP stuff to do at connect-time, called from + * the generic Curl_connect(). + */ +CURLcode Curl_http_connect(struct connectdata *conn) +{ + struct SessionHandle *data; + CURLcode result; + + data=conn->data; + + /* If we are not using a proxy and we want a secure connection, perform SSL + * initialization & connection now. If using a proxy with https, then we + * must tell the proxy to CONNECT to the host we want to talk to. Only + * after the connect has occured, can we start talking SSL + */ + + if(conn->bits.tunnel_proxy) { + + /* either SSL over proxy, or explicitly asked for */ + result = Curl_ConnectHTTPProxyTunnel(conn, FIRSTSOCKET, + conn->host.name, + conn->remote_port); + if(CURLE_OK != result) + return result; + } + + if(conn->protocol & PROT_HTTPS) { + /* now, perform the SSL initialization for this socket */ + result = Curl_SSLConnect(conn, FIRSTSOCKET); + if(result) + return result; + } + + if(conn->bits.user_passwd && !data->state.this_is_a_follow) { + /* Authorization: is requested, this is not a followed location, get the + original host name */ + if (data->state.auth_host) + /* Free to avoid leaking memory on multiple requests*/ + free(data->state.auth_host); + + data->state.auth_host = strdup(conn->host.name); + } + + return CURLE_OK; +} + +/* + * Curl_http_done() gets called from Curl_done() after a single HTTP request + * has been performed. + */ + +CURLcode Curl_http_done(struct connectdata *conn, + CURLcode status) +{ + struct SessionHandle *data; + struct HTTP *http; + (void)status; /* no use for us */ + + data=conn->data; + http=conn->proto.http; + + /* set the proper values (possibly modified on POST) */ + conn->fread = data->set.fread; /* restore */ + conn->fread_in = data->set.in; /* restore */ + + if (http == NULL) + return CURLE_OK; + + if(http->send_buffer) { + send_buffer *buff = http->send_buffer; + + free(buff->buffer); + free(buff); + http->send_buffer = NULL; /* cleaer the pointer */ + } + + if(HTTPREQ_POST_FORM == data->set.httpreq) { + conn->bytecount = http->readbytecount + http->writebytecount; + + Curl_formclean(http->sendit); /* Now free that whole lot */ + } + else if(HTTPREQ_PUT == data->set.httpreq) + conn->bytecount = http->readbytecount + http->writebytecount; + + if(!conn->bits.retry && + ((http->readbytecount + + conn->headerbytecount - + conn->deductheadercount)) <= 0) { + /* If this connection isn't simply closed to be retried, AND nothing was + read from the HTTP server (that counts), this can't be right so we + return an error here */ + failf(data, "Empty reply from server"); + return CURLE_GOT_NOTHING; + } + + return CURLE_OK; +} + +/* + * Curl_http() gets called from the generic Curl_do() function when a HTTP + * request is to be performed. This creates and sends a properly constructed + * HTTP request. + */ +CURLcode Curl_http(struct connectdata *conn) +{ + struct SessionHandle *data=conn->data; + char *buf = data->state.buffer; /* this is a short cut to the buffer */ + CURLcode result; + struct HTTP *http; + char *ppath = conn->path; + char *host = conn->host.name; + const char *te = ""; /* tranfer-encoding */ + char *ptr; + char *request; + Curl_HttpReq httpreq = data->set.httpreq; + char *addcookies = NULL; + + if(!conn->proto.http) { + /* Only allocate this struct if we don't already have it! */ + + http = (struct HTTP *)malloc(sizeof(struct HTTP)); + if(!http) + return CURLE_OUT_OF_MEMORY; + memset(http, 0, sizeof(struct HTTP)); + conn->proto.http = http; + } + else + http = conn->proto.http; + + /* We default to persistant connections */ + conn->bits.close = FALSE; + + if ( (conn->protocol&(PROT_HTTP|PROT_FTP)) && + data->set.upload) { + httpreq = HTTPREQ_PUT; + } + + /* Now set the 'request' pointer to the proper request string */ + if(data->set.customrequest) + request = data->set.customrequest; + else { + if(conn->bits.no_body) + request = (char *)"HEAD"; + else { + curlassert((httpreq > HTTPREQ_NONE) && (httpreq < HTTPREQ_LAST)); + switch(httpreq) { + case HTTPREQ_POST: + case HTTPREQ_POST_FORM: + request = (char *)"POST"; + break; + case HTTPREQ_PUT: + request = (char *)"PUT"; + break; + default: /* this should never happen */ + case HTTPREQ_GET: + request = (char *)"GET"; + break; + case HTTPREQ_HEAD: + request = (char *)"HEAD"; + break; + } + } + } + + /* The User-Agent string might have been allocated in url.c already, because + it might have been used in the proxy connect, but if we have got a header + with the user-agent string specified, we erase the previously made string + here. */ + if(checkheaders(data, "User-Agent:") && conn->allocptr.uagent) { + free(conn->allocptr.uagent); + conn->allocptr.uagent=NULL; + } + + /* setup the authentication headers */ + result = Curl_http_output_auth(conn, request, ppath, FALSE); + if(result) + return result; + + if((!data->state.authhost.done || !data->state.authproxy.done ) && + (httpreq != HTTPREQ_GET)) { + /* Until we are authenticated, we switch over to HEAD. Unless its a GET + we want to do. The explanation for this is rather long and boring, but + the point is that it can't be done otherwise without risking having to + send the POST or PUT data multiple times. */ + httpreq = HTTPREQ_HEAD; + request = (char *)"HEAD"; + conn->bits.no_body = TRUE; + conn->bits.authprobe = TRUE; /* this is a request done to probe for + authentication methods */ + } + else + conn->bits.authprobe = FALSE; + + Curl_safefree(conn->allocptr.ref); + if(data->change.referer && !checkheaders(data, "Referer:")) + conn->allocptr.ref = aprintf("Referer: %s\015\012", data->change.referer); + else + conn->allocptr.ref = NULL; + + if(data->set.cookie && !checkheaders(data, "Cookie:")) + addcookies = data->set.cookie; + + if(!conn->bits.upload_chunky && (httpreq != HTTPREQ_GET)) { + /* not a chunky transfer yet, but data is to be sent */ + ptr = checkheaders(data, "Transfer-Encoding:"); + if(ptr) { + /* Some kind of TE is requested, check if 'chunked' is chosen */ + conn->bits.upload_chunky = + Curl_compareheader(ptr, "Transfer-Encoding:", "chunked"); + te = ""; + } + } + else if(conn->bits.upload_chunky) { + /* RFC2616 section 4.4: + Messages MUST NOT include both a Content-Length header field and a + non-identity transfer-coding. If the message does include a non- + identity transfer-coding, the Content-Length MUST be ignored. */ + + if(!checkheaders(data, "Transfer-Encoding:")) { + te = "Transfer-Encoding: chunked\r\n"; + } + else { + te = ""; + conn->bits.upload_chunky = FALSE; /* transfer-encoding was disabled, + so don't chunkify this! */ + } + } + + Curl_safefree(conn->allocptr.host); + + ptr = checkheaders(data, "Host:"); + if(ptr && !data->state.this_is_a_follow) { + /* If we have a given custom Host: header, we extract the host name in + order to possibly use it for cookie reasons later on. We only allow the + custom Host: header if this is NOT a redirect, as setting Host: in the + redirected request is being out on thin ice. */ + char *start = ptr+strlen("Host:"); + while(*start && isspace((int)*start )) + start++; + ptr = start; /* start host-scanning here */ + + /* scan through the string to find the end (space or colon) */ + while(*ptr && !isspace((int)*ptr) && !(':'==*ptr)) + ptr++; + + if(ptr != start) { + size_t len=ptr-start; + conn->allocptr.cookiehost = malloc(len+1); + if(!conn->allocptr.cookiehost) + return CURLE_OUT_OF_MEMORY; + memcpy(conn->allocptr.cookiehost, start, len); + conn->allocptr.cookiehost[len]=0; + } + + conn->allocptr.host = NULL; + } + else { + /* When building Host: headers, we must put the host name within + [brackets] if the host name is a plain IPv6-address. RFC2732-style. */ + + if(((conn->protocol&PROT_HTTPS) && (conn->remote_port == PORT_HTTPS)) || + (!(conn->protocol&PROT_HTTPS) && (conn->remote_port == PORT_HTTP)) ) + /* If (HTTPS on port 443) OR (non-HTTPS on port 80) then don't include + the port number in the host string */ + conn->allocptr.host = aprintf("Host: %s%s%s\r\n", + conn->bits.ipv6_ip?"[":"", + host, + conn->bits.ipv6_ip?"]":""); + else + conn->allocptr.host = aprintf("Host: %s%s%s:%d\r\n", + conn->bits.ipv6_ip?"[":"", + host, + conn->bits.ipv6_ip?"]":"", + conn->remote_port); + + if(!conn->allocptr.host) + /* without Host: we can't make a nice request */ + return CURLE_OUT_OF_MEMORY; + } + + if (conn->bits.httpproxy && !conn->bits.tunnel_proxy) { + /* Using a proxy but does not tunnel through it */ + + /* The path sent to the proxy is in fact the entire URL. But if the remote + host is a IDN-name, we must make sure that the request we produce only + uses the encoded host name! */ + if(conn->host.dispname != conn->host.name) { + char *url = data->change.url; + char *iPtr = strstr(url, conn->host.dispname); + if(iPtr) { + /* This is where the display name starts in the URL, now replace this + part with the encoded name. TODO: This method of replacing the host + name is rather crude as I believe there's a slight risk that the + user has entered a user name or password that contain the host name + string. */ + size_t currlen = strlen(conn->host.dispname); + size_t newlen = strlen(conn->host.name); + size_t urllen = strlen(url); + + char *newurl; + + newurl = malloc(urllen + newlen - currlen + 1); + if(newurl) { + /* copy the part before the host name */ + memcpy(newurl, url, iPtr - url); + /* append the new host name instead of the old */ + memcpy(newurl + (iPtr - url), conn->host.name, newlen); + /* append the piece after the host name */ + memcpy(newurl + newlen + (iPtr - url), + iPtr + currlen, /* copy the trailing zero byte too */ + urllen - (iPtr-url) - currlen + 1); + if(data->change.url_alloc) + free(data->change.url); + data->change.url = newurl; + data->change.url_alloc = TRUE; + } + else + return CURLE_OUT_OF_MEMORY; + } + } + ppath = data->change.url; + } + if(HTTPREQ_POST_FORM == httpreq) { + /* we must build the whole darned post sequence first, so that we have + a size of the whole shebang before we start to send it */ + result = Curl_getFormData(&http->sendit, data->set.httppost, + &http->postsize); + if(CURLE_OK != result) { + /* Curl_getFormData() doesn't use failf() */ + failf(data, "failed creating formpost data"); + return result; + } + } + + + if(!checkheaders(data, "Pragma:")) + http->p_pragma = "Pragma: no-cache\r\n"; + + if(!checkheaders(data, "Accept:")) + http->p_accept = "Accept: */*\r\n"; + + if(( (HTTPREQ_POST == httpreq) || + (HTTPREQ_POST_FORM == httpreq) || + (HTTPREQ_PUT == httpreq) ) && + conn->resume_from) { + /********************************************************************** + * Resuming upload in HTTP means that we PUT or POST and that we have + * got a resume_from value set. The resume value has already created + * a Range: header that will be passed along. We need to "fast forward" + * the file the given number of bytes and decrease the assume upload + * file size before we continue this venture in the dark lands of HTTP. + *********************************************************************/ + + if(conn->resume_from < 0 ) { + /* + * This is meant to get the size of the present remote-file by itself. + * We don't support this now. Bail out! + */ + conn->resume_from = 0; + } + + if(conn->resume_from) { + /* do we still game? */ + curl_off_t passed=0; + + /* Now, let's read off the proper amount of bytes from the + input. If we knew it was a proper file we could've just + fseek()ed but we only have a stream here */ + do { + size_t readthisamountnow = (size_t)(conn->resume_from - passed); + size_t actuallyread; + + if(readthisamountnow > BUFSIZE) + readthisamountnow = BUFSIZE; + + actuallyread = + data->set.fread(data->state.buffer, 1, (size_t)readthisamountnow, + data->set.in); + + passed += actuallyread; + if(actuallyread != readthisamountnow) { + failf(data, "Could only read %" FORMAT_OFF_T + " bytes from the input", + passed); + return CURLE_READ_ERROR; + } + } while(passed != conn->resume_from); /* loop until done */ + + /* now, decrease the size of the read */ + if(data->set.infilesize>0) { + data->set.infilesize -= conn->resume_from; + + if(data->set.infilesize <= 0) { + failf(data, "File already completely uploaded"); + return CURLE_PARTIAL_FILE; + } + } + /* we've passed, proceed as normal */ + } + } + if(conn->bits.use_range) { + /* + * A range is selected. We use different headers whether we're downloading + * or uploading and we always let customized headers override our internal + * ones if any such are specified. + */ + if((httpreq == HTTPREQ_GET) && + !checkheaders(data, "Range:")) { + /* if a line like this was already allocated, free the previous one */ + if(conn->allocptr.rangeline) + free(conn->allocptr.rangeline); + conn->allocptr.rangeline = aprintf("Range: bytes=%s\r\n", conn->range); + } + else if((httpreq != HTTPREQ_GET) && + !checkheaders(data, "Content-Range:")) { + + if(conn->resume_from) { + /* This is because "resume" was selected */ + curl_off_t total_expected_size= + conn->resume_from + data->set.infilesize; + conn->allocptr.rangeline = + aprintf("Content-Range: bytes %s%" FORMAT_OFF_T + "/%" FORMAT_OFF_T "\r\n", + conn->range, total_expected_size-1, + total_expected_size); + } + else { + /* Range was selected and then we just pass the incoming range and + append total size */ + conn->allocptr.rangeline = + aprintf("Content-Range: bytes %s/%" FORMAT_OFF_T "\r\n", + conn->range, data->set.infilesize); + } + } + } + + { + /* Use 1.1 unless the use specificly asked for 1.0 */ + const char *httpstring= + data->set.httpversion==CURL_HTTP_VERSION_1_0?"1.0":"1.1"; + + send_buffer *req_buffer; + struct curl_slist *headers=data->set.headers; + curl_off_t postsize; /* off_t type to be able to hold a large file size */ + + /* initialize a dynamic send-buffer */ + req_buffer = add_buffer_init(); + + if(!req_buffer) + return CURLE_OUT_OF_MEMORY; + + /* add the main request stuff */ + result = + add_bufferf(req_buffer, + "%s " /* GET/HEAD/POST/PUT */ + "%s HTTP/%s\r\n" /* path + HTTP version */ + "%s" /* proxyuserpwd */ + "%s" /* userpwd */ + "%s" /* range */ + "%s" /* user agent */ + "%s" /* host */ + "%s" /* pragma */ + "%s" /* accept */ + "%s" /* accept-encoding */ + "%s" /* referer */ + "%s",/* transfer-encoding */ + + request, + ppath, + httpstring, + conn->allocptr.proxyuserpwd? + conn->allocptr.proxyuserpwd:"", + conn->allocptr.userpwd?conn->allocptr.userpwd:"", + (conn->bits.use_range && conn->allocptr.rangeline)? + conn->allocptr.rangeline:"", + (data->set.useragent && *data->set.useragent && conn->allocptr.uagent)? + conn->allocptr.uagent:"", + (conn->allocptr.host?conn->allocptr.host:""), /* Host: host */ + http->p_pragma?http->p_pragma:"", + http->p_accept?http->p_accept:"", + (data->set.encoding && *data->set.encoding && conn->allocptr.accept_encoding)? + conn->allocptr.accept_encoding:"", + (data->change.referer && conn->allocptr.ref)?conn->allocptr.ref:"" /* Referer: */, + te + ); + + if(result) + return result; + + if(data->cookies || addcookies) { + struct Cookie *co=NULL; /* no cookies from start */ + int count=0; + + if(data->cookies) { + Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); + co = Curl_cookie_getlist(data->cookies, + conn->allocptr.cookiehost? + conn->allocptr.cookiehost:host, ppath, + (bool)(conn->protocol&PROT_HTTPS?TRUE:FALSE)); + Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE); + } + if(co) { + struct Cookie *store=co; + /* now loop through all cookies that matched */ + while(co) { + if(co->value) { + if(0 == count) { + result = add_bufferf(req_buffer, "Cookie: "); + if(result) + break; + } + result = add_bufferf(req_buffer, + "%s%s=%s", count?"; ":"", + co->name, co->value); + if(result) + break; + count++; + } + co = co->next; /* next cookie please */ + } + Curl_cookie_freelist(store); /* free the cookie list */ + } + if(addcookies && (CURLE_OK == result)) { + if(!count) + result = add_bufferf(req_buffer, "Cookie: "); + if(CURLE_OK == result) { + result = add_bufferf(req_buffer, "%s%s", + count?"; ":"", + addcookies); + count++; + } + } + if(count && (CURLE_OK == result)) + result = add_buffer(req_buffer, "\r\n", 2); + + if(result) + return result; + } + + if(data->set.timecondition) { + struct tm *thistime; + + /* Phil Karn (Fri, 13 Apr 2001) pointed out that the If-Modified-Since + * header family should have their times set in GMT as RFC2616 defines: + * "All HTTP date/time stamps MUST be represented in Greenwich Mean Time + * (GMT), without exception. For the purposes of HTTP, GMT is exactly + * equal to UTC (Coordinated Universal Time)." (see page 20 of RFC2616). + */ + +#ifdef HAVE_GMTIME_R + /* thread-safe version */ + struct tm keeptime; + thistime = (struct tm *)gmtime_r(&data->set.timevalue, &keeptime); +#else + thistime = gmtime(&data->set.timevalue); +#endif + +#ifdef HAVE_STRFTIME + /* format: "Tue, 15 Nov 1994 12:45:26 GMT" */ + strftime(buf, BUFSIZE-1, "%a, %d %b %Y %H:%M:%S GMT", thistime); +#else + /* TODO: Right, we *could* write a replacement here */ + strcpy(buf, "no strftime() support"); +#endif + switch(data->set.timecondition) { + case CURL_TIMECOND_IFMODSINCE: + default: + result = add_bufferf(req_buffer, + "If-Modified-Since: %s\r\n", buf); + break; + case CURL_TIMECOND_IFUNMODSINCE: + result = add_bufferf(req_buffer, + "If-Unmodified-Since: %s\r\n", buf); + break; + case CURL_TIMECOND_LASTMOD: + result = add_bufferf(req_buffer, + "Last-Modified: %s\r\n", buf); + break; + } + if(result) + return result; + } + + while(headers) { + ptr = strchr(headers->data, ':'); + if(ptr) { + /* we require a colon for this to be a true header */ + + ptr++; /* pass the colon */ + while(*ptr && isspace((int)*ptr)) + ptr++; + + if(*ptr) { + /* only send this if the contents was non-blank */ + + result = add_bufferf(req_buffer, "%s\r\n", headers->data); + if(result) + return result; + } + } + headers = headers->next; + } + + http->postdata = NULL; /* nothing to post at this point */ + Curl_pgrsSetUploadSize(data, 0); /* upload size is 0 atm */ + + /* If 'authdone' is FALSE, we must not set the write socket index to the + Curl_transfer() call below, as we're not ready to actually upload any + data yet. */ + + switch(httpreq) { + + case HTTPREQ_POST_FORM: + if(Curl_FormInit(&http->form, http->sendit)) { + failf(data, "Internal HTTP POST error!"); + return CURLE_HTTP_POST_ERROR; + } + + /* set the read function to read from the generated form data */ + conn->fread = (curl_read_callback)Curl_FormReader; + conn->fread_in = &http->form; + + http->sending = HTTPSEND_BODY; + + if(!conn->bits.upload_chunky) { + /* only add Content-Length if not uploading chunked */ + result = add_bufferf(req_buffer, + "Content-Length: %" FORMAT_OFF_T "\r\n", + http->postsize); + if(result) + return result; + } + + if(!checkheaders(data, "Expect:")) { + /* if not disabled explicitly we add a Expect: 100-continue + to the headers which actually speeds up post operations (as + there is one packet coming back from the web server) */ + result = add_bufferf(req_buffer, + "Expect: 100-continue\r\n"); + if(result) + return result; + data->set.expect100header = TRUE; + } + + if(!checkheaders(data, "Content-Type:")) { + /* Get Content-Type: line from Curl_formpostheader. + + The Content-Type header line also contains the MIME boundary + string etc why disabling this header is likely to not make things + work, but we support disabling it anyway. + */ + char *contentType; + size_t linelength=0; + contentType = Curl_formpostheader((void *)&http->form, + &linelength); + if(!contentType) { + failf(data, "Could not get Content-Type header line!"); + return CURLE_HTTP_POST_ERROR; + } + result = add_buffer(req_buffer, contentType, linelength); + if(result) + return result; + } + + /* make the request end in a true CRLF */ + result = add_buffer(req_buffer, "\r\n", 2); + if(result) + return result; + + /* set upload size to the progress meter */ + Curl_pgrsSetUploadSize(data, http->postsize); + + /* fire away the whole request to the server */ + result = add_buffer_send(req_buffer, conn, + &data->info.request_size); + if(result) + failf(data, "Failed sending POST request"); + else + /* setup variables for the upcoming transfer */ + result = Curl_Transfer(conn, FIRSTSOCKET, -1, TRUE, + &http->readbytecount, + FIRSTSOCKET, + &http->writebytecount); + if(result) { + Curl_formclean(http->sendit); /* free that whole lot */ + return result; + } + break; + + case HTTPREQ_PUT: /* Let's PUT the data to the server! */ + + if((data->set.infilesize>0) && !conn->bits.upload_chunky) { + /* only add Content-Length if not uploading chunked */ + result = add_bufferf(req_buffer, + "Content-Length: %" FORMAT_OFF_T "\r\n", /* size */ + data->set.infilesize ); + if(result) + return result; + } + + if(!checkheaders(data, "Expect:")) { + /* if not disabled explicitly we add a Expect: 100-continue + to the headers which actually speeds up post operations (as + there is one packet coming back from the web server) */ + result = add_bufferf(req_buffer, + "Expect: 100-continue\r\n"); + if(result) + return result; + data->set.expect100header = TRUE; + } + + result = add_buffer(req_buffer, "\r\n", 2); /* end of headers */ + if(result) + return result; + + /* set the upload size to the progress meter */ + Curl_pgrsSetUploadSize(data, data->set.infilesize); + + /* this sends the buffer and frees all the buffer resources */ + result = add_buffer_send(req_buffer, conn, + &data->info.request_size); + if(result) + failf(data, "Failed sending POST request"); + else + /* prepare for transfer */ + result = Curl_Transfer(conn, FIRSTSOCKET, -1, TRUE, + &http->readbytecount, + FIRSTSOCKET, + &http->writebytecount); + if(result) + return result; + break; + + case HTTPREQ_POST: + /* this is the simple POST, using x-www-form-urlencoded style */ + + /* store the size of the postfields */ + postsize = data->set.postfieldsize? + data->set.postfieldsize: + (data->set.postfields?(curl_off_t)strlen(data->set.postfields):0); + + if(!conn->bits.upload_chunky) { + /* We only set Content-Length and allow a custom Content-Length if + we don't upload data chunked, as RFC2616 forbids us to set both + kinds of headers (Transfer-Encoding: chunked and Content-Length) */ + + if(!checkheaders(data, "Content-Length:")) { + /* we allow replacing this header, although it isn't very wise to + actually set your own */ + result = add_bufferf(req_buffer, + "Content-Length: %" FORMAT_OFF_T"\r\n", + postsize); + if(result) + return result; + } + } + + if(!checkheaders(data, "Content-Type:")) { + result = add_bufferf(req_buffer, + "Content-Type: application/x-www-form-urlencoded\r\n"); + if(result) + return result; + } + + if(data->set.postfields) { + + if((data->state.authhost.done || data->state.authproxy.done ) + && (postsize < (100*1024))) { + /* If we're not done with the authentication phase, we don't expect + to actually send off any data yet. Hence, we delay the sending of + the body until we receive that friendly 100-continue response */ + + /* The post data is less than 100K, then append it to the header. + This limit is no magic limit but only set to prevent really huge + POSTs to get the data duplicated with malloc() and family. */ + + result = add_buffer(req_buffer, "\r\n", 2); /* end of headers! */ + if(result) + return result; + + if(!conn->bits.upload_chunky) { + /* We're not sending it 'chunked', append it to the request + already now to reduce the number if send() calls */ + result = add_buffer(req_buffer, data->set.postfields, + (size_t)postsize); + } + else { + /* Append the POST data chunky-style */ + result = add_bufferf(req_buffer, "%x\r\n", (int)postsize); + if(CURLE_OK == result) + result = add_buffer(req_buffer, data->set.postfields, + (size_t)postsize); + if(CURLE_OK == result) + result = add_buffer(req_buffer, + "\r\n0\r\n\r\n", 7); /* end of a chunked + transfer stream */ + } + if(result) + return result; + } + else { + /* A huge POST coming up, do data separate from the request */ + http->postsize = postsize; + http->postdata = data->set.postfields; + + http->sending = HTTPSEND_BODY; + + conn->fread = (curl_read_callback)readmoredata; + conn->fread_in = (void *)conn; + + /* set the upload size to the progress meter */ + Curl_pgrsSetUploadSize(data, http->postsize); + + if(!checkheaders(data, "Expect:")) { + /* if not disabled explicitly we add a Expect: 100-continue to the + headers which actually speeds up post operations (as there is + one packet coming back from the web server) */ + add_bufferf(req_buffer, + "Expect: 100-continue\r\n"); + data->set.expect100header = TRUE; + } + + add_buffer(req_buffer, "\r\n", 2); /* end of headers! */ + } + } + else { + add_buffer(req_buffer, "\r\n", 2); /* end of headers! */ + + /* set the upload size to the progress meter */ + Curl_pgrsSetUploadSize(data, data->set.infilesize); + + /* set the pointer to mark that we will send the post body using + the read callback */ + http->postdata = (char *)&http->postdata; + } + /* issue the request */ + result = add_buffer_send(req_buffer, conn, + &data->info.request_size); + + if(result) + failf(data, "Failed sending HTTP POST request"); + else + result = + Curl_Transfer(conn, FIRSTSOCKET, -1, TRUE, + &http->readbytecount, + http->postdata?FIRSTSOCKET:-1, + http->postdata?&http->writebytecount:NULL); + break; + + default: + add_buffer(req_buffer, "\r\n", 2); + + /* issue the request */ + result = add_buffer_send(req_buffer, conn, + &data->info.request_size); + + if(result) + failf(data, "Failed sending HTTP request"); + else + /* HTTP GET/HEAD download: */ + result = Curl_Transfer(conn, FIRSTSOCKET, -1, TRUE, + &http->readbytecount, + http->postdata?FIRSTSOCKET:-1, + http->postdata?&http->writebytecount:NULL); + } + if(result) + return result; + } + + return CURLE_OK; +} +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/http_chunks.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/http_chunks.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/http_chunks.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/http_chunks.c 2004-10-06 00:42:38.000000000 +0800 @@ -0,0 +1,264 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: http_chunks.c,v 1.6 2004/10/05 16:42:38 hoffman Exp $ + ***************************************************************************/ +#include "setup.h" + +#ifndef CURL_DISABLE_HTTP +/* -- WIN32 approved -- */ +#include +#include +#include +#include +#include + +#include "urldata.h" /* it includes http_chunks.h */ +#include "sendf.h" /* for the client write stuff */ + +#include "content_encoding.h" +#include "http.h" +#include "curl_memory.h" + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +/* The last #include file should be: */ +#include "memdebug.h" + +/* + * Chunk format (simplified): + * + * [ chunk extension ] CRLF + * CRLF + * + * Highlights from RFC2616 section 3.6 say: + + The chunked encoding modifies the body of a message in order to + transfer it as a series of chunks, each with its own size indicator, + followed by an OPTIONAL trailer containing entity-header fields. This + allows dynamically produced content to be transferred along with the + information necessary for the recipient to verify that it has + received the full message. + + Chunked-Body = *chunk + last-chunk + trailer + CRLF + + chunk = chunk-size [ chunk-extension ] CRLF + chunk-data CRLF + chunk-size = 1*HEX + last-chunk = 1*("0") [ chunk-extension ] CRLF + + chunk-extension= *( ";" chunk-ext-name [ "=" chunk-ext-val ] ) + chunk-ext-name = token + chunk-ext-val = token | quoted-string + chunk-data = chunk-size(OCTET) + trailer = *(entity-header CRLF) + + The chunk-size field is a string of hex digits indicating the size of + the chunk. The chunked encoding is ended by any chunk whose size is + zero, followed by the trailer, which is terminated by an empty line. + + */ + + +void Curl_httpchunk_init(struct connectdata *conn) +{ + struct Curl_chunker *chunk = &conn->proto.http->chunk; + chunk->hexindex=0; /* start at 0 */ + chunk->dataleft=0; /* no data left yet! */ + chunk->state = CHUNK_HEX; /* we get hex first! */ +} + +/* + * chunk_read() returns a OK for normal operations, or a positive return code + * for errors. STOP means this sequence of chunks is complete. The 'wrote' + * argument is set to tell the caller how many bytes we actually passed to the + * client (for byte-counting and whatever). + * + * The states and the state-machine is further explained in the header file. + */ +CHUNKcode Curl_httpchunk_read(struct connectdata *conn, + char *datap, + ssize_t datalen, + ssize_t *wrotep) +{ + CURLcode result=CURLE_OK; + struct Curl_chunker *ch = &conn->proto.http->chunk; + struct Curl_transfer_keeper *k = &conn->keep; + size_t piece; + size_t length = (size_t)datalen; + size_t *wrote = (size_t *)wrotep; + + *wrote = 0; /* nothing's written yet */ + + while(length) { + switch(ch->state) { + case CHUNK_HEX: + if(isxdigit((int)*datap)) { + if(ch->hexindex < MAXNUM_SIZE) { + ch->hexbuffer[ch->hexindex] = *datap; + datap++; + length--; + ch->hexindex++; + } + else { + return CHUNKE_TOO_LONG_HEX; /* longer hex than we support */ + } + } + else { + if(0 == ch->hexindex) { + /* This is illegal data, we received junk where we expected + a hexadecimal digit. */ + return CHUNKE_ILLEGAL_HEX; + } + /* length and datap are unmodified */ + ch->hexbuffer[ch->hexindex]=0; + ch->datasize=strtoul(ch->hexbuffer, NULL, 16); + ch->state = CHUNK_POSTHEX; + } + break; + + case CHUNK_POSTHEX: + /* In this state, we're waiting for CRLF to arrive. We support + this to allow so called chunk-extensions to show up here + before the CRLF comes. */ + if(*datap == '\r') + ch->state = CHUNK_CR; + length--; + datap++; + break; + + case CHUNK_CR: + /* waiting for the LF */ + if(*datap == '\n') { + /* we're now expecting data to come, unless size was zero! */ + if(0 == ch->datasize) { + ch->state = CHUNK_STOP; /* stop reading! */ + if(1 == length) { + /* This was the final byte, return right now */ + return CHUNKE_STOP; + } + } + else + ch->state = CHUNK_DATA; + } + else + /* previously we got a fake CR, go back to CR waiting! */ + ch->state = CHUNK_CR; + datap++; + length--; + break; + + case CHUNK_DATA: + /* we get pure and fine data + + We expect another 'datasize' of data. We have 'length' right now, + it can be more or less than 'datasize'. Get the smallest piece. + */ + piece = (ch->datasize >= length)?length:ch->datasize; + + /* Write the data portion available */ +#ifdef HAVE_LIBZ + switch (conn->keep.content_encoding) { + case IDENTITY: +#endif + if(!k->ignorebody) + result = Curl_client_write(conn->data, CLIENTWRITE_BODY, datap, + piece); +#ifdef HAVE_LIBZ + break; + + case DEFLATE: + /* update conn->keep.str to point to the chunk data. */ + conn->keep.str = datap; + result = Curl_unencode_deflate_write(conn->data, &conn->keep, + (ssize_t)piece); + break; + + case GZIP: + /* update conn->keep.str to point to the chunk data. */ + conn->keep.str = datap; + result = Curl_unencode_gzip_write(conn->data, &conn->keep, + (ssize_t)piece); + break; + + case COMPRESS: + default: + failf (conn->data, + "Unrecognized content encoding type. " + "libcurl understands `identity', `deflate' and `gzip' " + "content encodings."); + return CHUNKE_BAD_ENCODING; + } +#endif + + if(result) + return CHUNKE_WRITE_ERROR; + + *wrote += piece; + + ch->datasize -= piece; /* decrease amount left to expect */ + datap += piece; /* move read pointer forward */ + length -= piece; /* decrease space left in this round */ + + if(0 == ch->datasize) + /* end of data this round, we now expect a trailing CRLF */ + ch->state = CHUNK_POSTCR; + break; + + case CHUNK_POSTCR: + if(*datap == '\r') { + ch->state = CHUNK_POSTLF; + datap++; + length--; + } + else + return CHUNKE_BAD_CHUNK; + break; + + case CHUNK_POSTLF: + if(*datap == '\n') { + /* + * The last one before we go back to hex state and start all + * over. + */ + Curl_httpchunk_init(conn); + datap++; + length--; + } + else + return CHUNKE_BAD_CHUNK; + break; + + case CHUNK_STOP: + /* If we arrive here, there is data left in the end of the buffer + even if there's no more chunks to read */ + ch->dataleft = length; + return CHUNKE_STOP; /* return stop */ + default: + return CHUNKE_STATE_ERROR; + } + } + return CHUNKE_OK; +} +#endif /* CURL_DISABLE_HTTP */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/http_chunks.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/http_chunks.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/http_chunks.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/http_chunks.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,88 @@ +#ifndef __HTTP_CHUNKS_H +#define __HTTP_CHUNKS_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: http_chunks.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ +/* + * The longest possible hexadecimal number we support in a chunked transfer. + * Weird enough, RFC2616 doesn't set a maximum size! Since we use strtoul() + * to convert it, we "only" support 2^32 bytes chunk data. + */ +#define MAXNUM_SIZE 16 + +typedef enum { + CHUNK_FIRST, /* never use */ + + /* In this we await and buffer all hexadecimal digits until we get one + that isn't a hexadecimal digit. When done, we go POSTHEX */ + CHUNK_HEX, + + /* We have received the hexadecimal digit and we eat all characters until + we get a CRLF pair. When we see a CR we go to the CR state. */ + CHUNK_POSTHEX, + + /* A single CR has been found and we should get a LF right away in this + state or we go back to POSTHEX. When LF is received, we go to DATA. + If the size given was zero, we set state to STOP and return. */ + CHUNK_CR, + + /* We eat the amount of data specified. When done, we move on to the + POST_CR state. */ + CHUNK_DATA, + + /* POSTCR should get a CR and nothing else, then move to POSTLF */ + CHUNK_POSTCR, + + /* POSTLF should get a LF and nothing else, then move back to HEX as + the CRLF combination marks the end of a chunk */ + CHUNK_POSTLF, + + /* This is mainly used to really mark that we're out of the game. + NOTE: that there's a 'dataleft' field in the struct that will tell how + many bytes that were not passed to the client in the end of the last + buffer! */ + CHUNK_STOP, + + CHUNK_LAST /* never use */ +} ChunkyState; + +typedef enum { + CHUNKE_STOP = -1, + CHUNKE_OK = 0, + CHUNKE_TOO_LONG_HEX = 1, + CHUNKE_ILLEGAL_HEX, + CHUNKE_BAD_CHUNK, + CHUNKE_WRITE_ERROR, + CHUNKE_STATE_ERROR, + CHUNKE_BAD_ENCODING, + CHUNKE_LAST +} CHUNKcode; + +struct Curl_chunker { + char hexbuffer[ MAXNUM_SIZE + 1]; + int hexindex; + ChunkyState state; + size_t datasize; + size_t dataleft; /* untouched data amount at the end of the last buffer */ +}; + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/http_digest.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/http_digest.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/http_digest.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/http_digest.c 2004-10-13 22:45:30.000000000 +0800 @@ -0,0 +1,482 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: http_digest.c,v 1.4 2004/10/13 14:45:30 andy Exp $ + ***************************************************************************/ +#include "setup.h" + +#ifndef CURL_DISABLE_HTTP +/* -- WIN32 approved -- */ +#include +#include +#include +#include +#include + +#include "urldata.h" +#include "sendf.h" +#include "strequal.h" +#include "base64.h" +#include "md5.h" +#include "http_digest.h" +#include "strtok.h" +#include "url.h" /* for Curl_safefree() */ +#include "curl_memory.h" + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +/* The last #include file should be: */ +#include "memdebug.h" + +/* Test example headers: + +WWW-Authenticate: Digest realm="testrealm", nonce="1053604598" +Proxy-Authenticate: Digest realm="testrealm", nonce="1053604598" + +*/ + +CURLdigest Curl_input_digest(struct connectdata *conn, + bool proxy, + char *header) /* rest of the *-authenticate: + header */ +{ + bool more = TRUE; + char *token; + char *tmp; + bool foundAuth = FALSE; + bool foundAuthInt = FALSE; + struct SessionHandle *data=conn->data; + bool before = FALSE; /* got a nonce before */ + struct digestdata *d; + + if(proxy) { + d = &data->state.proxydigest; + } + else { + d = &data->state.digest; + } + + /* skip initial whitespaces */ + while(*header && isspace((int)*header)) + header++; + + if(checkprefix("Digest", header)) { + header += strlen("Digest"); + + /* If we already have received a nonce, keep that in mind */ + if(d->nonce) + before = TRUE; + + /* clear off any former leftovers and init to defaults */ + Curl_digest_cleanup_one(d); + + while(more) { + char value[32]; + char content[128]; + size_t totlen; + + while(*header && isspace((int)*header)) + header++; + + /* how big can these strings be? */ + if((2 == sscanf(header, "%31[^=]=\"%127[^\"]\"", + value, content)) || + /* try the same scan but without quotes around the content but don't + include the possibly trailing comma */ + (2 == sscanf(header, "%31[^=]=%127[^,]", + value, content)) ) { + if(strequal(value, "nonce")) { + d->nonce = strdup(content); + if(!d->nonce) + return CURLDIGEST_NOMEM; + } + else if(strequal(value, "stale")) { + if(strequal(content, "true")) { + d->stale = TRUE; + d->nc = 1; /* we make a new nonce now */ + } + } + else if(strequal(value, "realm")) { + d->realm = strdup(content); + if(!d->realm) + return CURLDIGEST_NOMEM; + } + else if(strequal(value, "opaque")) { + d->opaque = strdup(content); + if(!d->opaque) + return CURLDIGEST_NOMEM; + } + else if(strequal(value, "qop")) { + char *tok_buf; + /* tokenize the list and choose auth if possible, use a temporary + clone of the buffer since strtok_r() ruins it */ + tmp = strdup(content); + if(!tmp) + return CURLDIGEST_NOMEM; + token = strtok_r(tmp, ",", &tok_buf); + while (token != NULL) { + if (strequal(token, "auth")) { + foundAuth = TRUE; + } + else if (strequal(token, "auth-int")) { + foundAuthInt = TRUE; + } + token = strtok_r(NULL, ",", &tok_buf); + } + free(tmp); + /*select only auth o auth-int. Otherwise, ignore*/ + if (foundAuth) { + d->qop = strdup("auth"); + if(!d->qop) + return CURLDIGEST_NOMEM; + } + else if (foundAuthInt) { + d->qop = strdup("auth-int"); + if(!d->qop) + return CURLDIGEST_NOMEM; + } + } + else if(strequal(value, "algorithm")) { + d->algorithm = strdup(content); + if(!d->algorithm) + return CURLDIGEST_NOMEM; + if(strequal(content, "MD5-sess")) + d->algo = CURLDIGESTALGO_MD5SESS; + else if(strequal(content, "MD5")) + d->algo = CURLDIGESTALGO_MD5; + else + return CURLDIGEST_BADALGO; + } + else { + /* unknown specifier, ignore it! */ + } + totlen = strlen(value)+strlen(content)+1; + + if(header[strlen(value)+1] == '\"') + /* the contents were within quotes, then add 2 for them to the + length */ + totlen += 2; + } + else + break; /* we're done here */ + + header += totlen; + if(',' == *header) + /* allow the list to be comma-separated */ + header++; + } + /* We had a nonce since before, and we got another one now without + 'stale=true'. This means we provided bad credentials in the previous + request */ + if(before && !d->stale) + return CURLDIGEST_BAD; + + /* We got this header without a nonce, that's a bad Digest line! */ + if(!d->nonce) + return CURLDIGEST_BAD; + } + else + /* else not a digest, get out */ + return CURLDIGEST_NONE; + + return CURLDIGEST_FINE; +} + +/* convert md5 chunk to RFC2617 (section 3.1.3) -suitable ascii string*/ +static void md5_to_ascii(unsigned char *source, /* 16 bytes */ + unsigned char *dest) /* 33 bytes */ +{ + int i; + for(i=0; i<16; i++) + snprintf((char *)&dest[i*2], 3, "%02x", source[i]); +} + +CURLcode Curl_output_digest(struct connectdata *conn, + bool proxy, + unsigned char *request, + unsigned char *uripath) +{ + /* We have a Digest setup for this, use it! Now, to get all the details for + this sorted out, I must urge you dear friend to read up on the RFC2617 + section 3.2.2, */ + unsigned char md5buf[16]; /* 16 bytes/128 bits */ + unsigned char request_digest[33]; + unsigned char *md5this; + unsigned char *ha1; + unsigned char ha2[33];/* 32 digits and 1 zero byte */ + char cnoncebuf[7]; + char *cnonce; + char *tmp; + struct timeval now; + + char **allocuserpwd; + char *userp; + char *passwdp; + struct auth *authp; + + struct SessionHandle *data = conn->data; + struct digestdata *d; + + if(proxy) { + d = &data->state.proxydigest; + allocuserpwd = &conn->allocptr.proxyuserpwd; + userp = conn->proxyuser; + passwdp = conn->proxypasswd; + authp = &data->state.authproxy; + } + else { + d = &data->state.digest; + allocuserpwd = &conn->allocptr.userpwd; + userp = conn->user; + passwdp = conn->passwd; + authp = &data->state.authhost; + } + + /* not set means empty */ + if(!userp) + userp=(char *)""; + + if(!passwdp) + passwdp=(char *)""; + + if(!d->nonce) { + authp->done = FALSE; + return CURLE_OK; + } + authp->done = TRUE; + + if(!d->nc) + d->nc = 1; + + if(!d->cnonce) { + /* Generate a cnonce */ + now = Curl_tvnow(); + snprintf(cnoncebuf, sizeof(cnoncebuf), "%06ld", now.tv_sec); + if(Curl_base64_encode(cnoncebuf, strlen(cnoncebuf), &cnonce)) + d->cnonce = cnonce; + else + return CURLE_OUT_OF_MEMORY; + } + + /* + if the algorithm is "MD5" or unspecified (which then defaults to MD5): + + A1 = unq(username-value) ":" unq(realm-value) ":" passwd + + if the algorithm is "MD5-sess" then: + + A1 = H( unq(username-value) ":" unq(realm-value) ":" passwd ) + ":" unq(nonce-value) ":" unq(cnonce-value) + */ + + md5this = (unsigned char *) + aprintf("%s:%s:%s", userp, d->realm, passwdp); + if(!md5this) + return CURLE_OUT_OF_MEMORY; + Curl_md5it(md5buf, md5this); + free(md5this); /* free this again */ + + ha1 = (unsigned char *)malloc(33); /* 32 digits and 1 zero byte */ + if(!ha1) + return CURLE_OUT_OF_MEMORY; + + md5_to_ascii(md5buf, ha1); + + if(d->algo == CURLDIGESTALGO_MD5SESS) { + /* nonce and cnonce are OUTSIDE the hash */ + tmp = aprintf("%s:%s:%s", ha1, d->nonce, d->cnonce); + free(ha1); + if(!tmp) + return CURLE_OUT_OF_MEMORY; + ha1 = (unsigned char *)tmp; + } + + /* + If the "qop" directive's value is "auth" or is unspecified, then A2 is: + + A2 = Method ":" digest-uri-value + + If the "qop" value is "auth-int", then A2 is: + + A2 = Method ":" digest-uri-value ":" H(entity-body) + + (The "Method" value is the HTTP request method as specified in section + 5.1.1 of RFC 2616) + */ + + md5this = (unsigned char *)aprintf("%s:%s", request, uripath); + if(!md5this) { + free(ha1); + return CURLE_OUT_OF_MEMORY; + } + + if (d->qop && strequal(d->qop, "auth-int")) { + /* We don't support auth-int at the moment. I can't see a easy way to get + entity-body here */ + /* TODO: Append H(entity-body)*/ + } + Curl_md5it(md5buf, md5this); + free(md5this); /* free this again */ + md5_to_ascii(md5buf, ha2); + + if (d->qop) { + md5this = (unsigned char *)aprintf("%s:%s:%08x:%s:%s:%s", + ha1, + d->nonce, + d->nc, + d->cnonce, + d->qop, + ha2); + } + else { + md5this = (unsigned char *)aprintf("%s:%s:%s", + ha1, + d->nonce, + ha2); + } + free(ha1); + if(!md5this) + return CURLE_OUT_OF_MEMORY; + + Curl_md5it(md5buf, md5this); + free(md5this); /* free this again */ + md5_to_ascii(md5buf, request_digest); + + /* for test case 64 (snooped from a Mozilla 1.3a request) + + Authorization: Digest username="testuser", realm="testrealm", \ + nonce="1053604145", uri="/64", response="c55f7f30d83d774a3d2dcacf725abaca" + */ + + Curl_safefree(*allocuserpwd); + + if (d->qop) { + *allocuserpwd = + aprintf( "%sAuthorization: Digest " + "username=\"%s\", " + "realm=\"%s\", " + "nonce=\"%s\", " + "uri=\"%s\", " + "cnonce=\"%s\", " + "nc=%08x, " + "qop=\"%s\", " + "response=\"%s\"", + proxy?"Proxy-":"", + userp, + d->realm, + d->nonce, + uripath, /* this is the PATH part of the URL */ + d->cnonce, + d->nc, + d->qop, + request_digest); + + if(strequal(d->qop, "auth")) + d->nc++; /* The nc (from RFC) has to be a 8 hex digit number 0 padded + which tells to the server how many times you are using the + same nonce in the qop=auth mode. */ + } + else { + *allocuserpwd = + aprintf( "%sAuthorization: Digest " + "username=\"%s\", " + "realm=\"%s\", " + "nonce=\"%s\", " + "uri=\"%s\", " + "response=\"%s\"", + proxy?"Proxy-":"", + userp, + d->realm, + d->nonce, + uripath, /* this is the PATH part of the URL */ + request_digest); + } + if(!*allocuserpwd) + return CURLE_OUT_OF_MEMORY; + + /* Add optional fields */ + if(d->opaque) { + /* append opaque */ + tmp = aprintf("%s, opaque=\"%s\"", *allocuserpwd, d->opaque); + if(!tmp) + return CURLE_OUT_OF_MEMORY; + free(*allocuserpwd); + *allocuserpwd = tmp; + } + + if(d->algorithm) { + /* append algorithm */ + tmp = aprintf("%s, algorithm=\"%s\"", *allocuserpwd, d->algorithm); + if(!tmp) + return CURLE_OUT_OF_MEMORY; + free(*allocuserpwd); + *allocuserpwd = tmp; + } + + /* append CRLF to the userpwd header */ + tmp = (char*) realloc(*allocuserpwd, strlen(*allocuserpwd) + 3 + 1); + if(!tmp) + return CURLE_OUT_OF_MEMORY; + strcat(tmp, "\r\n"); + *allocuserpwd = tmp; + + return CURLE_OK; +} + +void Curl_digest_cleanup_one(struct digestdata *d) +{ + if(d->nonce) + free(d->nonce); + d->nonce = NULL; + + if(d->cnonce) + free(d->cnonce); + d->cnonce = NULL; + + if(d->realm) + free(d->realm); + d->realm = NULL; + + if(d->opaque) + free(d->opaque); + d->opaque = NULL; + + if(d->qop) + free(d->qop); + d->qop = NULL; + + if(d->algorithm) + free(d->algorithm); + d->algorithm = NULL; + + d->nc = 0; + d->algo = CURLDIGESTALGO_MD5; /* default algorithm */ + d->stale = FALSE; /* default means normal, not stale */ +} + + +void Curl_digest_cleanup(struct SessionHandle *data) +{ + Curl_digest_cleanup_one(&data->state.digest); + Curl_digest_cleanup_one(&data->state.proxydigest); +} + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/http_digest.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/http_digest.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/http_digest.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/http_digest.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,53 @@ +#ifndef __HTTP_DIGEST_H +#define __HTTP_DIGEST_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: http_digest.h,v 1.2 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +typedef enum { + CURLDIGEST_NONE, /* not a digest */ + CURLDIGEST_BAD, /* a digest, but one we don't like */ + CURLDIGEST_BADALGO, /* unsupported algorithm requested */ + CURLDIGEST_NOMEM, + CURLDIGEST_FINE, /* a digest we act on */ + + CURLDIGEST_LAST /* last entry in this enum, don't use */ +} CURLdigest; + +enum { + CURLDIGESTALGO_MD5, + CURLDIGESTALGO_MD5SESS +}; + +/* this is for digest header input */ +CURLdigest Curl_input_digest(struct connectdata *conn, + bool proxy, char *header); + +/* this is for creating digest header output */ +CURLcode Curl_output_digest(struct connectdata *conn, + bool proxy, + unsigned char *request, + unsigned char *uripath); +void Curl_digest_cleanup(struct SessionHandle *data); +void Curl_digest_cleanup_one(struct digestdata *dig); + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/http.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/http.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/http.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/http.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,61 @@ +#ifndef __HTTP_H +#define __HTTP_H + +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: http.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ +#ifndef CURL_DISABLE_HTTP +bool Curl_compareheader(char *headerline, /* line to check */ + const char *header, /* header keyword _with_ colon */ + const char *content); /* content string to find */ + +/* ftp can use this as well */ +CURLcode Curl_ConnectHTTPProxyTunnel(struct connectdata *conn, + int tunnelsocket, + char *hostname, int remote_port); + +/* protocol-specific functions set up to be called by the main engine */ +CURLcode Curl_http(struct connectdata *conn); +CURLcode Curl_http_done(struct connectdata *, CURLcode); +CURLcode Curl_http_connect(struct connectdata *conn); + +/* The following functions are defined in http_chunks.c */ +void Curl_httpchunk_init(struct connectdata *conn); +CHUNKcode Curl_httpchunk_read(struct connectdata *conn, char *datap, + ssize_t length, ssize_t *wrote); + +/* These functions are in http.c */ +void Curl_http_auth_stage(struct SessionHandle *data, int stage); +CURLcode Curl_http_input_auth(struct connectdata *conn, + int httpcode, char *header); +CURLcode Curl_http_auth_act(struct connectdata *conn); + +int Curl_http_should_fail(struct connectdata *conn); + +/* If only the PICKNONE bit is set, there has been a round-trip and we + selected to use no auth at all. Ie, we actively select no auth, as opposed + to not having one selected. The other CURLAUTH_* defines are present in the + public curl/curl.h header. */ +#define CURLAUTH_PICKNONE (1<<30) /* don't use auth */ + +#endif +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/http_negotiate.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/http_negotiate.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/http_negotiate.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/http_negotiate.c 2004-10-06 00:42:38.000000000 +0800 @@ -0,0 +1,332 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: http_negotiate.c,v 1.3 2004/10/05 16:42:38 hoffman Exp $ + ***************************************************************************/ +#include "setup.h" + +#ifdef HAVE_GSSAPI +#ifdef HAVE_GSSMIT +#define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name +#endif + +#ifndef CURL_DISABLE_HTTP + /* -- WIN32 approved -- */ +#include +#include +#include +#include +#include +#include + +#include "urldata.h" +#include "sendf.h" +#include "strequal.h" +#include "base64.h" +#include "http_negotiate.h" +#include "curl_memory.h" + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +/* The last #include file should be: */ +#include "memdebug.h" + +static int +get_gss_name(struct connectdata *conn, gss_name_t *server) +{ + struct negotiatedata *neg_ctx = &conn->data->state.negotiate; + OM_uint32 major_status, minor_status; + gss_buffer_desc token = GSS_C_EMPTY_BUFFER; + char name[2048]; + const char* service; + + /* GSSAPI implementation by Globus (known as GSI) requires the name to be + of form "/" instead of @ (ie. slash instead + of at-sign). Also GSI servers are often identified as 'host' not 'khttp'. + Change following lines if you want to use GSI */ + + /* IIS uses the @ form but uses 'http' as the service name */ + + if (neg_ctx->gss) + service = "KHTTP"; + else + service = "HTTP"; + + token.length = strlen(service) + 1 + strlen(conn->host.name) + 1; + if (token.length + 1 > sizeof(name)) + return EMSGSIZE; + + snprintf(name, sizeof(name), "%s@%s", service, conn->host.name); + + token.value = (void *) name; + major_status = gss_import_name(&minor_status, + &token, + GSS_C_NT_HOSTBASED_SERVICE, + server); + + return GSS_ERROR(major_status) ? -1 : 0; +} + +static void +log_gss_error(struct connectdata *conn, OM_uint32 error_status, char *prefix) +{ + OM_uint32 maj_stat, min_stat; + OM_uint32 msg_ctx = 0; + gss_buffer_desc status_string; + char buf[1024]; + size_t len; + + snprintf(buf, sizeof(buf), "%s", prefix); + len = strlen(buf); + do { + maj_stat = gss_display_status (&min_stat, + error_status, + GSS_C_MECH_CODE, + GSS_C_NO_OID, + &msg_ctx, + &status_string); + if (sizeof(buf) > len + status_string.length + 1) { + snprintf(buf + len, sizeof(buf) - len, + ": %s", (char*) status_string.value); + len += status_string.length; + } + gss_release_buffer(&min_stat, &status_string); + } while (!GSS_ERROR(maj_stat) && msg_ctx != 0); + + infof(conn->data, buf); +} + +int Curl_input_negotiate(struct connectdata *conn, char *header) +{ + struct negotiatedata *neg_ctx = &conn->data->state.negotiate; + OM_uint32 major_status, minor_status, minor_status2; + gss_buffer_desc input_token = GSS_C_EMPTY_BUFFER; + gss_buffer_desc output_token = GSS_C_EMPTY_BUFFER; + int ret; + size_t len; + bool gss; + const char* protocol; + + while(*header && isspace((int)*header)) + header++; + if(checkprefix("GSS-Negotiate", header)) { + protocol = "GSS-Negotiate"; + gss = TRUE; + } + else if (checkprefix("Negotiate", header)) { + protocol = "Negotiate"; + gss = FALSE; + } + else + return -1; + + if (neg_ctx->context) { + if (neg_ctx->gss != gss) { + return -1; + } + } + else { + neg_ctx->protocol = protocol; + neg_ctx->gss = gss; + } + + if (neg_ctx->context && neg_ctx->status == GSS_S_COMPLETE) { + /* We finished succesfully our part of authentication, but server + * rejected it (since we're again here). Exit with an error since we + * can't invent anything better */ + Curl_cleanup_negotiate(conn->data); + return -1; + } + + if (neg_ctx->server_name == NULL && + (ret = get_gss_name(conn, &neg_ctx->server_name))) + return ret; + + header += strlen(neg_ctx->protocol); + while(*header && isspace((int)*header)) + header++; + + len = strlen(header); + if (len > 0) { + int rawlen; + input_token.length = (len+3)/4 * 3; + input_token.value = malloc(input_token.length); + if (input_token.value == NULL) + return ENOMEM; + rawlen = Curl_base64_decode(header, input_token.value); + if (rawlen < 0) + return -1; + input_token.length = rawlen; + +#ifdef HAVE_SPNEGO /* Handle SPNEGO */ + if (checkprefix("Negotiate", header)) { + ASN1_OBJECT * object = NULL; + int rc = 1; + unsigned char * spnegoToken = NULL; + size_t spnegoTokenLength = 0; + unsigned char * mechToken = NULL; + size_t mechTokenLength = 0; + + spnegoToken = malloc(input_token.length); + if (input_token.value == NULL) + return ENOMEM; + spnegoTokenLength = input_token.length; + + object = OBJ_txt2obj ("1.2.840.113554.1.2.2", 1); + if (!parseSpnegoTargetToken(spnegoToken, + spnegoTokenLength, + NULL, + NULL, + &mechToken, + &mechTokenLength, + NULL, + NULL)) { + free(spnegoToken); + spnegoToken = NULL; + infof(conn->data, "Parse SPNEGO Target Token failed\n"); + } + else { + free(input_token.value); + input_token.value = NULL; + input_token.value = malloc(mechTokenLength); + memcpy(input_token.value, mechToken,mechTokenLength); + input_token.length = mechTokenLength; + free(mechToken); + mechToken = NULL; + infof(conn->data, "Parse SPNEGO Target Token succeded\n"); + } + } +#endif + } + + major_status = gss_init_sec_context(&minor_status, + GSS_C_NO_CREDENTIAL, + &neg_ctx->context, + neg_ctx->server_name, + GSS_C_NO_OID, + GSS_C_DELEG_FLAG, + 0, + GSS_C_NO_CHANNEL_BINDINGS, + &input_token, + NULL, + &output_token, + NULL, + NULL); + if (input_token.length > 0) + gss_release_buffer(&minor_status2, &input_token); + neg_ctx->status = major_status; + if (GSS_ERROR(major_status)) { + /* Curl_cleanup_negotiate(conn->data) ??? */ + log_gss_error(conn, minor_status, + (char *)"gss_init_sec_context() failed: "); + return -1; + } + + if (output_token.length == 0) { + return -1; + } + + neg_ctx->output_token = output_token; + /* conn->bits.close = FALSE; */ + + return 0; +} + + +CURLcode Curl_output_negotiate(struct connectdata *conn) +{ + struct negotiatedata *neg_ctx = &conn->data->state.negotiate; + OM_uint32 minor_status; + char *encoded = NULL; + int len; + +#ifdef HAVE_SPNEGO /* Handle SPNEGO */ + if (checkprefix("Negotiate",neg_ctx->protocol)) { + ASN1_OBJECT * object = NULL; + int rc = 1; + unsigned char * spnegoToken = NULL; + size_t spnegoTokenLength = 0; + unsigned char * responseToken = NULL; + size_t responseTokenLength = 0; + + responseToken = malloc(neg_ctx->output_token.length); + if ( responseToken == NULL) + return CURLE_OUT_OF_MEMORY; + memcpy(responseToken, neg_ctx->output_token.value, + neg_ctx->output_token.length); + responseTokenLength = neg_ctx->output_token.length; + + object=OBJ_txt2obj ("1.2.840.113554.1.2.2", 1); + if (!makeSpnegoInitialToken (object, + responseToken, + responseTokenLength, + &spnegoToken, + &spnegoTokenLength)) { + free(responseToken); + responseToken = NULL; + infof(conn->data, "Make SPNEGO Initial Token failed\n"); + } + else { + free(neg_ctx->output_token.value); + responseToken = NULL; + neg_ctx->output_token.value = malloc(spnegoTokenLength); + memcpy(neg_ctx->output_token.value, spnegoToken,spnegoTokenLength); + neg_ctx->output_token.length = spnegoTokenLength; + free(spnegoToken); + spnegoToken = NULL; + infof(conn->data, "Make SPNEGO Initial Token succeded\n"); + } + } +#endif + len = Curl_base64_encode(neg_ctx->output_token.value, + neg_ctx->output_token.length, + &encoded); + + if (len < 0) + return CURLE_OUT_OF_MEMORY; + + conn->allocptr.userpwd = + aprintf("Authorization: %s %s\r\n", neg_ctx->protocol, encoded); + free(encoded); + gss_release_buffer(&minor_status, &neg_ctx->output_token); + return (conn->allocptr.userpwd == NULL) ? CURLE_OUT_OF_MEMORY : CURLE_OK; +} + +void Curl_cleanup_negotiate(struct SessionHandle *data) +{ + OM_uint32 minor_status; + struct negotiatedata *neg_ctx = &data->state.negotiate; + + if (neg_ctx->context != GSS_C_NO_CONTEXT) + gss_delete_sec_context(&minor_status, &neg_ctx->context, GSS_C_NO_BUFFER); + + if (neg_ctx->output_token.length != 0) + gss_release_buffer(&minor_status, &neg_ctx->output_token); + + if (neg_ctx->server_name != GSS_C_NO_NAME) + gss_release_name(&minor_status, &neg_ctx->server_name); + + memset(neg_ctx, 0, sizeof(*neg_ctx)); +} + + +#endif +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/http_negotiate.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/http_negotiate.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/http_negotiate.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/http_negotiate.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,39 @@ +#ifndef __HTTP_NEGOTIATE_H +#define __HTTP_NEGOTIATE_H + +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: http_negotiate.h,v 1.2 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +#ifdef HAVE_GSSAPI + +/* this is for Negotiate header input */ +int Curl_input_negotiate(struct connectdata *conn, char *header); + +/* this is for creating Negotiate header output */ +CURLcode Curl_output_negotiate(struct connectdata *conn); + +void Curl_cleanup_negotiate(struct SessionHandle *data); + +#endif + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/http_ntlm.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/http_ntlm.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/http_ntlm.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/http_ntlm.c 2004-10-06 00:42:38.000000000 +0800 @@ -0,0 +1,585 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: http_ntlm.c,v 1.3 2004/10/05 16:42:38 hoffman Exp $ + ***************************************************************************/ +#include "setup.h" + +/* NTLM details: + + http://davenport.sourceforge.net/ntlm.html + http://www.innovation.ch/java/ntlm.html + +*/ + +#ifndef CURL_DISABLE_HTTP +#ifdef USE_SSLEAY +/* We need OpenSSL for the crypto lib to provide us with MD4 and DES */ + +/* -- WIN32 approved -- */ +#include +#include +#include +#include +#include + +#include "urldata.h" +#include "sendf.h" +#include "strequal.h" +#include "base64.h" +#include "http_ntlm.h" +#include "url.h" +#include "curl_memory.h" + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +#include +#include +#include + +#if OPENSSL_VERSION_NUMBER < 0x00907001L +#define DES_key_schedule des_key_schedule +#define DES_cblock des_cblock +#define DES_set_odd_parity des_set_odd_parity +#define DES_set_key des_set_key +#define DES_ecb_encrypt des_ecb_encrypt + +/* This is how things were done in the old days */ +#define DESKEY(x) x +#define DESKEYARG(x) x +#else +/* Modern version */ +#define DESKEYARG(x) *x +#define DESKEY(x) &x +#endif + +/* The last #include file should be: */ +#include "memdebug.h" + +/* Define this to make the type-3 message include the NT response message */ +#define USE_NTRESPONSES 1 + +/* + (*) = A "security buffer" is a triplet consisting of two shorts and one + long: + + 1. a 'short' containing the length of the buffer in bytes + 2. a 'short' containing the allocated space for the buffer in bytes + 3. a 'long' containing the offset to the start of the buffer from the + beginning of the NTLM message, in bytes. +*/ + + +CURLntlm Curl_input_ntlm(struct connectdata *conn, + bool proxy, /* if proxy or not */ + char *header) /* rest of the www-authenticate: + header */ +{ + /* point to the correct struct with this */ + struct ntlmdata *ntlm; + + ntlm = proxy?&conn->proxyntlm:&conn->ntlm; + + /* skip initial whitespaces */ + while(*header && isspace((int)*header)) + header++; + + if(checkprefix("NTLM", header)) { + unsigned char buffer[256]; + header += strlen("NTLM"); + + while(*header && isspace((int)*header)) + header++; + + if(*header) { + /* We got a type-2 message here: + + Index Description Content + 0 NTLMSSP Signature Null-terminated ASCII "NTLMSSP" + (0x4e544c4d53535000) + 8 NTLM Message Type long (0x02000000) + 12 Target Name security buffer(*) + 20 Flags long + 24 Challenge 8 bytes + (32) Context (optional) 8 bytes (two consecutive longs) + (40) Target Information (optional) security buffer(*) + 32 (48) start of data block + */ + + size_t size = Curl_base64_decode(header, (char *)buffer); + + ntlm->state = NTLMSTATE_TYPE2; /* we got a type-2 */ + + if(size >= 48) + /* the nonce of interest is index [24 .. 31], 8 bytes */ + memcpy(ntlm->nonce, &buffer[24], 8); + + /* at index decimal 20, there's a 32bit NTLM flag field */ + + } + else { + if(ntlm->state >= NTLMSTATE_TYPE1) + return CURLNTLM_BAD; + + ntlm->state = NTLMSTATE_TYPE1; /* we should sent away a type-1 */ + } + } + return CURLNTLM_FINE; +} + +/* + * Turns a 56 bit key into the 64 bit, odd parity key and sets the key. The + * key schedule ks is also set. + */ +static void setup_des_key(unsigned char *key_56, + DES_key_schedule DESKEYARG(ks)) +{ + DES_cblock key; + + key[0] = key_56[0]; + key[1] = ((key_56[0] << 7) & 0xFF) | (key_56[1] >> 1); + key[2] = ((key_56[1] << 6) & 0xFF) | (key_56[2] >> 2); + key[3] = ((key_56[2] << 5) & 0xFF) | (key_56[3] >> 3); + key[4] = ((key_56[3] << 4) & 0xFF) | (key_56[4] >> 4); + key[5] = ((key_56[4] << 3) & 0xFF) | (key_56[5] >> 5); + key[6] = ((key_56[5] << 2) & 0xFF) | (key_56[6] >> 6); + key[7] = (key_56[6] << 1) & 0xFF; + + DES_set_odd_parity(&key); + DES_set_key(&key, ks); +} + + /* + * takes a 21 byte array and treats it as 3 56-bit DES keys. The + * 8 byte plaintext is encrypted with each key and the resulting 24 + * bytes are stored in the results array. + */ +static void calc_resp(unsigned char *keys, + unsigned char *plaintext, + unsigned char *results) +{ + DES_key_schedule ks; + + setup_des_key(keys, DESKEY(ks)); + DES_ecb_encrypt((DES_cblock*) plaintext, (DES_cblock*) results, + DESKEY(ks), DES_ENCRYPT); + + setup_des_key(keys+7, DESKEY(ks)); + DES_ecb_encrypt((DES_cblock*) plaintext, (DES_cblock*) (results+8), + DESKEY(ks), DES_ENCRYPT); + + setup_des_key(keys+14, DESKEY(ks)); + DES_ecb_encrypt((DES_cblock*) plaintext, (DES_cblock*) (results+16), + DESKEY(ks), DES_ENCRYPT); +} + +/* + * Set up lanmanager and nt hashed passwords + */ +static void mkhash(char *password, + unsigned char *nonce, /* 8 bytes */ + unsigned char *lmresp /* must fit 0x18 bytes */ +#ifdef USE_NTRESPONSES + , unsigned char *ntresp /* must fit 0x18 bytes */ +#endif + ) +{ + unsigned char lmbuffer[21]; +#ifdef USE_NTRESPONSES + unsigned char ntbuffer[21]; +#endif + unsigned char *pw; + static const unsigned char magic[] = { + 0x4B, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25 + }; + unsigned int i; + size_t len = strlen(password); + + /* make it fit at least 14 bytes */ + pw = malloc(len<7?14:len*2); + if(!pw) + return; /* this will lead to a badly generated package */ + + if (len > 14) + len = 14; + + for (i=0; i> 8) +#define LONGQUARTET(x) ((x) & 0xff), (((x) >> 8)&0xff), \ + (((x) >>16)&0xff), ((x)>>24) + +/* this is for creating ntlm header output */ +CURLcode Curl_output_ntlm(struct connectdata *conn, + bool proxy) +{ + const char *domain=""; /* empty */ + const char *host=""; /* empty */ + int domlen=(int)strlen(domain); + int hostlen = (int)strlen(host); + int hostoff; /* host name offset */ + int domoff; /* domain name offset */ + size_t size; + char *base64=NULL; + unsigned char ntlmbuf[256]; /* enough, unless the host/domain is very long */ + + /* point to the address of the pointer that holds the string to sent to the + server, which is for a plain host or for a HTTP proxy */ + char **allocuserpwd; + + /* point to the name and password for this */ + char *userp; + char *passwdp; + /* point to the correct struct with this */ + struct ntlmdata *ntlm; + struct auth *authp; + + curlassert(conn); + curlassert(conn->data); + + if(proxy) { + allocuserpwd = &conn->allocptr.proxyuserpwd; + userp = conn->proxyuser; + passwdp = conn->proxypasswd; + ntlm = &conn->proxyntlm; + authp = &conn->data->state.authproxy; + } + else { + allocuserpwd = &conn->allocptr.userpwd; + userp = conn->user; + passwdp = conn->passwd; + ntlm = &conn->ntlm; + authp = &conn->data->state.authhost; + } + authp->done = FALSE; + + /* not set means empty */ + if(!userp) + userp=(char *)""; + + if(!passwdp) + passwdp=(char *)""; + + switch(ntlm->state) { + case NTLMSTATE_TYPE1: + default: /* for the weird cases we (re)start here */ + hostoff = 32; + domoff = hostoff + hostlen; + + /* Create and send a type-1 message: + + Index Description Content + 0 NTLMSSP Signature Null-terminated ASCII "NTLMSSP" + (0x4e544c4d53535000) + 8 NTLM Message Type long (0x01000000) + 12 Flags long + 16 Supplied Domain security buffer(*) + 24 Supplied Workstation security buffer(*) + 32 start of data block + + */ + + snprintf((char *)ntlmbuf, sizeof(ntlmbuf), "NTLMSSP%c" + "\x01%c%c%c" /* 32-bit type = 1 */ + "%c%c%c%c" /* 32-bit NTLM flag field */ + "%c%c" /* domain length */ + "%c%c" /* domain allocated space */ + "%c%c" /* domain name offset */ + "%c%c" /* 2 zeroes */ + "%c%c" /* host length */ + "%c%c" /* host allocated space */ + "%c%c" /* host name offset */ + "%c%c" /* 2 zeroes */ + "%s" /* host name */ + "%s", /* domain string */ + 0, /* trailing zero */ + 0,0,0, /* part of type-1 long */ + + LONGQUARTET( + NTLMFLAG_NEGOTIATE_OEM| /* 2 */ + NTLMFLAG_NEGOTIATE_NTLM_KEY /* 200 */ + /* equals 0x0202 */ + ), + SHORTPAIR(domlen), + SHORTPAIR(domlen), + SHORTPAIR(domoff), + 0,0, + SHORTPAIR(hostlen), + SHORTPAIR(hostlen), + SHORTPAIR(hostoff), + 0,0, + host, domain); + + /* initial packet length */ + size = 32 + hostlen + domlen; + + /* now keeper of the base64 encoded package size */ + size = Curl_base64_encode((char *)ntlmbuf, size, &base64); + + if(size >0 ) { + Curl_safefree(*allocuserpwd); + *allocuserpwd = aprintf("%sAuthorization: NTLM %s\r\n", + proxy?"Proxy-":"", + base64); + free(base64); + } + else + return CURLE_OUT_OF_MEMORY; /* FIX TODO */ + + break; + + case NTLMSTATE_TYPE2: + /* We received the type-2 already, create a type-3 message: + + Index Description Content + 0 NTLMSSP Signature Null-terminated ASCII "NTLMSSP" + (0x4e544c4d53535000) + 8 NTLM Message Type long (0x03000000) + 12 LM/LMv2 Response security buffer(*) + 20 NTLM/NTLMv2 Response security buffer(*) + 28 Domain Name security buffer(*) + 36 User Name security buffer(*) + 44 Workstation Name security buffer(*) + (52) Session Key (optional) security buffer(*) + (60) Flags (optional) long + 52 (64) start of data block + + */ + + { + int lmrespoff; + int ntrespoff; + int useroff; + unsigned char lmresp[0x18]; /* fixed-size */ +#ifdef USE_NTRESPONSES + unsigned char ntresp[0x18]; /* fixed-size */ +#endif + const char *user; + int userlen; + + user = strchr(userp, '\\'); + if(!user) + user = strchr(userp, '/'); + + if (user) { + domain = userp; + domlen = (int)(user - domain); + user++; + } + else + user = userp; + userlen = (int)strlen(user); + + mkhash(passwdp, &ntlm->nonce[0], lmresp +#ifdef USE_NTRESPONSES + , ntresp +#endif + ); + + domoff = 64; /* always */ + useroff = domoff + domlen; + hostoff = useroff + userlen; + lmrespoff = hostoff + hostlen; + ntrespoff = lmrespoff + 0x18; + + /* Create the big type-3 message binary blob */ + size = snprintf((char *)ntlmbuf, sizeof(ntlmbuf), + "NTLMSSP%c" + "\x03%c%c%c" /* type-3, 32 bits */ + + "%c%c%c%c" /* LanManager length + allocated space */ + "%c%c" /* LanManager offset */ + "%c%c" /* 2 zeroes */ + + "%c%c" /* NT-response length */ + "%c%c" /* NT-response allocated space */ + "%c%c" /* NT-response offset */ + "%c%c" /* 2 zeroes */ + + "%c%c" /* domain length */ + "%c%c" /* domain allocated space */ + "%c%c" /* domain name offset */ + "%c%c" /* 2 zeroes */ + + "%c%c" /* user length */ + "%c%c" /* user allocated space */ + "%c%c" /* user offset */ + "%c%c" /* 2 zeroes */ + + "%c%c" /* host length */ + "%c%c" /* host allocated space */ + "%c%c" /* host offset */ + "%c%c%c%c%c%c" /* 6 zeroes */ + + "\xff\xff" /* message length */ + "%c%c" /* 2 zeroes */ + + "\x01\x82" /* flags */ + "%c%c" /* 2 zeroes */ + + /* domain string */ + /* user string */ + /* host string */ + /* LanManager response */ + /* NT response */ + , + 0, /* zero termination */ + 0,0,0, /* type-3 long, the 24 upper bits */ + + SHORTPAIR(0x18), /* LanManager response length, twice */ + SHORTPAIR(0x18), + SHORTPAIR(lmrespoff), + 0x0, 0x0, + +#ifdef USE_NTRESPONSES + SHORTPAIR(0x18), /* NT-response length, twice */ + SHORTPAIR(0x18), +#else + 0x0, 0x0, + 0x0, 0x0, +#endif + SHORTPAIR(ntrespoff), + 0x0, 0x0, + + SHORTPAIR(domlen), + SHORTPAIR(domlen), + SHORTPAIR(domoff), + 0x0, 0x0, + + SHORTPAIR(userlen), + SHORTPAIR(userlen), + SHORTPAIR(useroff), + 0x0, 0x0, + + SHORTPAIR(hostlen), + SHORTPAIR(hostlen), + SHORTPAIR(hostoff), + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + + 0x0, 0x0, + + 0x0, 0x0); + + /* size is now 64 */ + size=64; + ntlmbuf[62]=ntlmbuf[63]=0; + + memcpy(&ntlmbuf[size], domain, domlen); + size += domlen; + + memcpy(&ntlmbuf[size], user, userlen); + size += userlen; + + /* we append the binary hashes to the end of the blob */ + if(size < ((int)sizeof(ntlmbuf) - 0x18)) { + memcpy(&ntlmbuf[size], lmresp, 0x18); + size += 0x18; + } + +#ifdef USE_NTRESPONSES + if(size < ((int)sizeof(ntlmbuf) - 0x18)) { + memcpy(&ntlmbuf[size], ntresp, 0x18); + size += 0x18; + } +#endif + + ntlmbuf[56] = (unsigned char)(size & 0xff); + ntlmbuf[57] = (unsigned char)(size >> 8); + + /* convert the binary blob into base64 */ + size = Curl_base64_encode((char *)ntlmbuf, size, &base64); + + if(size >0 ) { + Curl_safefree(*allocuserpwd); + *allocuserpwd = aprintf("%sAuthorization: NTLM %s\r\n", + proxy?"Proxy-":"", + base64); + free(base64); + } + else + return CURLE_OUT_OF_MEMORY; /* FIX TODO */ + + ntlm->state = NTLMSTATE_TYPE3; /* we sent a type-3 */ + authp->done = TRUE; + } + break; + + case NTLMSTATE_TYPE3: + /* connection is already authenticated, + * don't send a header in future requests */ + if(*allocuserpwd) { + free(*allocuserpwd); + *allocuserpwd=NULL; + } + authp->done = TRUE; + break; + } + + return CURLE_OK; +} +#endif /* USE_SSLEAY */ +#endif /* !CURL_DISABLE_HTTP */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/http_ntlm.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/http_ntlm.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/http_ntlm.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/http_ntlm.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,143 @@ +#ifndef __HTTP_NTLM_H +#define __HTTP_NTLM_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: http_ntlm.h,v 1.2 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +typedef enum { + CURLNTLM_NONE, /* not a ntlm */ + CURLNTLM_BAD, /* an ntlm, but one we don't like */ + CURLNTLM_FIRST, /* the first 401-reply we got with NTLM */ + CURLNTLM_FINE, /* an ntlm we act on */ + + CURLNTLM_LAST /* last entry in this enum, don't use */ +} CURLntlm; + +/* this is for ntlm header input */ +CURLntlm Curl_input_ntlm(struct connectdata *conn, bool proxy, char *header); + +/* this is for creating ntlm header output */ +CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy); + +void Curl_ntlm_cleanup(struct SessionHandle *data); + + +/* Flag bits definitions based on http://davenport.sourceforge.net/ntlm.html */ + +#define NTLMFLAG_NEGOTIATE_UNICODE (1<<0) +/* Indicates that Unicode strings are supported for use in security buffer + data. */ + +#define NTLMFLAG_NEGOTIATE_OEM (1<<1) +/* Indicates that OEM strings are supported for use in security buffer data. */ + +#define NTLMFLAG_REQUEST_TARGET (1<<2) +/* Requests that the server's authentication realm be included in the Type 2 + message. */ + +/* unknown (1<<3) */ +#define NTLMFLAG_NEGOTIATE_SIGN (1<<4) +/* Specifies that authenticated communication between the client and server + should carry a digital signature (message integrity). */ + +#define NTLMFLAG_NEGOTIATE_SEAL (1<<5) +/* Specifies that authenticated communication between the client and server + should be encrypted (message confidentiality). */ + +#define NTLMFLAG_NEGOTIATE_DATAGRAM_STYLE (1<<6) +/* unknown purpose */ + +#define NTLMFLAG_NEGOTIATE_LM_KEY (1<<7) +/* Indicates that the LAN Manager session key should be used for signing and + sealing authenticated communications. */ + +#define NTLMFLAG_NEGOTIATE_NETWARE (1<<8) +/* unknown purpose */ + +#define NTLMFLAG_NEGOTIATE_NTLM_KEY (1<<9) +/* Indicates that NTLM authentication is being used. */ + +/* unknown (1<<10) */ +/* unknown (1<<11) */ + +#define NTLMFLAG_NEGOTIATE_DOMAIN_SUPPLIED (1<<12) +/* Sent by the client in the Type 1 message to indicate that a desired + authentication realm is included in the message. */ + +#define NTLMFLAG_NEGOTIATE_WORKSTATION_SUPPLIED (1<<13) +/* Sent by the client in the Type 1 message to indicate that the client + workstation's name is included in the message. */ + +#define NTLMFLAG_NEGOTIATE_LOCAL_CALL (1<<14) +/* Sent by the server to indicate that the server and client are on the same + machine. Implies that the client may use a pre-established local security + context rather than responding to the challenge. */ + +#define NTLMFLAG_NEGOTIATE_ALWAYS_SIGN (1<<15) +/* Indicates that authenticated communication between the client and server + should be signed with a "dummy" signature. */ + +#define NTLMFLAG_TARGET_TYPE_DOMAIN (1<<16) +/* Sent by the server in the Type 2 message to indicate that the target + authentication realm is a domain. */ + +#define NTLMFLAG_TARGET_TYPE_SERVER (1<<17) +/* Sent by the server in the Type 2 message to indicate that the target + authentication realm is a server. */ + +#define NTLMFLAG_TARGET_TYPE_SHARE (1<<18) +/* Sent by the server in the Type 2 message to indicate that the target + authentication realm is a share. Presumably, this is for share-level + authentication. Usage is unclear. */ + +#define NTLMFLAG_NEGOTIATE_NTLM2_KEY (1<<19) +/* Indicates that the NTLM2 signing and sealing scheme should be used for + protecting authenticated communications. */ + +#define NTLMFLAG_REQUEST_INIT_RESPONSE (1<<20) +/* unknown purpose */ + +#define NTLMFLAG_REQUEST_ACCEPT_RESPONSE (1<<21) +/* unknown purpose */ + +#define NTLMFLAG_REQUEST_NONNT_SESSION_KEY (1<<22) +/* unknown purpose */ + +#define NTLMFLAG_NEGOTIATE_TARGET_INFO (1<<23) +/* Sent by the server in the Type 2 message to indicate that it is including a + Target Information block in the message. */ + +/* unknown (1<24) */ +/* unknown (1<25) */ +/* unknown (1<26) */ +/* unknown (1<27) */ +/* unknown (1<28) */ + +#define NTLMFLAG_NEGOTIATE_128 (1<<29) +/* Indicates that 128-bit encryption is supported. */ + +#define NTLMFLAG_NEGOTIATE_KEY_EXCHANGE (1<<30) +/* unknown purpose */ + +#define NTLMFLAG_NEGOTIATE_56 (1<<31) +/* Indicates that 56-bit encryption is supported. */ +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/if2ip.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/if2ip.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/if2ip.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/if2ip.c 2004-10-11 23:47:14.000000000 +0800 @@ -0,0 +1,142 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: if2ip.c,v 1.7 2004/10/11 15:47:14 andy Exp $ + ***************************************************************************/ + +#include "setup.h" + +#include +#include +#include + +#ifdef HAVE_UNISTD_H +#include +#endif + +#if !defined(WIN32) && !defined(__BEOS__) && !defined(__CYGWIN32__) && \ + !defined(__riscos__) && !defined(__INTERIX) && !defined(NETWARE) + +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_ARPA_INET_H +#include +#endif + +#ifdef HAVE_SYS_TIME_H +/* This must be before net/if.h for AIX 3.2 to enjoy life */ +#include +#endif +#ifdef HAVE_NET_IF_H +#include +#endif +#ifdef HAVE_SYS_IOCTL_H +#include +#endif + +/* -- if2ip() -- */ +#ifdef HAVE_NETDB_H +#include +#endif + +#ifdef HAVE_SYS_SOCKIO_H +#include +#endif + +#if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL) +#include "inet_ntoa_r.h" +#endif + +#ifdef VMS +#include +#endif + +#include "if2ip.h" +#include "curl_memory.h" + +/* The last #include file should be: */ +#include "memdebug.h" + +#define SYS_ERROR -1 + +char *Curl_if2ip(const char *interface, char *buf, int buf_size) +{ + int dummy; + char *ip=NULL; + + if(!interface) + return NULL; + + dummy = socket(AF_INET, SOCK_STREAM, 0); + if (SYS_ERROR == dummy) { + return NULL; + } + else { + struct ifreq req; + size_t len = strlen(interface); + memset(&req, 0, sizeof(req)); + if(len >= sizeof(req.ifr_name)) + return NULL; /* this can't be a fine interface name */ + memcpy(req.ifr_name, interface, len+1); + req.ifr_addr.sa_family = AF_INET; +#ifdef IOCTL_3_ARGS + if (SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req)) { +#else + if (SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req, sizeof(req))) { +#endif + sclose(dummy); + return NULL; + } + else { + struct in_addr in; + + union { + struct sockaddr_in *sin; + struct sockaddr *s; + } soadd; + + soadd.s = &req.ifr_dstaddr; + memcpy(&in, &(soadd.sin->sin_addr.s_addr), sizeof(in)); +#if defined(HAVE_INET_NTOA_R) + ip = inet_ntoa_r(in,buf,buf_size); +#else + ip = strncpy(buf,inet_ntoa(in),buf_size); + ip[buf_size - 1] = 0; +#endif + } + sclose(dummy); + } + return ip; +} + +/* -- end of if2ip() -- */ +#else +char *Curl_if2ip(const char *interface, char *buf, int buf_size) +{ + (void) interface; + (void) buf; + (void) buf_size; + return NULL; +} +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/if2ip.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/if2ip.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/if2ip.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/if2ip.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,69 @@ +#ifndef __IF2IP_H +#define __IF2IP_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: if2ip.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ +#include "setup.h" + +#if !defined(WIN32) && !defined(__BEOS__) && !defined(__CYGWIN32__) && \ + !defined(__riscos__) && !defined(__INTERIX) +extern char *Curl_if2ip(const char *interface, char *buf, int buf_size); +#else +#define Curl_if2ip(a,b,c) NULL +#endif +#ifdef __INTERIX +/* Nedelcho Stanev's work-around for SFU 3.0 */ +struct ifreq { +#define IFNAMSIZ 16 +#define IFHWADDRLEN 6 + union { + char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + } ifr_ifrn; + + union { + struct sockaddr ifru_addr; + struct sockaddr ifru_broadaddr; + struct sockaddr ifru_netmask; + struct sockaddr ifru_hwaddr; + short ifru_flags; + int ifru_metric; + int ifru_mtu; + } ifr_ifru; +}; + +/* This define was added by Daniel to avoid an extra #ifdef INTERIX in the + C code. */ +#define ifr_dstaddr ifr_addr + +#define ifr_name ifr_ifrn.ifrn_name /* interface name */ +#define ifr_addr ifr_ifru.ifru_addr /* address */ +#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ +#define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */ +#define ifr_flags ifr_ifru.ifru_flags /* flags */ +#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ +#define ifr_metric ifr_ifru.ifru_metric /* metric */ +#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ + +#define SIOCGIFADDR _IOW('s', 102, struct ifreq) /* Get if addr */ +#endif /* interix */ + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/inet_ntoa_r.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/inet_ntoa_r.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/inet_ntoa_r.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/inet_ntoa_r.h 2003-01-07 10:13:39.000000000 +0800 @@ -0,0 +1,9 @@ +#ifndef __INET_NTOA_R_H +#define __INET_NTOA_R_H +/* + * My solaris 5.6 system running gcc 2.8.1 does *not* have this prototype + * in any system include file! Isn't that weird? + */ +char *inet_ntoa_r(const struct in_addr in, char *buffer, int buflen); + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/inet_ntop.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/inet_ntop.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/inet_ntop.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/inet_ntop.c 2004-10-11 23:53:29.000000000 +0800 @@ -0,0 +1,204 @@ +/* + * Original code by Paul Vixie. "curlified" by Gisle Vanem. + */ + +#include "setup.h" + +#ifndef HAVE_INET_NTOP + +#ifdef HAVE_SYS_PARAM_H +#include +#endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_ARPA_INET_H +#include +#endif +#include +#include + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +#include "inet_ntop.h" + +#if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL) +/* this platform has a inet_ntoa_r() function, but no proto declared anywhere + so we include our own proto to make compilers happy */ +#include "inet_ntoa_r.h" +#endif + +#define IN6ADDRSZ 16 +#define INADDRSZ 4 +#define INT16SZ 2 + +#ifdef WIN32 +#define EAFNOSUPPORT WSAEAFNOSUPPORT +#define SET_ERRNO(e) WSASetLastError(errno = (e)) +#else +#define SET_ERRNO(e) errno = e +#endif + +/* + * Format an IPv4 address, more or less like inet_ntoa(). + * + * Returns `dst' (as a const) + * Note: + * - uses no statics + * - takes a u_char* not an in_addr as input + */ +static const char *inet_ntop4 (const u_char *src, char *dst, size_t size) +{ +#ifdef HAVE_INET_NTOA_R + return inet_ntoa_r(*(struct in_addr*)src, dst, size); +#else + union { + const u_char* uch; + const struct in_addr* iad; + } srcaddr; + const char *addr; + srcaddr.uch = src; + addr = inet_ntoa(*srcaddr.iad); + + if (strlen(addr) >= size) + { + SET_ERRNO(ENOSPC); + return (NULL); + } + return strcpy(dst, addr); +#endif +} + +#ifdef ENABLE_IPV6 +/* + * Convert IPv6 binary address into presentation (printable) format. + */ +static const char *inet_ntop6 (const u_char *src, char *dst, size_t size) +{ + /* + * Note that int32_t and int16_t need only be "at least" large enough + * to contain a value of the specified size. On some systems, like + * Crays, there is no such thing as an integer variable with 16 bits. + * Keep this in mind if you think this function should have been coded + * to use pointer overlays. All the world's not a VAX. + */ + char tmp [sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")]; + char *tp; + struct { + long base; + long len; + } best, cur; + u_long words [IN6ADDRSZ / INT16SZ]; + int i; + + /* Preprocess: + * Copy the input (bytewise) array into a wordwise array. + * Find the longest run of 0x00's in src[] for :: shorthanding. + */ + memset(words, 0, sizeof(words)); + for (i = 0; i < IN6ADDRSZ; i++) + words[i/2] |= (src[i] << ((1 - (i % 2)) << 3)); + + best.base = -1; + cur.base = -1; + for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) + { + if (words[i] == 0) + { + if (cur.base == -1) + cur.base = i, cur.len = 1; + else + cur.len++; + } + else if (cur.base != -1) + { + if (best.base == -1 || cur.len > best.len) + best = cur; + cur.base = -1; + } + } + if ((cur.base != -1) && (best.base == -1 || cur.len > best.len)) + best = cur; + if (best.base != -1 && best.len < 2) + best.base = -1; + + /* Format the result. + */ + tp = tmp; + for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) + { + /* Are we inside the best run of 0x00's? + */ + if (best.base != -1 && i >= best.base && i < (best.base + best.len)) + { + if (i == best.base) + *tp++ = ':'; + continue; + } + + /* Are we following an initial run of 0x00s or any real hex? + */ + if (i != 0) + *tp++ = ':'; + + /* Is this address an encapsulated IPv4? + */ + if (i == 6 && best.base == 0 && + (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) + { + if (!inet_ntop4(src+12, tp, sizeof(tmp) - (tp - tmp))) + { + SET_ERRNO(ENOSPC); + return (NULL); + } + tp += strlen(tp); + break; + } + tp += snprintf(tp, 5, "%lx", words[i]); + } + + /* Was it a trailing run of 0x00's? + */ + if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ)) + *tp++ = ':'; + *tp++ = '\0'; + + /* Check for overflow, copy, and we're done. + */ + if ((size_t)(tp - tmp) > size) + { + SET_ERRNO(ENOSPC); + return (NULL); + } + return strcpy (dst, tmp); +} +#endif /* ENABLE_IPV6 */ + +/* + * Convert a network format address to presentation format. + * + * Returns pointer to presentation format address (`dst'), + * Returns NULL on error (see errno). + */ +const char *Curl_inet_ntop(int af, const void *src, char *buf, size_t size) +{ + switch (af) { + case AF_INET: + return inet_ntop4((const u_char*)src, buf, size); +#ifdef ENABLE_IPV6 + case AF_INET6: + return inet_ntop6((const u_char*)src, buf, size); +#endif + default: + SET_ERRNO(EAFNOSUPPORT); + return NULL; + } +} +#endif /* HAVE_INET_NTOP */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/inet_ntop.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/inet_ntop.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/inet_ntop.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/inet_ntop.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,37 @@ +#ifndef __INET_NTOP_H +#define __INET_NTOP_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: inet_ntop.h,v 1.1 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +#include "setup.h" + +#ifdef HAVE_INET_NTOP +#define Curl_inet_ntop(af,addr,buf,size) inet_ntop(af,addr,buf,size) +#ifdef HAVE_ARPA_INET_H +#include +#endif +#else +const char *Curl_inet_ntop(int af, const void *addr, char *buf, size_t size); +#endif + +#endif /* __INET_NTOP_H */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/inet_pton.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/inet_pton.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/inet_pton.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/inet_pton.c 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,240 @@ +/* This is from the BIND 4.9.4 release, modified to compile by itself */ + +/* Copyright (c) 1996 by Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#include "setup.h" + +#ifndef HAVE_INET_PTON + +#ifdef HAVE_SYS_PARAM_H +#include +#endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_ARPA_INET_H +#include +#endif +#include +#include + +#include "inet_pton.h" + +#define IN6ADDRSZ 16 +#define INADDRSZ 4 +#define INT16SZ 2 + +#ifdef WIN32 +#define EAFNOSUPPORT WSAEAFNOSUPPORT +#endif + +/* + * WARNING: Don't even consider trying to compile this on a system where + * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. + */ + +static int inet_pton4(const char *src, unsigned char *dst); +#ifdef ENABLE_IPV6 +static int inet_pton6(const char *src, unsigned char *dst); +#endif + +/* int + * inet_pton(af, src, dst) + * convert from presentation format (which usually means ASCII printable) + * to network format (which is usually some kind of binary format). + * return: + * 1 if the address was valid for the specified address family + * 0 if the address wasn't valid (`dst' is untouched in this case) + * -1 if some other error occurred (`dst' is untouched in this case, too) + * author: + * Paul Vixie, 1996. + */ +int +Curl_inet_pton(int af, const char *src, void *dst) +{ + switch (af) { + case AF_INET: + return (inet_pton4(src, dst)); +#ifdef ENABLE_IPV6 +#ifndef AF_INET6 +#define AF_INET6 AF_MAX+1 /* just to let this compile */ +#endif + case AF_INET6: + return (inet_pton6(src, dst)); +#endif + default: + errno = EAFNOSUPPORT; + return (-1); + } + /* NOTREACHED */ +} + +/* int + * inet_pton4(src, dst) + * like inet_aton() but without all the hexadecimal and shorthand. + * return: + * 1 if `src' is a valid dotted quad, else 0. + * notice: + * does not touch `dst' unless it's returning 1. + * author: + * Paul Vixie, 1996. + */ +static int +inet_pton4(const char *src, unsigned char *dst) +{ + static const char digits[] = "0123456789"; + int saw_digit, octets, ch; + unsigned char tmp[INADDRSZ], *tp; + + saw_digit = 0; + octets = 0; + *(tp = tmp) = 0; + while ((ch = *src++) != '\0') { + const char *pch; + + if ((pch = strchr(digits, ch)) != NULL) { + u_int new = *tp * 10 + (pch - digits); + + if (new > 255) + return (0); + *tp = new; + if (! saw_digit) { + if (++octets > 4) + return (0); + saw_digit = 1; + } + } else if (ch == '.' && saw_digit) { + if (octets == 4) + return (0); + *++tp = 0; + saw_digit = 0; + } else + return (0); + } + if (octets < 4) + return (0); + /* bcopy(tmp, dst, INADDRSZ); */ + memcpy(dst, tmp, INADDRSZ); + return (1); +} + +#ifdef ENABLE_IPV6 +/* int + * inet_pton6(src, dst) + * convert presentation level address to network order binary form. + * return: + * 1 if `src' is a valid [RFC1884 2.2] address, else 0. + * notice: + * (1) does not touch `dst' unless it's returning 1. + * (2) :: in a full address is silently ignored. + * credit: + * inspired by Mark Andrews. + * author: + * Paul Vixie, 1996. + */ +static int +inet_pton6(const char *src, unsigned char *dst) +{ + static const char xdigits_l[] = "0123456789abcdef", + xdigits_u[] = "0123456789ABCDEF"; + unsigned char tmp[IN6ADDRSZ], *tp, *endp, *colonp; + const char *xdigits, *curtok; + int ch, saw_xdigit; + u_int val; + + memset((tp = tmp), 0, IN6ADDRSZ); + endp = tp + IN6ADDRSZ; + colonp = NULL; + /* Leading :: requires some special handling. */ + if (*src == ':') + if (*++src != ':') + return (0); + curtok = src; + saw_xdigit = 0; + val = 0; + while ((ch = *src++) != '\0') { + const char *pch; + + if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) + pch = strchr((xdigits = xdigits_u), ch); + if (pch != NULL) { + val <<= 4; + val |= (pch - xdigits); + if (val > 0xffff) + return (0); + saw_xdigit = 1; + continue; + } + if (ch == ':') { + curtok = src; + if (!saw_xdigit) { + if (colonp) + return (0); + colonp = tp; + continue; + } + if (tp + INT16SZ > endp) + return (0); + *tp++ = (unsigned char) (val >> 8) & 0xff; + *tp++ = (unsigned char) val & 0xff; + saw_xdigit = 0; + val = 0; + continue; + } + if (ch == '.' && ((tp + INADDRSZ) <= endp) && + inet_pton4(curtok, tp) > 0) { + tp += INADDRSZ; + saw_xdigit = 0; + break; /* '\0' was seen by inet_pton4(). */ + } + return (0); + } + if (saw_xdigit) { + if (tp + INT16SZ > endp) + return (0); + *tp++ = (unsigned char) (val >> 8) & 0xff; + *tp++ = (unsigned char) val & 0xff; + } + if (colonp != NULL) { + /* + * Since some memmove()'s erroneously fail to handle + * overlapping regions, we'll do the shift by hand. + */ + const int n = tp - colonp; + int i; + + for (i = 1; i <= n; i++) { + endp[- i] = colonp[n - i]; + colonp[n - i] = 0; + } + tp = endp; + } + if (tp != endp) + return (0); + /* bcopy(tmp, dst, IN6ADDRSZ); */ + memcpy(dst, tmp, IN6ADDRSZ); + return (1); +} +#endif /* ENABLE_IPV6 */ + +#endif /* HAVE_INET_PTON */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/inet_pton.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/inet_pton.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/inet_pton.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/inet_pton.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,37 @@ +#ifndef __INET_PTON_H +#define __INET_PTON_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: inet_pton.h,v 1.2 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +#include "setup.h" + +#ifdef HAVE_INET_PTON +#define Curl_inet_pton(x,y,z) inet_pton(x,y,z) +#ifdef HAVE_ARPA_INET_H +#include +#endif +#else +int Curl_inet_pton(int, const char *, void *); +#endif + +#endif /* __INET_PTON_H */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/krb4.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/krb4.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/krb4.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/krb4.c 2004-10-06 00:42:38.000000000 +0800 @@ -0,0 +1,408 @@ +/* This source code was modified by Martin Hedenfalk for + * use in Curl. His latest changes were done 2000-09-18. + * + * It has since been patched away like a madman by Daniel Stenberg + * to make it better applied to curl conditions, and to make + * it not use globals, pollute name space and more. This source code awaits a + * rewrite to work around the paragraph 2 in the BSD licenses as explained + * below. + * + * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ + +#include "setup.h" + +#ifndef CURL_DISABLE_FTP +#ifdef HAVE_KRB4 + +#include "security.h" +#include "base64.h" +#include +#ifdef HAVE_NETDB_H +#include +#endif +#include +#include +#include + +#ifdef HAVE_UNISTD_H +#include /* for getpid() */ +#endif + +#include "ftp.h" +#include "sendf.h" +#include "krb4.h" +#include "curl_memory.h" + +#if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL) +#include "inet_ntoa_r.h" +#endif + +/* The last #include file should be: */ +#include "memdebug.h" + +#define LOCAL_ADDR (&conn->local_addr) +#define REMOTE_ADDR conn->ip_addr->ai_addr +#define myctladdr LOCAL_ADDR +#define hisctladdr REMOTE_ADDR + +struct krb4_data { + des_cblock key; + des_key_schedule schedule; + char name[ANAME_SZ]; + char instance[INST_SZ]; + char realm[REALM_SZ]; +}; + +#ifndef HAVE_STRLCPY +/* if it ever goes non-static, make it Curl_ prefixed! */ +static size_t +strlcpy (char *dst, const char *src, size_t dst_sz) +{ + size_t n; + char *p; + + for (p = dst, n = 0; + n + 1 < dst_sz && *src != '\0'; + ++p, ++src, ++n) + *p = *src; + *p = '\0'; + if (*src == '\0') + return n; + else + return n + strlen (src); +} +#else +size_t strlcpy (char *dst, const char *src, size_t dst_sz); +#endif + +static int +krb4_check_prot(void *app_data, int level) +{ + app_data = NULL; /* prevent compiler warning */ + if(level == prot_confidential) + return -1; + return 0; +} + +static int +krb4_decode(void *app_data, void *buf, int len, int level, + struct connectdata *conn) +{ + MSG_DAT m; + int e; + struct krb4_data *d = app_data; + + if(level == prot_safe) + e = krb_rd_safe(buf, len, &d->key, + (struct sockaddr_in *)REMOTE_ADDR, + (struct sockaddr_in *)LOCAL_ADDR, &m); + else + e = krb_rd_priv(buf, len, d->schedule, &d->key, + (struct sockaddr_in *)REMOTE_ADDR, + (struct sockaddr_in *)LOCAL_ADDR, &m); + if(e) { + struct SessionHandle *data = conn->data; + infof(data, "krb4_decode: %s\n", krb_get_err_text(e)); + return -1; + } + memmove(buf, m.app_data, m.app_length); + return m.app_length; +} + +static int +krb4_overhead(void *app_data, int level, int len) +{ + /* no arguments are used, just init them to prevent compiler warnings */ + app_data = NULL; + level = 0; + len = 0; + return 31; +} + +static int +krb4_encode(void *app_data, void *from, int length, int level, void **to, + struct connectdata *conn) +{ + struct krb4_data *d = app_data; + *to = malloc(length + 31); + if(level == prot_safe) + return krb_mk_safe(from, *to, length, &d->key, + (struct sockaddr_in *)LOCAL_ADDR, + (struct sockaddr_in *)REMOTE_ADDR); + else if(level == prot_private) + return krb_mk_priv(from, *to, length, d->schedule, &d->key, + (struct sockaddr_in *)LOCAL_ADDR, + (struct sockaddr_in *)REMOTE_ADDR); + else + return -1; +} + +static int +mk_auth(struct krb4_data *d, KTEXT adat, + const char *service, char *host, int checksum) +{ + int ret; + CREDENTIALS cred; + char sname[SNAME_SZ], inst[INST_SZ], realm[REALM_SZ]; + + strlcpy(sname, service, sizeof(sname)); + strlcpy(inst, krb_get_phost(host), sizeof(inst)); + strlcpy(realm, krb_realmofhost(host), sizeof(realm)); + ret = krb_mk_req(adat, sname, inst, realm, checksum); + if(ret) + return ret; + strlcpy(sname, service, sizeof(sname)); + strlcpy(inst, krb_get_phost(host), sizeof(inst)); + strlcpy(realm, krb_realmofhost(host), sizeof(realm)); + ret = krb_get_cred(sname, inst, realm, &cred); + memmove(&d->key, &cred.session, sizeof(des_cblock)); + des_key_sched(&d->key, d->schedule); + memset(&cred, 0, sizeof(cred)); + return ret; +} + +#ifdef HAVE_KRB_GET_OUR_IP_FOR_REALM +int krb_get_our_ip_for_realm(char *, struct in_addr *); +#endif + +static int +krb4_auth(void *app_data, struct connectdata *conn) +{ + int ret; + char *p; + int len; + KTEXT_ST adat; + MSG_DAT msg_data; + int checksum; + u_int32_t cs; + struct krb4_data *d = app_data; + char *host = conn->host.name; + ssize_t nread; + int l = sizeof(conn->local_addr); + struct SessionHandle *data = conn->data; + CURLcode result; + + if(getsockname(conn->sock[FIRSTSOCKET], + (struct sockaddr *)LOCAL_ADDR, &l) < 0) + perror("getsockname()"); + + checksum = getpid(); + ret = mk_auth(d, &adat, "ftp", host, checksum); + if(ret == KDC_PR_UNKNOWN) + ret = mk_auth(d, &adat, "rcmd", host, checksum); + if(ret) { + Curl_infof(data, "%s\n", krb_get_err_text(ret)); + return AUTH_CONTINUE; + } + +#ifdef HAVE_KRB_GET_OUR_IP_FOR_REALM + if (krb_get_config_bool("nat_in_use")) { + struct sockaddr_in *localaddr = (struct sockaddr_in *)LOCAL_ADDR; + struct in_addr natAddr; + + if (krb_get_our_ip_for_realm(krb_realmofhost(host), + &natAddr) != KSUCCESS + && krb_get_our_ip_for_realm(NULL, &natAddr) != KSUCCESS) + Curl_infof(data, "Can't get address for realm %s\n", + krb_realmofhost(host)); + else { + if (natAddr.s_addr != localaddr->sin_addr.s_addr) { +#ifdef HAVE_INET_NTOA_R + char ntoa_buf[64]; + char *ip = (char *)inet_ntoa_r(natAddr, ntoa_buf, sizeof(ntoa_buf)); +#else + char *ip = (char *)inet_ntoa(natAddr); +#endif + Curl_infof(data, "Using NAT IP address (%s) for kerberos 4\n", ip); + localaddr->sin_addr = natAddr; + } + } + } +#endif + + if(Curl_base64_encode((char *)adat.dat, adat.length, &p) < 1) { + Curl_failf(data, "Out of memory base64-encoding"); + return AUTH_CONTINUE; + } + + result = Curl_ftpsendf(conn, "ADAT %s", p); + + free(p); + + if(result) + return -2; + + if(Curl_GetFTPResponse(&nread, conn, NULL)) + return -1; + + if(data->state.buffer[0] != '2'){ + Curl_failf(data, "Server didn't accept auth data"); + return AUTH_ERROR; + } + + p = strstr(data->state.buffer, "ADAT="); + if(!p) { + Curl_failf(data, "Remote host didn't send adat reply"); + return AUTH_ERROR; + } + p += 5; + len = Curl_base64_decode(p, (char *)adat.dat); + if(len < 0) { + Curl_failf(data, "Failed to decode base64 from server"); + return AUTH_ERROR; + } + adat.length = len; + ret = krb_rd_safe(adat.dat, adat.length, &d->key, + (struct sockaddr_in *)hisctladdr, + (struct sockaddr_in *)myctladdr, &msg_data); + if(ret) { + Curl_failf(data, "Error reading reply from server: %s", + krb_get_err_text(ret)); + return AUTH_ERROR; + } + krb_get_int(msg_data.app_data, &cs, 4, 0); + if(cs - checksum != 1) { + Curl_failf(data, "Bad checksum returned from server"); + return AUTH_ERROR; + } + return AUTH_OK; +} + +struct Curl_sec_client_mech Curl_krb4_client_mech = { + "KERBEROS_V4", + sizeof(struct krb4_data), + NULL, /* init */ + krb4_auth, + NULL, /* end */ + krb4_check_prot, + krb4_overhead, + krb4_encode, + krb4_decode +}; + +CURLcode Curl_krb_kauth(struct connectdata *conn) +{ + des_cblock key; + des_key_schedule schedule; + KTEXT_ST tkt, tktcopy; + char *name; + char *p; + char passwd[100]; + int tmp; + ssize_t nread; + int save; + CURLcode result; + + save = Curl_set_command_prot(conn, prot_private); + + result = Curl_ftpsendf(conn, "SITE KAUTH %s", conn->user); + + if(result) + return result; + + result = Curl_GetFTPResponse(&nread, conn, NULL); + if(result) + return result; + + if(conn->data->state.buffer[0] != '3'){ + Curl_set_command_prot(conn, save); + return CURLE_FTP_WEIRD_SERVER_REPLY; + } + + p = strstr(conn->data->state.buffer, "T="); + if(!p) { + Curl_failf(conn->data, "Bad reply from server"); + Curl_set_command_prot(conn, save); + return CURLE_FTP_WEIRD_SERVER_REPLY; + } + + p += 2; + tmp = Curl_base64_decode(p, (char *)tkt.dat); + if(tmp < 0) { + Curl_failf(conn->data, "Failed to decode base64 in reply.\n"); + Curl_set_command_prot(conn, save); + return CURLE_FTP_WEIRD_SERVER_REPLY; + } + tkt.length = tmp; + tktcopy.length = tkt.length; + + p = strstr(conn->data->state.buffer, "P="); + if(!p) { + Curl_failf(conn->data, "Bad reply from server"); + Curl_set_command_prot(conn, save); + return CURLE_FTP_WEIRD_SERVER_REPLY; + } + name = p + 2; + for(; *p && *p != ' ' && *p != '\r' && *p != '\n'; p++); + *p = 0; + + des_string_to_key (conn->passwd, &key); + des_key_sched(&key, schedule); + + des_pcbc_encrypt((void *)tkt.dat, (void *)tktcopy.dat, + tkt.length, + schedule, &key, DES_DECRYPT); + if (strcmp ((char*)tktcopy.dat + 8, + KRB_TICKET_GRANTING_TICKET) != 0) { + afs_string_to_key(passwd, + krb_realmofhost(conn->host.name), + &key); + des_key_sched(&key, schedule); + des_pcbc_encrypt((void *)tkt.dat, (void *)tktcopy.dat, + tkt.length, + schedule, &key, DES_DECRYPT); + } + memset(key, 0, sizeof(key)); + memset(schedule, 0, sizeof(schedule)); + memset(passwd, 0, sizeof(passwd)); + if(Curl_base64_encode((char *)tktcopy.dat, tktcopy.length, &p) < 1) { + failf(conn->data, "Out of memory base64-encoding."); + Curl_set_command_prot(conn, save); + return CURLE_OUT_OF_MEMORY; + } + memset (tktcopy.dat, 0, tktcopy.length); + + result = Curl_ftpsendf(conn, "SITE KAUTH %s %s", name, p); + free(p); + if(result) + return result; + + result = Curl_GetFTPResponse(&nread, conn, NULL); + if(result) + return result; + Curl_set_command_prot(conn, save); + + return CURLE_OK; +} + +#endif /* HAVE_KRB4 */ +#endif /* CURL_DISABLE_FTP */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/krb4.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/krb4.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/krb4.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/krb4.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,27 @@ +#ifndef __KRB4_H +#define __KRB4_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: krb4.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ +CURLcode Curl_krb_kauth(struct connectdata *conn); + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/ldap.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/ldap.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/ldap.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/ldap.c 2004-10-06 00:42:38.000000000 +0800 @@ -0,0 +1,625 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: ldap.c,v 1.9 2004/10/05 16:42:38 hoffman Exp $ + ***************************************************************************/ + +#include "setup.h" + +#ifndef CURL_DISABLE_LDAP +/* -- WIN32 approved -- */ +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(WIN32) +# include +# include +# include +#endif + +#ifdef HAVE_UNISTD_H +# include +#endif + +#ifdef HAVE_DLFCN_H +# include +#endif + +#include "urldata.h" +#include +#include "sendf.h" +#include "escape.h" +#include "transfer.h" +#include "strequal.h" +#include "strtok.h" +#include "ldap.h" +#include "curl_memory.h" + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +#include "memdebug.h" + +/* WLdap32.dll functions are *not* stdcall. Must call these via __cdecl + * pointers in case libcurl was compiled as fastcall (-Gr). + */ +#if !defined(WIN32) && !defined(__cdecl) +#define __cdecl +#endif + +#ifndef LDAP_SIZELIMIT_EXCEEDED +#define LDAP_SIZELIMIT_EXCEEDED 4 +#endif + +#define DLOPEN_MODE RTLD_LAZY /*! assume all dlopen() implementations have + this */ + +#if defined(RTLD_LAZY_GLOBAL) /* It turns out some systems use this: */ +# undef DLOPEN_MODE +# define DLOPEN_MODE RTLD_LAZY_GLOBAL +#elif defined(RTLD_GLOBAL) +# undef DLOPEN_MODE +# define DLOPEN_MODE (RTLD_LAZY | RTLD_GLOBAL) +#endif + +#define DYNA_GET_FUNCTION(type, fnc) do { \ + (fnc) = (type)DynaGetFunction(#fnc); \ + if ((fnc) == NULL) \ + return CURLE_FUNCTION_NOT_FOUND; \ + } while (0) + +/*! CygWin etc. configure could set these, but we don't want it. + * Must use WLdap32.dll code. + */ +#if defined(WIN32) +#undef HAVE_DLOPEN +#undef HAVE_LIBDL +#endif + +typedef void * (*dynafunc)(void *input); + +/*********************************************************************** + */ +static void *libldap = NULL; +#ifndef WIN32 +static void *liblber = NULL; +#endif + +static int DynaOpen(const char **mod_name) +{ +#if defined(HAVE_DLOPEN) || defined(HAVE_LIBDL) + if (libldap == NULL) { + /* + * libldap.so should be able to resolve its dependency on + * liblber.so automatically, but since it does not we will + * handle it here by opening liblber.so as global. + */ + *mod_name = "liblber.so"; + liblber = dlopen(*mod_name, DLOPEN_MODE); + + /* Assume loading libldap.so will fail if loading of liblber.so failed + */ + if (liblber) { + *mod_name = "libldap.so"; + libldap = dlopen(*mod_name, RTLD_LAZY); + } + } + return (libldap != NULL && liblber != NULL); + +#elif defined(WIN32) + *mod_name = "wldap32.dll"; + if (!libldap) + libldap = (void*)LoadLibrary(*mod_name); + return (libldap != NULL); + +#else + return (0); +#endif +} + +static void DynaClose(void) +{ +#if defined(HAVE_DLOPEN) || defined(HAVE_LIBDL) + if (libldap) { + dlclose(libldap); + libldap=NULL; + } + if (liblber) { + dlclose(liblber); + liblber=NULL; + } +#elif defined(WIN32) + if (libldap) { + FreeLibrary ((HMODULE)libldap); + libldap = NULL; + } +#endif +} + +static dynafunc DynaGetFunction(const char *name) +{ + dynafunc func = (dynafunc)NULL; + +#if defined(HAVE_DLOPEN) || defined(HAVE_LIBDL) + if (libldap) { + /* This typecast magic below was brought by Joe Halpin. In ISO C, you + * cannot typecast a data pointer to a function pointer, but that's + * exactly what we need to do here to avoid compiler warnings on picky + * compilers! */ + *(void**) (&func) = dlsym(libldap, name); + } +#elif defined(WIN32) + if (libldap) { + func = (dynafunc)GetProcAddress((HINSTANCE)libldap, name); + } +#endif + return func; +} + +/*********************************************************************** + */ +typedef struct ldap_url_desc { + struct ldap_url_desc *lud_next; + char *lud_scheme; + char *lud_host; + int lud_port; + char *lud_dn; + char **lud_attrs; + int lud_scope; + char *lud_filter; + char **lud_exts; + int lud_crit_exts; +} LDAPURLDesc; + +#ifdef WIN32 +static int _ldap_url_parse (const struct connectdata *conn, + LDAPURLDesc **ludp); +static void _ldap_free_urldesc (LDAPURLDesc *ludp); + +static void (*ldap_free_urldesc)(LDAPURLDesc *) = _ldap_free_urldesc; +#endif + +#ifdef DEBUG_LDAP + #define LDAP_TRACE(x) do { \ + _ldap_trace ("%u: ", __LINE__); \ + _ldap_trace x; \ + } while (0) + + static void _ldap_trace (const char *fmt, ...); +#else + #define LDAP_TRACE(x) ((void)0) +#endif + + +CURLcode Curl_ldap(struct connectdata *conn) +{ + CURLcode status = CURLE_OK; + int rc = 0; +#ifndef WIN32 + int (*ldap_url_parse)(char *, LDAPURLDesc **); + void (*ldap_free_urldesc)(void *); +#endif + void *(__cdecl *ldap_init)(char *, int); + int (__cdecl *ldap_simple_bind_s)(void *, char *, char *); + int (__cdecl *ldap_unbind_s)(void *); + int (__cdecl *ldap_search_s)(void *, char *, int, char *, char **, + int, void **); + void *(__cdecl *ldap_first_entry)(void *, void *); + void *(__cdecl *ldap_next_entry)(void *, void *); + char *(__cdecl *ldap_err2string)(int); + char *(__cdecl *ldap_get_dn)(void *, void *); + char *(__cdecl *ldap_first_attribute)(void *, void *, void **); + char *(__cdecl *ldap_next_attribute)(void *, void *, void *); + char **(__cdecl *ldap_get_values)(void *, void *, const char *); + void (__cdecl *ldap_value_free)(char **); + void (__cdecl *ldap_memfree)(void *); + void (__cdecl *ber_free)(void *, int); + + void *server; + LDAPURLDesc *ludp = NULL; + const char *mod_name; + void *result; + void *entryIterator; /*! type should be 'LDAPMessage *' */ + int num = 0; + struct SessionHandle *data=conn->data; + + infof(data, "LDAP local: %s\n", data->change.url); + + if (!DynaOpen(&mod_name)) { + failf(data, "The %s LDAP library/libraries couldn't be opened", mod_name); + return CURLE_LIBRARY_NOT_FOUND; + } + + /* The types are needed because ANSI C distinguishes between + * pointer-to-object (data) and pointer-to-function. + */ + DYNA_GET_FUNCTION(void *(*)(char *, int), ldap_init); + DYNA_GET_FUNCTION(int (*)(void *, char *, char *), ldap_simple_bind_s); + DYNA_GET_FUNCTION(int (*)(void *), ldap_unbind_s); +#ifndef WIN32 + DYNA_GET_FUNCTION(int (*)(char *, LDAPURLDesc **), ldap_url_parse); + DYNA_GET_FUNCTION(void (*)(void *), ldap_free_urldesc); +#endif + DYNA_GET_FUNCTION(int (*)(void *, char *, int, char *, char **, int, + void **), ldap_search_s); + DYNA_GET_FUNCTION(void *(*)(void *, void *), ldap_first_entry); + DYNA_GET_FUNCTION(void *(*)(void *, void *), ldap_next_entry); + DYNA_GET_FUNCTION(char *(*)(int), ldap_err2string); + DYNA_GET_FUNCTION(char *(*)(void *, void *), ldap_get_dn); + DYNA_GET_FUNCTION(char *(*)(void *, void *, void **), ldap_first_attribute); + DYNA_GET_FUNCTION(char *(*)(void *, void *, void *), ldap_next_attribute); + DYNA_GET_FUNCTION(char **(*)(void *, void *, const char *), ldap_get_values); + DYNA_GET_FUNCTION(void (*)(char **), ldap_value_free); + DYNA_GET_FUNCTION(void (*)(void *), ldap_memfree); + DYNA_GET_FUNCTION(void (*)(void *, int), ber_free); + + server = (*ldap_init)(conn->host.name, (int)conn->port); + if (server == NULL) { + failf(data, "LDAP local: Cannot connect to %s:%d", + conn->host.name, conn->port); + status = CURLE_COULDNT_CONNECT; + goto quit; + } + + rc = (*ldap_simple_bind_s)(server, + conn->bits.user_passwd ? conn->user : NULL, + conn->bits.user_passwd ? conn->passwd : NULL); + if (rc != 0) { + failf(data, "LDAP local: %s", (*ldap_err2string)(rc)); + status = CURLE_LDAP_CANNOT_BIND; + goto quit; + } + +#ifdef WIN32 + rc = _ldap_url_parse(conn, &ludp); +#else + rc = (*ldap_url_parse)(data->change.url, &ludp); +#endif + + if (rc != 0) { + failf(data, "LDAP local: %s", (*ldap_err2string)(rc)); + status = CURLE_LDAP_INVALID_URL; + goto quit; + } + + rc = (*ldap_search_s)(server, ludp->lud_dn, ludp->lud_scope, + ludp->lud_filter, ludp->lud_attrs, 0, &result); + + if (rc != 0 && rc != LDAP_SIZELIMIT_EXCEEDED) { + failf(data, "LDAP remote: %s", (*ldap_err2string)(rc)); + status = CURLE_LDAP_SEARCH_FAILED; + goto quit; + } + + for(num = 0, entryIterator = (*ldap_first_entry)(server, result); + entryIterator; + entryIterator = (*ldap_next_entry)(server, entryIterator), num++) + { + void *ber = NULL; /*! is really 'BerElement **' */ + void *attribute; /*! suspicious that this isn't 'const' */ + char *dn = (*ldap_get_dn)(server, entryIterator); + int i; + + Curl_client_write(data, CLIENTWRITE_BODY, (char *)"DN: ", 4); + Curl_client_write(data, CLIENTWRITE_BODY, (char *)dn, 0); + Curl_client_write(data, CLIENTWRITE_BODY, (char *)"\n", 1); + + for (attribute = (*ldap_first_attribute)(server, entryIterator, &ber); + attribute; + attribute = (*ldap_next_attribute)(server, entryIterator, ber)) + { + char **vals = (*ldap_get_values)(server, entryIterator, attribute); + + if (vals != NULL) + { + for (i = 0; (vals[i] != NULL); i++) + { + Curl_client_write(data, CLIENTWRITE_BODY, (char *)"\t", 1); + Curl_client_write(data, CLIENTWRITE_BODY, (char*) attribute, 0); + Curl_client_write(data, CLIENTWRITE_BODY, (char *)": ", 2); + Curl_client_write(data, CLIENTWRITE_BODY, vals[i], 0); + Curl_client_write(data, CLIENTWRITE_BODY, (char *)"\n", 0); + } + + /* Free memory used to store values */ + (*ldap_value_free)(vals); + } + Curl_client_write(data, CLIENTWRITE_BODY, (char *)"\n", 1); + + (*ldap_memfree)(attribute); + (*ldap_memfree)(dn); + } + if (ber) + (*ber_free)(ber, 0); + } + +quit: + LDAP_TRACE (("Received %d entries\n", num)); + if (rc == LDAP_SIZELIMIT_EXCEEDED) + infof(data, "There are more than %d entries\n", num); + if (ludp) + (*ldap_free_urldesc)(ludp); + if (server) + (*ldap_unbind_s)(server); + + DynaClose(); + + /* no data to transfer */ + Curl_Transfer(conn, -1, -1, FALSE, NULL, -1, NULL); + + return status; +} + +#ifdef DEBUG_LDAP +static void _ldap_trace (const char *fmt, ...) +{ + static int do_trace = -1; + va_list args; + + if (do_trace == -1) { + const char *env = getenv("CURL_TRACE"); + do_trace = (env && atoi(env) > 0); + } + if (!do_trace) + return; + + va_start (args, fmt); + vfprintf (stderr, fmt, args); + va_end (args); +} +#endif + +#ifdef WIN32 +/* + * Return scope-value for a scope-string. + */ +static int str2scope (const char *p) +{ + if (!stricmp(p, "one")) + return LDAP_SCOPE_ONELEVEL; + if (!stricmp(p, "onetree")) + return LDAP_SCOPE_ONELEVEL; + if (!stricmp(p, "base")) + return LDAP_SCOPE_BASE; + if (!stricmp(p, "sub")) + return LDAP_SCOPE_SUBTREE; + if (!stricmp( p, "subtree")) + return LDAP_SCOPE_SUBTREE; + return (-1); +} + +/* + * Split 'str' into strings separated by commas. + * Note: res[] points into 'str'. + */ +static char **split_str (char *str) +{ + char **res, *lasts, *s; + int i; + + for (i = 2, s = strchr(str,','); s; i++) + s = strchr(++s,','); + + res = calloc(i, sizeof(char*)); + if (!res) + return NULL; + + for (i = 0, s = strtok_r(str, ",", &lasts); s; + s = strtok_r(NULL, ",", &lasts), i++) + res[i] = s; + return res; +} + +/* + * Unescape the LDAP-URL components + */ +static bool unescape_elements (LDAPURLDesc *ludp) +{ + int i; + + if (ludp->lud_filter) { + ludp->lud_filter = curl_unescape(ludp->lud_filter, 0); + if (!ludp->lud_filter) + return (FALSE); + } + + for (i = 0; ludp->lud_attrs && ludp->lud_attrs[i]; i++) { + ludp->lud_attrs[i] = curl_unescape(ludp->lud_attrs[i], 0); + if (!ludp->lud_attrs[i]) + return (FALSE); + } + + for (i = 0; ludp->lud_exts && ludp->lud_exts[i]; i++) { + ludp->lud_exts[i] = curl_unescape(ludp->lud_exts[i], 0); + if (!ludp->lud_exts[i]) + return (FALSE); + } + + if (ludp->lud_dn) { + char *dn = ludp->lud_dn; + char *new_dn = curl_unescape(dn, 0); + + free(dn); + if (!new_dn) + return (FALSE); + ludp->lud_dn = new_dn; + } + return (TRUE); +} + +/* + * Break apart the pieces of an LDAP URL. + * Syntax: + * ldap://:/???? + * + * already known from 'conn->host.name'. + * already known from 'conn->remote_port'. + * extract the rest from 'conn->path+1'. All fields are optional. e.g. + * ldap://:/??? yields ludp->lud_dn = "". + * + * Ref. http://developer.netscape.com/docs/manuals/dirsdk/csdk30/url.htm#2831915 + */ +static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp) +{ + char *p, *q; + int i; + + if (!conn->path || conn->path[0] != '/' || + !checkprefix(conn->protostr, conn->data->change.url)) + return LDAP_INVALID_SYNTAX; + + ludp->lud_scope = LDAP_SCOPE_BASE; + ludp->lud_port = conn->remote_port; + ludp->lud_host = conn->host.name; + + /* parse DN (Distinguished Name). + */ + ludp->lud_dn = strdup(conn->path+1); + if (!ludp->lud_dn) + return LDAP_NO_MEMORY; + + p = strchr(ludp->lud_dn, '?'); + LDAP_TRACE (("DN '%.*s'\n", p ? (size_t)(p-ludp->lud_dn) : strlen(ludp->lud_dn), + ludp->lud_dn)); + + if (!p) + goto success; + + *p++ = '\0'; + + /* parse attributes. skip "??". + */ + q = strchr(p, '?'); + if (q) + *q++ = '\0'; + + if (*p && *p != '?') { + ludp->lud_attrs = split_str(p); + if (!ludp->lud_attrs) + return LDAP_NO_MEMORY; + + for (i = 0; ludp->lud_attrs[i]; i++) + LDAP_TRACE (("attr[%d] '%s'\n", i, ludp->lud_attrs[i])); + } + + p = q; + if (!p) + goto success; + + /* parse scope. skip "??" + */ + q = strchr(p, '?'); + if (q) + *q++ = '\0'; + + if (*p && *p != '?') { + ludp->lud_scope = str2scope(p); + if (ludp->lud_scope == -1) + return LDAP_INVALID_SYNTAX; + LDAP_TRACE (("scope %d\n", ludp->lud_scope)); + } + + p = q; + if (!p) + goto success; + + /* parse filter + */ + q = strchr(p, '?'); + if (q) + *q++ = '\0'; + if (!*p) + return LDAP_INVALID_SYNTAX; + + ludp->lud_filter = p; + LDAP_TRACE (("filter '%s'\n", ludp->lud_filter)); + + p = q; + if (!p) + goto success; + + /* parse extensions + */ + ludp->lud_exts = split_str(p); + if (!ludp->lud_exts) + return LDAP_NO_MEMORY; + + for (i = 0; ludp->lud_exts[i]; i++) + LDAP_TRACE (("exts[%d] '%s'\n", i, ludp->lud_exts[i])); + +success: + if (!unescape_elements(ludp)) + return LDAP_NO_MEMORY; + return LDAP_SUCCESS; +} + +static int _ldap_url_parse (const struct connectdata *conn, + LDAPURLDesc **ludpp) +{ + LDAPURLDesc *ludp = calloc(sizeof(*ludp), 1); + int rc; + + *ludpp = NULL; + if (!ludp) + return LDAP_NO_MEMORY; + + rc = _ldap_url_parse2 (conn, ludp); + if (rc != LDAP_SUCCESS) { + _ldap_free_urldesc(ludp); + ludp = NULL; + } + *ludpp = ludp; + return (rc); +} + +static void _ldap_free_urldesc (LDAPURLDesc *ludp) +{ + int i; + + if (!ludp) + return; + + if (ludp->lud_dn) + free(ludp->lud_dn); + + if (ludp->lud_filter) + free(ludp->lud_filter); + + if (ludp->lud_attrs) { + for (i = 0; ludp->lud_attrs[i]; i++) + free(ludp->lud_attrs[i]); + free(ludp->lud_attrs); + } + + if (ludp->lud_exts) { + for (i = 0; ludp->lud_exts[i]; i++) + free(ludp->lud_exts[i]); + free(ludp->lud_exts); + } + free (ludp); +} +#endif /* WIN32 */ +#endif /* CURL_DISABLE_LDAP */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/ldap.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/ldap.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/ldap.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/ldap.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,29 @@ +#ifndef __LDAP_H +#define __LDAP_H + +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: ldap.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ +#ifndef CURL_DISABLE_LDAP +CURLcode Curl_ldap(struct connectdata *conn); +#endif +#endif /* __LDAP_H */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/llist.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/llist.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/llist.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/llist.c 2004-10-06 00:42:38.000000000 +0800 @@ -0,0 +1,130 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: llist.c,v 1.5 2004/10/05 16:42:38 hoffman Exp $ + ***************************************************************************/ + +#include "setup.h" + +#include +#include + +#include "llist.h" +#include "curl_memory.h" + +/* this must be the last include file */ +#include "memdebug.h" + +void +Curl_llist_init(curl_llist *l, curl_llist_dtor dtor) +{ + l->size = 0; + l->dtor = dtor; + l->head = NULL; + l->tail = NULL; +} + +curl_llist * +Curl_llist_alloc(curl_llist_dtor dtor) +{ + curl_llist *list; + + list = (curl_llist *)malloc(sizeof(curl_llist)); + if(NULL == list) + return NULL; + + Curl_llist_init(list, dtor); + + return list; +} + +/* + * Curl_llist_insert_next() returns 1 on success and 0 on failure. + */ +int +Curl_llist_insert_next(curl_llist *list, curl_llist_element *e, const void *p) +{ + curl_llist_element *ne = + (curl_llist_element *) malloc(sizeof(curl_llist_element)); + if(!ne) + return 0; + + ne->ptr = (void *) p; + if (list->size == 0) { + list->head = ne; + list->head->prev = NULL; + list->head->next = NULL; + list->tail = ne; + } + else { + ne->next = e->next; + ne->prev = e; + if (e->next) { + e->next->prev = ne; + } + else { + list->tail = ne; + } + e->next = ne; + } + + ++list->size; + + return 1; +} + +int +Curl_llist_remove(curl_llist *list, curl_llist_element *e, void *user) +{ + if (e == NULL || list->size == 0) + return 1; + + if (e == list->head) { + list->head = e->next; + + if (list->head == NULL) + list->tail = NULL; + else + e->next->prev = NULL; + } else { + e->prev->next = e->next; + if (!e->next) + list->tail = e->prev; + else + e->next->prev = e->prev; + } + + list->dtor(user, e->ptr); + free(e); + --list->size; + + return 1; +} + +void +Curl_llist_destroy(curl_llist *list, void *user) +{ + if(list) { + while (list->size > 0) + Curl_llist_remove(list, list->tail, user); + + free(list); + } +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/llist.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/llist.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/llist.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/llist.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,56 @@ +#ifndef __LLIST_H +#define __LLIST_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: llist.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +#include "setup.h" +#include + +typedef void (*curl_llist_dtor)(void *, void *); + +typedef struct _curl_llist_element { + void *ptr; + + struct _curl_llist_element *prev; + struct _curl_llist_element *next; +} curl_llist_element; + +typedef struct _curl_llist { + curl_llist_element *head; + curl_llist_element *tail; + + curl_llist_dtor dtor; + + size_t size; +} curl_llist; + +void Curl_llist_init(curl_llist *, curl_llist_dtor); +curl_llist *Curl_llist_alloc(curl_llist_dtor); +int Curl_llist_insert_next(curl_llist *, curl_llist_element *, const void *); +int Curl_llist_insert_prev(curl_llist *, curl_llist_element *, const void *); +int Curl_llist_remove(curl_llist *, curl_llist_element *, void *); +int Curl_llist_remove_next(curl_llist *, curl_llist_element *, void *); +size_t Curl_llist_count(curl_llist *); +void Curl_llist_destroy(curl_llist *, void *); + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/md5.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/md5.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/md5.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/md5.c 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,348 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: md5.c,v 1.2 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +#include "setup.h" + +#ifndef USE_SSLEAY +/* This code segment is only used if OpenSSL is not provided, as if it is + we use the MD5-function provided there instead. No good duplicating + code! */ + +/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All +rights reserved. + +License to copy and use this software is granted provided that it +is identified as the "RSA Data Security, Inc. MD5 Message-Digest +Algorithm" in all material mentioning or referencing this software +or this function. + +License is also granted to make and use derivative works provided +that such works are identified as "derived from the RSA Data +Security, Inc. MD5 Message-Digest Algorithm" in all material +mentioning or referencing the derived work. + +RSA Data Security, Inc. makes no representations concerning either +the merchantability of this software or the suitability of this +software for any particular purpose. It is provided "as is" +without express or implied warranty of any kind. + +These notices must be retained in any copies of any part of this +documentation and/or software. + */ + +#include + +/* UINT4 defines a four byte word */ +typedef unsigned int UINT4; + +/* MD5 context. */ +struct md5_ctx { + UINT4 state[4]; /* state (ABCD) */ + UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ + unsigned char buffer[64]; /* input buffer */ +}; + +typedef struct md5_ctx MD5_CTX; + +static void MD5_Init(struct md5_ctx *); +static void MD5_Update(struct md5_ctx *, unsigned char *, unsigned int); +static void MD5_Final(unsigned char [16], struct md5_ctx *); + +/* Constants for MD5Transform routine. + */ + +#define S11 7 +#define S12 12 +#define S13 17 +#define S14 22 +#define S21 5 +#define S22 9 +#define S23 14 +#define S24 20 +#define S31 4 +#define S32 11 +#define S33 16 +#define S34 23 +#define S41 6 +#define S42 10 +#define S43 15 +#define S44 21 + +static void MD5Transform(UINT4 [4], unsigned char [64]); +static void Encode(unsigned char *, UINT4 *, unsigned int); +static void Decode(UINT4 *, unsigned char *, unsigned int); + +static unsigned char PADDING[64] = { + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +/* F, G, H and I are basic MD5 functions. + */ +#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) +#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) +#define H(x, y, z) ((x) ^ (y) ^ (z)) +#define I(x, y, z) ((y) ^ ((x) | (~z))) + +/* ROTATE_LEFT rotates x left n bits. + */ +#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) + +/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. +Rotation is separate from addition to prevent recomputation. + */ +#define FF(a, b, c, d, x, s, ac) { \ + (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } +#define GG(a, b, c, d, x, s, ac) { \ + (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } +#define HH(a, b, c, d, x, s, ac) { \ + (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } +#define II(a, b, c, d, x, s, ac) { \ + (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } + +/* MD5 initialization. Begins an MD5 operation, writing a new context. + */ +static void MD5_Init(struct md5_ctx *context) +{ + context->count[0] = context->count[1] = 0; + /* Load magic initialization constants. */ + context->state[0] = 0x67452301; + context->state[1] = 0xefcdab89; + context->state[2] = 0x98badcfe; + context->state[3] = 0x10325476; +} + +/* MD5 block update operation. Continues an MD5 message-digest + operation, processing another message block, and updating the + context. + */ +static void MD5_Update (struct md5_ctx *context, /* context */ + unsigned char *input, /* input block */ + unsigned int inputLen)/* length of input block */ +{ + unsigned int i, bufindex, partLen; + + /* Compute number of bytes mod 64 */ + bufindex = (unsigned int)((context->count[0] >> 3) & 0x3F); + + /* Update number of bits */ + if ((context->count[0] += ((UINT4)inputLen << 3)) + < ((UINT4)inputLen << 3)) + context->count[1]++; + context->count[1] += ((UINT4)inputLen >> 29); + + partLen = 64 - bufindex; + + /* Transform as many times as possible. */ + if (inputLen >= partLen) { + memcpy((void *)&context->buffer[bufindex], (void *)input, partLen); + MD5Transform(context->state, context->buffer); + + for (i = partLen; i + 63 < inputLen; i += 64) + MD5Transform(context->state, &input[i]); + + bufindex = 0; + } + else + i = 0; + + /* Buffer remaining input */ + memcpy((void *)&context->buffer[bufindex], (void *)&input[i], inputLen-i); +} + +/* MD5 finalization. Ends an MD5 message-digest operation, writing the + the message digest and zeroizing the context. +*/ +static void MD5_Final(unsigned char digest[16], /* message digest */ + struct md5_ctx *context) /* context */ +{ + unsigned char bits[8]; + unsigned int count, padLen; + + /* Save number of bits */ + Encode (bits, context->count, 8); + + /* Pad out to 56 mod 64. */ + count = (unsigned int)((context->count[0] >> 3) & 0x3f); + padLen = (count < 56) ? (56 - count) : (120 - count); + MD5_Update (context, PADDING, padLen); + + /* Append length (before padding) */ + MD5_Update (context, bits, 8); + + /* Store state in digest */ + Encode (digest, context->state, 16); + + /* Zeroize sensitive information. */ + memset ((void *)context, 0, sizeof (*context)); +} + +/* MD5 basic transformation. Transforms state based on block. */ +static void MD5Transform(UINT4 state[4], + unsigned char block[64]) +{ + UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; + + Decode (x, block, 64); + + /* Round 1 */ + FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ + FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ + FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ + FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ + FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ + FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ + FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ + FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ + FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ + FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ + FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ + FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ + FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ + FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ + FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ + FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ + + /* Round 2 */ + GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ + GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ + GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ + GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ + GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ + GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */ + GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ + GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ + GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ + GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ + GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ + GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ + GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ + GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ + GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ + GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ + + /* Round 3 */ + HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ + HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ + HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ + HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ + HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ + HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ + HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ + HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ + HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ + HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ + HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ + HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ + HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ + HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ + HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ + HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ + + /* Round 4 */ + II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ + II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ + II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ + II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ + II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ + II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ + II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ + II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ + II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ + II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ + II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ + II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ + II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ + II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ + II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ + II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ + + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + + /* Zeroize sensitive information. */ + memset((void *)x, 0, sizeof (x)); +} + +/* Encodes input (UINT4) into output (unsigned char). Assumes len is + a multiple of 4. + */ +static void Encode (unsigned char *output, + UINT4 *input, + unsigned int len) +{ + unsigned int i, j; + + for (i = 0, j = 0; j < len; i++, j += 4) { + output[j] = (unsigned char)(input[i] & 0xff); + output[j+1] = (unsigned char)((input[i] >> 8) & 0xff); + output[j+2] = (unsigned char)((input[i] >> 16) & 0xff); + output[j+3] = (unsigned char)((input[i] >> 24) & 0xff); + } +} + +/* Decodes input (unsigned char) into output (UINT4). Assumes len is + a multiple of 4. +*/ +static void Decode (UINT4 *output, + unsigned char *input, + unsigned int len) +{ + unsigned int i, j; + + for (i = 0, j = 0; j < len; i++, j += 4) + output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | + (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24); +} + +#else +/* If OpenSSL is present */ +#include +#include +#endif + +#include "md5.h" + +void Curl_md5it(unsigned char *outbuffer, /* 16 bytes */ + unsigned char *input) +{ + MD5_CTX ctx; + MD5_Init(&ctx); + MD5_Update(&ctx, input, strlen((char *)input)); + MD5_Final(outbuffer, &ctx); +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/md5.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/md5.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/md5.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/md5.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,29 @@ +#ifndef __MD5_H +#define __MD5_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: md5.h,v 1.2 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +void Curl_md5it(unsigned char *output, + unsigned char *input); + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/memdebug.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/memdebug.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/memdebug.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/memdebug.c 2004-10-06 00:42:38.000000000 +0800 @@ -0,0 +1,293 @@ +#ifdef CURLDEBUG +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: memdebug.c,v 1.5 2004/10/05 16:42:38 hoffman Exp $ + ***************************************************************************/ + +#include "setup.h" + +#include + +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + +#define _MPRINTF_REPLACE +#include +#include "urldata.h" +#include +#include +#include + +#ifdef HAVE_UNISTD_H +#include +#endif + +#define MEMDEBUG_NODEFINES /* don't redefine the standard functions */ +#include "curl_memory.h" +#include "memdebug.h" + +struct memdebug { + size_t size; + double mem[1]; + /* I'm hoping this is the thing with the strictest alignment + * requirements. That also means we waste some space :-( */ +}; + +/* + * Note that these debug functions are very simple and they are meant to + * remain so. For advanced analysis, record a log file and write perl scripts + * to analyze them! + * + * Don't use these with multithreaded test programs! + */ + +#define logfile curl_debuglogfile +FILE *curl_debuglogfile; +static bool memlimit; /* enable memory limit */ +static long memsize; /* set number of mallocs allowed */ + +/* this sets the log file name */ +void curl_memdebug(const char *logname) +{ + if(logname) + logfile = fopen(logname, "w"); + else + logfile = stderr; +} + +/* This function sets the number of malloc() calls that should return + successfully! */ +void curl_memlimit(long limit) +{ + memlimit = TRUE; + memsize = limit; +} + +/* returns TRUE if this isn't allowed! */ +static bool countcheck(const char *func, int line, const char *source) +{ + /* if source is NULL, then the call is made internally and this check + should not be made */ + if(memlimit && source) { + if(!memsize) { + if(logfile && source) + fprintf(logfile, "LIMIT %s:%d %s reached memlimit\n", + source, line, func); + if(source) + fprintf(stderr, "LIMIT %s:%d %s reached memlimit\n", + source, line, func); + return TRUE; /* RETURN ERROR! */ + } + else + memsize--; /* countdown */ + + /* log the countdown */ + if(logfile && source) + fprintf(logfile, "LIMIT %s:%d %ld ALLOCS left\n", + source, line, memsize); + + } + + return FALSE; /* allow this */ +} + +void *curl_domalloc(size_t wantedsize, int line, const char *source) +{ + struct memdebug *mem; + size_t size; + + if(countcheck("malloc", line, source)) + return NULL; + + /* alloc at least 64 bytes */ + size = sizeof(struct memdebug)+wantedsize; + + mem=(struct memdebug *)(Curl_cmalloc)(size); + if(mem) { + /* fill memory with junk */ + memset(mem->mem, 0xA5, wantedsize); + mem->size = wantedsize; + } + + if(logfile && source) + fprintf(logfile, "MEM %s:%d malloc(%zd) = %p\n", + source, line, wantedsize, mem ? mem->mem : 0); + return (mem ? mem->mem : NULL); +} + +void *curl_docalloc(size_t wanted_elements, size_t wanted_size, + int line, const char *source) +{ + struct memdebug *mem; + size_t size, user_size; + + if(countcheck("calloc", line, source)) + return NULL; + + /* alloc at least 64 bytes */ + user_size = wanted_size * wanted_elements; + size = sizeof(struct memdebug) + user_size; + + mem = (struct memdebug *)(Curl_cmalloc)(size); + if(mem) { + /* fill memory with zeroes */ + memset(mem->mem, 0, user_size); + mem->size = user_size; + } + + if(logfile && source) + fprintf(logfile, "MEM %s:%d calloc(%u,%u) = %p\n", + source, line, wanted_elements, wanted_size, mem ? mem->mem : 0); + return (mem ? mem->mem : NULL); +} + +char *curl_dostrdup(const char *str, int line, const char *source) +{ + char *mem; + size_t len; + + curlassert(str != NULL); + + if(countcheck("strdup", line, source)) + return NULL; + + len=strlen(str)+1; + + mem=curl_domalloc(len, 0, NULL); /* NULL prevents logging */ + if (mem) + memcpy(mem, str, len); + + if(logfile) + fprintf(logfile, "MEM %s:%d strdup(%p) (%zd) = %p\n", + source, line, str, len, mem); + + return mem; +} + +/* We provide a realloc() that accepts a NULL as pointer, which then + performs a malloc(). In order to work with ares. */ +void *curl_dorealloc(void *ptr, size_t wantedsize, + int line, const char *source) +{ + struct memdebug *mem=NULL; + + size_t size = sizeof(struct memdebug)+wantedsize; + + if(countcheck("realloc", line, source)) + return NULL; + + if(ptr) + mem = (struct memdebug *)((char *)ptr - offsetof(struct memdebug, mem)); + + mem=(struct memdebug *)(Curl_crealloc)(mem, size); + if(logfile) + fprintf(logfile, "MEM %s:%d realloc(0x%x, %zd) = %p\n", + source, line, ptr, wantedsize, mem?mem->mem:NULL); + + if(mem) { + mem->size = wantedsize; + return mem->mem; + } + + return NULL; +} + +void curl_dofree(void *ptr, int line, const char *source) +{ + struct memdebug *mem; + + curlassert(ptr != NULL); + + mem = (struct memdebug *)((char *)ptr - offsetof(struct memdebug, mem)); + + /* destroy */ + memset(mem->mem, 0x13, mem->size); + + /* free for real */ + (Curl_cfree)(mem); + + if(logfile) + fprintf(logfile, "MEM %s:%d free(%p)\n", source, line, ptr); +} + +int curl_socket(int domain, int type, int protocol, int line, + const char *source) +{ + int sockfd=(socket)(domain, type, protocol); + if(logfile && (sockfd!=-1)) + fprintf(logfile, "FD %s:%d socket() = %d\n", + source, line, sockfd); + return sockfd; +} + +int curl_accept(int s, void *saddr, void *saddrlen, + int line, const char *source) +{ + struct sockaddr *addr = (struct sockaddr *)saddr; + socklen_t *addrlen = (socklen_t *)saddrlen; + int sockfd=(accept)(s, addr, addrlen); + if(logfile) + fprintf(logfile, "FD %s:%d accept() = %d\n", + source, line, sockfd); + return sockfd; +} + +/* this is our own defined way to close sockets on *ALL* platforms */ +int curl_sclose(int sockfd, int line, const char *source) +{ + int res=sclose(sockfd); + if(logfile) + fprintf(logfile, "FD %s:%d sclose(%d)\n", + source, line, sockfd); + return res; +} + +FILE *curl_fopen(const char *file, const char *mode, + int line, const char *source) +{ + FILE *res=(fopen)(file, mode); + if(logfile) + fprintf(logfile, "FILE %s:%d fopen(\"%s\",\"%s\") = %p\n", + source, line, file, mode, res); + return res; +} + +int curl_fclose(FILE *file, int line, const char *source) +{ + int res; + + curlassert(file != NULL); + + res=(fclose)(file); + if(logfile) + fprintf(logfile, "FILE %s:%d fclose(%p)\n", + source, line, file); + return res; +} +#else +#ifdef VMS +int VOID_VAR_MEMDEBUG; +#else +/* we provide a fake do-nothing function here to avoid compiler warnings */ +void curl_memdebug(void) {} +#endif /* VMS */ +#endif /* CURLDEBUG */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/memdebug.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/memdebug.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/memdebug.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/memdebug.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,108 @@ +#ifdef CURLDEBUG +#ifndef _CURL_MEDEBUG_H +#define _CURL_MEDEBUG_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: memdebug.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +/* + * CAUTION: this header is designed to work when included by the app-side + * as well as the library. Do not mix with library internals! + */ + +#include "setup.h" + +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#include +#ifdef HAVE_MEMORY_H +#include +#endif + +#define logfile curl_debuglogfile + +extern FILE *logfile; + +/* memory functions */ +void *curl_domalloc(size_t size, int line, const char *source); +void *curl_docalloc(size_t elements, size_t size, int line, const char *source); +void *curl_dorealloc(void *ptr, size_t size, int line, const char *source); +void curl_dofree(void *ptr, int line, const char *source); +char *curl_dostrdup(const char *str, int line, const char *source); +void curl_memdebug(const char *logname); +void curl_memlimit(long limit); + +/* file descriptor manipulators */ +int curl_socket(int domain, int type, int protocol, int line , const char *); +int curl_sclose(int sockfd, int, const char *source); +int curl_accept(int s, void *addr, void *addrlen, + int line, const char *source); + +/* FILE functions */ +FILE *curl_fopen(const char *file, const char *mode, int line, + const char *source); +int curl_fclose(FILE *file, int line, const char *source); + +#ifndef MEMDEBUG_NODEFINES + +/* Set this symbol on the command-line, recompile all lib-sources */ +#undef strdup +#define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__) +#define malloc(size) curl_domalloc(size, __LINE__, __FILE__) +#define calloc(nbelem,size) curl_docalloc(nbelem, size, __LINE__, __FILE__) +#define realloc(ptr,size) curl_dorealloc(ptr, size, __LINE__, __FILE__) +#define free(ptr) curl_dofree(ptr, __LINE__, __FILE__) + +#define socket(domain,type,protocol)\ + curl_socket(domain,type,protocol,__LINE__,__FILE__) +#undef accept /* for those with accept as a macro */ +#define accept(sock,addr,len)\ + curl_accept(sock,addr,len,__LINE__,__FILE__) + +#define getaddrinfo(host,serv,hint,res) \ + curl_dogetaddrinfo(host,serv,hint,res,__LINE__,__FILE__) +#define getnameinfo(sa,salen,host,hostlen,serv,servlen,flags) \ + curl_dogetnameinfo(sa,salen,host,hostlen,serv,servlen,flags, __LINE__, \ + __FILE__) +#define freeaddrinfo(data) \ + curl_dofreeaddrinfo(data,__LINE__,__FILE__) + +/* sclose is probably already defined, redefine it! */ +#undef sclose +#define sclose(sockfd) curl_sclose(sockfd,__LINE__,__FILE__) +/* ares-adjusted define: */ +#undef closesocket +#define closesocket(sockfd) curl_sclose(sockfd,__LINE__,__FILE__) + +#undef fopen +#define fopen(file,mode) curl_fopen(file,mode,__LINE__,__FILE__) +#define fclose(file) curl_fclose(file,__LINE__,__FILE__) + +#endif /* MEMDEBUG_NODEFINES */ + +#endif /* _CURL_MEDEBUG_H */ +#endif /* CURLDEBUG */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/mprintf.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/mprintf.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/mprintf.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/mprintf.c 2004-10-13 22:45:30.000000000 +0800 @@ -0,0 +1,1219 @@ +/**************************************************************************** + * + * $Id: mprintf.c,v 1.8 2004/10/13 14:45:30 andy Exp $ + * + ************************************************************************* + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND + * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. + * + * Purpose: + * A merge of Bjorn Reese's format() function and Daniel's dsprintf() + * 1.0. A full blooded printf() clone with full support for $ + * everywhere (parameters, widths and precisions) including variabled + * sized parameters (like doubles, long longs, long doubles and even + * void * in 64-bit architectures). + * + * Current restrictions: + * - Max 128 parameters + * - No 'long double' support. + * + * If you ever want truly portable and good *printf() clones, the project that + * took on from here is named 'Trio' and you find more details on the trio web + * page at http://daniel.haxx.se/trio/ + */ + + +#include "setup.h" +#include +#include +#include +#include +#include +#include + +#include + +#ifndef SIZEOF_LONG_DOUBLE +#define SIZEOF_LONG_DOUBLE 0 +#endif + +#ifndef SIZEOF_SIZE_T +/* default to 4 bytes for size_t unless defined in the config.h */ +#define SIZEOF_SIZE_T 4 +#endif + +#ifdef DPRINTF_DEBUG +#define HAVE_LONGLONG +#define LONG_LONG long long +#define ENABLE_64BIT +#endif + +#include "curl_memory.h" +/* The last #include file should be: */ +#include "memdebug.h" + +#define BUFFSIZE 256 /* buffer for long-to-str and float-to-str calcs */ +#define MAX_PARAMETERS 128 /* lame static limit */ + +#undef TRUE +#undef FALSE +#undef BOOL +#ifdef __cplusplus +# define TRUE true +# define FALSE false +# define BOOL bool +#else +# define TRUE ((char)(1 == 1)) +# define FALSE ((char)(0 == 1)) +# define BOOL char +#endif + + +/* Lower-case digits. */ +static const char lower_digits[] = "0123456789abcdefghijklmnopqrstuvwxyz"; + +/* Upper-case digits. */ +static const char upper_digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + +#define OUTCHAR(x) \ + do{ \ + if(stream((unsigned char)(x), (FILE *)data) != -1) \ + done++; \ + else \ + return done; /* return immediately on failure */ \ + } while(0) + +/* Data type to read from the arglist */ +typedef enum { + FORMAT_UNKNOWN = 0, + FORMAT_STRING, + FORMAT_PTR, + FORMAT_INT, + FORMAT_INTPTR, + FORMAT_LONG, + FORMAT_LONGLONG, + FORMAT_DOUBLE, + FORMAT_LONGDOUBLE, + FORMAT_WIDTH /* For internal use */ +} FormatType; + +/* convertion and display flags */ +enum { + FLAGS_NEW = 0, + FLAGS_SPACE = 1<<0, + FLAGS_SHOWSIGN = 1<<1, + FLAGS_LEFT = 1<<2, + FLAGS_ALT = 1<<3, + FLAGS_SHORT = 1<<4, + FLAGS_LONG = 1<<5, + FLAGS_LONGLONG = 1<<6, + FLAGS_LONGDOUBLE = 1<<7, + FLAGS_PAD_NIL = 1<<8, + FLAGS_UNSIGNED = 1<<9, + FLAGS_OCTAL = 1<<10, + FLAGS_HEX = 1<<11, + FLAGS_UPPER = 1<<12, + FLAGS_WIDTH = 1<<13, /* '*' or '*$' used */ + FLAGS_WIDTHPARAM = 1<<14, /* width PARAMETER was specified */ + FLAGS_PREC = 1<<15, /* precision was specified */ + FLAGS_PRECPARAM = 1<<16, /* precision PARAMETER was specified */ + FLAGS_CHAR = 1<<17, /* %c story */ + FLAGS_FLOATE = 1<<18, /* %e or %E */ + FLAGS_FLOATG = 1<<19 /* %g or %G */ +}; + +typedef struct { + FormatType type; + int flags; + long width; /* width OR width parameter number */ + long precision; /* precision OR precision parameter number */ + union { + char *str; + void *ptr; + long num; +#ifdef ENABLE_64BIT + LONG_LONG lnum; +#endif + double dnum; + } data; +} va_stack_t; + +struct nsprintf { + char *buffer; + size_t length; + size_t max; +}; + +struct asprintf { + char *buffer; /* allocated buffer */ + size_t len; /* length of string */ + size_t alloc; /* length of alloc */ + bool fail; /* TRUE if an alloc has failed and thus the output is not + the complete data */ +}; + +int curl_msprintf(char *buffer, const char *format, ...); + +static long dprintf_DollarString(char *input, char **end) +{ + int number=0; + while(isdigit((int)*input)) { + number *= 10; + number += *input-'0'; + input++; + } + if(number && ('$'==*input++)) { + *end = input; + return number; + } + return 0; +} + +static BOOL dprintf_IsQualifierNoDollar(char c) +{ + switch (c) { + case '-': case '+': case ' ': case '#': case '.': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case 'h': case 'l': case 'L': case 'z': case 'q': + case '*': case 'O': + return TRUE; + default: + return FALSE; + } +} + +#ifdef DPRINTF_DEBUG2 +int dprintf_Pass1Report(va_stack_t *vto, int max) +{ + int i; + char buffer[128]; + int bit; + int flags; + + for(i=0; i max_param) + max_param = this_param; + + /* + * The parameter with number 'i' should be used. Next, we need + * to get SIZE and TYPE of the parameter. Add the information + * to our array. + */ + + width = 0; + precision = 0; + + /* Handle the flags */ + + while (dprintf_IsQualifierNoDollar(*fmt)) { + switch (*fmt++) { + case ' ': + flags |= FLAGS_SPACE; + break; + case '+': + flags |= FLAGS_SHOWSIGN; + break; + case '-': + flags |= FLAGS_LEFT; + flags &= ~FLAGS_PAD_NIL; + break; + case '#': + flags |= FLAGS_ALT; + break; + case '.': + flags |= FLAGS_PREC; + if ('*' == *fmt) { + /* The precision is picked from a specified parameter */ + + flags |= FLAGS_PRECPARAM; + fmt++; + param_num++; + + i = dprintf_DollarString(fmt, &fmt); + if (i) + precision = i; + else + precision = param_num; + + if (precision > max_param) + max_param = precision; + } + else { + flags |= FLAGS_PREC; + precision = strtol(fmt, &fmt, 10); + } + break; + case 'h': + flags |= FLAGS_SHORT; + break; + case 'l': + if (flags & FLAGS_LONG) + flags |= FLAGS_LONGLONG; + else + flags |= FLAGS_LONG; + break; + case 'L': + flags |= FLAGS_LONGDOUBLE; + break; + case 'q': + flags |= FLAGS_LONGLONG; + break; + case 'z': + /* the code below generates a warning if -Wunreachable-code is + used */ +#if SIZEOF_SIZE_T>4 + flags |= FLAGS_LONGLONG; +#else + flags |= FLAGS_LONG; +#endif + break; + case 'O': +#if SIZEOF_CURL_OFF_T > 4 + flags |= FLAGS_LONGLONG; +#else + flags |= FLAGS_LONG; +#endif + break; + case '0': + if (!(flags & FLAGS_LEFT)) + flags |= FLAGS_PAD_NIL; + /* FALLTHROUGH */ + case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + flags |= FLAGS_WIDTH; + width = strtol(fmt-1, &fmt, 10); + break; + case '*': /* Special case */ + flags |= FLAGS_WIDTHPARAM; + param_num++; + + i = dprintf_DollarString(fmt, &fmt); + if(i) + width = i; + else + width = param_num; + if(width > max_param) + max_param=width; + break; + default: + break; + } + } /* switch */ + + /* Handle the specifier */ + + i = this_param - 1; + + switch (*fmt) { + case 'S': + flags |= FLAGS_ALT; + /* FALLTHROUGH */ + case 's': + vto[i].type = FORMAT_STRING; + break; + case 'n': + vto[i].type = FORMAT_INTPTR; + break; + case 'p': + vto[i].type = FORMAT_PTR; + break; + case 'd': case 'i': + vto[i].type = FORMAT_INT; + break; + case 'u': + vto[i].type = FORMAT_INT; + flags |= FLAGS_UNSIGNED; + break; + case 'o': + vto[i].type = FORMAT_INT; + flags |= FLAGS_OCTAL; + break; + case 'x': + vto[i].type = FORMAT_INT; + flags |= FLAGS_HEX; + break; + case 'X': + vto[i].type = FORMAT_INT; + flags |= FLAGS_HEX|FLAGS_UPPER; + break; + case 'c': + vto[i].type = FORMAT_INT; + flags |= FLAGS_CHAR; + break; + case 'f': + vto[i].type = FORMAT_DOUBLE; + break; + case 'e': + vto[i].type = FORMAT_DOUBLE; + flags |= FLAGS_FLOATE; + break; + case 'E': + vto[i].type = FORMAT_DOUBLE; + flags |= FLAGS_FLOATE|FLAGS_UPPER; + break; + case 'g': + vto[i].type = FORMAT_DOUBLE; + flags |= FLAGS_FLOATG; + break; + case 'G': + vto[i].type = FORMAT_DOUBLE; + flags |= FLAGS_FLOATG|FLAGS_UPPER; + break; + default: + vto[i].type = FORMAT_UNKNOWN; + break; + } /* switch */ + + vto[i].flags = flags; + vto[i].width = width; + vto[i].precision = precision; + + if (flags & FLAGS_WIDTHPARAM) { + /* we have the width specified from a parameter, so we make that + parameter's info setup properly */ + vto[i].width = width - 1; + i = width - 1; + vto[i].type = FORMAT_WIDTH; + vto[i].flags = FLAGS_NEW; + vto[i].precision = vto[i].width = 0; /* can't use width or precision + of width! */ + } + if (flags & FLAGS_PRECPARAM) { + /* we have the precision specified from a parameter, so we make that + parameter's info setup properly */ + vto[i].precision = precision - 1; + i = precision - 1; + vto[i].type = FORMAT_WIDTH; + vto[i].flags = FLAGS_NEW; + vto[i].precision = vto[i].width = 0; /* can't use width or precision + of width! */ + } + *endpos++ = fmt + 1; /* end of this sequence */ + } + } + +#ifdef DPRINTF_DEBUG2 + dprintf_Pass1Report(vto, max_param); +#endif + + /* Read the arg list parameters into our data list */ + for (i=0; i$ sequence */ + param=dprintf_DollarString(f, &f); + + if(!param) + param = param_num; + else + --param; + + param_num++; /* increase this always to allow "%2$s %1$s %s" and then the + third %s will pick the 3rd argument */ + + p = &vto[param]; + + /* pick up the specified width */ + if(p->flags & FLAGS_WIDTHPARAM) + width = vto[p->width].data.num; + else + width = p->width; + + /* pick up the specified precision */ + if(p->flags & FLAGS_PRECPARAM) + prec = vto[p->precision].data.num; + else if(p->flags & FLAGS_PREC) + prec = p->precision; + else + prec = -1; + + alt = (p->flags & FLAGS_ALT)?TRUE:FALSE; + + switch (p->type) { + case FORMAT_INT: + num = p->data.num; + if(p->flags & FLAGS_CHAR) { + /* Character. */ + if (!(p->flags & FLAGS_LEFT)) + while (--width > 0) + OUTCHAR(' '); + OUTCHAR((char) num); + if (p->flags & FLAGS_LEFT) + while (--width > 0) + OUTCHAR(' '); + break; + } + if(p->flags & FLAGS_UNSIGNED) { + /* Decimal unsigned integer. */ + base = 10; + goto unsigned_number; + } + if(p->flags & FLAGS_OCTAL) { + /* Octal unsigned integer. */ + base = 8; + goto unsigned_number; + } + if(p->flags & FLAGS_HEX) { + /* Hexadecimal unsigned integer. */ + + digits = (p->flags & FLAGS_UPPER)? upper_digits : lower_digits; + base = 16; + goto unsigned_number; + } + + /* Decimal integer. */ + base = 10; + +#ifdef ENABLE_64BIT + if(p->flags & FLAGS_LONGLONG) { + /* long long */ + is_neg = p->data.lnum < 0; + num = is_neg ? (- p->data.lnum) : p->data.lnum; + } + else +#endif + { + signed_num = (long) num; + is_neg = signed_num < 0; + num = is_neg ? (- signed_num) : signed_num; + } + goto number; + + unsigned_number: + /* Unsigned number of base BASE. */ + is_neg = 0; + + number: + /* Number of base BASE. */ + { + char *workend = &work[sizeof(work) - 1]; + char *w; + + /* Supply a default precision if none was given. */ + if (prec == -1) + prec = 1; + + /* Put the number in WORK. */ + w = workend; + while (num > 0) { + *w-- = digits[num % base]; + num /= base; + } + width -= workend - w; + prec -= workend - w; + + if (alt && base == 8 && prec <= 0) { + *w-- = '0'; + --width; + } + + if (prec > 0) { + width -= prec; + while (prec-- > 0) + *w-- = '0'; + } + + if (alt && base == 16) + width -= 2; + + if (is_neg || (p->flags & FLAGS_SHOWSIGN) || (p->flags & FLAGS_SPACE)) + --width; + + if (!(p->flags & FLAGS_LEFT) && !(p->flags & FLAGS_PAD_NIL)) + while (width-- > 0) + OUTCHAR(' '); + + if (is_neg) + OUTCHAR('-'); + else if (p->flags & FLAGS_SHOWSIGN) + OUTCHAR('+'); + else if (p->flags & FLAGS_SPACE) + OUTCHAR(' '); + + if (alt && base == 16) { + OUTCHAR('0'); + if(p->flags & FLAGS_UPPER) + OUTCHAR('X'); + else + OUTCHAR('x'); + } + + if (!(p->flags & FLAGS_LEFT) && (p->flags & FLAGS_PAD_NIL)) + while (width-- > 0) + OUTCHAR('0'); + + /* Write the number. */ + while (++w <= workend) { + OUTCHAR(*w); + } + + if (p->flags & FLAGS_LEFT) + while (width-- > 0) + OUTCHAR(' '); + } + break; + + case FORMAT_STRING: + /* String. */ + { + static char null[] = "(nil)"; + char *str; + size_t len; + + str = (char *) p->data.str; + if ( str == NULL) { + /* Write null[] if there's space. */ + if (prec == -1 || prec >= (long) sizeof(null) - 1) { + str = null; + len = sizeof(null) - 1; + /* Disable quotes around (nil) */ + p->flags &= (~FLAGS_ALT); + } + else { + str = (char *)""; + len = 0; + } + } + else + len = strlen(str); + + if (prec != -1 && (size_t) prec < len) + len = prec; + width -= len; + + if (p->flags & FLAGS_ALT) + OUTCHAR('"'); + + if (!(p->flags&FLAGS_LEFT)) + while (width-- > 0) + OUTCHAR(' '); + + while (len-- > 0) + OUTCHAR(*str++); + if (p->flags&FLAGS_LEFT) + while (width-- > 0) + OUTCHAR(' '); + + if (p->flags & FLAGS_ALT) + OUTCHAR('"'); + } + break; + + case FORMAT_PTR: + /* Generic pointer. */ + { + void *ptr; + ptr = (void *) p->data.ptr; + if (ptr != NULL) { + /* If the pointer is not NULL, write it as a %#x spec. */ + base = 16; + digits = (p->flags & FLAGS_UPPER)? upper_digits : lower_digits; + alt = 1; + num = (unsigned long) ptr; + is_neg = 0; + goto number; + } + else { + /* Write "(nil)" for a nil pointer. */ + static char strnil[] = "(nil)"; + char *point; + + width -= sizeof(strnil) - 1; + if (p->flags & FLAGS_LEFT) + while (width-- > 0) + OUTCHAR(' '); + for (point = strnil; *point != '\0'; ++point) + OUTCHAR(*point); + if (! (p->flags & FLAGS_LEFT)) + while (width-- > 0) + OUTCHAR(' '); + } + } + break; + + case FORMAT_DOUBLE: + { + char formatbuf[32]="%"; + char *fptr; + size_t left = sizeof(formatbuf)-strlen(formatbuf); + int len; + + width = -1; + if (p->flags & FLAGS_WIDTH) + width = p->width; + else if (p->flags & FLAGS_WIDTHPARAM) + width = vto[p->width].data.num; + + prec = -1; + if (p->flags & FLAGS_PREC) + prec = p->precision; + else if (p->flags & FLAGS_PRECPARAM) + prec = vto[p->precision].data.num; + + if (p->flags & FLAGS_LEFT) + strcat(formatbuf, "-"); + if (p->flags & FLAGS_SHOWSIGN) + strcat(formatbuf, "+"); + if (p->flags & FLAGS_SPACE) + strcat(formatbuf, " "); + if (p->flags & FLAGS_ALT) + strcat(formatbuf, "#"); + + fptr=&formatbuf[strlen(formatbuf)]; + + if(width >= 0) { + /* RECURSIVE USAGE */ + len = curl_msnprintf(fptr, left, "%ld", width); + fptr += len; + left -= len; + } + if(prec >= 0) { + /* RECURSIVE USAGE */ + len = curl_msnprintf(fptr, left, ".%ld", prec); + fptr += len; + left -= len; + } + (void)left; + if (p->flags & FLAGS_LONG) + *fptr++ = 'l'; + + if (p->flags & FLAGS_FLOATE) + *fptr++ = p->flags&FLAGS_UPPER ? 'E':'e'; + else if (p->flags & FLAGS_FLOATG) + *fptr++ = p->flags & FLAGS_UPPER ? 'G' : 'g'; + else + *fptr++ = 'f'; + + *fptr = 0; /* and a final zero termination */ + + /* NOTE NOTE NOTE!! Not all sprintf() implementations returns number + of output characters */ + (sprintf)(work, formatbuf, p->data.dnum); + + for(fptr=work; *fptr; fptr++) + OUTCHAR(*fptr); + } + break; + + case FORMAT_INTPTR: + /* Answer the count of characters written. */ +#ifdef ENABLE_64BIT + if (p->flags & FLAGS_LONGLONG) + *(LONG_LONG *) p->data.ptr = (LONG_LONG)done; + else +#endif + if (p->flags & FLAGS_LONG) + *(long *) p->data.ptr = (long)done; + else if (!(p->flags & FLAGS_SHORT)) + *(int *) p->data.ptr = (int)done; + else + *(short *) p->data.ptr = (short)done; + break; + + default: + break; + } + f = *end++; /* goto end of %-code */ + + } + return done; +} + +/* fputc() look-alike */ +static int addbyter(int output, FILE *data) +{ + struct nsprintf *infop=(struct nsprintf *)data; + unsigned char outc = (unsigned char)output; + + if(infop->length < infop->max) { + /* only do this if we haven't reached max length yet */ + infop->buffer[0] = outc; /* store */ + infop->buffer++; /* increase pointer */ + infop->length++; /* we are now one byte larger */ + return outc; /* fputc() returns like this on success */ + } + return -1; +} + +int curl_mvsnprintf(char *buffer, size_t maxlength, const char *format, + va_list ap_save) +{ + int retcode; + struct nsprintf info; + + info.buffer = buffer; + info.length = 0; + info.max = maxlength; + + retcode = dprintf_formatf(&info, addbyter, format, ap_save); + if(info.max) { + /* we terminate this with a zero byte */ + if(info.max == info.length) + /* we're at maximum, scrap the last letter */ + info.buffer[-1] = 0; + else + info.buffer[0] = 0; + } + return retcode; +} + +int curl_msnprintf(char *buffer, size_t maxlength, const char *format, ...) +{ + int retcode; + va_list ap_save; /* argument pointer */ + va_start(ap_save, format); + retcode = curl_mvsnprintf(buffer, maxlength, format, ap_save); + va_end(ap_save); + return retcode; +} + +/* fputc() look-alike */ +static int alloc_addbyter(int output, FILE *data) +{ + struct asprintf *infop=(struct asprintf *)data; + unsigned char outc = (unsigned char)output; + + if(!infop->buffer) { + infop->buffer=(char *)malloc(32); + if(!infop->buffer) { + infop->fail = TRUE; + return -1; /* fail */ + } + infop->alloc = 32; + infop->len =0; + } + else if(infop->len+1 >= infop->alloc) { + char *newptr; + + newptr = (char *)realloc(infop->buffer, infop->alloc*2); + + if(!newptr) { + infop->fail = TRUE; + return -1; + } + infop->buffer = newptr; + infop->alloc *= 2; + } + + infop->buffer[ infop->len ] = outc; + + infop->len++; + + return outc; /* fputc() returns like this on success */ +} + +char *curl_maprintf(const char *format, ...) +{ + va_list ap_save; /* argument pointer */ + int retcode; + struct asprintf info; + + info.buffer = NULL; + info.len = 0; + info.alloc = 0; + info.fail = FALSE; + + va_start(ap_save, format); + retcode = dprintf_formatf(&info, alloc_addbyter, format, ap_save); + va_end(ap_save); + if((-1 == retcode) || info.fail) { + if(info.alloc) + free(info.buffer); + return NULL; + } + if(info.alloc) { + info.buffer[info.len] = 0; /* we terminate this with a zero byte */ + return info.buffer; + } + else + return strdup(""); +} + +char *curl_mvaprintf(const char *format, va_list ap_save) +{ + int retcode; + struct asprintf info; + + info.buffer = NULL; + info.len = 0; + info.alloc = 0; + info.fail = FALSE; + + retcode = dprintf_formatf(&info, alloc_addbyter, format, ap_save); + if((-1 == retcode) || info.fail) { + if(info.alloc) + free(info.buffer); + return NULL; + } + + if(info.alloc) { + info.buffer[info.len] = 0; /* we terminate this with a zero byte */ + return info.buffer; + } + else + return strdup(""); +} + +static int storebuffer(int output, FILE *data) +{ + char **buffer = (char **)data; + unsigned char outc = (unsigned char)output; + **buffer = outc; + (*buffer)++; + return outc; /* act like fputc() ! */ +} + +int curl_msprintf(char *buffer, const char *format, ...) +{ + va_list ap_save; /* argument pointer */ + int retcode; + va_start(ap_save, format); + retcode = dprintf_formatf(&buffer, storebuffer, format, ap_save); + va_end(ap_save); + *buffer=0; /* we terminate this with a zero byte */ + return retcode; +} + +#ifndef WIN32 /* not needed on win32 */ +extern int fputc(int, FILE *); +#endif + +int curl_mprintf(const char *format, ...) +{ + int retcode; + va_list ap_save; /* argument pointer */ + va_start(ap_save, format); + retcode = dprintf_formatf(stdout, fputc, format, ap_save); + va_end(ap_save); + return retcode; +} + +int curl_mfprintf(FILE *whereto, const char *format, ...) +{ + int retcode; + va_list ap_save; /* argument pointer */ + va_start(ap_save, format); + retcode = dprintf_formatf(whereto, fputc, format, ap_save); + va_end(ap_save); + return retcode; +} + +int curl_mvsprintf(char *buffer, const char *format, va_list ap_save) +{ + int retcode; + retcode = dprintf_formatf(&buffer, storebuffer, format, ap_save); + *buffer=0; /* we terminate this with a zero byte */ + return retcode; +} + +int curl_mvprintf(const char *format, va_list ap_save) +{ + return dprintf_formatf(stdout, fputc, format, ap_save); +} + +int curl_mvfprintf(FILE *whereto, const char *format, va_list ap_save) +{ + return dprintf_formatf(whereto, fputc, format, ap_save); +} + +#ifdef DPRINTF_DEBUG +int main() +{ + char buffer[129]; + char *ptr; +#ifdef ENABLE_64BIT + long long one=99; + long long two=100; + long long test = 0x1000000000LL; + curl_mprintf("%lld %lld %lld\n", one, two, test); +#endif + + curl_mprintf("%3d %5d\n", 10, 1998); + + ptr=curl_maprintf("test this then baby %s%s%s%s%s%s %d %d %d loser baby get a hit in yer face now!", "", "pretty long string pretty long string pretty long string pretty long string pretty long string", "/", "/", "/", "pretty long string", 1998, 1999, 2001); + + puts(ptr); + + memset(ptr, 55, strlen(ptr)+1); + + free(ptr); + +#if 1 + curl_mprintf(buffer, "%s %s %d", "daniel", "stenberg", 19988); + puts(buffer); + + curl_mfprintf(stderr, "%s %#08x\n", "dummy", 65); + + printf("%s %#08x\n", "dummy", 65); + { + double tryout = 3.14156592; + curl_mprintf(buffer, "%.2g %G %f %e %E", tryout, tryout, tryout, tryout, tryout); + puts(buffer); + printf("%.2g %G %f %e %E\n", tryout, tryout, tryout, tryout, tryout); + } +#endif + + return 0; +} + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/multi.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/multi.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/multi.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/multi.c 2004-10-13 22:45:30.000000000 +0800 @@ -0,0 +1,648 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: multi.c,v 1.8 2004/10/13 14:45:30 andy Exp $ + ***************************************************************************/ + +#include "setup.h" +#include +#include + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif + +#include + +#include "urldata.h" +#include "transfer.h" +#include "url.h" +#include "connect.h" +#include "progress.h" +#include "curl_memory.h" + +/* The last #include file should be: */ +#include "memdebug.h" + +struct Curl_message { + /* the 'CURLMsg' is the part that is visible to the external user */ + struct CURLMsg extmsg; + struct Curl_message *next; +}; + +typedef enum { + CURLM_STATE_INIT, + CURLM_STATE_CONNECT, /* resolve/connect has been sent off */ + CURLM_STATE_WAITRESOLVE, /* we're awaiting the resolve to finalize */ + CURLM_STATE_WAITCONNECT, /* we're awaiting the connect to finalize */ + CURLM_STATE_DO, /* send off the request (part 1) */ + CURLM_STATE_DO_MORE, /* send off the request (part 2) */ + CURLM_STATE_PERFORM, /* transfer data */ + CURLM_STATE_DONE, /* post data transfer operation */ + CURLM_STATE_COMPLETED, /* operation complete */ + + CURLM_STATE_LAST /* not a true state, never use this */ +} CURLMstate; + +struct Curl_one_easy { + /* first, two fields for the linked list of these */ + struct Curl_one_easy *next; + struct Curl_one_easy *prev; + + struct SessionHandle *easy_handle; /* the easy handle for this unit */ + struct connectdata *easy_conn; /* the "unit's" connection */ + + CURLMstate state; /* the handle's state */ + CURLcode result; /* previous result */ + + struct Curl_message *msg; /* A pointer to one single posted message. + Cleanup should be done on this pointer NOT on + the linked list in Curl_multi. This message + will be deleted when this handle is removed + from the multi-handle */ + int msg_num; /* number of messages left in 'msg' to return */ +}; + + +#define CURL_MULTI_HANDLE 0x000bab1e + +#define GOOD_MULTI_HANDLE(x) ((x)&&(((struct Curl_multi *)x)->type == CURL_MULTI_HANDLE)) +#define GOOD_EASY_HANDLE(x) (x) + +/* This is the struct known as CURLM on the outside */ +struct Curl_multi { + /* First a simple identifier to easier detect if a user mix up + this multi handle with an easy handle. Set this to CURL_MULTI_HANDLE. */ + long type; + + /* We have a linked list with easy handles */ + struct Curl_one_easy easy; + /* This is the amount of entries in the linked list above. */ + int num_easy; + + int num_msgs; /* total amount of messages in the easy handles */ + + /* Hostname cache */ + curl_hash *hostcache; +}; + + +CURLM *curl_multi_init(void) +{ + struct Curl_multi *multi; + + multi = (void *)malloc(sizeof(struct Curl_multi)); + + if(multi) { + memset(multi, 0, sizeof(struct Curl_multi)); + multi->type = CURL_MULTI_HANDLE; + } + else + return NULL; + + multi->hostcache = Curl_mk_dnscache(); + if(!multi->hostcache) { + /* failure, free mem and bail out */ + free(multi); + multi = NULL; + } + return (CURLM *) multi; +} + +CURLMcode curl_multi_add_handle(CURLM *multi_handle, + CURL *easy_handle) +{ + struct Curl_multi *multi=(struct Curl_multi *)multi_handle; + struct Curl_one_easy *easy; + + /* First, make some basic checks that the CURLM handle is a good handle */ + if(!GOOD_MULTI_HANDLE(multi)) + return CURLM_BAD_HANDLE; + + /* Verify that we got a somewhat good easy handle too */ + if(!GOOD_EASY_HANDLE(easy_handle)) + return CURLM_BAD_EASY_HANDLE; + + /* Now, time to add an easy handle to the multi stack */ + easy = (struct Curl_one_easy *)malloc(sizeof(struct Curl_one_easy)); + if(!easy) + return CURLM_OUT_OF_MEMORY; + + /* clean it all first (just to be sure) */ + memset(easy, 0, sizeof(struct Curl_one_easy)); + + /* set the easy handle */ + easy->easy_handle = easy_handle; + easy->state = CURLM_STATE_INIT; + + /* for multi interface connections, we share DNS cache automaticly */ + easy->easy_handle->hostcache = multi->hostcache; + + /* We add this new entry first in the list. We make our 'next' point to the + previous next and our 'prev' point back to the 'first' struct */ + easy->next = multi->easy.next; + easy->prev = &multi->easy; + + /* make 'easy' the first node in the chain */ + multi->easy.next = easy; + + /* if there was a next node, make sure its 'prev' pointer links back to + the new node */ + if(easy->next) + easy->next->prev = easy; + + /* increase the node-counter */ + multi->num_easy++; + + return CURLM_CALL_MULTI_PERFORM; +} + +CURLMcode curl_multi_remove_handle(CURLM *multi_handle, + CURL *curl_handle) +{ + struct Curl_multi *multi=(struct Curl_multi *)multi_handle; + struct Curl_one_easy *easy; + + /* First, make some basic checks that the CURLM handle is a good handle */ + if(!GOOD_MULTI_HANDLE(multi)) + return CURLM_BAD_HANDLE; + + /* Verify that we got a somewhat good easy handle too */ + if(!GOOD_EASY_HANDLE(curl_handle)) + return CURLM_BAD_EASY_HANDLE; + + /* scan through the list and remove the 'curl_handle' */ + easy = multi->easy.next; + while(easy) { + if(easy->easy_handle == (struct SessionHandle *)curl_handle) + break; + easy=easy->next; + } + if(easy) { + /* If the 'state' is not INIT or COMPLETED, we might need to do something + nice to put the easy_handle in a good known state when this returns. */ + + /* clear out the usage of the shared DNS cache */ + easy->easy_handle->hostcache = NULL; + + /* make the previous node point to our next */ + if(easy->prev) + easy->prev->next = easy->next; + /* make our next point to our previous node */ + if(easy->next) + easy->next->prev = easy->prev; + + /* NOTE NOTE NOTE + We do not touch the easy handle here! */ + if (easy->msg) + free(easy->msg); + free(easy); + + multi->num_easy--; /* one less to care about now */ + + return CURLM_OK; + } + else + return CURLM_BAD_EASY_HANDLE; /* twasn't found */ +} + +CURLMcode curl_multi_fdset(CURLM *multi_handle, + fd_set *read_fd_set, fd_set *write_fd_set, + fd_set *exc_fd_set, int *max_fd) +{ + /* Scan through all the easy handles to get the file descriptors set. + Some easy handles may not have connected to the remote host yet, + and then we must make sure that is done. */ + struct Curl_multi *multi=(struct Curl_multi *)multi_handle; + struct Curl_one_easy *easy; + int this_max_fd=-1; + + if(!GOOD_MULTI_HANDLE(multi)) + return CURLM_BAD_HANDLE; + + *max_fd = -1; /* so far none! */ + + easy=multi->easy.next; + while(easy) { + switch(easy->state) { + default: + break; + case CURLM_STATE_WAITRESOLVE: + /* waiting for a resolve to complete */ + Curl_fdset(easy->easy_conn, read_fd_set, write_fd_set, &this_max_fd); + if(this_max_fd > *max_fd) + *max_fd = this_max_fd; + break; + + case CURLM_STATE_WAITCONNECT: + case CURLM_STATE_DO_MORE: + { + /* when we're waiting for a connect, we wait for the socket to + become writable */ + struct connectdata *conn = easy->easy_conn; + curl_socket_t sockfd; + + if(CURLM_STATE_WAITCONNECT == easy->state) { + sockfd = conn->sock[FIRSTSOCKET]; + FD_SET(sockfd, write_fd_set); + } + else { + /* When in DO_MORE state, we could be either waiting for us + to connect to a remote site, or we could wait for that site + to connect to us. It makes a difference in the way: if we + connect to the site we wait for the socket to become writable, if + the site connects to us we wait for it to become readable */ + sockfd = conn->sock[SECONDARYSOCKET]; + FD_SET(sockfd, write_fd_set); + } + + if((int)sockfd > *max_fd) + *max_fd = (int)sockfd; + } + break; + case CURLM_STATE_PERFORM: + /* This should have a set of file descriptors for us to set. */ + /* after the transfer is done, go DONE */ + + Curl_single_fdset(easy->easy_conn, + read_fd_set, write_fd_set, + exc_fd_set, &this_max_fd); + + /* remember the maximum file descriptor */ + if(this_max_fd > *max_fd) + *max_fd = this_max_fd; + + break; + } + easy = easy->next; /* check next handle */ + } + + return CURLM_OK; +} + +CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles) +{ + struct Curl_multi *multi=(struct Curl_multi *)multi_handle; + struct Curl_one_easy *easy; + bool done; + CURLMcode result=CURLM_OK; + struct Curl_message *msg; + bool connected; + bool async; + + *running_handles = 0; /* bump this once for every living handle */ + + if(!GOOD_MULTI_HANDLE(multi)) + return CURLM_BAD_HANDLE; + + easy=multi->easy.next; + while(easy) { +#if 0 + fprintf(stderr, "HANDLE %p: State: %x\n", + (char *)easy, easy->state); +#endif + do { + if (CURLM_STATE_WAITCONNECT <= easy->state && + easy->state <= CURLM_STATE_DO && + easy->easy_handle->change.url_changed) { + char *gotourl; + Curl_posttransfer(easy->easy_handle); + + easy->result = Curl_done(&easy->easy_conn, CURLE_OK); + if(CURLE_OK == easy->result) { + gotourl = strdup(easy->easy_handle->change.url); + if(gotourl) { + easy->easy_handle->change.url_changed = FALSE; + easy->result = Curl_follow(easy->easy_handle, gotourl); + if(CURLE_OK == easy->result) + easy->state = CURLM_STATE_CONNECT; + else + free(gotourl); + } + else { + easy->result = CURLE_OUT_OF_MEMORY; + easy->state = CURLM_STATE_COMPLETED; + break; + } + } + } + + easy->easy_handle->change.url_changed = FALSE; + + switch(easy->state) { + case CURLM_STATE_INIT: + /* init this transfer. */ + easy->result=Curl_pretransfer(easy->easy_handle); + + if(CURLE_OK == easy->result) { + /* after init, go CONNECT */ + easy->state = CURLM_STATE_CONNECT; + result = CURLM_CALL_MULTI_PERFORM; + + easy->easy_handle->state.used_interface = Curl_if_multi; + } + break; + + case CURLM_STATE_CONNECT: + /* Connect. We get a connection identifier filled in. */ + Curl_pgrsTime(easy->easy_handle, TIMER_STARTSINGLE); + easy->result = Curl_connect(easy->easy_handle, &easy->easy_conn, + &async); + + if(CURLE_OK == easy->result) { + if(async) + /* We're now waiting for an asynchronous name lookup */ + easy->state = CURLM_STATE_WAITRESOLVE; + else { + /* after the connect has been sent off, go WAITCONNECT */ + easy->state = CURLM_STATE_WAITCONNECT; + result = CURLM_CALL_MULTI_PERFORM; + } + } + break; + + case CURLM_STATE_WAITRESOLVE: + /* awaiting an asynch name resolve to complete */ + { + struct Curl_dns_entry *dns = NULL; + + /* check if we have the name resolved by now */ + easy->result = Curl_is_resolved(easy->easy_conn, &dns); + + if(dns) { + /* Perform the next step in the connection phase, and then move on + to the WAITCONNECT state */ + easy->result = Curl_async_resolved(easy->easy_conn); + + if(CURLE_OK != easy->result) + /* if Curl_async_resolved() returns failure, the connection struct + is already freed and gone */ + easy->easy_conn = NULL; /* no more connection */ + + easy->state = CURLM_STATE_WAITCONNECT; + } + + if(CURLE_OK != easy->result) { + /* failure detected */ + Curl_disconnect(easy->easy_conn); /* disconnect properly */ + easy->easy_conn = NULL; /* no more connection */ + break; + } + } + break; + + case CURLM_STATE_WAITCONNECT: + /* awaiting a completion of an asynch connect */ + easy->result = Curl_is_connected(easy->easy_conn, FIRSTSOCKET, + &connected); + if(connected) + easy->result = Curl_protocol_connect(easy->easy_conn); + + if(CURLE_OK != easy->result) { + /* failure detected */ + Curl_disconnect(easy->easy_conn); /* close the connection */ + easy->easy_conn = NULL; /* no more connection */ + break; + } + + if(connected) { + /* after the connect has completed, go DO */ + easy->state = CURLM_STATE_DO; + result = CURLM_CALL_MULTI_PERFORM; + } + break; + + case CURLM_STATE_DO: + /* Do the fetch or put request */ + easy->result = Curl_do(&easy->easy_conn); + if(CURLE_OK == easy->result) { + + /* after do, go PERFORM... or DO_MORE */ + if(easy->easy_conn->bits.do_more) { + /* we're supposed to do more, but we need to sit down, relax + and wait a little while first */ + easy->state = CURLM_STATE_DO_MORE; + result = CURLM_OK; + } + else { + /* we're done with the DO, now PERFORM */ + easy->result = Curl_readwrite_init(easy->easy_conn); + if(CURLE_OK == easy->result) { + easy->state = CURLM_STATE_PERFORM; + result = CURLM_CALL_MULTI_PERFORM; + } + } + } + break; + + case CURLM_STATE_DO_MORE: + /* + * First, check if we really are ready to do more. + */ + easy->result = Curl_is_connected(easy->easy_conn, SECONDARYSOCKET, + &connected); + if(connected) { + /* + * When we are connected, DO MORE and then go PERFORM + */ + easy->result = Curl_do_more(easy->easy_conn); + + if(CURLE_OK == easy->result) + easy->result = Curl_readwrite_init(easy->easy_conn); + + if(CURLE_OK == easy->result) { + easy->state = CURLM_STATE_PERFORM; + result = CURLM_CALL_MULTI_PERFORM; + } + } + break; + + case CURLM_STATE_PERFORM: + /* read/write data if it is ready to do so */ + easy->result = Curl_readwrite(easy->easy_conn, &done); + + if(easy->result) { + /* The transfer phase returned error, we mark the connection to get + * closed to prevent being re-used. This is becasue we can't + * possibly know if the connection is in a good shape or not now. */ + easy->easy_conn->bits.close = TRUE; + + if(CURL_SOCKET_BAD != easy->easy_conn->sock[SECONDARYSOCKET]) { + /* if we failed anywhere, we must clean up the secondary socket if + it was used */ + sclose(easy->easy_conn->sock[SECONDARYSOCKET]); + easy->easy_conn->sock[SECONDARYSOCKET]=-1; + } + Curl_posttransfer(easy->easy_handle); + Curl_done(&easy->easy_conn, easy->result); + } + + /* after the transfer is done, go DONE */ + else if(TRUE == done) { + + /* call this even if the readwrite function returned error */ + Curl_posttransfer(easy->easy_handle); + + /* When we follow redirects, must to go back to the CONNECT state */ + if(easy->easy_conn->newurl) { + char *newurl = easy->easy_conn->newurl; + easy->easy_conn->newurl = NULL; + easy->result = Curl_done(&easy->easy_conn, CURLE_OK); + if(easy->result == CURLE_OK) + easy->result = Curl_follow(easy->easy_handle, newurl); + if(CURLE_OK == easy->result) { + easy->state = CURLM_STATE_CONNECT; + result = CURLM_CALL_MULTI_PERFORM; + } + } + else { + easy->state = CURLM_STATE_DONE; + result = CURLM_CALL_MULTI_PERFORM; + } + } + break; + case CURLM_STATE_DONE: + /* post-transfer command */ + easy->result = Curl_done(&easy->easy_conn, CURLE_OK); + + /* after we have DONE what we're supposed to do, go COMPLETED, and + it doesn't matter what the Curl_done() returned! */ + easy->state = CURLM_STATE_COMPLETED; + break; + + case CURLM_STATE_COMPLETED: + /* this is a completed transfer, it is likely to still be connected */ + + /* This node should be delinked from the list now and we should post + an information message that we are complete. */ + break; + default: + return CURLM_INTERNAL_ERROR; + } + + if(CURLM_STATE_COMPLETED != easy->state) { + if(CURLE_OK != easy->result) { + /* + * If an error was returned, and we aren't in completed state now, + * then we go to completed and consider this transfer aborted. */ + easy->state = CURLM_STATE_COMPLETED; + } + else + /* this one still lives! */ + (*running_handles)++; + } + + } while (easy->easy_handle->change.url_changed); + + if ((CURLM_STATE_COMPLETED == easy->state) && !easy->msg) { + /* clear out the usage of the shared DNS cache */ + easy->easy_handle->hostcache = NULL; + + /* now add a node to the Curl_message linked list with this info */ + msg = (struct Curl_message *)malloc(sizeof(struct Curl_message)); + + if(!msg) + return CURLM_OUT_OF_MEMORY; + + msg->extmsg.msg = CURLMSG_DONE; + msg->extmsg.easy_handle = easy->easy_handle; + msg->extmsg.data.result = easy->result; + msg->next=NULL; + + easy->msg = msg; + easy->msg_num = 1; /* there is one unread message here */ + + multi->num_msgs++; /* increase message counter */ + } + + easy = easy->next; /* operate on next handle */ + } + + return result; +} + +CURLMcode curl_multi_cleanup(CURLM *multi_handle) +{ + struct Curl_multi *multi=(struct Curl_multi *)multi_handle; + struct Curl_one_easy *easy; + struct Curl_one_easy *nexteasy; + + if(GOOD_MULTI_HANDLE(multi)) { + multi->type = 0; /* not good anymore */ + Curl_hash_destroy(multi->hostcache); + + /* remove all easy handles */ + easy = multi->easy.next; + while(easy) { + nexteasy=easy->next; + /* clear out the usage of the shared DNS cache */ + easy->easy_handle->hostcache = NULL; + + if (easy->msg) + free(easy->msg); + free(easy); + easy = nexteasy; + } + + free(multi); + + return CURLM_OK; + } + else + return CURLM_BAD_HANDLE; +} + +CURLMsg *curl_multi_info_read(CURLM *multi_handle, int *msgs_in_queue) +{ + struct Curl_multi *multi=(struct Curl_multi *)multi_handle; + + *msgs_in_queue = 0; /* default to none */ + + if(GOOD_MULTI_HANDLE(multi)) { + struct Curl_one_easy *easy; + + if(!multi->num_msgs) + return NULL; /* no messages left to return */ + + easy=multi->easy.next; + while(easy) { + if(easy->msg_num) { + easy->msg_num--; + break; + } + easy = easy->next; + } + if(!easy) + return NULL; /* this means internal count confusion really */ + + multi->num_msgs--; + *msgs_in_queue = multi->num_msgs; + + return &easy->msg->extmsg; + } + else + return NULL; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/netrc.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/netrc.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/netrc.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/netrc.c 2004-10-06 00:42:38.000000000 +0800 @@ -0,0 +1,247 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: netrc.c,v 1.7 2004/10/05 16:42:38 hoffman Exp $ + ***************************************************************************/ + +#include "setup.h" + +#include +#include +#include + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_PWD_H +#include +#endif +#ifdef VMS +#include +#endif + +#include +#include "netrc.h" + +#include "strequal.h" +#include "strtok.h" +#include "curl_memory.h" + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +/* The last #include file should be: */ +#include "memdebug.h" + +/* Debug this single source file with: + 'make netrc' then run './netrc'! + + Oh, make sure you have a .netrc file too ;-) + */ + +/* Get user and password from .netrc when given a machine name */ + +enum { + NOTHING, + HOSTFOUND, /* the 'machine' keyword was found */ + HOSTCOMPLETE, /* the machine name following the keyword was found too */ + HOSTVALID, /* this is "our" machine! */ + + HOSTEND /* LAST enum */ +}; + +/* make sure we have room for at least this size: */ +#define LOGINSIZE 64 +#define PASSWORDSIZE 64 + +/* returns -1 on failure, 0 if the host is found, 1 is the host isn't found */ +int Curl_parsenetrc(char *host, + char *login, + char *password, + char *netrcfile) +{ + FILE *file; + int retcode=1; + int specific_login = (login[0] != 0); + char *home = NULL; + bool home_alloc = FALSE; + bool netrc_alloc = FALSE; + int state=NOTHING; + + char state_login=0; /* Found a login keyword */ + char state_password=0; /* Found a password keyword */ + int state_our_login=FALSE; /* With specific_login, found *our* login name */ + +#define NETRC DOT_CHAR "netrc" + +#ifdef CURLDEBUG + { + /* This is a hack to allow testing. + * If compiled with --enable-debug and CURL_DEBUG_NETRC is defined, + * then it's the path to a substitute .netrc for testing purposes *only* */ + + char *override = curl_getenv("CURL_DEBUG_NETRC"); + + if (override) { + printf("NETRC: overridden " NETRC " file: %s\n", home); + netrcfile = override; + netrc_alloc = TRUE; + } + } +#endif /* CURLDEBUG */ + if(!netrcfile) { + home = curl_getenv("HOME"); /* portable environment reader */ + if(home) { + home_alloc = TRUE; +#if defined(HAVE_GETPWUID) && defined(HAVE_GETEUID) + } + else { + struct passwd *pw; + pw= getpwuid(geteuid()); + if (pw) { +#ifdef VMS + home = decc$translate_vms(pw->pw_dir); +#else + home = pw->pw_dir; +#endif + } +#endif + } + + if(!home) + return -1; + + netrcfile = curl_maprintf("%s%s%s", home, DIR_CHAR, NETRC); + if(!netrcfile) { + if(home_alloc) + free(home); + return -1; + } + netrc_alloc = TRUE; + } + + file = fopen(netrcfile, "r"); + if(file) { + char *tok; + char *tok_buf; + bool done=FALSE; + char netrcbuffer[256]; + + while(!done && fgets(netrcbuffer, sizeof(netrcbuffer), file)) { + tok=strtok_r(netrcbuffer, " \t\n", &tok_buf); + while(!done && tok) { + + if (login[0] && password[0]) { + done=TRUE; + break; + } + + switch(state) { + case NOTHING: + if(strequal("machine", tok)) { + /* the next tok is the machine name, this is in itself the + delimiter that starts the stuff entered for this machine, + after this we need to search for 'login' and + 'password'. */ + state=HOSTFOUND; + } + break; + case HOSTFOUND: + if(strequal(host, tok)) { + /* and yes, this is our host! */ + state=HOSTVALID; +#ifdef _NETRC_DEBUG + printf("HOST: %s\n", tok); +#endif + retcode=0; /* we did find our host */ + } + else + /* not our host */ + state=NOTHING; + break; + case HOSTVALID: + /* we are now parsing sub-keywords concerning "our" host */ + if(state_login) { + if (specific_login) { + state_our_login = strequal(login, tok); + } + else { + strncpy(login, tok, LOGINSIZE-1); +#ifdef _NETRC_DEBUG + printf("LOGIN: %s\n", login); +#endif + } + state_login=0; + } + else if(state_password) { + if (state_our_login || !specific_login) { + strncpy(password, tok, PASSWORDSIZE-1); +#ifdef _NETRC_DEBUG + printf("PASSWORD: %s\n", password); +#endif + } + state_password=0; + } + else if(strequal("login", tok)) + state_login=1; + else if(strequal("password", tok)) + state_password=1; + else if(strequal("machine", tok)) { + /* ok, there's machine here go => */ + state = HOSTFOUND; + state_our_login = FALSE; + } + break; + } /* switch (state) */ + + tok = strtok_r(NULL, " \t\n", &tok_buf); + } /* while (tok) */ + } /* while fgets() */ + + fclose(file); + } + + if(home_alloc) + free(home); + if(netrc_alloc) + free(netrcfile); + + return retcode; +} + +#ifdef _NETRC_DEBUG +int main(int argc, char **argv) +{ + char login[64]=""; + char password[64]=""; + + if(argc<2) + return -1; + + if(0 == ParseNetrc(argv[1], login, password)) { + printf("HOST: %s LOGIN: %s PASSWORD: %s\n", + argv[1], login, password); + } +} + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/netrc.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/netrc.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/netrc.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/netrc.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,34 @@ +#ifndef __NETRC_H +#define __NETRC_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: netrc.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ +int Curl_parsenetrc(char *host, + char *login, + char *password, + char *filename); + /* Assume: password[0]=0, host[0] != 0. + * If login[0] = 0, search for login and password within a machine section + * in the netrc. + * If login[0] != 0, search for password within machine and login. + */ +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/nwlib.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/nwlib.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/nwlib.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/nwlib.c 2004-10-06 00:42:38.000000000 +0800 @@ -0,0 +1,300 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: nwlib.c,v 1.2 2004/10/05 16:42:38 hoffman Exp $ + ***************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "curl_memory.h" +#include "memdebug.h" + +typedef struct +{ + int _errno; + void *twentybytes; +} libthreaddata_t; + +typedef struct +{ + int x; + int y; + int z; + void *tenbytes; + NXKey_t perthreadkey; /* if -1, no key obtained... */ + NXMutex_t *lock; +} libdata_t; + +int gLibId = -1; +void *gLibHandle = (void *) NULL; +rtag_t gAllocTag = (rtag_t) NULL; +NXMutex_t *gLibLock = (NXMutex_t *) NULL; + +/* internal library function prototypes... */ +int DisposeLibraryData ( void * ); +void DisposeThreadData ( void * ); +int GetOrSetUpData ( int id, libdata_t **data, libthreaddata_t **threaddata ); + + +int _NonAppStart( void *NLMHandle, + void *errorScreen, + const char *cmdLine, + const char *loadDirPath, + size_t uninitializedDataLength, + void *NLMFileHandle, + int (*readRoutineP)( int conn, + void *fileHandle, size_t offset, + size_t nbytes, + size_t *bytesRead, + void *buffer ), + size_t customDataOffset, + size_t customDataSize, + int messageCount, + const char **messages ) +{ + NX_LOCK_INFO_ALLOC(liblock, "Per-Application Data Lock", 0); + +#ifndef __GNUC__ +#pragma unused(cmdLine) +#pragma unused(loadDirPath) +#pragma unused(uninitializedDataLength) +#pragma unused(NLMFileHandle) +#pragma unused(readRoutineP) +#pragma unused(customDataOffset) +#pragma unused(customDataSize) +#pragma unused(messageCount) +#pragma unused(messages) +#endif + +/* +** Here we process our command line, post errors (to the error screen), +** perform initializations and anything else we need to do before being able +** to accept calls into us. If we succeed, we return non-zero and the NetWare +** Loader will leave us up, otherwise we fail to load and get dumped. +*/ + gAllocTag = AllocateResourceTag(NLMHandle, + " memory allocations", + AllocSignature); + + if (!gAllocTag) { + OutputToScreen(errorScreen, "Unable to allocate resource tag for " + "library memory allocations.\n"); + return -1; + } + + gLibId = register_library(DisposeLibraryData); + + if (gLibId < -1) { + OutputToScreen(errorScreen, "Unable to register library with kernel.\n"); + return -1; + } + + gLibHandle = NLMHandle; + + gLibLock = NXMutexAlloc(0, 0, &liblock); + + if (!gLibLock) { + OutputToScreen(errorScreen, "Unable to allocate library data lock.\n"); + return -1; + } + + return 0; +} + +/* +** Here we clean up any resources we allocated. Resource tags is a big part +** of what we created, but NetWare doesn't ask us to free those. +*/ +void _NonAppStop( void ) +{ + (void) unregister_library(gLibId); + NXMutexFree(gLibLock); +} + +/* +** This function cannot be the first in the file for if the file is linked +** first, then the check-unload function's offset will be nlmname.nlm+0 +** which is how to tell that there isn't one. When the check function is +** first in the linked objects, it is ambiguous. For this reason, we will +** put it inside this file after the stop function. +** +** Here we check to see if it's alright to ourselves to be unloaded. If not, +** we return a non-zero value. Right now, there isn't any reason not to allow +** it. +*/ +int _NonAppCheckUnload( void ) +{ + return 0; +} + +int GetOrSetUpData(int id, libdata_t **appData, + libthreaddata_t **threadData ) +{ + int err; + libdata_t *app_data; + libthreaddata_t *thread_data; + NXKey_t key; + NX_LOCK_INFO_ALLOC(liblock, "Application Data Lock", 0); + + err = 0; + thread_data = (libthreaddata_t *) NULL; + +/* +** Attempt to get our data for the application calling us. This is where we +** store whatever application-specific information we need to carry in support +** of calling applications. +*/ + app_data = (libdata_t *) get_app_data(id); + + if (!app_data) { +/* +** This application hasn't called us before; set up application AND per-thread +** data. Of course, just in case a thread from this same application is calling +** us simultaneously, we better lock our application data-creation mutex. We +** also need to recheck for data after we acquire the lock because WE might be +** that other thread that was too late to create the data and the first thread +** in will have created it. +*/ + NXLock(gLibLock); + + if (!(app_data = (libdata_t *) get_app_data(id))) { + app_data = (libdata_t *) malloc(sizeof(libdata_t)); + + if (app_data) { + memset(app_data, 0, sizeof(libdata_t)); + + app_data->tenbytes = malloc(10); + app_data->lock = NXMutexAlloc(0, 0, &liblock); + + if (!app_data->tenbytes || !app_data->lock) { + if (app_data->lock) + NXMutexFree(app_data->lock); + + free(app_data); + app_data = (libdata_t *) NULL; + err = ENOMEM; + } + + if (app_data) { +/* +** Here we burn in the application data that we were trying to get by calling +** get_app_data(). Next time we call the first function, we'll get this data +** we're just now setting. We also go on here to establish the per-thread data +** for the calling thread, something we'll have to do on each application +** thread the first time it calls us. +*/ + err = set_app_data(gLibId, app_data); + + if (err) { + free(app_data); + app_data = (libdata_t *) NULL; + err = ENOMEM; + } + else { + /* create key for thread-specific data... */ + err = NXKeyCreate(DisposeThreadData, (void *) NULL, &key); + + if (err) /* (no more keys left?) */ + key = -1; + + app_data->perthreadkey = key; + } + } + } + } + + NXUnlock(gLibLock); + } + + if (app_data) { + key = app_data->perthreadkey; + + if (key != -1 /* couldn't create a key? no thread data */ + && !(err = NXKeyGetValue(key, (void **) &thread_data)) + && !thread_data) { +/* +** Allocate the per-thread data for the calling thread. Regardless of whether +** there was already application data or not, this may be the first call by a +** a new thread. The fact that we allocation 20 bytes on a pointer is not very +** important, this just helps to demonstrate that we can have arbitrarily +** complex per-thread data. +*/ + thread_data = (libthreaddata_t *) malloc(sizeof(libthreaddata_t)); + + if (thread_data) { + thread_data->_errno = 0; + thread_data->twentybytes = malloc(20); + + if (!thread_data->twentybytes) { + free(thread_data); + thread_data = (libthreaddata_t *) NULL; + err = ENOMEM; + } + + if ((err = NXKeySetValue(key, thread_data))) { + free(thread_data->twentybytes); + free(thread_data); + thread_data = (libthreaddata_t *) NULL; + } + } + } + } + + if (appData) + *appData = app_data; + + if (threadData) + *threadData = thread_data; + + return err; +} + +int DisposeLibraryData( void *data) +{ + if (data) { + void *tenbytes = ((libdata_t *) data)->tenbytes; + + if (tenbytes) + free(tenbytes); + + free(data); + } + + return 0; +} + +void DisposeThreadData(void *data) +{ + if (data) { + void *twentybytes = ((libthreaddata_t *) data)->twentybytes; + + if (twentybytes) + free(twentybytes); + + free(data); + } +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Platforms/config-aix.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Platforms/config-aix.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Platforms/config-aix.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Platforms/config-aix.h 2003-01-09 04:08:52.000000000 +0800 @@ -0,0 +1,486 @@ +/* lib/config.h. Generated by configure. */ +/* lib/config.h.in. Generated from configure.in by autoheader. */ +/* Name of this package! */ +#define PACKAGE "curl" + +/* Version number of this archive. */ +#define VERSION "7.10.2" + +/* Define if you have the getpass function. */ +/* #undef HAVE_GETPASS */ + +/* Define cpu-machine-OS */ +#define OS "powerpc-ibm-aix5.1.0.0" + +/* Define if you have the gethostbyaddr_r() function with 5 arguments */ +#define HAVE_GETHOSTBYADDR_R_5 1 + +/* Define if you have the gethostbyaddr_r() function with 7 arguments */ +/* #undef HAVE_GETHOSTBYADDR_R_7 */ + +/* Define if you have the gethostbyaddr_r() function with 8 arguments */ +/* #undef HAVE_GETHOSTBYADDR_R_8 */ + +/* Define if you have the gethostbyname_r() function with 3 arguments */ +#define HAVE_GETHOSTBYNAME_R_3 1 + +/* Define if you have the gethostbyname_r() function with 5 arguments */ +/* #undef HAVE_GETHOSTBYNAME_R_5 */ + +/* Define if you have the gethostbyname_r() function with 6 arguments */ +/* #undef HAVE_GETHOSTBYNAME_R_6 */ + +/* Define if you have the inet_ntoa_r function declared. */ +/* #undef HAVE_INET_NTOA_R_DECL */ + +/* Define if you need the _REENTRANT define for some functions */ +/* #undef NEED_REENTRANT */ + +/* Define if you have the Kerberos4 libraries (including -ldes) */ +/* #undef KRB4 */ + +/* Define if you want to enable IPv6 support */ +#define ENABLE_IPV6 1 + +/* Define this to 'int' if ssize_t is not an available typedefed type */ +/* #undef ssize_t */ + +/* Define this to 'int' if socklen_t is not an available typedefed type */ +/* #undef socklen_t */ + +/* Define this as a suitable file to read random data from */ +/* #undef RANDOM_FILE */ + +/* Define this to your Entropy Gathering Daemon socket pathname */ +/* #undef EGD_SOCKET */ + +/* Define if you have a working OpenSSL installation */ +/* #undef OPENSSL_ENABLED */ + +/* Define the one correct non-blocking socket method below */ +/* #undef HAVE_FIONBIO */ +/* #undef HAVE_IOCTLSOCKET */ +/* #undef HAVE_IOCTLSOCKET_CASE */ +/* #undef HAVE_O_NONBLOCK */ +#define HAVE_DISABLED_NONBLOCKING 1 + +/* Define this to 'int' if in_addr_t is not an available typedefed type */ +/* #undef in_addr_t */ + +/* Define to disable DICT */ +/* #undef CURL_DISABLE_DICT */ + +/* Define to disable FILE */ +/* #undef CURL_DISABLE_FILE */ + +/* Define to disable FTP */ +/* #undef CURL_DISABLE_FTP */ + +/* Define to disable GOPHER */ +/* #undef CURL_DISABLE_GOPHER */ + +/* Define to disable HTTP */ +/* #undef CURL_DISABLE_HTTP */ + +/* Define to disable LDAP */ +/* #undef CURL_DISABLE_LDAP */ + +/* Define to disable TELNET */ +/* #undef CURL_DISABLE_TELNET */ + +/* Define if you have zlib present */ +#define HAVE_LIBZ 1 + +/* CA bundle full path name */ +#define CURL_CA_BUNDLE "/usr/local/share/curl/curl-ca-bundle.crt" + +/* to disable FILE */ +/* #undef CURL_DISABLE_FILE */ + +/* to disable FTP */ +/* #undef CURL_DISABLE_FTP */ + +/* to disable GOPHER */ +/* #undef CURL_DISABLE_GOPHER */ + +/* to disable HTTP */ +/* #undef CURL_DISABLE_HTTP */ + +/* to disable LDAP */ +/* #undef CURL_DISABLE_LDAP */ + +/* to disable TELNET */ +/* #undef CURL_DISABLE_TELNET */ + +/* Set to explicitly specify we don't want to use thread-safe functions */ +/* #undef DISABLED_THREADSAFE */ + +/* your Entropy Gathering Daemon socket pathname */ +/* #undef EGD_SOCKET */ + +/* Define if you want to enable IPv6 support */ +#define ENABLE_IPV6 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ALLOCA_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ARPA_INET_H 1 + +/* Define to 1 if you have the `closesocket' function. */ +/* #undef HAVE_CLOSESOCKET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CRYPTO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DES_H */ + +/* to disable NON-BLOCKING connections */ +#define HAVE_DISABLED_NONBLOCKING 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `dlopen' function. */ +#define HAVE_DLOPEN 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_ERR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if getaddrinfo exists and works */ +#define HAVE_GETADDRINFO 1 + +/* Define to 1 if you have the `geteuid' function. */ +#define HAVE_GETEUID 1 + +/* Define to 1 if you have the `gethostbyaddr' function. */ +#define HAVE_GETHOSTBYADDR 1 + +/* Define to 1 if you have the `gethostbyaddr_r' function. */ +#define HAVE_GETHOSTBYADDR_R 1 + +/* Define to 1 if you have the `gethostbyname_r' function. */ +#define HAVE_GETHOSTBYNAME_R 1 + +/* Define to 1 if you have the `getpass_r' function. */ +/* #undef HAVE_GETPASS_R */ + +/* Define to 1 if you have the `getpwuid' function. */ +#define HAVE_GETPWUID 1 + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `gmtime_r' function. */ +#define HAVE_GMTIME_R 1 + +/* Define to 1 if you have the `inet_addr' function. */ +#define HAVE_INET_ADDR 1 + +/* Define to 1 if you have the `inet_ntoa' function. */ +#define HAVE_INET_NTOA 1 + +/* Define to 1 if you have the `inet_ntoa_r' function. */ +#define HAVE_INET_NTOA_R 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* Define to 1 if you have the `krb_get_our_ip_for_realm' function. */ +/* #undef HAVE_KRB_GET_OUR_IP_FOR_REALM */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_KRB_H */ + +/* Define to 1 if you have the `crypto' library (-lcrypto). */ +/* #undef HAVE_LIBCRYPTO */ + +/* Define to 1 if you have the `dl' library (-ldl). */ +/* #undef HAVE_LIBDL */ + +/* Define to 1 if you have the `nsl' library (-lnsl). */ +/* #undef HAVE_LIBNSL */ + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +/* #undef HAVE_LIBRESOLV */ + +/* Define to 1 if you have the `resolve' library (-lresolve). */ +/* #undef HAVE_LIBRESOLVE */ + +/* Define to 1 if you have the `socket' library (-lsocket). */ +/* #undef HAVE_LIBSOCKET */ + +/* Define to 1 if you have the `ssl' library (-lssl). */ +/* #undef HAVE_LIBSSL */ + +/* If zlib is available */ +#define HAVE_LIBZ 1 + +/* Define to 1 if you have the `localtime_r' function. */ +#define HAVE_LOCALTIME_R 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MALLOC_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETDB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_IF_ETHER_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_IN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NET_IF_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_OPENSSL_CRYPTO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_OPENSSL_ENGINE_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_OPENSSL_ERR_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_OPENSSL_PEM_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_OPENSSL_RSA_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_OPENSSL_SSL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_OPENSSL_X509_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PEM_H */ + +/* Define to 1 if you have the `perror' function. */ +#define HAVE_PERROR 1 + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_PWD_H 1 + +/* Define to 1 if you have the `RAND_egd' function. */ +/* #undef HAVE_RAND_EGD */ + +/* Define to 1 if you have the `RAND_screen' function. */ +/* #undef HAVE_RAND_SCREEN */ + +/* Define to 1 if you have the `RAND_status' function. */ +/* #undef HAVE_RAND_STATUS */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_RSA_H */ + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SETJMP_H 1 + +/* Define to 1 if you have the `setvbuf' function. */ +#define HAVE_SETVBUF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SGTTY_H 1 + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the `signal' function. */ +#define HAVE_SIGNAL 1 + +/* If you have sigsetjmp */ +#define HAVE_SIGSETJMP 1 + +/* Define to 1 if you have the `socket' function. */ +#define HAVE_SOCKET 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SSL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STDINT_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strcasecmp' function. */ +#define HAVE_STRCASECMP 1 + +/* Define to 1 if you have the `strcmpi' function. */ +/* #undef HAVE_STRCMPI */ + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the `stricmp' function. */ +/* #undef HAVE_STRICMP */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strlcat' function. */ +/* #undef HAVE_STRLCAT */ + +/* Define to 1 if you have the `strlcpy' function. */ +/* #undef HAVE_STRLCPY */ + +/* Define to 1 if you have the `strstr' function. */ +#define HAVE_STRSTR 1 + +/* Define to 1 if you have the `strtok_r' function. */ +#define HAVE_STRTOK_R 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SOCKIO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_UTIME_H */ + +/* Define to 1 if you have the `tcgetattr' function. */ +#define HAVE_TCGETATTR 1 + +/* Define to 1 if you have the `tcsetattr' function. */ +#define HAVE_TCSETATTR 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TIME_H 1 + +/* Define to 1 if you have the `uname' function. */ +#define HAVE_UNAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `utime' function. */ +#define HAVE_UTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WINSOCK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_X509_H */ + +/* if you have the zlib.h header file */ +/* #undef HAVE_ZLIB_H */ + +/* if you have the Kerberos4 libraries (including -ldes) */ +/* #undef KRB4 */ + +/* cpu-machine-OS */ +#define OS "powerpc-ibm-aix5.1.0.0" + +/* Name of package */ +#define PACKAGE "curl" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "" + +/* a suitable file to read random data from */ +/* #undef RANDOM_FILE */ + +/* Define as the return type of signal handlers (`int' or `void'). */ +#define RETSIGTYPE void + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Version number of package */ +#define VERSION "7.10.2" + +/* Define to 1 if on AIX 3. + System headers sometimes define this. + We just want to avoid a redefinition error message. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif + +/* Number of bits in a file offset, on hosts where this is settable. */ +/* #undef _FILE_OFFSET_BITS */ + +/* Define for large files, on AIX-style hosts. */ +#define _LARGE_FILES 1 + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* type to use in place of in_addr_t if not defined */ +/* #undef in_addr_t */ + +/* Define to `unsigned' if does not define. */ +/* #undef size_t */ + +/* type to use in place of socklen_t if not defined */ +/* #undef socklen_t */ + +/* Define to `int' if does not define. */ +/* #undef ssize_t */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Platforms/WindowsCache.cmake /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Platforms/WindowsCache.cmake --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Platforms/WindowsCache.cmake 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Platforms/WindowsCache.cmake 2003-07-09 03:54:24.000000000 +0800 @@ -0,0 +1,123 @@ +IF(NOT UNIX) + IF(WIN32) + SET(HAVE_LIBDL 0) + SET(HAVE_LIBUCB 0) + SET(HAVE_LIBSOCKET 0) + SET(NOT_NEED_LIBNSL 0) + SET(HAVE_LIBNSL 0) + SET(HAVE_LIBZ 0) + SET(HAVE_LIBCRYPTO 0) + + SET(HAVE_DLOPEN 0) + + SET(HAVE_ALLOCA_H 0) + SET(HAVE_ARPA_INET_H 0) + SET(HAVE_DLFCN_H 0) + SET(HAVE_FCNTL_H 1) + SET(HAVE_FEATURES_H 0) + SET(HAVE_INTTYPES_H 0) + SET(HAVE_IO_H 1) + SET(HAVE_MALLOC_H 1) + SET(HAVE_MEMORY_H 1) + SET(HAVE_NETDB_H 0) + SET(HAVE_NETINET_IF_ETHER_H 0) + SET(HAVE_NETINET_IN_H 0) + SET(HAVE_NET_IF_H 0) + SET(HAVE_PWD_H 0) + SET(HAVE_SETJMP_H 1) + SET(HAVE_SGTTY_H 0) + SET(HAVE_SIGNAL_H 1) + SET(HAVE_SOCKIO_H 0) + SET(HAVE_STDINT_H 0) + SET(HAVE_STDLIB_H 1) + SET(HAVE_STRINGS_H 0) + SET(HAVE_STRING_H 1) + SET(HAVE_SYS_PARAM_H 0) + SET(HAVE_SYS_POLL_H 0) + SET(HAVE_SYS_SELECT_H 0) + SET(HAVE_SYS_SOCKET_H 0) + SET(HAVE_SYS_SOCKIO_H 0) + SET(HAVE_SYS_STAT_H 1) + SET(HAVE_SYS_TIME_H 0) + SET(HAVE_SYS_TYPES_H 1) + SET(HAVE_SYS_UTIME_H 1) + SET(HAVE_TERMIOS_H 0) + SET(HAVE_TERMIO_H 0) + SET(HAVE_TIME_H 1) + SET(HAVE_UNISTD_H 0) + SET(HAVE_UTIME_H 0) + SET(HAVE_WINSOCK_H 1) + SET(HAVE_X509_H 0) + SET(HAVE_ZLIB_H 0) + + SET(HAVE_SIZEOF_LONG_DOUBLE 1) + SET(HAVE_SIZEOF_SSIZE_T 0) + SET(SIZEOF_LONG_DOUBLE 8) + + SET(HAVE_SOCKET 1) + SET(HAVE_POLL 0) + SET(HAVE_SELECT 1) + SET(HAVE_STRDUP 1) + SET(HAVE_STRSTR 1) + SET(HAVE_STRTOK_R 0) + SET(HAVE_STRFTIME 1) + SET(HAVE_UNAME 0) + SET(HAVE_STRCASECMP 0) + SET(HAVE_STRICMP 1) + SET(HAVE_STRCMPI 1) + SET(HAVE_GETHOSTBYADDR 1) + SET(HAVE_GETTIMEOFDAY 0) + SET(HAVE_INET_ADDR 1) + SET(HAVE_INET_NTOA 1) + SET(HAVE_INET_NTOA_R 0) + SET(HAVE_TCGETATTR 0) + SET(HAVE_TCSETATTR 0) + SET(HAVE_PERROR 1) + SET(HAVE_CLOSESOCKET 1) + SET(HAVE_SETVBUF 0) + SET(HAVE_SIGSETJMP 0) + SET(HAVE_GETPASS_R 0) + SET(HAVE_STRLCAT 0) + SET(HAVE_GETPWUID 0) + SET(HAVE_GETEUID 0) + SET(HAVE_UTIME 1) + SET(HAVE_RAND_EGD 0) + SET(HAVE_RAND_SCREEN 0) + SET(HAVE_RAND_STATUS 0) + SET(HAVE_GMTIME_R 0) + SET(HAVE_LOCALTIME_R 0) + SET(HAVE_GETHOSTBYADDR_R 0) + SET(HAVE_GETHOSTBYNAME_R 0) + SET(HAVE_SIGNAL_FUNC 1) + SET(HAVE_SIGNAL_MACRO 0) + + SET(HAVE_GETHOSTBYADDR_R_5 0) + SET(HAVE_GETHOSTBYADDR_R_5_REENTRANT 0) + SET(HAVE_GETHOSTBYADDR_R_7 0) + SET(HAVE_GETHOSTBYADDR_R_7_REENTRANT 0) + SET(HAVE_GETHOSTBYADDR_R_8 0) + SET(HAVE_GETHOSTBYADDR_R_8_REENTRANT 0) + SET(HAVE_GETHOSTBYNAME_R_3 0) + SET(HAVE_GETHOSTBYNAME_R_3_REENTRANT 0) + SET(HAVE_GETHOSTBYNAME_R_5 0) + SET(HAVE_GETHOSTBYNAME_R_5_REENTRANT 0) + SET(HAVE_GETHOSTBYNAME_R_6 0) + SET(HAVE_GETHOSTBYNAME_R_6_REENTRANT 0) + + SET(TIME_WITH_SYS_TIME 0) + SET(HAVE_O_NONBLOCK 0) + SET(HAVE_IN_ADDR_T 0) + SET(HAVE_SOCKLEN_T 0) + SET(HAVE_INET_NTOA_R_DECL 0) + SET(HAVE_INET_NTOA_R_DECL_REENTRANT 0) + SET(HAVE_GETADDRINFO 0) + SET(STDC_HEADERS 1) + SET(RETSIGTYPE_TEST 1) + + SET(HAVE_SIGACTION 0) + SET(HAVE_MACRO_SIGSETJMP 0) + ELSE(WIN32) + MESSAGE("This file should be included on Windows platform only") + ENDIF(WIN32) +ENDIF(NOT UNIX) + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/progress.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/progress.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/progress.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/progress.c 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,426 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: progress.c,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +#include "setup.h" + +#include +#include + +#if defined(__EMX__) +#include +#endif + +#include +#include "urldata.h" +#include "sendf.h" +#include "progress.h" + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +/* Provide a string that is 2 + 1 + 2 + 1 + 2 = 8 letters long (plus the zero + byte) */ +static void time2str(char *r, long t) +{ + long h; + if(!t) { + strcpy(r, "--:--:--"); + return; + } + h = (t/3600); + if(h <= 99) { + long m = (t-(h*3600))/60; + long s = (t-(h*3600)-(m*60)); + snprintf(r, 9, "%2ld:%02ld:%02ld",h,m,s); + } + else { + /* this equals to more than 99 hours, switch to a more suitable output + format to fit within the limits. */ + if(h/24 <= 999) + snprintf(r, 9, "%3ldd %02ldh", h/24, h-(h/24)*24); + else + snprintf(r, 9, "%7ldd", h/24); + } +} + +/* The point of this function would be to return a string of the input data, + but never longer than 5 columns (+ one zero byte). + Add suffix k, M, G when suitable... */ +static char *max5data(curl_off_t bytes, char *max5) +{ +#define ONE_KILOBYTE 1024 +#define ONE_MEGABYTE (1024* ONE_KILOBYTE) +#define ONE_GIGABYTE (1024* ONE_MEGABYTE) +#define ONE_TERRABYTE ((curl_off_t)1024* ONE_GIGABYTE) +#define ONE_PETABYTE ((curl_off_t)1024* ONE_TERRABYTE) + + if(bytes < 100000) { + snprintf(max5, 6, "%5" FORMAT_OFF_T, bytes); + } + else if(bytes < (10000*ONE_KILOBYTE)) { + snprintf(max5, 6, "%4" FORMAT_OFF_T "k", (curl_off_t)(bytes/ONE_KILOBYTE)); + } + else if(bytes < (100*ONE_MEGABYTE)) { + /* 'XX.XM' is good as long as we're less than 100 megs */ + snprintf(max5, 6, "%2d.%0dM", + (int)(bytes/ONE_MEGABYTE), + (int)(bytes%ONE_MEGABYTE)/(ONE_MEGABYTE/10) ); + } +#if SIZEOF_CURL_OFF_T > 4 + else if(bytes < ( (curl_off_t)10000*ONE_MEGABYTE)) + /* 'XXXXM' is good until we're at 10000MB or above */ + snprintf(max5, 6, "%4" FORMAT_OFF_T "M", (curl_off_t)(bytes/ONE_MEGABYTE)); + + else if(bytes < (curl_off_t)100*ONE_GIGABYTE) + /* 10000 MB - 100 GB, we show it as XX.XG */ + snprintf(max5, 6, "%2d.%0dG", + (int)(bytes/ONE_GIGABYTE), + (int)(bytes%ONE_GIGABYTE)/(ONE_GIGABYTE/10) ); + + else if(bytes < (curl_off_t)10000 * ONE_GIGABYTE) + /* up to 10000GB, display without decimal: XXXXG */ + snprintf(max5, 6, "%4dG", (int)(bytes/ONE_GIGABYTE)); + + else if(bytes < (curl_off_t)10000 * ONE_TERRABYTE) + /* up to 10000TB, display without decimal: XXXXT */ + snprintf(max5, 6, "%4dT", (int)(bytes/ONE_TERRABYTE)); + else { + /* up to 10000PB, display without decimal: XXXXP */ + snprintf(max5, 6, "%4dP", (int)(bytes/ONE_PETABYTE)); + + /* 16384 petabytes (16 exabytes) is maximum a 64 bit number can hold, + but this type is signed so 8192PB will be max.*/ + } + +#else + else + snprintf(max5, 6, "%4" FORMAT_OFF_T "M", (curl_off_t)(bytes/ONE_MEGABYTE)); +#endif + + return max5; +} + +/* + + New proposed interface, 9th of February 2000: + + pgrsStartNow() - sets start time + pgrsSetDownloadSize(x) - known expected download size + pgrsSetUploadSize(x) - known expected upload size + pgrsSetDownloadCounter() - amount of data currently downloaded + pgrsSetUploadCounter() - amount of data currently uploaded + pgrsUpdate() - show progress + pgrsDone() - transfer complete + +*/ + +void Curl_pgrsDone(struct connectdata *conn) +{ + struct SessionHandle *data = conn->data; + data->progress.lastshow=0; + Curl_pgrsUpdate(conn); /* the final (forced) update */ + if(!(data->progress.flags & PGRS_HIDE) && + !data->progress.callback) + /* only output if we don't use a progress callback and we're not hidden */ + fprintf(data->set.err, "\n"); +} + +/* reset all times except redirect */ +void Curl_pgrsResetTimes(struct SessionHandle *data) +{ + data->progress.t_nslookup = 0.0; + data->progress.t_connect = 0.0; + data->progress.t_pretransfer = 0.0; + data->progress.t_starttransfer = 0.0; +} + +void Curl_pgrsTime(struct SessionHandle *data, timerid timer) +{ + switch(timer) { + default: + case TIMER_NONE: + /* mistake filter */ + break; + case TIMER_STARTSINGLE: + /* This is set at the start of a single fetch */ + data->progress.t_startsingle = Curl_tvnow(); + break; + + case TIMER_NAMELOOKUP: + data->progress.t_nslookup = + Curl_tvdiff_secs(Curl_tvnow(), data->progress.t_startsingle); + break; + case TIMER_CONNECT: + data->progress.t_connect = + Curl_tvdiff_secs(Curl_tvnow(), data->progress.t_startsingle); + break; + case TIMER_PRETRANSFER: + data->progress.t_pretransfer = + Curl_tvdiff_secs(Curl_tvnow(), data->progress.t_startsingle); + break; + case TIMER_STARTTRANSFER: + data->progress.t_starttransfer = + Curl_tvdiff_secs(Curl_tvnow(), data->progress.t_startsingle); + break; + case TIMER_POSTRANSFER: + /* this is the normal end-of-transfer thing */ + break; + case TIMER_REDIRECT: + data->progress.t_redirect = + Curl_tvdiff_secs(Curl_tvnow(), data->progress.start); + break; + } +} + +void Curl_pgrsStartNow(struct SessionHandle *data) +{ + data->progress.speeder_c = 0; /* reset the progress meter display */ + data->progress.start = Curl_tvnow(); +} + +void Curl_pgrsSetDownloadCounter(struct SessionHandle *data, curl_off_t size) +{ + data->progress.downloaded = size; +} + +void Curl_pgrsSetUploadCounter(struct SessionHandle *data, curl_off_t size) +{ + data->progress.uploaded = size; +} + +void Curl_pgrsSetDownloadSize(struct SessionHandle *data, curl_off_t size) +{ + data->progress.size_dl = size; + if(size > 0) + data->progress.flags |= PGRS_DL_SIZE_KNOWN; + else + data->progress.flags &= ~PGRS_DL_SIZE_KNOWN; +} + +void Curl_pgrsSetUploadSize(struct SessionHandle *data, curl_off_t size) +{ + data->progress.size_ul = size; + if(size > 0) + data->progress.flags |= PGRS_UL_SIZE_KNOWN; + else + data->progress.flags &= ~PGRS_UL_SIZE_KNOWN; +} + +int Curl_pgrsUpdate(struct connectdata *conn) +{ + struct timeval now; + int result; + char max5[6][10]; + int dlpercen=0; + int ulpercen=0; + int total_percen=0; + curl_off_t total_transfer; + curl_off_t total_expected_transfer; + long timespent; + struct SessionHandle *data = conn->data; + int nowindex = data->progress.speeder_c% CURR_TIME; + int checkindex; + int countindex; /* amount of seconds stored in the speeder array */ + char time_left[10]; + char time_total[10]; + char time_spent[10]; + long ulestimate=0; + long dlestimate=0; + long total_estimate; + + if(data->progress.flags & PGRS_HIDE) + ; /* We do enter this function even if we don't wanna see anything, since + this is were lots of the calculations are being made that will be used + even when not displayed! */ + else if(!(data->progress.flags & PGRS_HEADERS_OUT)) { + if (!data->progress.callback) { + if(conn->resume_from) + fprintf(data->set.err, + "** Resuming transfer from byte position %" FORMAT_OFF_T + "\n", + conn->resume_from); + fprintf(data->set.err, + " %% Total %% Received %% Xferd Average Speed Time Time Time Current\n" + " Dload Upload Total Spent Left Speed\n"); + } + data->progress.flags |= PGRS_HEADERS_OUT; /* headers are shown */ + } + + now = Curl_tvnow(); /* what time is it */ + + /* The time spent so far (from the start) */ + data->progress.timespent = Curl_tvdiff_secs(now, data->progress.start); + timespent = (long)data->progress.timespent; + + /* The average download speed this far */ + data->progress.dlspeed = (curl_off_t) + ((double)data->progress.downloaded/ + (data->progress.timespent>0?data->progress.timespent:1)); + + /* The average upload speed this far */ + data->progress.ulspeed = (curl_off_t) + ((double)data->progress.uploaded/ + (data->progress.timespent>0?data->progress.timespent:1)); + + if(data->progress.lastshow == Curl_tvlong(now)) + return 0; /* never update this more than once a second if the end isn't + reached */ + data->progress.lastshow = now.tv_sec; + + /* Let's do the "current speed" thing, which should use the fastest + of the dl/ul speeds. Store the fasted speed at entry 'nowindex'. */ + data->progress.speeder[ nowindex ] = + data->progress.downloaded>data->progress.uploaded? + data->progress.downloaded:data->progress.uploaded; + + /* remember the exact time for this moment */ + data->progress.speeder_time [ nowindex ] = now; + + /* advance our speeder_c counter, which is increased every time we get + here and we expect it to never wrap as 2^32 is a lot of seconds! */ + data->progress.speeder_c++; + + /* figure out how many index entries of data we have stored in our speeder + array. With N_ENTRIES filled in, we have about N_ENTRIES-1 seconds of + transfer. Imagine, after one second we have filled in two entries, + after two seconds we've filled in three entries etc. */ + countindex = ((data->progress.speeder_c>=CURR_TIME)? + CURR_TIME:data->progress.speeder_c) - 1; + + /* first of all, we don't do this if there's no counted seconds yet */ + if(countindex) { + long span_ms; + + /* Get the index position to compare with the 'nowindex' position. + Get the oldest entry possible. While we have less than CURR_TIME + entries, the first entry will remain the oldest. */ + checkindex = (data->progress.speeder_c>=CURR_TIME)? + data->progress.speeder_c%CURR_TIME:0; + + /* Figure out the exact time for the time span */ + span_ms = Curl_tvdiff(now, + data->progress.speeder_time[checkindex]); + if(0 == span_ms) + span_ms=1; /* at least one millisecond MUST have passed */ + + /* Calculate the average speed the last 'span_ms' milliseconds */ + { + curl_off_t amount = data->progress.speeder[nowindex]- + data->progress.speeder[checkindex]; + + if(amount > 0xffffffff/1000) + /* the 'amount' value is bigger than would fit in 32 bits if + multiplied with 1000, so we use the double math for this */ + data->progress.current_speed = (curl_off_t) + ((double)amount/((double)span_ms/1000.0)); + else + /* the 'amount' value is small enough to fit within 32 bits even + when multiplied with 1000 */ + data->progress.current_speed = amount*1000/span_ms; + } + } + else + /* the first second we use the main average */ + data->progress.current_speed = + (data->progress.ulspeed>data->progress.dlspeed)? + data->progress.ulspeed:data->progress.dlspeed; + + if(data->progress.flags & PGRS_HIDE) + return 0; + + else if(data->set.fprogress) { + /* There's a callback set, so we call that instead of writing + anything ourselves. This really is the way to go. */ + result= data->set.fprogress(data->set.progress_client, + (double)data->progress.size_dl, + (double)data->progress.downloaded, + (double)data->progress.size_ul, + (double)data->progress.uploaded); + if(result) + failf(data, "Callback aborted"); + return result; + } + + /* Figure out the estimated time of arrival for the upload */ + if((data->progress.flags & PGRS_UL_SIZE_KNOWN) && + (data->progress.ulspeed>0) && + (data->progress.size_ul > 100) ) { + ulestimate = (long)(data->progress.size_ul / data->progress.ulspeed); + ulpercen = (int)(100*(data->progress.uploaded/100) / + (data->progress.size_ul/100) ); + } + + /* ... and the download */ + if((data->progress.flags & PGRS_DL_SIZE_KNOWN) && + (data->progress.dlspeed>0) && + (data->progress.size_dl>100)) { + dlestimate = (long)(data->progress.size_dl / data->progress.dlspeed); + dlpercen = (int)(100*(data->progress.downloaded/100) / + (data->progress.size_dl/100)); + } + + /* Now figure out which of them that is slower and use for the for + total estimate! */ + total_estimate = ulestimate>dlestimate?ulestimate:dlestimate; + + /* create the three time strings */ + time2str(time_left, total_estimate > 0?(total_estimate - timespent):0); + time2str(time_total, total_estimate); + time2str(time_spent, timespent); + + /* Get the total amount of data expected to get transfered */ + total_expected_transfer = + (data->progress.flags & PGRS_UL_SIZE_KNOWN? + data->progress.size_ul:data->progress.uploaded)+ + (data->progress.flags & PGRS_DL_SIZE_KNOWN? + data->progress.size_dl:data->progress.downloaded); + + /* We have transfered this much so far */ + total_transfer = data->progress.downloaded + data->progress.uploaded; + + /* Get the percentage of data transfered so far */ + if(total_expected_transfer > 100) + total_percen=(int)(100*(total_transfer/100) / + (total_expected_transfer/100) ); + + fprintf(data->set.err, + "\r%3d %s %3d %s %3d %s %s %s %s %s %s %s", + total_percen, /* 3 letters */ /* total % */ + max5data(total_expected_transfer, max5[2]), /* total size */ + dlpercen, /* 3 letters */ /* rcvd % */ + max5data(data->progress.downloaded, max5[0]), /* rcvd size */ + ulpercen, /* 3 letters */ /* xfer % */ + max5data(data->progress.uploaded, max5[1]), /* xfer size */ + max5data(data->progress.dlspeed, max5[3]), /* avrg dl speed */ + max5data(data->progress.ulspeed, max5[4]), /* avrg ul speed */ + time_total, /* 8 letters */ /* total time */ + time_spent, /* 8 letters */ /* time spent */ + time_left, /* 8 letters */ /* time left */ + max5data(data->progress.current_speed, max5[5]) /* current speed */ + ); + + /* we flush the output stream to make it appear as soon as possible */ + fflush(data->set.err); + + return 0; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/progress.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/progress.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/progress.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/progress.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,70 @@ +#ifndef __PROGRESS_H +#define __PROGRESS_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: progress.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +#include "timeval.h" + + +typedef enum { + TIMER_NONE, + TIMER_NAMELOOKUP, + TIMER_CONNECT, + TIMER_PRETRANSFER, + TIMER_STARTTRANSFER, + TIMER_POSTRANSFER, + TIMER_STARTSINGLE, + TIMER_REDIRECT, + TIMER_LAST /* must be last */ +} timerid; + +void Curl_pgrsDone(struct connectdata *); +void Curl_pgrsStartNow(struct SessionHandle *data); +void Curl_pgrsSetDownloadSize(struct SessionHandle *data, curl_off_t size); +void Curl_pgrsSetUploadSize(struct SessionHandle *data, curl_off_t size); +void Curl_pgrsSetDownloadCounter(struct SessionHandle *data, curl_off_t size); +void Curl_pgrsSetUploadCounter(struct SessionHandle *data, curl_off_t size); +int Curl_pgrsUpdate(struct connectdata *); +void Curl_pgrsResetTimes(struct SessionHandle *data); +void Curl_pgrsTime(struct SessionHandle *data, timerid timer); + + +/* Don't show progress for sizes smaller than: */ +#define LEAST_SIZE_PROGRESS BUFSIZE + +#define PROGRESS_DOWNLOAD (1<<0) +#define PROGRESS_UPLOAD (1<<1) +#define PROGRESS_DOWN_AND_UP (PROGRESS_UPLOAD | PROGRESS_DOWNLOAD) + +#define PGRS_SHOW_DL (1<<0) +#define PGRS_SHOW_UL (1<<1) +#define PGRS_DONE_DL (1<<2) +#define PGRS_DONE_UL (1<<3) +#define PGRS_HIDE (1<<4) +#define PGRS_UL_SIZE_KNOWN (1<<5) +#define PGRS_DL_SIZE_KNOWN (1<<6) + +#define PGRS_HEADERS_OUT (1<<7) /* set when the headers have been written */ + + +#endif /* __PROGRESS_H */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/security.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/security.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/security.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/security.c 2004-10-06 00:42:38.000000000 +0800 @@ -0,0 +1,483 @@ +/* This source code was modified by Martin Hedenfalk for + * use in Curl. His latest changes were done 2000-09-18. + * + * It has since been patched and modified a lot by Daniel Stenberg + * to make it better applied to curl conditions, and to make + * it not use globals, pollute name space and more. This source code awaits a + * rewrite to work around the paragraph 2 in the BSD licenses as explained + * below. + * + * Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ + +#include "setup.h" + +#ifndef CURL_DISABLE_FTP +#ifdef HAVE_KRB4 + +#define _MPRINTF_REPLACE /* we want curl-functions instead of native ones */ +#include + +#include "security.h" +#include +#include +#include + +#ifdef HAVE_UNISTD_H +#include +#endif + +#include "base64.h" +#include "sendf.h" +#include "ftp.h" +#include "curl_memory.h" + +/* The last #include file should be: */ +#include "memdebug.h" + +#define min(a, b) ((a) < (b) ? (a) : (b)) + +static struct { + enum protection_level level; + const char *name; +} level_names[] = { + { prot_clear, "clear" }, + { prot_safe, "safe" }, + { prot_confidential, "confidential" }, + { prot_private, "private" } +}; + +static enum protection_level +name_to_level(const char *name) +{ + int i; + for(i = 0; i < (int)sizeof(level_names)/(int)sizeof(level_names[0]); i++) + if(!strncasecmp(level_names[i].name, name, strlen(name))) + return level_names[i].level; + return (enum protection_level)-1; +} + +static struct Curl_sec_client_mech *mechs[] = { +#ifdef KRB5 + /* not supported */ +#endif +#ifdef HAVE_KRB4 + &Curl_krb4_client_mech, +#endif + NULL +}; + +int +Curl_sec_getc(struct connectdata *conn, FILE *F) +{ + if(conn->sec_complete && conn->data_prot) { + char c; + if(Curl_sec_read(conn, fileno(F), &c, 1) <= 0) + return EOF; + return c; + } + else + return getc(F); +} + +static int +block_read(int fd, void *buf, size_t len) +{ + unsigned char *p = buf; + int b; + while(len) { + b = read(fd, p, len); + if (b == 0) + return 0; + else if (b < 0) + return -1; + len -= b; + p += b; + } + return p - (unsigned char*)buf; +} + +static int +block_write(int fd, void *buf, size_t len) +{ + unsigned char *p = buf; + int b; + while(len) { + b = write(fd, p, len); + if(b < 0) + return -1; + len -= b; + p += b; + } + return p - (unsigned char*)buf; +} + +static int +sec_get_data(struct connectdata *conn, + int fd, struct krb4buffer *buf) +{ + int len; + int b; + + b = block_read(fd, &len, sizeof(len)); + if (b == 0) + return 0; + else if (b < 0) + return -1; + len = ntohl(len); + buf->data = realloc(buf->data, len); + b = block_read(fd, buf->data, len); + if (b == 0) + return 0; + else if (b < 0) + return -1; + buf->size = (conn->mech->decode)(conn->app_data, buf->data, len, + conn->data_prot, conn); + buf->index = 0; + return 0; +} + +static size_t +buffer_read(struct krb4buffer *buf, void *data, size_t len) +{ + len = min(len, buf->size - buf->index); + memcpy(data, (char*)buf->data + buf->index, len); + buf->index += len; + return len; +} + +static size_t +buffer_write(struct krb4buffer *buf, void *data, size_t len) +{ + if(buf->index + len > buf->size) { + void *tmp; + if(buf->data == NULL) + tmp = malloc(1024); + else + tmp = realloc(buf->data, buf->index + len); + if(tmp == NULL) + return -1; + buf->data = tmp; + buf->size = buf->index + len; + } + memcpy((char*)buf->data + buf->index, data, len); + buf->index += len; + return len; +} + +int +Curl_sec_read(struct connectdata *conn, int fd, void *buffer, int length) +{ + size_t len; + int rx = 0; + + if(conn->sec_complete == 0 || conn->data_prot == 0) + return read(fd, buffer, length); + + if(conn->in_buffer.eof_flag){ + conn->in_buffer.eof_flag = 0; + return 0; + } + + len = buffer_read(&conn->in_buffer, buffer, length); + length -= len; + rx += len; + buffer = (char*)buffer + len; + + while(length) { + if(sec_get_data(conn, fd, &conn->in_buffer) < 0) + return -1; + if(conn->in_buffer.size == 0) { + if(rx) + conn->in_buffer.eof_flag = 1; + return rx; + } + len = buffer_read(&conn->in_buffer, buffer, length); + length -= len; + rx += len; + buffer = (char*)buffer + len; + } + return rx; +} + +static int +sec_send(struct connectdata *conn, int fd, char *from, int length) +{ + int bytes; + void *buf; + bytes = (conn->mech->encode)(conn->app_data, from, length, conn->data_prot, + &buf, conn); + bytes = htonl(bytes); + block_write(fd, &bytes, sizeof(bytes)); + block_write(fd, buf, ntohl(bytes)); + free(buf); + return length; +} + +int +Curl_sec_fflush_fd(struct connectdata *conn, int fd) +{ + if(conn->data_prot != prot_clear) { + if(conn->out_buffer.index > 0){ + Curl_sec_write(conn, fd, + conn->out_buffer.data, conn->out_buffer.index); + conn->out_buffer.index = 0; + } + sec_send(conn, fd, NULL, 0); + } + return 0; +} + +int +Curl_sec_write(struct connectdata *conn, int fd, char *buffer, int length) +{ + int len = conn->buffer_size; + int tx = 0; + + if(conn->data_prot == prot_clear) + return write(fd, buffer, length); + + len -= (conn->mech->overhead)(conn->app_data, conn->data_prot, len); + while(length){ + if(length < len) + len = length; + sec_send(conn, fd, buffer, len); + length -= len; + buffer += len; + tx += len; + } + return tx; +} + +int +Curl_sec_putc(struct connectdata *conn, int c, FILE *F) +{ + char ch = c; + if(conn->data_prot == prot_clear) + return putc(c, F); + + buffer_write(&conn->out_buffer, &ch, 1); + if(c == '\n' || conn->out_buffer.index >= 1024 /* XXX */) { + Curl_sec_write(conn, fileno(F), conn->out_buffer.data, + conn->out_buffer.index); + conn->out_buffer.index = 0; + } + return c; +} + +int +Curl_sec_read_msg(struct connectdata *conn, char *s, int level) +{ + int len; + char *buf; + int code; + + buf = malloc(strlen(s)); + len = Curl_base64_decode(s + 4, buf); /* XXX */ + + len = (conn->mech->decode)(conn->app_data, buf, len, level, conn); + if(len < 0) { + free(buf); + return -1; + } + + buf[len] = '\0'; + + if(buf[3] == '-') + code = 0; + else + sscanf(buf, "%d", &code); + if(buf[len-1] == '\n') + buf[len-1] = '\0'; + strcpy(s, buf); + free(buf); + return code; +} + +enum protection_level +Curl_set_command_prot(struct connectdata *conn, enum protection_level level) +{ + enum protection_level old = conn->command_prot; + conn->command_prot = level; + return old; +} + +static int +sec_prot_internal(struct connectdata *conn, int level) +{ + char *p; + unsigned int s = 1048576; + ssize_t nread; + + if(!conn->sec_complete){ + infof(conn->data, "No security data exchange has taken place.\n"); + return -1; + } + + if(level){ + int code; + if(Curl_ftpsendf(conn, "PBSZ %u", s)) + return -1; + + if(Curl_GetFTPResponse(&nread, conn, &code)) + return -1; + + if(code/100 != '2'){ + failf(conn->data, "Failed to set protection buffer size."); + return -1; + } + conn->buffer_size = s; + + p = strstr(conn->data->state.buffer, "PBSZ="); + if(p) + sscanf(p, "PBSZ=%u", &s); + if(s < conn->buffer_size) + conn->buffer_size = s; + } + + if(Curl_ftpsendf(conn, "PROT %c", level["CSEP"])) + return -1; + + if(Curl_GetFTPResponse(&nread, conn, NULL)) + return -1; + + if(conn->data->state.buffer[0] != '2'){ + failf(conn->data, "Failed to set protection level."); + return -1; + } + + conn->data_prot = (enum protection_level)level; + return 0; +} + +void +Curl_sec_set_protection_level(struct connectdata *conn) +{ + if(conn->sec_complete && conn->data_prot != conn->request_data_prot) + sec_prot_internal(conn, conn->request_data_prot); +} + + +int +Curl_sec_request_prot(struct connectdata *conn, const char *level) +{ + int l = name_to_level(level); + if(l == -1) + return -1; + conn->request_data_prot = (enum protection_level)l; + return 0; +} + +int +Curl_sec_login(struct connectdata *conn) +{ + int ret; + struct Curl_sec_client_mech **m; + ssize_t nread; + struct SessionHandle *data=conn->data; + int ftpcode; + + for(m = mechs; *m && (*m)->name; m++) { + void *tmp; + + tmp = realloc(conn->app_data, (*m)->size); + if (tmp == NULL) { + failf (data, "realloc %u failed", (*m)->size); + return -1; + } + conn->app_data = tmp; + + if((*m)->init && (*(*m)->init)(conn->app_data) != 0) { + infof(data, "Skipping %s...\n", (*m)->name); + continue; + } + infof(data, "Trying %s...\n", (*m)->name); + + if(Curl_ftpsendf(conn, "AUTH %s", (*m)->name)) + return -1; + + if(Curl_GetFTPResponse(&nread, conn, &ftpcode)) + return -1; + + if(conn->data->state.buffer[0] != '3'){ + switch(ftpcode) { + case 504: + infof(data, + "%s is not supported by the server.\n", (*m)->name); + break; + case 534: + infof(data, "%s rejected as security mechanism.\n", (*m)->name); + break; + default: + if(conn->data->state.buffer[0] == '5') { + infof(data, "The server doesn't support the FTP " + "security extensions.\n"); + return -1; + } + break; + } + continue; + } + + ret = (*(*m)->auth)(conn->app_data, conn); + + if(ret == AUTH_CONTINUE) + continue; + else if(ret != AUTH_OK){ + /* mechanism is supposed to output error string */ + return -1; + } + conn->mech = *m; + conn->sec_complete = 1; + conn->command_prot = prot_safe; + break; + } + + return *m == NULL; +} + +void +Curl_sec_end(struct connectdata *conn) +{ + if (conn->mech != NULL) { + if(conn->mech->end) + (conn->mech->end)(conn->app_data); + memset(conn->app_data, 0, conn->mech->size); + free(conn->app_data); + conn->app_data = NULL; + } + conn->sec_complete = 0; + conn->data_prot = (enum protection_level)0; + conn->mech=NULL; +} + +#endif /* HAVE_KRB4 */ +#endif /* CURL_DISABLE_FTP */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/security.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/security.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/security.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/security.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,72 @@ +#ifndef __SECURITY_H +#define __SECURITY_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: security.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +/* this is a re-write */ + +#include +#include "urldata.h" /* for struct connectdata * */ + +struct Curl_sec_client_mech { + const char *name; + size_t size; + int (*init)(void *); + int (*auth)(void *, struct connectdata *); + void (*end)(void *); + int (*check_prot)(void *, int); + int (*overhead)(void *, int, int); + int (*encode)(void *, void*, int, int, void**, struct connectdata *); + int (*decode)(void *, void*, int, int, struct connectdata *); +}; + + +#define AUTH_OK 0 +#define AUTH_CONTINUE 1 +#define AUTH_ERROR 2 + +extern struct Curl_sec_client_mech Curl_krb4_client_mech; + +int Curl_sec_fflush_fd(struct connectdata *conn, int fd); +int Curl_sec_fprintf (struct connectdata *, FILE *, const char *, ...); +int Curl_sec_getc (struct connectdata *conn, FILE *); +int Curl_sec_putc (struct connectdata *conn, int, FILE *); +int Curl_sec_read (struct connectdata *conn, int, void *, int); +int Curl_sec_read_msg (struct connectdata *conn, char *, int); + +int Curl_sec_vfprintf(struct connectdata *, FILE *, const char *, va_list); +int Curl_sec_fprintf2(struct connectdata *conn, FILE *f, const char *fmt, ...); +int Curl_sec_vfprintf2(struct connectdata *conn, FILE *, const char *, va_list); +int Curl_sec_write (struct connectdata *conn, int, char *, int); + +void Curl_sec_end (struct connectdata *); +int Curl_sec_login (struct connectdata *); +void Curl_sec_prot (int, char **); +int Curl_sec_request_prot (struct connectdata *conn, const char *level); +void Curl_sec_set_protection_level(struct connectdata *conn); +void Curl_sec_status (void); + +enum protection_level Curl_set_command_prot(struct connectdata *, + enum protection_level); + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/sendf.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/sendf.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/sendf.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/sendf.c 2005-02-28 06:36:00.000000000 +0800 @@ -0,0 +1,496 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: sendf.c,v 1.8 2005/02/27 22:36:00 andy Exp $ + ***************************************************************************/ + +#include "setup.h" + +#include +#include +#include +#include + +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_SYS_SOCKET_H +#include /* required for send() & recv() prototypes */ +#endif + +#ifdef HAVE_UNISTD_H +#include +#endif + +#include +#include "urldata.h" +#include "sendf.h" +#include "connect.h" /* for the Curl_ourerrno() proto */ + +#define _MPRINTF_REPLACE /* use the internal *printf() functions */ +#include + +#ifdef HAVE_KRB4 +#include "security.h" +#endif +#include +#include "curl_memory.h" +/* The last #include file should be: */ +#include "memdebug.h" + +/* returns last node in linked list */ +static struct curl_slist *slist_get_last(struct curl_slist *list) +{ + struct curl_slist *item; + + /* if caller passed us a NULL, return now */ + if (!list) + return NULL; + + /* loop through to find the last item */ + item = list; + while (item->next) { + item = item->next; + } + return item; +} + +/* + * curl_slist_append() appends a string to the linked list. It always retunrs + * the address of the first record, so that you can sure this function as an + * initialization function as well as an append function. If you find this + * bothersome, then simply create a separate _init function and call it + * appropriately from within the proram. + */ +struct curl_slist *curl_slist_append(struct curl_slist *list, + const char *data) +{ + struct curl_slist *last; + struct curl_slist *new_item; + + new_item = (struct curl_slist *) malloc(sizeof(struct curl_slist)); + if (new_item) { + char *cuDup = strdup(data); + if(cuDup) { + new_item->next = NULL; + new_item->data = cuDup; + } + else { + free(new_item); + return NULL; + } + } + else + return NULL; + + if (list) { + last = slist_get_last(list); + last->next = new_item; + return list; + } + + /* if this is the first item, then new_item *is* the list */ + return new_item; +} + +/* be nice and clean up resources */ +void curl_slist_free_all(struct curl_slist *list) +{ + struct curl_slist *next; + struct curl_slist *item; + + if (!list) + return; + + item = list; + do { + next = item->next; + + if (item->data) { + free(item->data); + } + free(item); + item = next; + } while (next); +} + +/* Curl_infof() is for info message along the way */ + +void Curl_infof(struct SessionHandle *data, const char *fmt, ...) +{ + if(data && data->set.verbose) { + va_list ap; + char print_buffer[1024 + 1]; + va_start(ap, fmt); + vsnprintf(print_buffer, 1024, fmt, ap); + va_end(ap); + Curl_debug(data, CURLINFO_TEXT, print_buffer, strlen(print_buffer), NULL); + } +} + +/* Curl_failf() is for messages stating why we failed. + * The message SHALL NOT include any LF or CR. + */ + +void Curl_failf(struct SessionHandle *data, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + if(data->set.errorbuffer && !data->state.errorbuf) { + vsnprintf(data->set.errorbuffer, CURL_ERROR_SIZE, fmt, ap); + data->state.errorbuf = TRUE; /* wrote error string */ + + if(data->set.verbose) { + size_t len = strlen(data->set.errorbuffer); + bool doneit=FALSE; + if(len < CURL_ERROR_SIZE - 1) { + doneit = TRUE; + data->set.errorbuffer[len] = '\n'; + data->set.errorbuffer[++len] = '\0'; + } + Curl_debug(data, CURLINFO_TEXT, data->set.errorbuffer, len, NULL); + if(doneit) + /* cut off the newline again */ + data->set.errorbuffer[--len]=0; + } + } + va_end(ap); +} + +/* Curl_sendf() sends formated data to the server */ +CURLcode Curl_sendf(curl_socket_t sockfd, struct connectdata *conn, + const char *fmt, ...) +{ + struct SessionHandle *data = conn->data; + ssize_t bytes_written; + size_t write_len; + CURLcode res; + char *s; + char *sptr; + va_list ap; + va_start(ap, fmt); + s = vaprintf(fmt, ap); /* returns an allocated string */ + va_end(ap); + if(!s) + return CURLE_OUT_OF_MEMORY; /* failure */ + + bytes_written=0; + write_len = strlen(s); + sptr = s; + + while (1) { + /* Write the buffer to the socket */ + res = Curl_write(conn, sockfd, sptr, write_len, &bytes_written); + + if(CURLE_OK != res) + break; + + if(data->set.verbose) + Curl_debug(data, CURLINFO_DATA_OUT, sptr, bytes_written, + conn->host.dispname); + + if((size_t)bytes_written != write_len) { + /* if not all was written at once, we must advance the pointer, decrease + the size left and try again! */ + write_len -= bytes_written; + sptr += bytes_written; + } + else + break; + } + + free(s); /* free the output string */ + + return res; +} + +/* + * Curl_write() is an internal write function that sends plain (binary) data + * to the server. Works with plain sockets, SSL or kerberos. + */ +CURLcode Curl_write(struct connectdata *conn, + curl_socket_t sockfd, + void *mem, + size_t len, + ssize_t *written) +{ + ssize_t bytes_written; + CURLcode retcode; + +#ifdef USE_SSLEAY + /* Set 'num' to 0 or 1, depending on which socket that has been sent here. + If it is the second socket, we set num to 1. Otherwise to 0. This lets + us use the correct ssl handle. */ + int num = (sockfd == conn->sock[SECONDARYSOCKET]); + /* SSL_write() is said to return 'int' while write() and send() returns + 'size_t' */ + if (conn->ssl[num].use) { + int err; + char error_buffer[120]; /* OpenSSL documents that this must be at least + 120 bytes long. */ + unsigned long sslerror; + int rc = SSL_write(conn->ssl[num].handle, mem, (int)len); + + if(rc < 0) { + err = SSL_get_error(conn->ssl[num].handle, rc); + + switch(err) { + case SSL_ERROR_WANT_READ: + case SSL_ERROR_WANT_WRITE: + /* The operation did not complete; the same TLS/SSL I/O function + should be called again later. This is basicly an EWOULDBLOCK + equivalent. */ + *written = 0; + return CURLE_OK; + case SSL_ERROR_SYSCALL: + failf(conn->data, "SSL_write() returned SYSCALL, errno = %d\n", + Curl_ourerrno()); + return CURLE_SEND_ERROR; + case SSL_ERROR_SSL: + /* A failure in the SSL library occurred, usually a protocol error. + The OpenSSL error queue contains more information on the error. */ + sslerror = ERR_get_error(); + failf(conn->data, "SSL_write() error: %s\n", + ERR_error_string(sslerror, error_buffer)); + return CURLE_SEND_ERROR; + } + /* a true error */ + failf(conn->data, "SSL_write() return error %d\n", err); + return CURLE_SEND_ERROR; + } + bytes_written = rc; + } + else { +#else + (void)conn; +#endif +#ifdef HAVE_KRB4 + if(conn->sec_complete) { + bytes_written = Curl_sec_write(conn, sockfd, mem, len); + } + else +#endif /* HAVE_KRB4 */ + { + bytes_written = (ssize_t)swrite(sockfd, mem, len); + } + if(-1 == bytes_written) { + int err = Curl_ourerrno(); + + if( +#ifdef WSAEWOULDBLOCK + /* This is how Windows does it */ + (WSAEWOULDBLOCK == err) +#else + /* As pointed out by Christophe Demory on March 11 2003, errno + may be EWOULDBLOCK or on some systems EAGAIN when it returned + due to its inability to send off data without blocking. We + therefor treat both error codes the same here */ + (EWOULDBLOCK == err) || (EAGAIN == err) || (EINTR == err) +#endif + ) + /* this is just a case of EWOULDBLOCK */ + bytes_written=0; + } +#ifdef USE_SSLEAY + } +#endif + + *written = bytes_written; + retcode = (-1 != bytes_written)?CURLE_OK:CURLE_SEND_ERROR; + + return retcode; +} + +/* client_write() sends data to the write callback(s) + + The bit pattern defines to what "streams" to write to. Body and/or header. + The defines are in sendf.h of course. + */ +CURLcode Curl_client_write(struct SessionHandle *data, + int type, + char *ptr, + size_t len) +{ + size_t wrote; + + if(0 == len) + len = strlen(ptr); + + if(type & CLIENTWRITE_BODY) { + wrote = data->set.fwrite(ptr, 1, len, data->set.out); + if(wrote != len) { + failf (data, "Failed writing body"); + return CURLE_WRITE_ERROR; + } + } + if((type & CLIENTWRITE_HEADER) && + (data->set.fwrite_header || data->set.writeheader) ) { + /* + * Write headers to the same callback or to the especially setup + * header callback function (added after version 7.7.1). + */ + curl_write_callback writeit= + data->set.fwrite_header?data->set.fwrite_header:data->set.fwrite; + + wrote = writeit(ptr, 1, len, data->set.writeheader); + if(wrote != len) { + failf (data, "Failed writing header"); + return CURLE_WRITE_ERROR; + } + } + + return CURLE_OK; +} + +/* + * Internal read-from-socket function. This is meant to deal with plain + * sockets, SSL sockets and kerberos sockets. + * + * If the read would block (EWOULDBLOCK) we return -1. Otherwise we return + * a regular CURLcode value. + */ +int Curl_read(struct connectdata *conn, /* connection data */ + curl_socket_t sockfd, /* read from this socket */ + char *buf, /* store read data here */ + size_t buffersize, /* max amount to read */ + ssize_t *n) /* amount bytes read */ +{ + ssize_t nread; +#ifdef USE_SSLEAY + /* Set 'num' to 0 or 1, depending on which socket that has been sent here. + If it is the second socket, we set num to 1. Otherwise to 0. This lets + us use the correct ssl handle. */ + int num = (sockfd == conn->sock[SECONDARYSOCKET]); + + *n=0; /* reset amount to zero */ + + if (conn->ssl[num].use) { + nread = (ssize_t)SSL_read(conn->ssl[num].handle, buf, (int)buffersize); + + if(nread < 0) { + /* failed SSL_read */ + int err = SSL_get_error(conn->ssl[num].handle, (int)nread); + + switch(err) { + case SSL_ERROR_NONE: /* this is not an error */ + case SSL_ERROR_ZERO_RETURN: /* no more data */ + break; + case SSL_ERROR_WANT_READ: + case SSL_ERROR_WANT_WRITE: + /* there's data pending, re-invoke SSL_read() */ + return -1; /* basicly EWOULDBLOCK */ + default: + /* openssl/ssl.h says "look at error stack/return value/errno" */ + { + char error_buffer[120]; /* OpenSSL documents that this must be at + least 120 bytes long. */ + unsigned long sslerror = ERR_get_error(); + failf(conn->data, "SSL read: %s, errno %d", + ERR_error_string(sslerror, error_buffer), + Curl_ourerrno() ); + } + return CURLE_RECV_ERROR; + } + } + } + else { +#else + (void)conn; +#endif + *n=0; /* reset amount to zero */ +#ifdef HAVE_KRB4 + if(conn->sec_complete) + nread = Curl_sec_read(conn, sockfd, buf, buffersize); + else +#endif + nread = sread(sockfd, buf, buffersize); + + if(-1 == nread) { + int err = Curl_ourerrno(); +#ifdef WIN32 + if(WSAEWOULDBLOCK == err) +#else + if((EWOULDBLOCK == err) || (EAGAIN == err) || (EINTR == err)) +#endif + return -1; + } + +#ifdef USE_SSLEAY + } +#endif /* USE_SSLEAY */ + *n = nread; + return CURLE_OK; +} + +/* return 0 on success */ +static int showit(struct SessionHandle *data, curl_infotype type, + char *ptr, size_t size) +{ + static const char * const s_infotype[CURLINFO_END] = { + "* ", "< ", "> ", "{ ", "} ", "{ ", "} " }; + + if(data->set.fdebug) + return (*data->set.fdebug)(data, type, ptr, size, + data->set.debugdata); + + switch(type) { + case CURLINFO_TEXT: + case CURLINFO_HEADER_OUT: + case CURLINFO_HEADER_IN: + fwrite(s_infotype[type], 2, 1, data->set.err); + fwrite(ptr, size, 1, data->set.err); + break; + default: /* nada */ + break; + } + return 0; +} + +int Curl_debug(struct SessionHandle *data, curl_infotype type, + char *ptr, size_t size, char *host) +{ + int rc; + if(data->set.printhost && host) { + char buffer[160]; + const char *t=NULL; + switch (type) { + case CURLINFO_HEADER_IN: + case CURLINFO_DATA_IN: + t = "from"; + break; + case CURLINFO_HEADER_OUT: + case CURLINFO_DATA_OUT: + t = "to"; + break; + default: + break; + } + + if(t) { + snprintf(buffer, sizeof(buffer), "[Data %s %s]", t, host); + rc = showit(data, CURLINFO_TEXT, buffer, strlen(buffer)); + if(rc) + return rc; + } + } + rc = showit(data, type, ptr, size); + return rc; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/sendf.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/sendf.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/sendf.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/sendf.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,56 @@ +#ifndef __SENDF_H +#define __SENDF_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: sendf.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +CURLcode Curl_sendf(curl_socket_t sockfd, struct connectdata *, + const char *fmt, ...); +void Curl_infof(struct SessionHandle *, const char *fmt, ...); +void Curl_failf(struct SessionHandle *, const char *fmt, ...); + +#define infof Curl_infof +#define failf Curl_failf + +#define CLIENTWRITE_BODY 1 +#define CLIENTWRITE_HEADER 2 +#define CLIENTWRITE_BOTH (CLIENTWRITE_BODY|CLIENTWRITE_HEADER) + +CURLcode Curl_client_write(struct SessionHandle *data, int type, char *ptr, + size_t len); + +/* internal read-function, does plain socket, SSL and krb4 */ +int Curl_read(struct connectdata *conn, curl_socket_t sockfd, + char *buf, size_t buffersize, + ssize_t *n); +/* internal write-function, does plain socket, SSL and krb4 */ +CURLcode Curl_write(struct connectdata *conn, + curl_socket_t sockfd, + void *mem, size_t len, + ssize_t *written); + +/* the function used to output verbose information */ +int Curl_debug(struct SessionHandle *handle, curl_infotype type, + char *data, size_t size, char *host); + + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/setup.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/setup.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/setup.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/setup.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,294 @@ +#ifndef __SETUP_H +#define __SETUP_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: setup.h,v 1.7 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +#ifdef HTTP_ONLY +#define CURL_DISABLE_FTP +#define CURL_DISABLE_LDAP +#define CURL_DISABLE_TELNET +#define CURL_DISABLE_DICT +#define CURL_DISABLE_FILE +#define CURL_DISABLE_GOPHER +#endif + +#if !defined(WIN32) && defined(__WIN32__) +/* This should be a good Borland fix. Alexander J. Oss told us! */ +#define WIN32 +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" /* the configure script results */ +#else +#ifdef WIN32 +/* hand-modified win32 config.h! */ +#include "config-win32.h" +#endif +#endif + +#ifdef macintosh +/* hand-modified MacOS config.h! */ +#include "config-mac.h" +#endif +#ifdef AMIGA +/* hand-modified AmigaOS config.h! */ +#include "amigaos.h" +#endif + +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif + +#if !defined(__cplusplus) && !defined(__BEOS__) +typedef unsigned char bool; +#define typedef_bool +#endif + +#ifdef HAVE_LONGLONG +#define LONG_LONG long long +#define ENABLE_64BIT +#else +#ifdef _MSC_VER +#define LONG_LONG __int64 +#define ENABLE_64BIT +#endif +#endif /* HAVE_LONGLONG */ + +#ifndef SIZEOF_CURL_OFF_T +/* If we don't know the size here, we assume a conservative size: 4. When + building libcurl, the actual size of this variable should be define in the + config*.h file. */ +#define SIZEOF_CURL_OFF_T 4 +#endif + +/* We set up our internal prefered (CURL_)FORMAT_OFF_T here */ +#if SIZEOF_CURL_OFF_T > 4 +#define FORMAT_OFF_T "lld" +#else +#define FORMAT_OFF_T "ld" +#endif + +#ifdef NEED_REENTRANT +/* Solaris machines needs _REENTRANT set for a few function prototypes and + things to appear in the #include files. We need to #define it before all + #include files */ +#define _REENTRANT +#endif + +#include +#ifdef HAVE_ASSERT_H +#include +#endif +#include + +#ifdef __TANDEM /* for nsr-tandem-nsk systems */ +#include +#endif + +#if defined(HAVE_X509_H) && defined(HAVE_SSL_H) && defined(HAVE_RSA_H) && \ +defined(HAVE_PEM_H) && defined(HAVE_ERR_H) && defined(HAVE_CRYPTO_H) && \ +defined(HAVE_LIBSSL) && defined(HAVE_LIBCRYPTO) + /* the six important includes files all exist and so do both libs, + defined SSLeay usage */ +#define USE_SSLEAY 1 +#endif +#if defined(HAVE_OPENSSL_X509_H) && defined(HAVE_OPENSSL_SSL_H) && \ +defined(HAVE_OPENSSL_RSA_H) && defined(HAVE_OPENSSL_PEM_H) && \ +defined(HAVE_OPENSSL_ERR_H) && defined(HAVE_OPENSSL_CRYPTO_H) && \ +defined(HAVE_LIBSSL) && defined(HAVE_LIBCRYPTO) + /* the six important includes files all exist and so do both libs, + defined SSLeay usage */ +#define USE_SSLEAY 1 +#define USE_OPENSSL 1 +#endif + +#ifndef STDC_HEADERS /* no standard C headers! */ +#include +#endif + +#if defined(CURLDEBUG) && defined(HAVE_ASSERT_H) +#define curlassert(x) assert(x) +#else +/* does nothing without CURLDEBUG defined */ +#define curlassert(x) +#endif + +#ifdef MSG_NOSIGNAL +/* If we have the MSG_NOSIGNAL define, we make sure to use that in the forth + argument to send() and recv() */ +#define SEND_4TH_ARG MSG_NOSIGNAL +#define HAVE_MSG_NOSIGNAL 1 /* we have MSG_NOSIGNAL */ +#else +#define SEND_4TH_ARG 0 +#endif + + +/* Below we define four functions. They should + 1. close a socket + 2. read from a socket + 3. write to a socket + + 4. set the SIGALRM signal timeout + 5. set dir/file naming defines + */ + +#ifdef WIN32 + +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN /* Prevent including in */ +#endif + +#if (defined(ENABLE_IPV6) || defined(CURLDEBUG)) && defined(_MSC_VER) && \ + (!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0500) +/* + * Needed to pull in the real getaddrinfo() and not the inline version + * in which doesn't support IPv6 (IPv4 only). is + * included from for <= 0x0500 SDKs. + */ +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0501 +#endif + +#include /* required by telnet.c */ + +#if defined(ENABLE_IPV6) || defined(USE_SSLEAY) +#include +#endif + +#if !defined(__GNUC__) || defined(__MINGW32__) +#define sclose(x) closesocket(x) +#define sread(x,y,z) recv(x,y,z, SEND_4TH_ARG) +#define swrite(x,y,z) (size_t)send(x,y,z, SEND_4TH_ARG) +#undef HAVE_ALARM +#else + /* gcc-for-win is still good :) */ +#define sclose(x) close(x) +#define sread(x,y,z) recv(x,y,z, SEND_4TH_ARG) +#define swrite(x,y,z) send(x,y,z, SEND_4TH_ARG) +#define HAVE_ALARM +#endif + +#define DIR_CHAR "\\" +#define DOT_CHAR "_" + +#else + +#ifdef DJGPP +#define sclose(x) close_s(x) +#define sread(x,y,z) read_s(x,y,z) +#define swrite(x,y,z) write_s(x,y,z) +#define select(n,r,w,x,t) select_s(n,r,w,x,t) +#define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z)) +#define IOCTL_3_ARGS +#include +#ifdef word +#undef word +#endif + +#else + +#ifdef __BEOS__ +#define sclose(x) closesocket(x) +#define sread(x,y,z) (ssize_t)recv(x,y,z, SEND_4TH_ARG) +#define swrite(x,y,z) (ssize_t)send(x,y,z, SEND_4TH_ARG) +#else +#define sclose(x) close(x) +#define sread(x,y,z) recv(x,y,z, SEND_4TH_ARG) +#define swrite(x,y,z) send(x,y,z, SEND_4TH_ARG) +#endif + +#define HAVE_ALARM + +#endif + +#ifdef _AMIGASF +#undef HAVE_ALARM +#undef sclose +#define sclose(x) CloseSocket(x) +#endif + +#define DIR_CHAR "/" +#define DOT_CHAR "." + +#ifdef DJGPP +#undef DOT_CHAR +#define DOT_CHAR "_" +#endif + +#ifndef fileno /* sunos 4 have this as a macro! */ +int fileno( FILE *stream); +#endif + +#endif + +/* now typedef our socket type */ +#ifdef WIN32 +typedef SOCKET curl_socket_t; +#define CURL_SOCKET_BAD INVALID_SOCKET +#else +typedef int curl_socket_t; +#define CURL_SOCKET_BAD -1 +#endif + +#if defined(ENABLE_IPV6) && defined(USE_ARES) +#error "ares does not yet support IPv6. Disable IPv6 or ares and rebuild" +#endif + +#if defined(WIN32) && !defined(__CYGWIN__) && !defined(USE_ARES) && \ + !defined(__LCC__) /* lcc-win32 doesn't have _beginthreadex() */ +#ifdef ENABLE_IPV6 +#define USE_THREADING_GETADDRINFO +#else +#define USE_THREADING_GETHOSTBYNAME /* Cygwin uses alarm() function */ +#endif +#endif + +#ifdef mpeix +#define IOCTL_3_ARGS +#endif + +#ifndef ECONNRESET +#ifdef WSAECONNRESET +#define ECONNRESET WSAECONNRESET +#else +/* This will effectively prevent the code from working in this particular + aspect, but it still compile fine! */ +#define ECONNRESET 10000 +#endif +#endif + +#ifdef NETWARE +#undef HAVE_ALARM +#endif + +#ifdef HAVE_LIBIDN +/* This could benefit from additional checks that some of the used/important + header files are present as well before we define the USE_* define. */ +#define USE_LIBIDN +#define LIBIDN_REQUIRED_VERSION "0.4.1" +#endif + +#endif /* __CONFIG_H */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/share.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/share.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/share.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/share.c 2004-10-06 00:42:38.000000000 +0800 @@ -0,0 +1,219 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: share.c,v 1.3 2004/10/05 16:42:38 hoffman Exp $ + ***************************************************************************/ + +#include "setup.h" +#include +#include +#include +#include +#include "urldata.h" +#include "share.h" +#include "curl_memory.h" + +/* The last #include file should be: */ +#include "memdebug.h" + +CURLSH * +curl_share_init(void) +{ + struct Curl_share *share = + (struct Curl_share *)malloc(sizeof(struct Curl_share)); + if (share) { + memset (share, 0, sizeof(struct Curl_share)); + share->specifier |= (1<dirty) + /* don't allow setting options while one or more handles are already + using this share */ + return CURLSHE_IN_USE; + + va_start(param, option); + + switch(option) { + case CURLSHOPT_SHARE: + /* this is a type this share will share */ + type = va_arg(param, int); + share->specifier |= (1<hostcache) { + share->hostcache = Curl_mk_dnscache(); + if(!share->hostcache) + return CURLSHE_NOMEM; + } + break; + +#ifndef CURL_DISABLE_HTTP + case CURL_LOCK_DATA_COOKIE: + if (!share->cookies) { + share->cookies = Curl_cookie_init(NULL, NULL, NULL, TRUE ); + if(!share->cookies) + return CURLSHE_NOMEM; + } + break; +#endif /* CURL_DISABLE_HTTP */ + + case CURL_LOCK_DATA_SSL_SESSION: /* not supported (yet) */ + case CURL_LOCK_DATA_CONNECT: /* not supported (yet) */ + + default: + return CURLSHE_BAD_OPTION; + } + break; + + case CURLSHOPT_UNSHARE: + /* this is a type this share will no longer share */ + type = va_arg(param, int); + share->specifier &= ~(1<hostcache) { + Curl_hash_destroy(share->hostcache); + share->hostcache = NULL; + } + break; + +#ifndef CURL_DISABLE_HTTP + case CURL_LOCK_DATA_COOKIE: + if (share->cookies) { + Curl_cookie_cleanup(share->cookies); + share->cookies = NULL; + } + break; +#endif /* CURL_DISABLE_HTTP */ + + case CURL_LOCK_DATA_SSL_SESSION: + break; + + case CURL_LOCK_DATA_CONNECT: + break; + + default: + return CURLSHE_BAD_OPTION; + } + break; + + case CURLSHOPT_LOCKFUNC: + lockfunc = va_arg(param, curl_lock_function); + share->lockfunc = lockfunc; + break; + + case CURLSHOPT_UNLOCKFUNC: + unlockfunc = va_arg(param, curl_unlock_function); + share->unlockfunc = unlockfunc; + break; + + case CURLSHOPT_USERDATA: + ptr = va_arg(param, void *); + share->clientdata = ptr; + break; + + default: + return CURLSHE_BAD_OPTION; + } + + return CURLSHE_OK; +} + +CURLSHcode +curl_share_cleanup(CURLSH *sh) +{ + struct Curl_share *share = (struct Curl_share *)sh; + + if (share == NULL) + return CURLSHE_INVALID; + + if(share->lockfunc) + share->lockfunc(NULL, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE, + share->clientdata); + + if (share->dirty) { + if(share->unlockfunc) + share->unlockfunc(NULL, CURL_LOCK_DATA_SHARE, share->clientdata); + return CURLSHE_IN_USE; + } + + if(share->hostcache) + Curl_hash_destroy(share->hostcache); + +#ifndef CURL_DISABLE_HTTP + if(share->cookies) + Curl_cookie_cleanup(share->cookies); +#endif /* CURL_DISABLE_HTTP */ + + if(share->unlockfunc) + share->unlockfunc(NULL, CURL_LOCK_DATA_SHARE, share->clientdata); + free(share); + + return CURLSHE_OK; +} + + +CURLSHcode +Curl_share_lock(struct SessionHandle *data, curl_lock_data type, + curl_lock_access accesstype) +{ + struct Curl_share *share = data->share; + + if (share == NULL) + return CURLSHE_INVALID; + + if(share->specifier & (1<lockfunc) /* only call this if set! */ + share->lockfunc(data, type, accesstype, share->clientdata); + } + /* else if we don't share this, pretend successful lock */ + + return CURLSHE_OK; +} + +CURLSHcode +Curl_share_unlock(struct SessionHandle *data, curl_lock_data type) +{ + struct Curl_share *share = data->share; + + if (share == NULL) + return CURLSHE_INVALID; + + if(share->specifier & (1<unlockfunc) /* only call this if set! */ + share->unlockfunc (data, type, share->clientdata); + } + + return CURLSHE_OK; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/share.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/share.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/share.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/share.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,55 @@ +#ifndef __CURL_SHARE_H +#define __CURL_SHARE_H + +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: share.h,v 1.2 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +#include "setup.h" +#include +#include "cookie.h" + +/* this struct is libcurl-private, don't export details */ +struct Curl_share { + unsigned int specifier; + volatile unsigned int dirty; + + curl_lock_function lockfunc; + curl_unlock_function unlockfunc; + void *clientdata; + + curl_hash *hostcache; + struct CookieInfo *cookies; +}; + +CURLSHcode Curl_share_lock ( + struct SessionHandle *, + curl_lock_data, + curl_lock_access + ); + +CURLSHcode Curl_share_unlock ( + struct SessionHandle *, + curl_lock_data + ); + +#endif /* __CURL_SHARE_H */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/speedcheck.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/speedcheck.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/speedcheck.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/speedcheck.c 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,67 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: speedcheck.c,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +#include "setup.h" + +#include +#include + +#include +#include "urldata.h" +#include "sendf.h" +#include "speedcheck.h" + +void Curl_speedinit(struct SessionHandle *data) +{ + memset(&data->state.keeps_speed, 0, sizeof(struct timeval)); +} + +CURLcode Curl_speedcheck(struct SessionHandle *data, + struct timeval now) +{ + if((data->progress.current_speed >= 0) && + data->set.low_speed_time && + (Curl_tvlong(data->state.keeps_speed) != 0) && + (data->progress.current_speed < data->set.low_speed_limit)) { + + /* We are now below the "low speed limit". If we are below it + for "low speed time" seconds we consider that enough reason + to abort the download. */ + + if( (Curl_tvdiff(now, data->state.keeps_speed)/1000) > + data->set.low_speed_time) { + /* we have been this slow for long enough, now die */ + failf(data, + "Operation too slow. " + "Less than %d bytes/sec transfered the last %d seconds", + data->set.low_speed_limit, + data->set.low_speed_time); + return CURLE_OPERATION_TIMEOUTED; + } + } + else { + /* we keep up the required speed all right */ + data->state.keeps_speed = now; + } + return CURLE_OK; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/speedcheck.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/speedcheck.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/speedcheck.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/speedcheck.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,34 @@ +#ifndef __SPEEDCHECK_H +#define __SPEEDCHECK_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: speedcheck.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +#include "setup.h" + +#include "timeval.h" + +void Curl_speedinit(struct SessionHandle *data); +CURLcode Curl_speedcheck(struct SessionHandle *data, + struct timeval now); + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/ssluse.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/ssluse.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/ssluse.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/ssluse.c 2004-10-06 00:42:38.000000000 +0800 @@ -0,0 +1,1487 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: ssluse.c,v 1.6 2004/10/05 16:42:38 hoffman Exp $ + ***************************************************************************/ + +/* + * The original SSL code for curl was written by + * Linas Vepstas and Sampo Kellomaki + */ + +#include "setup.h" + +#include +#include +#include +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + +#include "urldata.h" +#include "sendf.h" +#include "formdata.h" /* for the boundary function */ +#include "url.h" /* for the ssl config check function */ +#include "inet_pton.h" +#include "ssluse.h" +#include "connect.h" /* Curl_ourerrno() proto */ +#include "strequal.h" + +#define _MPRINTF_REPLACE /* use the internal *printf() functions */ +#include + +#ifdef USE_SSLEAY +#include +#include + +#include "curl_memory.h" + +/* The last #include file should be: */ +#include "memdebug.h" + +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#if OPENSSL_VERSION_NUMBER >= 0x0090581fL +#define HAVE_SSL_GET1_SESSION 1 +#else +#undef HAVE_SSL_GET1_SESSION +#endif + +#if OPENSSL_VERSION_NUMBER >= 0x00904100L +#define HAVE_USERDATA_IN_PWD_CALLBACK 1 +#else +#undef HAVE_USERDATA_IN_PWD_CALLBACK +#endif + +#if OPENSSL_VERSION_NUMBER >= 0x00907001L +/* ENGINE_load_private_key() takes four arguments */ +#define HAVE_ENGINE_LOAD_FOUR_ARGS +#else +/* ENGINE_load_private_key() takes three arguments */ +#undef HAVE_ENGINE_LOAD_FOUR_ARGS +#endif + +#if OPENSSL_VERSION_NUMBER >= 0x00906001L +#define HAVE_ERR_ERROR_STRING_N 1 +#endif + + +#ifndef HAVE_USERDATA_IN_PWD_CALLBACK +static char global_passwd[64]; +#endif + +static int passwd_callback(char *buf, int num, int verify +#if HAVE_USERDATA_IN_PWD_CALLBACK + /* This was introduced in 0.9.4, we can set this + using SSL_CTX_set_default_passwd_cb_userdata() + */ + , void *global_passwd +#endif + ) +{ + if(verify) + fprintf(stderr, "%s\n", buf); + else { + if(num > (int)strlen((char *)global_passwd)) { + strcpy(buf, global_passwd); + return (int)strlen(buf); + } + } + return 0; +} + +/* + * rand_enough() is a function that returns TRUE if we have seeded the random + * engine properly. We use some preprocessor magic to provide a seed_enough() + * macro to use, just to prevent a compiler warning on this function if we + * pass in an argument that is never used. + */ + +#ifdef HAVE_RAND_STATUS +#define seed_enough(x) rand_enough() +static bool rand_enough(void) +{ + return RAND_status()?TRUE:FALSE; +} +#else +#define seed_enough(x) rand_enough(x) +static bool rand_enough(int nread) +{ + /* this is a very silly decision to make */ + return (nread > 500)?TRUE:FALSE; +} +#endif + +static +int random_the_seed(struct SessionHandle *data) +{ + char *buf = data->state.buffer; /* point to the big buffer */ + int nread=0; + + /* Q: should we add support for a random file name as a libcurl option? + A: Yes, it is here */ + +#ifndef RANDOM_FILE + /* if RANDOM_FILE isn't defined, we only perform this if an option tells + us to! */ + if(data->set.ssl.random_file) +#define RANDOM_FILE "" /* doesn't matter won't be used */ +#endif + { + /* let the option override the define */ + nread += RAND_load_file((data->set.ssl.random_file? + data->set.ssl.random_file:RANDOM_FILE), + 16384); + if(seed_enough(nread)) + return nread; + } + +#if defined(HAVE_RAND_EGD) + /* only available in OpenSSL 0.9.5 and later */ + /* EGD_SOCKET is set at configure time or not at all */ +#ifndef EGD_SOCKET + /* If we don't have the define set, we only do this if the egd-option + is set */ + if(data->set.ssl.egdsocket) +#define EGD_SOCKET "" /* doesn't matter won't be used */ +#endif + { + /* If there's an option and a define, the option overrides the + define */ + int ret = RAND_egd(data->set.ssl.egdsocket? + data->set.ssl.egdsocket:EGD_SOCKET); + if(-1 != ret) { + nread += ret; + if(seed_enough(nread)) + return nread; + } + } +#endif + + /* If we get here, it means we need to seed the PRNG using a "silly" + approach! */ +#ifdef HAVE_RAND_SCREEN + /* This one gets a random value by reading the currently shown screen */ + RAND_screen(); + nread = 100; /* just a value */ +#else + { + int len; + char *area; + + /* Changed call to RAND_seed to use the underlying RAND_add implementation + * directly. Do this in a loop, with the amount of additional entropy + * being dependent upon the algorithm used by Curl_FormBoundary(): N bytes + * of a 7-bit ascii set. -- Richard Gorton, March 11 2003. + */ + + do { + area = Curl_FormBoundary(); + if(!area) + return 3; /* out of memory */ + + len = (int)strlen(area); + RAND_add(area, len, (len >> 1)); + + free(area); /* now remove the random junk */ + } while (!RAND_status()); + } +#endif + + /* generates a default path for the random seed file */ + buf[0]=0; /* blank it first */ + RAND_file_name(buf, BUFSIZE); + if(buf[0]) { + /* we got a file name to try */ + nread += RAND_load_file(buf, 16384); + if(seed_enough(nread)) + return nread; + } + + infof(data, "libcurl is now using a weak random seed!\n"); + return nread; +} + +#ifndef SSL_FILETYPE_ENGINE +#define SSL_FILETYPE_ENGINE 42 +#endif +static int do_file_type(const char *type) +{ + if(!type || !type[0]) + return SSL_FILETYPE_PEM; + if(curl_strequal(type, "PEM")) + return SSL_FILETYPE_PEM; + if(curl_strequal(type, "DER")) + return SSL_FILETYPE_ASN1; + if(curl_strequal(type, "ENG")) + return SSL_FILETYPE_ENGINE; + return -1; +} + +static +int cert_stuff(struct connectdata *conn, + SSL_CTX* ctx, + char *cert_file, + const char *cert_type, + char *key_file, + const char *key_type) +{ + struct SessionHandle *data = conn->data; + int file_type; + + if(cert_file != NULL) { + SSL *ssl; + X509 *x509; + + if(data->set.key_passwd) { +#ifndef HAVE_USERDATA_IN_PWD_CALLBACK + /* + * If password has been given, we store that in the global + * area (*shudder*) for a while: + */ + size_t len = strlen(data->set.key_passwd); + if(len < sizeof(global_passwd)) + memcpy(global_passwd, data->set.key_passwd, len+1); +#else + /* + * We set the password in the callback userdata + */ + SSL_CTX_set_default_passwd_cb_userdata(ctx, + data->set.key_passwd); +#endif + /* Set passwd callback: */ + SSL_CTX_set_default_passwd_cb(ctx, passwd_callback); + } + + file_type = do_file_type(cert_type); + + switch(file_type) { + case SSL_FILETYPE_PEM: + /* SSL_CTX_use_certificate_chain_file() only works on PEM files */ + if(SSL_CTX_use_certificate_chain_file(ctx, + cert_file) != 1) { + failf(data, "unable to set certificate file (wrong password?)"); + return 0; + } + break; + + case SSL_FILETYPE_ASN1: + /* SSL_CTX_use_certificate_file() works with either PEM or ASN1, but + we use the case above for PEM so this can only be performed with + ASN1 files. */ + if(SSL_CTX_use_certificate_file(ctx, + cert_file, + file_type) != 1) { + failf(data, "unable to set certificate file (wrong password?)"); + return 0; + } + break; + case SSL_FILETYPE_ENGINE: + failf(data, "file type ENG for certificate not implemented"); + return 0; + + default: + failf(data, "not supported file type '%s' for certificate", cert_type); + return 0; + } + + file_type = do_file_type(key_type); + + switch(file_type) { + case SSL_FILETYPE_PEM: + if(key_file == NULL) + /* cert & key can only be in PEM case in the same file */ + key_file=cert_file; + case SSL_FILETYPE_ASN1: + if(SSL_CTX_use_PrivateKey_file(ctx, key_file, file_type) != 1) { + failf(data, "unable to set private key file: '%s' type %s\n", + key_file, key_type?key_type:"PEM"); + return 0; + } + break; + case SSL_FILETYPE_ENGINE: +#ifdef HAVE_OPENSSL_ENGINE_H + { /* XXXX still needs some work */ + EVP_PKEY *priv_key = NULL; + if(conn && conn->data && conn->data->engine) { +#ifdef HAVE_ENGINE_LOAD_FOUR_ARGS + UI_METHOD *ui_method = UI_OpenSSL(); +#endif + if(!key_file || !key_file[0]) { + failf(data, "no key set to load from crypto engine\n"); + return 0; + } + /* the typecast below was added to please mingw32 */ + priv_key = (EVP_PKEY *) + ENGINE_load_private_key(conn->data->engine,key_file, +#ifdef HAVE_ENGINE_LOAD_FOUR_ARGS + ui_method, +#endif + data->set.key_passwd); + if(!priv_key) { + failf(data, "failed to load private key from crypto engine\n"); + return 0; + } + if(SSL_CTX_use_PrivateKey(ctx, priv_key) != 1) { + failf(data, "unable to set private key\n"); + EVP_PKEY_free(priv_key); + return 0; + } + EVP_PKEY_free(priv_key); /* we don't need the handle any more... */ + } + else { + failf(data, "crypto engine not set, can't load private key\n"); + return 0; + } + } + break; +#else + failf(data, "file type ENG for private key not supported\n"); + return 0; +#endif + default: + failf(data, "not supported file type for private key\n"); + return 0; + } + + ssl=SSL_new(ctx); + x509=SSL_get_certificate(ssl); + + /* This version was provided by Evan Jordan and is supposed to not + leak memory as the previous version: */ + if(x509 != NULL) { + EVP_PKEY *pktmp = X509_get_pubkey(x509); + EVP_PKEY_copy_parameters(pktmp,SSL_get_privatekey(ssl)); + EVP_PKEY_free(pktmp); + } + + SSL_free(ssl); + + /* If we are using DSA, we can copy the parameters from + * the private key */ + + + /* Now we know that a key and cert have been set against + * the SSL context */ + if(!SSL_CTX_check_private_key(ctx)) { + failf(data, "Private key does not match the certificate public key"); + return(0); + } +#ifndef HAVE_USERDATA_IN_PWD_CALLBACK + /* erase it now */ + memset(global_passwd, 0, sizeof(global_passwd)); +#endif + } + return(1); +} + +static +int cert_verify_callback(int ok, X509_STORE_CTX *ctx) +{ + X509 *err_cert; + char buf[256]; + + err_cert=X509_STORE_CTX_get_current_cert(ctx); + X509_NAME_oneline(X509_get_subject_name(err_cert), buf, sizeof(buf)); + return ok; +} + +/* "global" init done? */ +static int init_ssl=0; + +/* we have the "SSL is seeded" boolean global for the application to + prevent multiple time-consuming seedings in vain */ +static bool ssl_seeded = FALSE; +#endif /* USE_SSLEAY */ + +/* Global init */ +void Curl_SSL_init(void) +{ +#ifdef USE_SSLEAY + /* make sure this is only done once */ + if(0 != init_ssl) + return; + + init_ssl++; /* never again */ + +#ifdef HAVE_ENGINE_LOAD_BUILTIN_ENGINES + ENGINE_load_builtin_engines(); +#endif + + /* Lets get nice error messages */ + SSL_load_error_strings(); + + /* Setup all the global SSL stuff */ + SSLeay_add_ssl_algorithms(); +#else + /* SSL disabled, do nothing */ +#endif +} + +/* Global cleanup */ +void Curl_SSL_cleanup(void) +{ +#ifdef USE_SSLEAY + if(init_ssl) { + /* only cleanup if we did a previous init */ + + /* Free the SSL error strings */ + ERR_free_strings(); + + /* EVP_cleanup() removes all ciphers and digests from the + table. */ + EVP_cleanup(); + +#ifdef HAVE_ENGINE_cleanup + ENGINE_cleanup(); +#endif + +#ifdef HAVE_CRYPTO_CLEANUP_ALL_EX_DATA + /* this function was not present in 0.9.6b, but was added sometimes + later */ + CRYPTO_cleanup_all_ex_data(); +#endif + + init_ssl=0; /* not inited any more */ + } +#else + /* SSL disabled, do nothing */ +#endif +} + +#ifndef USE_SSLEAY +void Curl_SSL_Close(struct connectdata *conn) +{ + (void)conn; +} +#endif + +#ifdef USE_SSLEAY + +/* + * This function is called when an SSL connection is closed. + */ +void Curl_SSL_Close(struct connectdata *conn) +{ + if(conn->ssl[FIRSTSOCKET].use) { + int i; + /* + ERR_remove_state() frees the error queue associated with + thread pid. If pid == 0, the current thread will have its + error queue removed. + + Since error queue data structures are allocated + automatically for new threads, they must be freed when + threads are terminated in oder to avoid memory leaks. + */ + ERR_remove_state(0); + + for(i=0; i<2; i++) { + struct ssl_connect_data *connssl = &conn->ssl[i]; + + if(connssl->handle) { + (void)SSL_shutdown(connssl->handle); + SSL_set_connect_state(connssl->handle); + + SSL_free (connssl->handle); + connssl->handle = NULL; + } + if(connssl->ctx) { + SSL_CTX_free (connssl->ctx); + connssl->ctx = NULL; + } + connssl->use = FALSE; /* get back to ordinary socket usage */ + } + } +} + + +/* + * This sets up a session cache to the specified size. + */ +CURLcode Curl_SSL_InitSessions(struct SessionHandle *data, long amount) +{ + struct curl_ssl_session *session; + + if(data->state.session) + /* this is just a precaution to prevent multiple inits */ + return CURLE_OK; + + session = (struct curl_ssl_session *) + malloc(amount * sizeof(struct curl_ssl_session)); + if(!session) + return CURLE_OUT_OF_MEMORY; + + /* "blank out" the newly allocated memory */ + memset(session, 0, amount * sizeof(struct curl_ssl_session)); + + /* store the info in the SSL section */ + data->set.ssl.numsessions = amount; + data->state.session = session; + data->state.sessionage = 1; /* this is brand new */ + + return CURLE_OK; +} + +/* + * Check if there's a session ID for the given connection in the cache, + * and if there's one suitable, it is returned. + */ +static int Get_SSL_Session(struct connectdata *conn, + SSL_SESSION **ssl_sessionid) +{ + struct curl_ssl_session *check; + struct SessionHandle *data = conn->data; + long i; + + for(i=0; i< data->set.ssl.numsessions; i++) { + check = &data->state.session[i]; + if(!check->sessionid) + /* not session ID means blank entry */ + continue; + if(curl_strequal(conn->host.name, check->name) && + (conn->remote_port == check->remote_port) && + Curl_ssl_config_matches(&conn->ssl_config, &check->ssl_config)) { + /* yes, we have a session ID! */ + data->state.sessionage++; /* increase general age */ + check->age = data->state.sessionage; /* set this as used in this age */ + *ssl_sessionid = check->sessionid; + return FALSE; + } + } + *ssl_sessionid = (SSL_SESSION *)NULL; + return TRUE; +} + +/* + * Kill a single session ID entry in the cache. + */ +static int Kill_Single_Session(struct curl_ssl_session *session) +{ + if(session->sessionid) { + /* defensive check */ + + /* free the ID */ + SSL_SESSION_free(session->sessionid); + session->sessionid=NULL; + session->age = 0; /* fresh */ + + Curl_free_ssl_config(&session->ssl_config); + + Curl_safefree(session->name); + session->name = NULL; /* no name */ + + return 0; /* ok */ + } + else + return 1; +} + +/* + * This function is called when the 'data' struct is going away. Close + * down everything and free all resources! + */ +int Curl_SSL_Close_All(struct SessionHandle *data) +{ + int i; + + if(data->state.session) { + for(i=0; i< data->set.ssl.numsessions; i++) + /* the single-killer function handles empty table slots */ + Kill_Single_Session(&data->state.session[i]); + + /* free the cache data */ + free(data->state.session); + } +#ifdef HAVE_OPENSSL_ENGINE_H + if(data->engine) + { + ENGINE_free(data->engine); + data->engine = NULL; + } +#endif + return 0; +} + +/* + * Extract the session id and store it in the session cache. + */ +static int Store_SSL_Session(struct connectdata *conn, + struct ssl_connect_data *ssl) +{ + SSL_SESSION *ssl_sessionid; + int i; + struct SessionHandle *data=conn->data; /* the mother of all structs */ + struct curl_ssl_session *store = &data->state.session[0]; + long oldest_age=data->state.session[0].age; /* zero if unused */ + char *clone_host; + + clone_host = strdup(conn->host.name); + if(!clone_host) + return -1; /* bail out */ + + /* ask OpenSSL, say please */ + +#ifdef HAVE_SSL_GET1_SESSION + ssl_sessionid = SSL_get1_session(ssl->handle); + + /* SSL_get1_session() will increment the reference + count and the session will stay in memory until explicitly freed with + SSL_SESSION_free(3), regardless of its state. + This function was introduced in openssl 0.9.5a. */ +#else + ssl_sessionid = SSL_get_session(ssl->handle); + + /* if SSL_get1_session() is unavailable, use SSL_get_session(). + This is an inferior option because the session can be flushed + at any time by openssl. It is included only so curl compiles + under versions of openssl < 0.9.5a. + + WARNING: How curl behaves if it's session is flushed is + untested. + */ +#endif + + /* Now we should add the session ID and the host name to the cache, (remove + the oldest if necessary) */ + + /* find an empty slot for us, or find the oldest */ + for(i=1; (iset.ssl.numsessions) && + data->state.session[i].sessionid; i++) { + if(data->state.session[i].age < oldest_age) { + oldest_age = data->state.session[i].age; + store = &data->state.session[i]; + } + } + if(i == data->set.ssl.numsessions) + /* cache is full, we must "kill" the oldest entry! */ + Kill_Single_Session(store); + else + store = &data->state.session[i]; /* use this slot */ + + /* now init the session struct wisely */ + store->sessionid = ssl_sessionid; + store->age = data->state.sessionage; /* set current age */ + store->name = clone_host; /* clone host name */ + store->remote_port = conn->remote_port; /* port number */ + + Curl_clone_ssl_config(&conn->ssl_config, &store->ssl_config); + + return 0; +} + +static int Curl_ASN1_UTCTIME_output(struct connectdata *conn, + const char *prefix, + ASN1_UTCTIME *tm) +{ + char *asn1_string; + int gmt=FALSE; + int i; + int year=0,month=0,day=0,hour=0,minute=0,second=0; + struct SessionHandle *data = conn->data; + + if(!data->set.verbose) + return 0; + + i=tm->length; + asn1_string=(char *)tm->data; + + if(i < 10) + return 1; + if(asn1_string[i-1] == 'Z') + gmt=TRUE; + for (i=0; i<10; i++) + if((asn1_string[i] > '9') || (asn1_string[i] < '0')) + return 2; + + year= (asn1_string[0]-'0')*10+(asn1_string[1]-'0'); + if(year < 50) + year+=100; + + month= (asn1_string[2]-'0')*10+(asn1_string[3]-'0'); + if((month > 12) || (month < 1)) + return 3; + + day= (asn1_string[4]-'0')*10+(asn1_string[5]-'0'); + hour= (asn1_string[6]-'0')*10+(asn1_string[7]-'0'); + minute= (asn1_string[8]-'0')*10+(asn1_string[9]-'0'); + + if((asn1_string[10] >= '0') && (asn1_string[10] <= '9') && + (asn1_string[11] >= '0') && (asn1_string[11] <= '9')) + second= (asn1_string[10]-'0')*10+(asn1_string[11]-'0'); + + infof(data, + "%s%04d-%02d-%02d %02d:%02d:%02d %s\n", + prefix, year+1900, month, day, hour, minute, second, (gmt?"GMT":"")); + + return 0; +} + +#endif + +/* ====================================================== */ +#ifdef USE_SSLEAY + +/* + * Match a hostname against a wildcard pattern. + * E.g. + * "foo.host.com" matches "*.host.com". + * + * We are a bit more liberal than RFC2818 describes in that we + * accept multiple "*" in pattern (similar to what some other browsers do). + * E.g. + * "abc.def.domain.com" should strickly not match "*.domain.com", but we + * don't consider "." to be important in CERT checking. + */ +#define HOST_NOMATCH 0 +#define HOST_MATCH 1 + +static int hostmatch(const char *hostname, const char *pattern) +{ + while (1) { + int c = *pattern++; + + if (c == '\0') + return (*hostname ? HOST_NOMATCH : HOST_MATCH); + + if (c == '*') { + c = *pattern; + if (c == '\0') /* "*\0" matches anything remaining */ + return HOST_MATCH; + + while (*hostname) { + /* The only recursive function in libcurl! */ + if (hostmatch(hostname++,pattern) == HOST_MATCH) + return HOST_MATCH; + } + return HOST_NOMATCH; + } + + if (toupper(c) != toupper(*hostname++)) + return HOST_NOMATCH; + } +} + +static int +cert_hostcheck(const char *match_pattern, const char *hostname) +{ + if (!match_pattern || !*match_pattern || + !hostname || !*hostname) /* sanity check */ + return 0; + + if(curl_strequal(hostname,match_pattern)) /* trivial case */ + return 1; + + if (hostmatch(hostname,match_pattern) == HOST_MATCH) + return 1; + return 0; +} + +/* Quote from RFC2818 section 3.1 "Server Identity" + + If a subjectAltName extension of type dNSName is present, that MUST + be used as the identity. Otherwise, the (most specific) Common Name + field in the Subject field of the certificate MUST be used. Although + the use of the Common Name is existing practice, it is deprecated and + Certification Authorities are encouraged to use the dNSName instead. + + Matching is performed using the matching rules specified by + [RFC2459]. If more than one identity of a given type is present in + the certificate (e.g., more than one dNSName name, a match in any one + of the set is considered acceptable.) Names may contain the wildcard + character * which is considered to match any single domain name + component or component fragment. E.g., *.a.com matches foo.a.com but + not bar.foo.a.com. f*.com matches foo.com but not bar.com. + + In some cases, the URI is specified as an IP address rather than a + hostname. In this case, the iPAddress subjectAltName must be present + in the certificate and must exactly match the IP in the URI. + +*/ +static CURLcode verifyhost(struct connectdata *conn, + X509 *server_cert) +{ + bool matched = FALSE; /* no alternative match yet */ + int target = GEN_DNS; /* target type, GEN_DNS or GEN_IPADD */ + int addrlen = 0; + struct SessionHandle *data = conn->data; + STACK_OF(GENERAL_NAME) *altnames; +#ifdef ENABLE_IPV6 + struct in6_addr addr; +#else + struct in_addr addr; +#endif + +#ifdef ENABLE_IPV6 + if(conn->bits.ipv6_ip && + Curl_inet_pton(AF_INET6, conn->host.name, &addr)) { + target = GEN_IPADD; + addrlen = sizeof(struct in6_addr); + } + else +#endif + if(Curl_inet_pton(AF_INET, conn->host.name, &addr)) { + target = GEN_IPADD; + addrlen = sizeof(struct in_addr); + } + + /* get a "list" of alternative names */ + altnames = X509_get_ext_d2i(server_cert, NID_subject_alt_name, NULL, NULL); + + if(altnames) { + int numalts; + int i; + + /* get amount of alternatives, RFC2459 claims there MUST be at least + one, but we don't depend on it... */ + numalts = sk_GENERAL_NAME_num(altnames); + + /* loop through all alternatives while none has matched */ + for (i=0; (itype == target) { + /* get data and length */ + const char *altptr = (char *)ASN1_STRING_data(check->d.ia5); + int altlen; + + switch(target) { + case GEN_DNS: /* name/pattern comparison */ + /* The OpenSSL man page explicitly says: "In general it cannot be + assumed that the data returned by ASN1_STRING_data() is null + terminated or does not contain embedded nulls." But also that + "The actual format of the data will depend on the actual string + type itself: for example for and IA5String the data will be ASCII" + + Gisle researched the OpenSSL sources: + "I checked the 0.9.6 and 0.9.8 sources before my patch and + it always 0-terminates an IA5String." + */ + if (cert_hostcheck(altptr, conn->host.name)) + matched = TRUE; + break; + + case GEN_IPADD: /* IP address comparison */ + /* compare alternative IP address if the data chunk is the same size + our server IP address is */ + altlen = ASN1_STRING_length(check->d.ia5); + if((altlen == addrlen) && !memcmp(altptr, &addr, altlen)) + matched = TRUE; + break; + } + } + } + GENERAL_NAMES_free(altnames); + } + + if(matched) + /* an alternative name matched the server hostname */ + infof(data, "\t subjectAltName: %s matched\n", conn->host.dispname); + else { + /* we have to look to the last occurence of a commonName in the + distinguished one to get the most significant one. */ + int j,i=-1 ; + +/* The following is done because of a bug in 0.9.6b */ + + unsigned char *nulstr = (unsigned char *)""; + unsigned char *peer_CN = nulstr; + + X509_NAME *name = X509_get_subject_name(server_cert) ; + if (name) + while ((j=X509_NAME_get_index_by_NID(name,NID_commonName,i))>=0) + i=j; + + /* we have the name entry and we will now convert this to a string + that we can use for comparison. Doing this we support BMPstring, + UTF8 etc. */ + + if (i>=0) { + ASN1_STRING *tmp = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(name,i)); + + /* In OpenSSL 0.9.7d and earlier, ASN1_STRING_to_UTF8 fails if the input + is already UTF-8 encoded. We check for this case and copy the raw + string manually to avoid the problem. This code can be made + conditional in the future when OpenSSL has been fixed. Work-around + brought by Alexis S. L. Carvalho. */ + if (tmp && ASN1_STRING_type(tmp) == V_ASN1_UTF8STRING) { + j = ASN1_STRING_length(tmp); + if (j >= 0) { + peer_CN = OPENSSL_malloc(j+1); + if (peer_CN) { + memcpy(peer_CN, ASN1_STRING_data(tmp), j); + peer_CN[j] = '\0'; + } + } + } + else /* not a UTF8 name */ + j = ASN1_STRING_to_UTF8(&peer_CN, tmp); + } + + if (peer_CN == nulstr) + peer_CN = NULL; + + if (!peer_CN) { + if(data->set.ssl.verifyhost > 1) { + failf(data, + "SSL: unable to obtain common name from peer certificate"); + return CURLE_SSL_PEER_CERTIFICATE; + } + else { + /* Consider verifyhost == 1 as an "OK" for a missing CN field, but we + output a note about the situation */ + infof(data, "\t common name: WARNING couldn't obtain\n"); + } + } + else if(!cert_hostcheck((const char *)peer_CN, conn->host.name)) { + if(data->set.ssl.verifyhost > 1) { + failf(data, "SSL: certificate subject name '%s' does not match " + "target host name '%s'", peer_CN, conn->host.dispname); + OPENSSL_free(peer_CN); + return CURLE_SSL_PEER_CERTIFICATE ; + } + else + infof(data, "\t common name: %s (does not match '%s')\n", + peer_CN, conn->host.dispname); + } + else { + infof(data, "\t common name: %s (matched)\n", peer_CN); + OPENSSL_free(peer_CN); + } + } + return CURLE_OK; +} +#endif + +/* The SSL_CTRL_SET_MSG_CALLBACK doesn't exist in ancient OpenSSL versions + and thus this cannot be done there. */ +#ifdef SSL_CTRL_SET_MSG_CALLBACK + +static const char *ssl_msg_type(int ssl_ver, int msg) +{ + if (ssl_ver == SSL2_VERSION_MAJOR) { + switch (msg) { + case SSL2_MT_ERROR: + return "Error"; + case SSL2_MT_CLIENT_HELLO: + return "Client hello"; + case SSL2_MT_CLIENT_MASTER_KEY: + return "Client key"; + case SSL2_MT_CLIENT_FINISHED: + return "Client finished"; + case SSL2_MT_SERVER_HELLO: + return "Server hello"; + case SSL2_MT_SERVER_VERIFY: + return "Server verify"; + case SSL2_MT_SERVER_FINISHED: + return "Server finished"; + case SSL2_MT_REQUEST_CERTIFICATE: + return "Request CERT"; + case SSL2_MT_CLIENT_CERTIFICATE: + return "Client CERT"; + } + } + else if (ssl_ver == SSL3_VERSION_MAJOR) { + switch (msg) { + case SSL3_MT_HELLO_REQUEST: + return "Hello request"; + case SSL3_MT_CLIENT_HELLO: + return "Client hello"; + case SSL3_MT_SERVER_HELLO: + return "Server hello"; + case SSL3_MT_CERTIFICATE: + return "CERT"; + case SSL3_MT_SERVER_KEY_EXCHANGE: + return "Server key exchange"; + case SSL3_MT_CLIENT_KEY_EXCHANGE: + return "Client key exchange"; + case SSL3_MT_CERTIFICATE_REQUEST: + return "Request CERT"; + case SSL3_MT_SERVER_DONE: + return "Server finished"; + case SSL3_MT_CERTIFICATE_VERIFY: + return "CERT verify"; + case SSL3_MT_FINISHED: + return "Finished"; + } + } + return "Unknown"; +} + +static const char *tls_rt_type(int type) +{ + return ( + type == SSL3_RT_CHANGE_CIPHER_SPEC ? "TLS change cipher, " : + type == SSL3_RT_ALERT ? "TLS alert, " : + type == SSL3_RT_HANDSHAKE ? "TLS handshake, " : + type == SSL3_RT_APPLICATION_DATA ? "TLS app data, " : + "TLS Unknown, "); +} + + +/* + * Our callback from the SSL/TLS layers. + */ +static void ssl_tls_trace(int direction, int ssl_ver, int content_type, + const void *buf, size_t len, const SSL *ssl, + struct connectdata *conn) +{ + struct SessionHandle *data = conn->data; + const char *msg_name, *tls_rt_name; + char ssl_buf[1024]; + int ver, msg_type, txt_len; + + if (!conn || !conn->data || !conn->data->set.fdebug || + (direction != 0 && direction != 1)) + return; + + data = conn->data; + ssl_ver >>= 8; + ver = (ssl_ver == SSL2_VERSION_MAJOR ? '2' : + ssl_ver == SSL3_VERSION_MAJOR ? '3' : '?'); + + /* SSLv2 doesn't seem to have TLS record-type headers, so OpenSSL + * always pass-up content-type as 0. But the interesting message-type + * is at 'buf[0]'. + */ + if (ssl_ver == SSL3_VERSION_MAJOR && content_type != 0) + tls_rt_name = tls_rt_type(content_type); + else + tls_rt_name = ""; + + msg_type = *(char*)buf; + msg_name = ssl_msg_type(ssl_ver, msg_type); + + txt_len = 1 + snprintf(ssl_buf, sizeof(ssl_buf), "SSLv%c, %s%s (%d):\n", + ver, tls_rt_name, msg_name, msg_type); + Curl_debug(data, CURLINFO_TEXT, ssl_buf, txt_len, NULL); + + Curl_debug(data, (direction == 1) ? CURLINFO_SSL_DATA_OUT : + CURLINFO_SSL_DATA_IN, (char *)buf, len, NULL); + (void) ssl; +} +#endif + +/* ====================================================== */ +CURLcode +Curl_SSLConnect(struct connectdata *conn, + int sockindex) +{ + CURLcode retcode = CURLE_OK; + +#ifdef USE_SSLEAY + struct SessionHandle *data = conn->data; + int err; + long lerr; + int what; + char * str; + SSL_METHOD *req_method; + SSL_SESSION *ssl_sessionid=NULL; + ASN1_TIME *certdate; + curl_socket_t sockfd = conn->sock[sockindex]; + struct ssl_connect_data *connssl = &conn->ssl[sockindex]; + + /* mark this is being ssl enabled from here on out. */ + connssl->use = TRUE; + + if(!ssl_seeded || data->set.ssl.random_file || data->set.ssl.egdsocket) { + /* Make funny stuff to get random input */ + random_the_seed(data); + + ssl_seeded = TRUE; + } + + /* check to see if we've been told to use an explicit SSL/TLS version */ + switch(data->set.ssl.version) { + default: + case CURL_SSLVERSION_DEFAULT: + /* we try to figure out version */ + req_method = SSLv23_client_method(); + break; + case CURL_SSLVERSION_TLSv1: + req_method = TLSv1_client_method(); + break; + case CURL_SSLVERSION_SSLv2: + req_method = SSLv2_client_method(); + break; + case CURL_SSLVERSION_SSLv3: + req_method = SSLv3_client_method(); + break; + } + + connssl->ctx = SSL_CTX_new(req_method); + + if(!connssl->ctx) { + failf(data, "SSL: couldn't create a context!"); + return CURLE_OUT_OF_MEMORY; + } + +#ifdef SSL_CTRL_SET_MSG_CALLBACK + if (data->set.fdebug) { + SSL_CTX_callback_ctrl(connssl->ctx, SSL_CTRL_SET_MSG_CALLBACK, + ssl_tls_trace); + SSL_CTX_ctrl(connssl->ctx, SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, conn); + } +#endif + + /* OpenSSL contains code to work-around lots of bugs and flaws in various + SSL-implementations. SSL_CTX_set_options() is used to enabled those + work-arounds. The man page for this option states that SSL_OP_ALL enables + ll the work-arounds and that "It is usually safe to use SSL_OP_ALL to + enable the bug workaround options if compatibility with somewhat broken + implementations is desired." + + */ + SSL_CTX_set_options(connssl->ctx, SSL_OP_ALL); + +#if 0 + /* + * Not sure it's needed to tell SSL_connect() that socket is + * non-blocking. It doesn't seem to care, but just return with + * SSL_ERROR_WANT_x. + */ + if (data->state.used_interface == Curl_if_multi) + SSL_CTX_ctrl(connssl->ctx, BIO_C_SET_NBIO, 1, NULL); +#endif + + if(data->set.cert) { + if(!cert_stuff(conn, + connssl->ctx, + data->set.cert, + data->set.cert_type, + data->set.key, + data->set.key_type)) { + /* failf() is already done in cert_stuff() */ + return CURLE_SSL_CERTPROBLEM; + } + } + + if(data->set.ssl.cipher_list) { + if(!SSL_CTX_set_cipher_list(connssl->ctx, + data->set.ssl.cipher_list)) { + failf(data, "failed setting cipher list"); + return CURLE_SSL_CIPHER; + } + } + + if (data->set.ssl.CAfile || data->set.ssl.CApath) { + /* tell SSL where to find CA certificates that are used to verify + the servers certificate. */ + if (!SSL_CTX_load_verify_locations(connssl->ctx, data->set.ssl.CAfile, + data->set.ssl.CApath)) { + if (data->set.ssl.verifypeer) { + /* Fail if we insist on successfully verifying the server. */ + failf(data,"error setting certificate verify locations:\n" + " CAfile: %s\n CApath: %s\n", + data->set.ssl.CAfile ? data->set.ssl.CAfile : "none", + data->set.ssl.CApath ? data->set.ssl.CApath : "none"); + return CURLE_SSL_CACERT; + } + else { + /* Just continue with a warning if no strict certificate verification + is required. */ + infof(data, "error setting certificate verify locations," + " continuing anyway:\n"); + } + } + else { + /* Everything is fine. */ + infof(data, "successfully set certificate verify locations:\n"); + } + infof(data, + " CAfile: %s\n" + " CApath: %s\n", + data->set.ssl.CAfile ? data->set.ssl.CAfile : "none", + data->set.ssl.CApath ? data->set.ssl.CApath : "none"); + } + /* SSL always tries to verify the peer, this only says whether it should + * fail to connect if the verification fails, or if it should continue + * anyway. In the latter case the result of the verification is checked with + * SSL_get_verify_result() below. */ + SSL_CTX_set_verify(connssl->ctx, + data->set.ssl.verifypeer?SSL_VERIFY_PEER:SSL_VERIFY_NONE, + cert_verify_callback); + + /* give application a chance to interfere with SSL set up. */ + if(data->set.ssl.fsslctx) { + retcode = (*data->set.ssl.fsslctx)(data, connssl->ctx, + data->set.ssl.fsslctxp); + if(retcode) { + failf(data,"error signaled by ssl ctx callback"); + return retcode; + } + } + + /* Lets make an SSL structure */ + connssl->handle = SSL_new(connssl->ctx); + SSL_set_connect_state(connssl->handle); + + connssl->server_cert = 0x0; + + if(!conn->bits.reuse) { + /* We're not re-using a connection, check if there's a cached ID we + can/should use here! */ + if(!Get_SSL_Session(conn, &ssl_sessionid)) { + /* we got a session id, use it! */ + SSL_set_session(connssl->handle, ssl_sessionid); + /* Informational message */ + infof (data, "SSL re-using session ID\n"); + } + } + + /* pass the raw socket into the SSL layers */ + SSL_set_fd(connssl->handle, sockfd); + + while(1) { + fd_set writefd; + fd_set readfd; + struct timeval interval; + long timeout_ms; + + /* Find out if any timeout is set. If not, use 300 seconds. + Otherwise, figure out the most strict timeout of the two possible one + and then how much time that has elapsed to know how much time we + allow for the connect call */ + if(data->set.timeout || data->set.connecttimeout) { + long has_passed; + + /* Evaluate in milliseconds how much time that has passed */ + has_passed = Curl_tvdiff(Curl_tvnow(), data->progress.start); + + /* get the most strict timeout of the ones converted to milliseconds */ + if(data->set.timeout && + (data->set.timeout>data->set.connecttimeout)) + timeout_ms = data->set.timeout*1000; + else + timeout_ms = data->set.connecttimeout*1000; + + /* subtract the passed time */ + timeout_ms -= has_passed; + + if(timeout_ms < 0) { + /* a precaution, no need to continue if time already is up */ + failf(data, "SSL connection timeout"); + return CURLE_OPERATION_TIMEOUTED; + } + } + else + /* no particular time-out has been set */ + timeout_ms= DEFAULT_CONNECT_TIMEOUT; + + + FD_ZERO(&writefd); + FD_ZERO(&readfd); + + err = SSL_connect(connssl->handle); + + /* 1 is fine + 0 is "not successful but was shut down controlled" + <0 is "handshake was not successful, because a fatal error occurred" */ + if(1 != err) { + int detail = SSL_get_error(connssl->handle, err); + + if(SSL_ERROR_WANT_READ == detail) + FD_SET(sockfd, &readfd); + else if(SSL_ERROR_WANT_WRITE == detail) + FD_SET(sockfd, &writefd); + else { + /* untreated error */ + unsigned long errdetail; + char error_buffer[120]; /* OpenSSL documents that this must be at least + 120 bytes long. */ + CURLcode rc; + const char *cert_problem = NULL; + + errdetail = ERR_get_error(); /* Gets the earliest error code from the + thread's error queue and removes the + entry. */ + + switch(errdetail) { + case 0x1407E086: + /* 1407E086: + SSL routines: + SSL2_SET_CERTIFICATE: + certificate verify failed */ + /* fall-through */ + case 0x14090086: + /* 14090086: + SSL routines: + SSL3_GET_SERVER_CERTIFICATE: + certificate verify failed */ + cert_problem = "SSL certificate problem, verify that the CA cert is" + " OK. Details:\n"; + rc = CURLE_SSL_CACERT; + break; + default: + rc = CURLE_SSL_CONNECT_ERROR; + break; + } + + /* detail is already set to the SSL error above */ + + /* If we e.g. use SSLv2 request-method and the server doesn't like us + * (RST connection etc.), OpenSSL gives no explanation whatsoever and + * the SO_ERROR is also lost. + */ + if (CURLE_SSL_CONNECT_ERROR == rc && errdetail == 0) { + failf(data, "Unknown SSL protocol error in connection to %s:%d ", + conn->host.name, conn->port); + return rc; + } + /* Could be a CERT problem */ + +#ifdef HAVE_ERR_ERROR_STRING_N + /* OpenSSL 0.9.6 and later has a function named + ERRO_error_string_n() that takes the size of the buffer as a + third argument */ + ERR_error_string_n(errdetail, error_buffer, sizeof(error_buffer)); +#else + ERR_error_string(errdetail, error_buffer); +#endif + failf(data, "%s%s", cert_problem ? cert_problem : "", error_buffer); + return rc; + } + } + else + /* we have been connected fine, get out of the connect loop */ + break; + + interval.tv_sec = (int)(timeout_ms/1000); + timeout_ms -= interval.tv_sec*1000; + + interval.tv_usec = timeout_ms*1000; + + while(1) { + what = select(sockfd+1, &readfd, &writefd, NULL, &interval); + if(what > 0) + /* reabable or writable, go loop in the outer loop */ + break; + else if(0 == what) { + /* timeout */ + failf(data, "SSL connection timeout"); + return CURLE_OPERATION_TIMEDOUT; + } + else { +#if !defined(WIN32) && defined(EINTR) + /* For platforms without EINTR all errnos are bad */ + if (errno == EINTR) + continue; /* retry the select() */ +#endif + /* anything other than the unimportant EINTR is fatally bad */ + failf(data, "select on SSL socket, errno: %d", Curl_ourerrno()); + return CURLE_SSL_CONNECT_ERROR; + } + } /* while()-loop for the select() */ + } /* while()-loop for the SSL_connect() */ + + /* Informational message */ + infof (data, "SSL connection using %s\n", + SSL_get_cipher(connssl->handle)); + + if(!ssl_sessionid) { + /* Since this is not a cached session ID, then we want to stach this one + in the cache! */ + Store_SSL_Session(conn, connssl); + } + + + /* Get server's certificate (note: beware of dynamic allocation) - opt */ + /* major serious hack alert -- we should check certificates + * to authenticate the server; otherwise we risk man-in-the-middle + * attack + */ + + connssl->server_cert = SSL_get_peer_certificate(connssl->handle); + if(!connssl->server_cert) { + failf(data, "SSL: couldn't get peer certificate!"); + return CURLE_SSL_PEER_CERTIFICATE; + } + infof (data, "Server certificate:\n"); + + str = X509_NAME_oneline(X509_get_subject_name(connssl->server_cert), + NULL, 0); + if(!str) { + failf(data, "SSL: couldn't get X509-subject!"); + X509_free(connssl->server_cert); + return CURLE_SSL_CONNECT_ERROR; + } + infof(data, "\t subject: %s\n", str); + CRYPTO_free(str); + + certdate = X509_get_notBefore(connssl->server_cert); + Curl_ASN1_UTCTIME_output(conn, "\t start date: ", certdate); + + certdate = X509_get_notAfter(connssl->server_cert); + Curl_ASN1_UTCTIME_output(conn, "\t expire date: ", certdate); + + if(data->set.ssl.verifyhost) { + retcode = verifyhost(conn, connssl->server_cert); + if(retcode) { + X509_free(connssl->server_cert); + return retcode; + } + } + + str = X509_NAME_oneline(X509_get_issuer_name(connssl->server_cert), + NULL, 0); + if(!str) { + failf(data, "SSL: couldn't get X509-issuer name!"); + retcode = CURLE_SSL_CONNECT_ERROR; + } + else { + infof(data, "\t issuer: %s\n", str); + CRYPTO_free(str); + + /* We could do all sorts of certificate verification stuff here before + deallocating the certificate. */ + + lerr = data->set.ssl.certverifyresult= + SSL_get_verify_result(connssl->handle); + if(data->set.ssl.certverifyresult != X509_V_OK) { + if(data->set.ssl.verifypeer) { + /* We probably never reach this, because SSL_connect() will fail + and we return earlyer if verifypeer is set? */ + failf(data, "SSL certificate verify result: %s (%ld)", + X509_verify_cert_error_string(lerr), lerr); + retcode = CURLE_SSL_PEER_CERTIFICATE; + } + else + infof(data, "SSL certificate verify result: %s (%ld)," + " continuing anyway.\n", + X509_verify_cert_error_string(err), lerr); + } + else + infof(data, "SSL certificate verify ok.\n"); + } + + X509_free(connssl->server_cert); +#else /* USE_SSLEAY */ + (void)conn; + (void)sockindex; +#endif + return retcode; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/ssluse.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/ssluse.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/ssluse.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/ssluse.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,38 @@ +#ifndef __SSLUSE_H +#define __SSLUSE_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: ssluse.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ +#include "urldata.h" +CURLcode Curl_SSLConnect(struct connectdata *conn, int sockindex); + +void Curl_SSL_init(void); /* Global SSL init */ +void Curl_SSL_cleanup(void); /* Global SSL cleanup */ + +/* init the SSL session ID cache */ +CURLcode Curl_SSL_InitSessions(struct SessionHandle *, long); +void Curl_SSL_Close(struct connectdata *conn); /* close a SSL connection */ + +/* tell the SSL stuff to close down all open information regarding + connections (and thus session ID caching etc) */ +int Curl_SSL_Close_All(struct SessionHandle *data); +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/strequal.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/strequal.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/strequal.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/strequal.c 2004-10-22 23:04:25.000000000 +0800 @@ -0,0 +1,140 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: strequal.c,v 1.6 2004/10/22 15:04:25 andy Exp $ + ***************************************************************************/ + +#include "setup.h" + +#include +#include + +#include "strequal.h" + +#ifdef HAVE_STRCASECMP +/* this is for "-ansi -Wall -pedantic" to stop complaining! */ +extern int (strcasecmp)(const char *s1, const char *s2); +extern int (strncasecmp)(const char *s1, const char *s2, size_t n); +#endif + +int curl_strequal(const char *first, const char *second) +{ +#if defined(HAVE_STRCASECMP) + return !(strcasecmp)(first, second); +#elif defined(HAVE_STRICMP) + return !(stricmp)(first, second); +#elif defined(HAVE_STRCMPI) + return !(strcmpi)(first, second); +#else + while (*first && *second) { + if (toupper(*first) != toupper(*second)) { + break; + } + first++; + second++; + } + return toupper(*first) == toupper(*second); +#endif +} + +int curl_strnequal(const char *first, const char *second, size_t max) +{ +#if defined(HAVE_STRCASECMP) + return !strncasecmp(first, second, max); +#elif defined(HAVE_STRICMP) + return !strnicmp(first, second, max); +#elif defined(HAVE_STRCMPI) + return !strncmpi(first, second, max); +#else + while (*first && *second && max) { + if (toupper(*first) != toupper(*second)) { + break; + } + max--; + first++; + second++; + } + if(0 == max) + return 1; /* they are equal this far */ + + return toupper(*first) == toupper(*second); +#endif +} + +/* + * Curl_strcasestr() finds the first occurrence of the substring needle in the + * string haystack. The terminating `\0' characters are not compared. The + * matching is done CASE INSENSITIVE, which thus is the difference between + * this and strstr(). + */ +char *Curl_strcasestr(const char *haystack, const char *needle) +{ + size_t nlen = strlen(needle); + size_t hlen = strlen(haystack); + + while(hlen-- >= nlen) { + if(curl_strnequal(haystack, needle, nlen)) + return (char *)haystack; + haystack++; + } + return NULL; +} + +#ifndef HAVE_STRLCAT +/* + * The strlcat() function appends the NUL-terminated string src to the end + * of dst. It will append at most size - strlen(dst) - 1 bytes, NUL-termi- + * nating the result. + * + * The strlcpy() and strlcat() functions return the total length of the + * string they tried to create. For strlcpy() that means the length of src. + * For strlcat() that means the initial length of dst plus the length of + * src. While this may seem somewhat confusing it was done to make trunca- + * tion detection simple. + * + * + */ +size_t Curl_strlcat(char *dst, const char *src, size_t siz) +{ + char *d = dst; + const char *s = src; + size_t n = siz; + size_t dlen; + + /* Find the end of dst and adjust bytes left but don't go past end */ + while (n-- != 0 && *d != '\0') + d++; + dlen = d - dst; + n = siz - dlen; + + if (n == 0) + return(dlen + strlen(s)); + while (*s != '\0') { + if (n != 1) { + *d++ = *s; + n--; + } + s++; + } + *d = '\0'; + + return(dlen + (s - src)); /* count does not include NUL */ +} +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/strequal.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/strequal.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/strequal.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/strequal.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,47 @@ +#ifndef __STREQUAL_H +#define __STREQUAL_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: strequal.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +/* + * These two actually are public functions. + */ +int curl_strequal(const char *first, const char *second); +int curl_strnequal(const char *first, const char *second, size_t max); + +#define strequal(a,b) curl_strequal(a,b) +#define strnequal(a,b,c) curl_strnequal(a,b,c) + +/* checkprefix() is a shorter version of the above, used when the first + argument is zero-byte terminated */ +#define checkprefix(a,b) strnequal(a,b,strlen(a)) + +/* case insensitive strstr() */ +char *Curl_strcasestr(const char *haystack, const char *needle); + +#ifndef HAVE_STRLCAT +#define strlcat(x,y,z) Curl_strlcat(x,y,z) +size_t Curl_strlcat(char *dst, const char *src, size_t siz); +#endif + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/strerror.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/strerror.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/strerror.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/strerror.c 2004-10-06 20:02:18.000000000 +0800 @@ -0,0 +1,569 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +#include "setup.h" + +#include +#include +#include +#include + +#include "strerror.h" + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +#ifdef HAVE_NO_STRERROR_R_DECL +#ifdef HAVE_POSIX_STRERROR_R +/* seen on AIX 5100-02 gcc 2.9 */ +extern int strerror_r(int errnum, char *strerrbuf, size_t buflen); +#else +extern char *strerror_r(int errnum, char *buf, size_t buflen); +#endif +#endif + +const char * +curl_easy_strerror(CURLcode error) +{ + switch (error) { + case CURLE_OK: + return "no error"; + + case CURLE_UNSUPPORTED_PROTOCOL: + return "unsupported protocol"; + + case CURLE_FAILED_INIT: + return "failed init"; + + case CURLE_URL_MALFORMAT: + return "URL using bad/illegal format or missing URL"; + + case CURLE_COULDNT_RESOLVE_PROXY: + return "couldnt resolve proxy"; + + case CURLE_COULDNT_RESOLVE_HOST: + return "couldnt resolve host"; + + case CURLE_COULDNT_CONNECT: + return "couldn't connect"; + + case CURLE_FTP_WEIRD_SERVER_REPLY: + return "FTP: weird server reply"; + + case CURLE_FTP_ACCESS_DENIED: + return "FTP: access denied"; + + case CURLE_FTP_USER_PASSWORD_INCORRECT: + return "FTP: user and/or password incorrect"; + + case CURLE_FTP_WEIRD_PASS_REPLY: + return "FTP: unknown PASS reply"; + + case CURLE_FTP_WEIRD_USER_REPLY: + return "FTP: unknown USER reply"; + + case CURLE_FTP_WEIRD_PASV_REPLY: + return "FTP: unknown PASV reply"; + + case CURLE_FTP_WEIRD_227_FORMAT: + return "FTP: unknown 227 response format"; + + case CURLE_FTP_CANT_GET_HOST: + return "FTP: can't figure out the host in the PASV response"; + + case CURLE_FTP_CANT_RECONNECT: + return "FTP: can't connect to server the response code is unknown"; + + case CURLE_FTP_COULDNT_SET_BINARY: + return "FTP: couldn't set binary mode"; + + case CURLE_PARTIAL_FILE: + return "Transferred a partial file"; + + case CURLE_FTP_COULDNT_RETR_FILE: + return "FTP: couldn't retrieve (RETR failed) the specified file"; + + case CURLE_FTP_WRITE_ERROR: + return "FTP: the post-transfer acknowledge response was not OK"; + + case CURLE_FTP_QUOTE_ERROR: + return "FTP: a quote command returned error"; + + case CURLE_HTTP_RETURNED_ERROR: + return "HTTP response code said error"; + + case CURLE_WRITE_ERROR: + return "failed writing received data to disk/application"; + + case CURLE_FTP_COULDNT_STOR_FILE: + return "failed FTP upload (the STOR command)"; + + case CURLE_READ_ERROR: + return "failed to open/read local data from file/application"; + + case CURLE_OUT_OF_MEMORY: + return "out of memory"; + + case CURLE_OPERATION_TIMEOUTED: + return "a timeout was reached"; + + case CURLE_FTP_COULDNT_SET_ASCII: + return "FTP could not set ASCII mode (TYPE A)"; + + case CURLE_FTP_PORT_FAILED: + return "FTP command PORT failed"; + + case CURLE_FTP_COULDNT_USE_REST: + return "FTP command REST failed"; + + case CURLE_FTP_COULDNT_GET_SIZE: + return "FTP command SIZE failed"; + + case CURLE_HTTP_RANGE_ERROR: + return "a range was requested but the server did not deliver it"; + + case CURLE_HTTP_POST_ERROR: + return "internal problem setting up the POST"; + + case CURLE_SSL_CONNECT_ERROR: + return "SSL connect error"; + + case CURLE_FTP_BAD_DOWNLOAD_RESUME: + return "couldn't resume FTP download"; + + case CURLE_FILE_COULDNT_READ_FILE: + return "couldn't read a file:// file"; + + case CURLE_LDAP_CANNOT_BIND: + return "LDAP: cannot bind"; + + case CURLE_LDAP_SEARCH_FAILED: + return "LDAP: search failed"; + + case CURLE_LIBRARY_NOT_FOUND: + return "a required shared library was not found"; + + case CURLE_FUNCTION_NOT_FOUND: + return "a required function in the shared library was not found"; + + case CURLE_ABORTED_BY_CALLBACK: + return "the operation was aborted by an application callback"; + + case CURLE_BAD_FUNCTION_ARGUMENT: + return "a libcurl function was given a bad argument"; + + case CURLE_INTERFACE_FAILED: + return "failed binding local connection end"; + + case CURLE_TOO_MANY_REDIRECTS : + return "number of redirects hit maximum amount"; + + case CURLE_UNKNOWN_TELNET_OPTION: + return "User specified an unknown option"; + + case CURLE_TELNET_OPTION_SYNTAX : + return "Malformed telnet option"; + + case CURLE_SSL_PEER_CERTIFICATE: + return "SSL peer certificate was not ok"; + + case CURLE_GOT_NOTHING: + return "server returned nothing (no headers, no data)"; + + case CURLE_SSL_ENGINE_NOTFOUND: + return "SSL crypto engine not found"; + + case CURLE_SSL_ENGINE_SETFAILED: + return "can not set SSL crypto engine as default"; + + case CURLE_SEND_ERROR: + return "failed sending data to the peer"; + + case CURLE_RECV_ERROR: + return "failure when receiving data from the peer"; + + case CURLE_SHARE_IN_USE: + return "share is already in use"; + + case CURLE_SSL_CERTPROBLEM: + return "problem with the local SSL certificate"; + + case CURLE_SSL_CIPHER: + return "couldn't use specified SSL cipher"; + + case CURLE_SSL_CACERT: + return "problem with the SSL CA cert (path? access rights?)"; + + case CURLE_BAD_CONTENT_ENCODING: + return "Unrecognized HTTP Content-Encoding"; + + case CURLE_LDAP_INVALID_URL: + return "Invalid LDAP URL"; + + case CURLE_FILESIZE_EXCEEDED: + return "Maximum file size exceeded"; + + case CURLE_FTP_SSL_FAILED: + return "Requested FTP SSL level failed"; + + case CURLE_URL_MALFORMAT_USER: /* not used by current libcurl */ + case CURLE_MALFORMAT_USER: /* not used by current libcurl */ + case CURLE_BAD_CALLING_ORDER: /* not used by current libcurl */ + case CURLE_BAD_PASSWORD_ENTERED:/* not used by current libcurl */ + case CURLE_OBSOLETE: /* not used by current libcurl */ + case CURL_LAST: + break; + } + /* + * By using a switch, gcc -Wall will complain about enum values + * which do not appear, helping keep this function up-to-date. + * By using gcc -Wall -Werror, you can't forget. + * + * A table would not have the same benefit. Most compilers will + * generate code very similar to a table in any case, so there + * is little performance gain from a table. And something is broken + * for the user's application, anyways, so does it matter how fast + * it _doesn't_ work? + * + * The line number for the error will be near this comment, which + * is why it is here, and not at the start of the switch. + */ + return "unknown error"; +} + +const char * +curl_multi_strerror(CURLMcode error) +{ + switch (error) { + case CURLM_CALL_MULTI_PERFORM: + return "please call curl_multi_perform() soon"; + + case CURLM_OK: + return "no error"; + + case CURLM_BAD_HANDLE: + return "invalid multi handle"; + + case CURLM_BAD_EASY_HANDLE: + return "invalid easy handle"; + + case CURLM_OUT_OF_MEMORY: + return "out of memory"; + + case CURLM_INTERNAL_ERROR: + return "internal error"; + + case CURLM_LAST: + break; + } + + return "unknown error"; +} + +const char * +curl_share_strerror(CURLSHcode error) +{ + switch (error) { + case CURLSHE_OK: + return "no error"; + + case CURLSHE_BAD_OPTION: + return "unknown share option"; + + case CURLSHE_IN_USE: + return "share currently in use"; + + case CURLSHE_INVALID: + return "invalid share handle"; + + case CURLSHE_NOMEM: + return "out of memory"; + + case CURLSHE_LAST: + break; + } + + return "CURLSH unknown"; +} + +#if defined(WIN32) && !defined(__CYGWIN__) + +/* This function handles most / all (?) Winsock errors cURL is able to produce. + */ +static const char * +get_winsock_error (int err, char *buf, size_t len) +{ + char *p; + + switch (err) { + case WSAEINTR: + p = "Call interrupted."; + break; + case WSAEBADF: + p = "Bad file"; + break; + case WSAEACCES: + p = "Bad access"; + break; + case WSAEFAULT: + p = "Bad argument"; + break; + case WSAEINVAL: + p = "Invalid arguments"; + break; + case WSAEMFILE: + p = "Out of file descriptors"; + break; + case WSAEWOULDBLOCK: + p = "Call would block"; + break; + case WSAEINPROGRESS: + case WSAEALREADY: + p = "Blocking call in progress"; + break; + case WSAENOTSOCK: + p = "Descriptor is not a socket."; + break; + case WSAEDESTADDRREQ: + p = "Need destination address"; + break; + case WSAEMSGSIZE: + p = "Bad message size"; + break; + case WSAEPROTOTYPE: + p = "Bad protocol"; + break; + case WSAENOPROTOOPT: + p = "Protocol option is unsupported"; + break; + case WSAEPROTONOSUPPORT: + p = "Protocol is unsupported"; + break; + case WSAESOCKTNOSUPPORT: + p = "Socket is unsupported"; + break; + case WSAEOPNOTSUPP: + p = "Operation not supported"; + break; + case WSAEAFNOSUPPORT: + p = "Address family not supported"; + break; + case WSAEPFNOSUPPORT: + p = "Protocol family not supported"; + break; + case WSAEADDRINUSE: + p = "Address already in use"; + break; + case WSAEADDRNOTAVAIL: + p = "Address not available"; + break; + case WSAENETDOWN: + p = "Network down"; + break; + case WSAENETUNREACH: + p = "Network unreachable"; + break; + case WSAENETRESET: + p = "Network has been reset"; + break; + case WSAECONNABORTED: + p = "Connection was aborted"; + break; + case WSAECONNRESET: + p = "Connection was reset"; + break; + case WSAENOBUFS: + p = "No buffer space"; + break; + case WSAEISCONN: + p = "Socket is already connected"; + break; + case WSAENOTCONN: + p = "Socket is not connected"; + break; + case WSAESHUTDOWN: + p = "Socket has been shut down"; + break; + case WSAETOOMANYREFS: + p = "Too many references"; + break; + case WSAETIMEDOUT: + p = "Timed out"; + break; + case WSAECONNREFUSED: + p = "Connection refused"; + break; + case WSAELOOP: + p = "Loop??"; + break; + case WSAENAMETOOLONG: + p = "Name too long"; + break; + case WSAEHOSTDOWN: + p = "Host down"; + break; + case WSAEHOSTUNREACH: + p = "Host unreachable"; + break; + case WSAENOTEMPTY: + p = "Not empty"; + break; + case WSAEPROCLIM: + p = "Process limit reached"; + break; + case WSAEUSERS: + p = "Too many users"; + break; + case WSAEDQUOT: + p = "Bad quota"; + break; + case WSAESTALE: + p = "Something is stale"; + break; + case WSAEREMOTE: + p = "Remote error"; + break; + case WSAEDISCON: + p = "Disconnected"; + break; + + /* Extended Winsock errors */ + case WSASYSNOTREADY: + p = "Winsock library is not ready"; + break; + case WSANOTINITIALISED: + p = "Winsock library not initalised"; + break; + case WSAVERNOTSUPPORTED: + p = "Winsock version not supported."; + break; + + /* getXbyY() errors (already handled in herrmsg): + * Authoritative Answer: Host not found */ + case WSAHOST_NOT_FOUND: + p = "Host not found"; + break; + + /* Non-Authoritative: Host not found, or SERVERFAIL */ + case WSATRY_AGAIN: + p = "Host not found, try again"; + break; + + /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ + case WSANO_RECOVERY: + p = "Unrecoverable error in call to nameserver"; + break; + + /* Valid name, no data record of requested type */ + case WSANO_DATA: + p = "No data record of requested type"; + break; + + default: + return NULL; + } + strncpy (buf, p, len); + buf [len-1] = '\0'; + return buf; +} +#endif /* WIN32 && !__CYGWIN__ */ + +/* + * Our thread-safe and smart strerror() replacement. + * + * The 'err' argument passed in to this function MUST be a true errno number + * as reported on this system. We do no range checking on the number before + * we pass it to the "number-to-message" convertion function and there might + * be systems that don't do proper range checking in there themselves. + * + * We don't do range checking (on systems other than Windows) since there is + * no good reliable and portable way to do it. + */ +const char *Curl_strerror(struct connectdata *conn, int err) +{ + char *buf, *p; + size_t max; + + curlassert(conn); + curlassert(err >= 0); + + buf = conn->syserr_buf; + max = sizeof(conn->syserr_buf)-1; + *buf = '\0'; + +#if defined(WIN32) && !defined(__CYGWIN__) + /* 'sys_nerr' is the maximum errno number, it is not widely portable */ + if (err >= 0 && err < sys_nerr) + strncpy(buf, strerror(err), max); + else { + if (!get_winsock_error (err, buf, max) && + !FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, + LANG_NEUTRAL, buf, max, NULL)) + snprintf(buf, max, "Unknown error %d (%#x)", err, err); + } +#else /* not native Windows coming up */ + + /* These should be atomic and hopefully thread-safe */ +#ifdef HAVE_STRERROR_R + /* There are two different APIs for strerror_r(). The POSIX and the GLIBC + versions. */ +#ifdef HAVE_POSIX_STRERROR_R + strerror_r(err, buf, max); + /* this may set errno to ERANGE if insufficient storage was supplied via + 'strerrbuf' and 'buflen' to contain the generated message string, or + EINVAL if the value of 'errnum' is not a valid error number.*/ +#else + { + /* HAVE_GLIBC_STRERROR_R */ + char buffer[256]; + char *msg = strerror_r(err, buffer, sizeof(buffer)); + /* this version of strerror_r() only *might* use the buffer we pass to + the function, but it always returns the error message as a pointer, + so we must copy that string unconditionally */ + if ( !msg ) + { + msg = "Unknown System Error"; + } + strncpy(buf, msg, max); + } +#endif /* end of HAVE_GLIBC_STRERROR_R */ +#else /* HAVE_STRERROR_R */ + { + char *msg = strerror(err); + if ( !msg ) + { + msg = "Unknown System Error"; + } + strncpy(buf, msg, max); + } +#endif /* end of HAVE_STRERROR_R */ +#endif /* end of ! Windows */ + + buf[max] = '\0'; /* make sure the string is zero terminated */ + + /* strip trailing '\r\n' or '\n'. */ + if ((p = strrchr(buf,'\n')) != NULL && (p - buf) >= 2) + *p = '\0'; + if ((p = strrchr(buf,'\r')) != NULL && (p - buf) >= 1) + *p = '\0'; + return buf; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/strerror.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/strerror.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/strerror.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/strerror.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,30 @@ +#ifndef __CURL_STRERROR_H +#define __CURL_STRERROR_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: strerror.h,v 1.1 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +#include "urldata.h" + +const char *Curl_strerror (struct connectdata *conn, int err); + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/strtok.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/strtok.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/strtok.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/strtok.c 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,68 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: strtok.c,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +#include "setup.h" + +#ifndef HAVE_STRTOK_R +#include +#include + +#include "strtok.h" + +char * +Curl_strtok_r(char *ptr, const char *sep, char **end) +{ + if (!ptr) + /* we got NULL input so then we get our last position instead */ + ptr = *end; + + /* pass all letters that are including in the separator string */ + while (*ptr && strchr(sep, *ptr)) + ++ptr; + + if (*ptr) { + /* so this is where the next piece of string starts */ + char *start = ptr; + + /* set the end pointer to the first byte after the start */ + *end = start + 1; + + /* scan through the string to find where it ends, it ends on a + null byte or a character that exists in the separator string */ + while (**end && !strchr(sep, **end)) + ++*end; + + if (**end) { + /* the end is not a null byte */ + **end = '\0'; /* zero terminate it! */ + ++*end; /* advance the last pointer to beyond the null byte */ + } + + return start; /* return the position where the string starts */ + } + + /* we ended up on a null byte, there are no more strings to find! */ + return NULL; +} + +#endif /* this was only compiled if strtok_r wasn't present */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/strtok.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/strtok.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/strtok.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/strtok.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,38 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: strtok.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +#ifndef _CURL_STRTOK_R_H +#define _CURL_STRTOK_R_H + +#include "setup.h" +#include + +#ifndef HAVE_STRTOK_R +char *Curl_strtok_r(char *s, const char *delim, char **last); +#define strtok_r Curl_strtok_r +#else +#include +#endif + +#endif + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/strtoofft.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/strtoofft.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/strtoofft.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/strtoofft.c 2004-10-08 05:48:36.000000000 +0800 @@ -0,0 +1,164 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: strtoofft.c,v 1.2 2004/10/07 21:48:36 andy Exp $ + ***************************************************************************/ + +#include "setup.h" +#include "strtoofft.h" + +#ifdef NEED_CURL_STRTOLL +#include +#include +#include + +static int get_char(char c, int base); + +/** + * Emulated version of the strtoll function. This extracts a long long + * value from the given input string and returns it. + */ +curl_off_t +curlx_strtoll(const char *nptr, char **endptr, int base) +{ + char *end; + int is_negative = 0; + int overflow; + int i; + curl_off_t value = 0; + curl_off_t newval; + + /* Skip leading whitespace. */ + end = (char *)nptr; + while (isspace((int)end[0])) { + end++; + } + + /* Handle the sign, if any. */ + if (end[0] == '-') { + is_negative = 1; + end++; + } + else if (end[0] == '+') { + end++; + } + else if (end[0] == '\0') { + /* We had nothing but perhaps some whitespace -- there was no number. */ + if (endptr) { + *endptr = end; + } + return 0; + } + + /* Handle special beginnings, if present and allowed. */ + if (end[0] == '0' && end[1] == 'x') { + if (base == 16 || base == 0) { + end += 2; + base = 16; + } + } + else if (end[0] == '0') { + if (base == 8 || base == 0) { + end++; + base = 8; + } + } + + /* Matching strtol, if the base is 0 and it doesn't look like + * the number is octal or hex, we assume it's base 10. + */ + if (base == 0) { + base = 10; + } + + /* Loop handling digits. */ + value = 0; + overflow = 0; + for (i = get_char(end[0], base); + i != -1; + end++, i = get_char(end[0], base)) { + newval = base * value + i; + if (newval < value) { + /* We've overflowed. */ + overflow = 1; + break; + } + else + value = newval; + } + + if (!overflow) { + if (is_negative) { + /* Fix the sign. */ + value *= -1; + } + } + else { +#ifdef HAVE_LONG_LONG_CONSTANT + if (is_negative) + value = 0x8000000000000000LL; + else + value = 0x7FFFFFFFFFFFFFFFLL; +#else + if (is_negative) + value = 0x8000000000000000L; + else + value = 0x7FFFFFFFFFFFFFFFL; +#endif + + errno = ERANGE; + } + + if (endptr) + *endptr = end; + + return value; +} + +/** + * Returns the value of c in the given base, or -1 if c cannot + * be interpreted properly in that base (i.e., is out of range, + * is a null, etc.). + * + * @param c the character to interpret according to base + * @param base the base in which to interpret c + * + * @return the value of c in base, or -1 if c isn't in range + */ +static int get_char(char c, int base) +{ + int value = -1; + if (c <= '9' && c >= '0') { + value = c - '0'; + } + else if (c <= 'Z' && c >= 'A') { + value = c - 'A' + 10; + } + else if (c <= 'z' && c >= 'a') { + value = c - 'a' + 10; + } + + if (value >= base) { + value = -1; + } + + return value; +} +#endif /* Only present if we need strtoll, but don't have it. */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/strtoofft.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/strtoofft.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/strtoofft.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/strtoofft.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,62 @@ +#ifndef _CURL_STRTOOFFT_H +#define _CURL_STRTOOFFT_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: strtoofft.h,v 1.1 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +/* + * CAUTION: this header is designed to work when included by the app-side + * as well as the library. Do not mix with library internals! + */ + +#include "setup.h" +#include +#include /* for the curl_off_t type */ + +/* Determine what type of file offset conversion handling we wish to use. For + * systems with a 32-bit curl_off_t type, we should use strtol. For systems + * with a 64-bit curl_off_t type, we should use strtoll if it exists, and if + * not, should try to emulate its functionality. At any rate, we define + * 'strtoofft' such that it can be used to work with curl_off_t's regardless. + */ +#if SIZEOF_CURL_OFF_T > 4 +#if HAVE_STRTOLL +#define curlx_strtoofft strtoll +#else /* HAVE_STRTOLL */ + +/* For MSVC7 we can use _strtoi64() which seems to be a strtoll() clone */ +#if defined(_MSC_VER) && (_MSC_VER >= 1300) +#define curlx_strtoofft _strtoi64 +#else /* MSVC7 or later */ +curl_off_t curlx_strtoll(const char *nptr, char **endptr, int base); +#define curlx_strtoofft curlx_strtoll +#define NEED_CURL_STRTOLL +#endif /* MSVC7 or later */ + +#endif /* HAVE_STRTOLL */ +#else /* SIZEOF_CURL_OFF_T > 4 */ +/* simply use strtol() to get 32bit numbers */ +#define curlx_strtoofft strtol +#endif + +#endif + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/telnet.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/telnet.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/telnet.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/telnet.c 2004-10-13 22:45:30.000000000 +0800 @@ -0,0 +1,1389 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: telnet.c,v 1.13 2004/10/13 14:45:30 andy Exp $ + ***************************************************************************/ + +#include "setup.h" + +#ifndef CURL_DISABLE_TELNET +/* -- WIN32 approved -- */ +#include +#include +#include +#include +#include +#include +#include + +#include + +#if defined(WIN32) +#include +#include +#else +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#include +#ifdef HAVE_ARPA_INET_H +#include +#endif +#ifdef HAVE_NET_IF_H +#include +#endif +#include +#include + +#ifdef HAVE_SYS_PARAM_H +#include +#endif + +#ifdef HAVE_SYS_SELECT_H +#include +#endif + + +#endif + +#include "urldata.h" +#include +#include "transfer.h" +#include "sendf.h" +#include "telnet.h" + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +#define TELOPTS +#define TELCMDS + +#include "arpa_telnet.h" +#include "curl_memory.h" + +/* The last #include file should be: */ +#include "memdebug.h" + +#define SUBBUFSIZE 512 + +#define CURL_SB_CLEAR(x) x->subpointer = x->subbuffer; +#define CURL_SB_TERM(x) { x->subend = x->subpointer; CURL_SB_CLEAR(x); } +#define CURL_SB_ACCUM(x,c) \ + if (x->subpointer < (x->subbuffer+sizeof x->subbuffer)) { \ + *x->subpointer++ = (c); \ + } + +#define CURL_SB_GET(x) ((*x->subpointer++)&0xff) +#define CURL_SB_PEEK(x) ((*x->subpointer)&0xff) +#define CURL_SB_EOF(x) (x->subpointer >= x->subend) +#define CURL_SB_LEN(x) (x->subend - x->subpointer) + +#ifdef WIN32 +typedef FARPROC WSOCK2_FUNC; +static CURLcode check_wsock2 ( struct SessionHandle *data ); +#endif + +static +void telrcv(struct connectdata *, + unsigned char *inbuf, /* Data received from socket */ + ssize_t count); /* Number of bytes received */ + +static void printoption(struct SessionHandle *data, + const char *direction, + int cmd, int option); + +static void negotiate(struct connectdata *); +static void send_negotiation(struct connectdata *, int cmd, int option); +static void set_local_option(struct connectdata *, int cmd, int option); +static void set_remote_option(struct connectdata *, int cmd, int option); + +static void printsub(struct SessionHandle *data, + int direction, unsigned char *pointer, + size_t length); +static void suboption(struct connectdata *); + +/* For negotiation compliant to RFC 1143 */ +#define CURL_NO 0 +#define CURL_YES 1 +#define CURL_WANTYES 2 +#define CURL_WANTNO 3 + +#define CURL_EMPTY 0 +#define CURL_OPPOSITE 1 + +/* + * Telnet receiver states for fsm + */ +typedef enum +{ + CURL_TS_DATA = 0, + CURL_TS_IAC, + CURL_TS_WILL, + CURL_TS_WONT, + CURL_TS_DO, + CURL_TS_DONT, + CURL_TS_CR, + CURL_TS_SB, /* sub-option collection */ + CURL_TS_SE /* looking for sub-option end */ +} TelnetReceive; + +struct TELNET { + int please_negotiate; + int already_negotiated; + int us[256]; + int usq[256]; + int us_preferred[256]; + int him[256]; + int himq[256]; + int him_preferred[256]; + char subopt_ttype[32]; /* Set with suboption TTYPE */ + char subopt_xdisploc[128]; /* Set with suboption XDISPLOC */ + struct curl_slist *telnet_vars; /* Environment variables */ + + /* suboptions */ + char subbuffer[SUBBUFSIZE]; + char *subpointer, *subend; /* buffer for sub-options */ + + TelnetReceive telrcv_state; +}; + +#ifdef WIN32 +static CURLcode +check_wsock2 ( struct SessionHandle *data ) +{ + int err; + WORD wVersionRequested; + WSADATA wsaData; + + curlassert(data); + + /* telnet requires at least WinSock 2.0 so ask for it. */ + wVersionRequested = MAKEWORD(2, 0); + + err = WSAStartup(wVersionRequested, &wsaData); + + /* We must've called this once already, so this call */ + /* should always succeed. But, just in case... */ + if (err != 0) { + failf(data,"WSAStartup failed (%d)",err); + return CURLE_FAILED_INIT; + } + + /* We have to have a WSACleanup call for every successful */ + /* WSAStartup call. */ + WSACleanup(); + + /* Check that our version is supported */ + if (LOBYTE(wsaData.wVersion) != LOBYTE(wVersionRequested) || + HIBYTE(wsaData.wVersion) != HIBYTE(wVersionRequested)) { + /* Our version isn't supported */ + failf(data,"insufficient winsock version to support " + "telnet"); + return CURLE_FAILED_INIT; + } + + /* Our version is supported */ + return CURLE_OK; +} +#endif +static +CURLcode init_telnet(struct connectdata *conn) +{ + struct TELNET *tn; + + tn = (struct TELNET *)calloc(1, sizeof(struct TELNET)); + if(!tn) + return CURLE_OUT_OF_MEMORY; + + conn->proto.telnet = (void *)tn; /* make us known */ + + tn->telrcv_state = CURL_TS_DATA; + + /* Init suboptions */ + CURL_SB_CLEAR(tn); + + /* Set the options we want by default */ + tn->us_preferred[CURL_TELOPT_BINARY] = CURL_YES; + tn->us_preferred[CURL_TELOPT_SGA] = CURL_YES; + tn->him_preferred[CURL_TELOPT_BINARY] = CURL_YES; + tn->him_preferred[CURL_TELOPT_SGA] = CURL_YES; + + return CURLE_OK; +} + +static void negotiate(struct connectdata *conn) +{ + int i; + struct TELNET *tn = (struct TELNET *)conn->proto.telnet; + + for(i = 0;i < CURL_NTELOPTS;i++) + { + if(tn->us_preferred[i] == CURL_YES) + set_local_option(conn, i, CURL_YES); + + if(tn->him_preferred[i] == CURL_YES) + set_remote_option(conn, i, CURL_YES); + } +} + +static void printoption(struct SessionHandle *data, + const char *direction, int cmd, int option) +{ + const char *fmt; + const char *opt; + + if (data->set.verbose) + { + if (cmd == CURL_IAC) + { + if (CURL_TELCMD_OK(option)) + Curl_infof(data, "%s IAC %s\n", direction, CURL_TELCMD(option)); + else + Curl_infof(data, "%s IAC %d\n", direction, option); + } + else + { + fmt = (cmd == CURL_WILL) ? "WILL" : (cmd == CURL_WONT) ? "WONT" : + (cmd == CURL_DO) ? "DO" : (cmd == CURL_DONT) ? "DONT" : 0; + if (fmt) + { + if (CURL_TELOPT_OK(option)) + opt = CURL_TELOPT(option); + else if (option == CURL_TELOPT_EXOPL) + opt = "EXOPL"; + else + opt = NULL; + + if(opt) + Curl_infof(data, "%s %s %s\n", direction, fmt, opt); + else + Curl_infof(data, "%s %s %d\n", direction, fmt, option); + } + else + Curl_infof(data, "%s %d %d\n", direction, cmd, option); + } + } +} + +static void send_negotiation(struct connectdata *conn, int cmd, int option) +{ + unsigned char buf[3]; + + buf[0] = CURL_IAC; + buf[1] = cmd; + buf[2] = option; + + (void)swrite(conn->sock[FIRSTSOCKET], buf, 3); + + printoption(conn->data, "SENT", cmd, option); +} + +static +void set_remote_option(struct connectdata *conn, int option, int newstate) +{ + struct TELNET *tn = (struct TELNET *)conn->proto.telnet; + if(newstate == CURL_YES) + { + switch(tn->him[option]) + { + case CURL_NO: + tn->him[option] = CURL_WANTYES; + send_negotiation(conn, CURL_DO, option); + break; + + case CURL_YES: + /* Already enabled */ + break; + + case CURL_WANTNO: + switch(tn->himq[option]) + { + case CURL_EMPTY: + /* Already negotiating for CURL_YES, queue the request */ + tn->himq[option] = CURL_OPPOSITE; + break; + case CURL_OPPOSITE: + /* Error: already queued an enable request */ + break; + } + break; + + case CURL_WANTYES: + switch(tn->himq[option]) + { + case CURL_EMPTY: + /* Error: already negotiating for enable */ + break; + case CURL_OPPOSITE: + tn->himq[option] = CURL_EMPTY; + break; + } + break; + } + } + else /* NO */ + { + switch(tn->him[option]) + { + case CURL_NO: + /* Already disabled */ + break; + + case CURL_YES: + tn->him[option] = CURL_WANTNO; + send_negotiation(conn, CURL_DONT, option); + break; + + case CURL_WANTNO: + switch(tn->himq[option]) + { + case CURL_EMPTY: + /* Already negotiating for NO */ + break; + case CURL_OPPOSITE: + tn->himq[option] = CURL_EMPTY; + break; + } + break; + + case CURL_WANTYES: + switch(tn->himq[option]) + { + case CURL_EMPTY: + tn->himq[option] = CURL_OPPOSITE; + break; + case CURL_OPPOSITE: + break; + } + break; + } + } +} + +static +void rec_will(struct connectdata *conn, int option) +{ + struct TELNET *tn = (struct TELNET *)conn->proto.telnet; + switch(tn->him[option]) + { + case CURL_NO: + if(tn->him_preferred[option] == CURL_YES) + { + tn->him[option] = CURL_YES; + send_negotiation(conn, CURL_DO, option); + } + else + { + send_negotiation(conn, CURL_DONT, option); + } + break; + + case CURL_YES: + /* Already enabled */ + break; + + case CURL_WANTNO: + switch(tn->himq[option]) + { + case CURL_EMPTY: + /* Error: DONT answered by WILL */ + tn->him[option] = CURL_NO; + break; + case CURL_OPPOSITE: + /* Error: DONT answered by WILL */ + tn->him[option] = CURL_YES; + tn->himq[option] = CURL_EMPTY; + break; + } + break; + + case CURL_WANTYES: + switch(tn->himq[option]) + { + case CURL_EMPTY: + tn->him[option] = CURL_YES; + break; + case CURL_OPPOSITE: + tn->him[option] = CURL_WANTNO; + tn->himq[option] = CURL_EMPTY; + send_negotiation(conn, CURL_DONT, option); + break; + } + break; + } +} + +static +void rec_wont(struct connectdata *conn, int option) +{ + struct TELNET *tn = (struct TELNET *)conn->proto.telnet; + switch(tn->him[option]) + { + case CURL_NO: + /* Already disabled */ + break; + + case CURL_YES: + tn->him[option] = CURL_NO; + send_negotiation(conn, CURL_DONT, option); + break; + + case CURL_WANTNO: + switch(tn->himq[option]) + { + case CURL_EMPTY: + tn->him[option] = CURL_NO; + break; + + case CURL_OPPOSITE: + tn->him[option] = CURL_WANTYES; + tn->himq[option] = CURL_EMPTY; + send_negotiation(conn, CURL_DO, option); + break; + } + break; + + case CURL_WANTYES: + switch(tn->himq[option]) + { + case CURL_EMPTY: + tn->him[option] = CURL_NO; + break; + case CURL_OPPOSITE: + tn->him[option] = CURL_NO; + tn->himq[option] = CURL_EMPTY; + break; + } + break; + } +} + +static void +set_local_option(struct connectdata *conn, int option, int newstate) +{ + struct TELNET *tn = (struct TELNET *)conn->proto.telnet; + if(newstate == CURL_YES) + { + switch(tn->us[option]) + { + case CURL_NO: + tn->us[option] = CURL_WANTYES; + send_negotiation(conn, CURL_WILL, option); + break; + + case CURL_YES: + /* Already enabled */ + break; + + case CURL_WANTNO: + switch(tn->usq[option]) + { + case CURL_EMPTY: + /* Already negotiating for CURL_YES, queue the request */ + tn->usq[option] = CURL_OPPOSITE; + break; + case CURL_OPPOSITE: + /* Error: already queued an enable request */ + break; + } + break; + + case CURL_WANTYES: + switch(tn->usq[option]) + { + case CURL_EMPTY: + /* Error: already negotiating for enable */ + break; + case CURL_OPPOSITE: + tn->usq[option] = CURL_EMPTY; + break; + } + break; + } + } + else /* NO */ + { + switch(tn->us[option]) + { + case CURL_NO: + /* Already disabled */ + break; + + case CURL_YES: + tn->us[option] = CURL_WANTNO; + send_negotiation(conn, CURL_WONT, option); + break; + + case CURL_WANTNO: + switch(tn->usq[option]) + { + case CURL_EMPTY: + /* Already negotiating for NO */ + break; + case CURL_OPPOSITE: + tn->usq[option] = CURL_EMPTY; + break; + } + break; + + case CURL_WANTYES: + switch(tn->usq[option]) + { + case CURL_EMPTY: + tn->usq[option] = CURL_OPPOSITE; + break; + case CURL_OPPOSITE: + break; + } + break; + } + } +} + +static +void rec_do(struct connectdata *conn, int option) +{ + struct TELNET *tn = (struct TELNET *)conn->proto.telnet; + switch(tn->us[option]) + { + case CURL_NO: + if(tn->us_preferred[option] == CURL_YES) + { + tn->us[option] = CURL_YES; + send_negotiation(conn, CURL_WILL, option); + } + else + { + send_negotiation(conn, CURL_WONT, option); + } + break; + + case CURL_YES: + /* Already enabled */ + break; + + case CURL_WANTNO: + switch(tn->usq[option]) + { + case CURL_EMPTY: + /* Error: DONT answered by WILL */ + tn->us[option] = CURL_NO; + break; + case CURL_OPPOSITE: + /* Error: DONT answered by WILL */ + tn->us[option] = CURL_YES; + tn->usq[option] = CURL_EMPTY; + break; + } + break; + + case CURL_WANTYES: + switch(tn->usq[option]) + { + case CURL_EMPTY: + tn->us[option] = CURL_YES; + break; + case CURL_OPPOSITE: + tn->us[option] = CURL_WANTNO; + tn->himq[option] = CURL_EMPTY; + send_negotiation(conn, CURL_WONT, option); + break; + } + break; + } +} + +static +void rec_dont(struct connectdata *conn, int option) +{ + struct TELNET *tn = (struct TELNET *)conn->proto.telnet; + switch(tn->us[option]) + { + case CURL_NO: + /* Already disabled */ + break; + + case CURL_YES: + tn->us[option] = CURL_NO; + send_negotiation(conn, CURL_WONT, option); + break; + + case CURL_WANTNO: + switch(tn->usq[option]) + { + case CURL_EMPTY: + tn->us[option] = CURL_NO; + break; + + case CURL_OPPOSITE: + tn->us[option] = CURL_WANTYES; + tn->usq[option] = CURL_EMPTY; + send_negotiation(conn, CURL_WILL, option); + break; + } + break; + + case CURL_WANTYES: + switch(tn->usq[option]) + { + case CURL_EMPTY: + tn->us[option] = CURL_NO; + break; + case CURL_OPPOSITE: + tn->us[option] = CURL_NO; + tn->usq[option] = CURL_EMPTY; + break; + } + break; + } +} + + +static void printsub(struct SessionHandle *data, + int direction, /* '<' or '>' */ + unsigned char *pointer, /* where suboption data is */ + size_t length) /* length of suboption data */ +{ + unsigned int i = 0; + + if (data->set.verbose) + { + if (direction) + { + Curl_infof(data, "%s IAC SB ", (direction == '<')? "RCVD":"SENT"); + if (length >= 3) + { + int j; + + i = pointer[length-2]; + j = pointer[length-1]; + + if (i != CURL_IAC || j != CURL_SE) + { + Curl_infof(data, "(terminated by "); + if (CURL_TELOPT_OK(i)) + Curl_infof(data, "%s ", CURL_TELOPT(i)); + else if (CURL_TELCMD_OK(i)) + Curl_infof(data, "%s ", CURL_TELCMD(i)); + else + Curl_infof(data, "%d ", i); + if (CURL_TELOPT_OK(j)) + Curl_infof(data, "%s", CURL_TELOPT(j)); + else if (CURL_TELCMD_OK(j)) + Curl_infof(data, "%s", CURL_TELCMD(j)); + else + Curl_infof(data, "%d", j); + Curl_infof(data, ", not IAC SE!) "); + } + } + length -= 2; + } + if (length < 1) + { + Curl_infof(data, "(Empty suboption?)"); + return; + } + + if (CURL_TELOPT_OK(pointer[0])) { + switch(pointer[0]) { + case CURL_TELOPT_TTYPE: + case CURL_TELOPT_XDISPLOC: + case CURL_TELOPT_NEW_ENVIRON: + Curl_infof(data, "%s", CURL_TELOPT(pointer[0])); + break; + default: + Curl_infof(data, "%s (unsupported)", CURL_TELOPT(pointer[0])); + break; + } + } + else + Curl_infof(data, "%d (unknown)", pointer[i]); + + switch(pointer[1]) { + case CURL_TELQUAL_IS: + Curl_infof(data, " IS"); + break; + case CURL_TELQUAL_SEND: + Curl_infof(data, " SEND"); + break; + case CURL_TELQUAL_INFO: + Curl_infof(data, " INFO/REPLY"); + break; + case CURL_TELQUAL_NAME: + Curl_infof(data, " NAME"); + break; + } + + switch(pointer[0]) { + case CURL_TELOPT_TTYPE: + case CURL_TELOPT_XDISPLOC: + pointer[length] = 0; + Curl_infof(data, " \"%s\"", &pointer[2]); + break; + case CURL_TELOPT_NEW_ENVIRON: + if(pointer[1] == CURL_TELQUAL_IS) { + Curl_infof(data, " "); + for(i = 3;i < length;i++) { + switch(pointer[i]) { + case CURL_NEW_ENV_VAR: + Curl_infof(data, ", "); + break; + case CURL_NEW_ENV_VALUE: + Curl_infof(data, " = "); + break; + default: + Curl_infof(data, "%c", pointer[i]); + break; + } + } + } + break; + default: + for (i = 2; i < length; i++) + Curl_infof(data, " %.2x", pointer[i]); + break; + } + + if (direction) + { + Curl_infof(data, "\n"); + } + } +} + +static CURLcode check_telnet_options(struct connectdata *conn) +{ + struct curl_slist *head; + char option_keyword[128]; + char option_arg[256]; + char *buf; + struct SessionHandle *data = conn->data; + struct TELNET *tn = (struct TELNET *)conn->proto.telnet; + + /* Add the user name as an environment variable if it + was given on the command line */ + if(conn->bits.user_passwd) + { + snprintf(option_arg, sizeof(option_arg), "USER,%s", conn->user); + tn->telnet_vars = curl_slist_append(tn->telnet_vars, option_arg); + + tn->us_preferred[CURL_TELOPT_NEW_ENVIRON] = CURL_YES; + } + + for(head = data->set.telnet_options; head; head=head->next) { + if(sscanf(head->data, "%127[^= ]%*[ =]%255s", + option_keyword, option_arg) == 2) { + + /* Terminal type */ + if(curl_strequal(option_keyword, "TTYPE")) { + strncpy(tn->subopt_ttype, option_arg, 31); + tn->subopt_ttype[31] = 0; /* String termination */ + tn->us_preferred[CURL_TELOPT_TTYPE] = CURL_YES; + continue; + } + + /* Display variable */ + if(curl_strequal(option_keyword, "XDISPLOC")) { + strncpy(tn->subopt_xdisploc, option_arg, 127); + tn->subopt_xdisploc[127] = 0; /* String termination */ + tn->us_preferred[CURL_TELOPT_XDISPLOC] = CURL_YES; + continue; + } + + /* Environment variable */ + if(curl_strequal(option_keyword, "NEW_ENV")) { + buf = strdup(option_arg); + if(!buf) + return CURLE_OUT_OF_MEMORY; + tn->telnet_vars = curl_slist_append(tn->telnet_vars, buf); + tn->us_preferred[CURL_TELOPT_NEW_ENVIRON] = CURL_YES; + continue; + } + + failf(data, "Unknown telnet option %s", head->data); + return CURLE_UNKNOWN_TELNET_OPTION; + } else { + failf(data, "Syntax error in telnet option: %s", head->data); + return CURLE_TELNET_OPTION_SYNTAX; + } + } + + return CURLE_OK; +} + +/* + * suboption() + * + * Look at the sub-option buffer, and try to be helpful to the other + * side. + */ + +static void suboption(struct connectdata *conn) +{ + struct curl_slist *v; + unsigned char temp[2048]; + size_t len; + size_t tmplen; + char varname[128]; + char varval[128]; + struct SessionHandle *data = conn->data; + struct TELNET *tn = (struct TELNET *)conn->proto.telnet; + + printsub(data, '<', (unsigned char *)tn->subbuffer, CURL_SB_LEN(tn)+2); + switch (CURL_SB_GET(tn)) { + case CURL_TELOPT_TTYPE: + len = strlen(tn->subopt_ttype) + 4 + 2; + snprintf((char *)temp, sizeof(temp), + "%c%c%c%c%s%c%c", CURL_IAC, CURL_SB, CURL_TELOPT_TTYPE, + CURL_TELQUAL_IS, tn->subopt_ttype, CURL_IAC, CURL_SE); + (void)swrite(conn->sock[FIRSTSOCKET], temp, len); + printsub(data, '>', &temp[2], len-2); + break; + case CURL_TELOPT_XDISPLOC: + len = strlen(tn->subopt_xdisploc) + 4 + 2; + snprintf((char *)temp, sizeof(temp), + "%c%c%c%c%s%c%c", CURL_IAC, CURL_SB, CURL_TELOPT_XDISPLOC, + CURL_TELQUAL_IS, tn->subopt_xdisploc, CURL_IAC, CURL_SE); + (void)swrite(conn->sock[FIRSTSOCKET], temp, len); + printsub(data, '>', &temp[2], len-2); + break; + case CURL_TELOPT_NEW_ENVIRON: + snprintf((char *)temp, sizeof(temp), + "%c%c%c%c", CURL_IAC, CURL_SB, CURL_TELOPT_NEW_ENVIRON, + CURL_TELQUAL_IS); + len = 4; + + for(v = tn->telnet_vars;v;v = v->next) { + tmplen = (strlen(v->data) + 1); + /* Add the variable only if it fits */ + if(len + tmplen < (int)sizeof(temp)-6) { + sscanf(v->data, "%127[^,],%127s", varname, varval); + snprintf((char *)&temp[len], sizeof(temp) - len, + "%c%s%c%s", CURL_NEW_ENV_VAR, varname, + CURL_NEW_ENV_VALUE, varval); + len += tmplen; + } + } + snprintf((char *)&temp[len], sizeof(temp) - len, + "%c%c", CURL_IAC, CURL_SE); + len += 2; + (void)swrite(conn->sock[FIRSTSOCKET], temp, len); + printsub(data, '>', &temp[2], len-2); + break; + } + return; +} + +static +void telrcv(struct connectdata *conn, + unsigned char *inbuf, /* Data received from socket */ + ssize_t count) /* Number of bytes received */ +{ + unsigned char c; + int in = 0; + struct SessionHandle *data = conn->data; + struct TELNET *tn = (struct TELNET *)conn->proto.telnet; + + while(count--) + { + c = inbuf[in++]; + + switch (tn->telrcv_state) + { + case CURL_TS_CR: + tn->telrcv_state = CURL_TS_DATA; + if (c == '\0') + { + break; /* Ignore \0 after CR */ + } + + Curl_client_write(data, CLIENTWRITE_BODY, (char *)&c, 1); + continue; + + case CURL_TS_DATA: + if (c == CURL_IAC) + { + tn->telrcv_state = CURL_TS_IAC; + break; + } + else if(c == '\r') + { + tn->telrcv_state = CURL_TS_CR; + } + + Curl_client_write(data, CLIENTWRITE_BODY, (char *)&c, 1); + continue; + + case CURL_TS_IAC: + process_iac: + switch (c) + { + case CURL_WILL: + tn->telrcv_state = CURL_TS_WILL; + continue; + case CURL_WONT: + tn->telrcv_state = CURL_TS_WONT; + continue; + case CURL_DO: + tn->telrcv_state = CURL_TS_DO; + continue; + case CURL_DONT: + tn->telrcv_state = CURL_TS_DONT; + continue; + case CURL_SB: + CURL_SB_CLEAR(tn); + tn->telrcv_state = CURL_TS_SB; + continue; + case CURL_IAC: + Curl_client_write(data, CLIENTWRITE_BODY, (char *)&c, 1); + break; + case CURL_DM: + case CURL_NOP: + case CURL_GA: + default: + printoption(data, "RCVD", CURL_IAC, c); + break; + } + tn->telrcv_state = CURL_TS_DATA; + continue; + + case CURL_TS_WILL: + printoption(data, "RCVD", CURL_WILL, c); + tn->please_negotiate = 1; + rec_will(conn, c); + tn->telrcv_state = CURL_TS_DATA; + continue; + + case CURL_TS_WONT: + printoption(data, "RCVD", CURL_WONT, c); + tn->please_negotiate = 1; + rec_wont(conn, c); + tn->telrcv_state = CURL_TS_DATA; + continue; + + case CURL_TS_DO: + printoption(data, "RCVD", CURL_DO, c); + tn->please_negotiate = 1; + rec_do(conn, c); + tn->telrcv_state = CURL_TS_DATA; + continue; + + case CURL_TS_DONT: + printoption(data, "RCVD", CURL_DONT, c); + tn->please_negotiate = 1; + rec_dont(conn, c); + tn->telrcv_state = CURL_TS_DATA; + continue; + + case CURL_TS_SB: + if (c == CURL_IAC) + { + tn->telrcv_state = CURL_TS_SE; + } + else + { + CURL_SB_ACCUM(tn,c); + } + continue; + + case CURL_TS_SE: + if (c != CURL_SE) + { + if (c != CURL_IAC) + { + /* + * This is an error. We only expect to get + * "IAC IAC" or "IAC SE". Several things may + * have happend. An IAC was not doubled, the + * IAC SE was left off, or another option got + * inserted into the suboption are all possibilities. + * If we assume that the IAC was not doubled, + * and really the IAC SE was left off, we could + * get into an infinate loop here. So, instead, + * we terminate the suboption, and process the + * partial suboption if we can. + */ + CURL_SB_ACCUM(tn, (unsigned char)CURL_IAC); + CURL_SB_ACCUM(tn, c); + tn->subpointer -= 2; + CURL_SB_TERM(tn); + + printoption(data, "In SUBOPTION processing, RCVD", CURL_IAC, c); + suboption(conn); /* handle sub-option */ + tn->telrcv_state = CURL_TS_IAC; + goto process_iac; + } + CURL_SB_ACCUM(tn,c); + tn->telrcv_state = CURL_TS_SB; + } + else + { + CURL_SB_ACCUM(tn, (unsigned char)CURL_IAC); + CURL_SB_ACCUM(tn, (unsigned char)CURL_SE); + tn->subpointer -= 2; + CURL_SB_TERM(tn); + suboption(conn); /* handle sub-option */ + tn->telrcv_state = CURL_TS_DATA; + } + break; + } + } +} + +CURLcode Curl_telnet_done(struct connectdata *conn, CURLcode status) +{ + struct TELNET *tn = (struct TELNET *)conn->proto.telnet; + (void)status; /* unused */ + + curl_slist_free_all(tn->telnet_vars); + + free(conn->proto.telnet); + conn->proto.telnet = NULL; + + return CURLE_OK; +} + +CURLcode Curl_telnet(struct connectdata *conn) +{ + CURLcode code; + struct SessionHandle *data = conn->data; + curl_socket_t sockfd = conn->sock[FIRSTSOCKET]; +#ifdef WIN32 + HMODULE wsock2; + WSOCK2_FUNC close_event_func; + WSOCK2_FUNC create_event_func; + WSOCK2_FUNC event_select_func; + WSOCK2_FUNC enum_netevents_func; + WSAEVENT event_handle; + WSANETWORKEVENTS events; + HANDLE stdin_handle; + HANDLE objs[2]; + DWORD obj_count; + DWORD wait_timeout; + DWORD waitret; + DWORD readfile_read; +#else + fd_set readfd; + fd_set keepfd; +#endif + ssize_t nread; + bool keepon = TRUE; + char *buf = data->state.buffer; + struct TELNET *tn; + + code = init_telnet(conn); + if(code) + return code; + + tn = (struct TELNET *)conn->proto.telnet; + + code = check_telnet_options(conn); + if(code) + return code; + +#ifdef WIN32 + /* + ** This functionality only works with WinSock >= 2.0. So, + ** make sure have it. + */ + code = check_wsock2(data); + if (code) + return code; + + /* OK, so we have WinSock 2.0. We need to dynamically */ + /* load ws2_32.dll and get the function pointers we need. */ + wsock2 = LoadLibrary("WS2_32.DLL"); + if (wsock2 == NULL) { + failf(data,"failed to load WS2_32.DLL (%d)",GetLastError()); + return CURLE_FAILED_INIT; + } + + /* Grab a pointer to WSACreateEvent */ + create_event_func = GetProcAddress(wsock2,"WSACreateEvent"); + if (create_event_func == NULL) { + failf(data,"failed to find WSACreateEvent function (%d)", + GetLastError()); + FreeLibrary(wsock2); + return CURLE_FAILED_INIT; + } + + /* And WSACloseEvent */ + close_event_func = GetProcAddress(wsock2,"WSACloseEvent"); + if (create_event_func == NULL) { + failf(data,"failed to find WSACloseEvent function (%d)", + GetLastError()); + FreeLibrary(wsock2); + return CURLE_FAILED_INIT; + } + + /* And WSAEventSelect */ + event_select_func = GetProcAddress(wsock2,"WSAEventSelect"); + if (event_select_func == NULL) { + failf(data,"failed to find WSAEventSelect function (%d)", + GetLastError()); + FreeLibrary(wsock2); + return CURLE_FAILED_INIT; + } + + /* And WSAEnumNetworkEvents */ + enum_netevents_func = GetProcAddress(wsock2,"WSAEnumNetworkEvents"); + if (enum_netevents_func == NULL) { + failf(data,"failed to find WSAEnumNetworkEvents function (%d)", + GetLastError()); + FreeLibrary(wsock2); + return CURLE_FAILED_INIT; + } + + /* We want to wait for both stdin and the socket. Since + ** the select() function in winsock only works on sockets + ** we have to use the WaitForMultipleObjects() call. + */ + + /* First, create a sockets event object */ + event_handle = (WSAEVENT)create_event_func(); + if (event_handle == WSA_INVALID_EVENT) { + failf(data,"WSACreateEvent failed (%d)",WSAGetLastError()); + FreeLibrary(wsock2); + return CURLE_FAILED_INIT; + } + + /* The get the Windows file handle for stdin */ + stdin_handle = GetStdHandle(STD_INPUT_HANDLE); + + /* Create the list of objects to wait for */ + objs[0] = event_handle; + objs[1] = stdin_handle; + + /* Tell winsock what events we want to listen to */ + if(event_select_func(sockfd, event_handle, FD_READ|FD_CLOSE) == SOCKET_ERROR) { + close_event_func(event_handle); + FreeLibrary(wsock2); + return 0; + } + + /* If stdin_handle is a pipe, use PeekNamedPipe() method to check it, + else use the old WaitForMultipleObjects() way */ + if(GetFileType(stdin_handle) == FILE_TYPE_PIPE) { + /* Don't wait for stdin_handle, just wait for event_handle */ + obj_count = 1; + /* Check stdin_handle per 100 milliseconds */ + wait_timeout = 100; + } else { + obj_count = 2; + wait_timeout = INFINITE; + } + + /* Keep on listening and act on events */ + while(keepon) { + waitret = WaitForMultipleObjects(obj_count, objs, FALSE, wait_timeout); + switch(waitret) { + case WAIT_TIMEOUT: + { + unsigned char outbuf[2]; + int out_count; + ssize_t bytes_written; + char *buffer = buf; + + for(;;) { + if(!PeekNamedPipe(stdin_handle, NULL, 0, NULL, &readfile_read, NULL)) { + keepon = FALSE; + break; + } + nread = readfile_read; + + if(!nread) + break; + + if(!ReadFile(stdin_handle, buf, sizeof(data->state.buffer), + &readfile_read, NULL)) { + keepon = FALSE; + break; + } + nread = readfile_read; + + while(nread--) { + outbuf[0] = *buffer++; + out_count = 1; + if(outbuf[0] == CURL_IAC) + outbuf[out_count++] = CURL_IAC; + + Curl_write(conn, conn->sock[FIRSTSOCKET], outbuf, + out_count, &bytes_written); + } + } + } + break; + + case WAIT_OBJECT_0 + 1: + { + unsigned char outbuf[2]; + int out_count; + ssize_t bytes_written; + char *buffer = buf; + + if(!ReadFile(stdin_handle, buf, sizeof(data->state.buffer), + &readfile_read, NULL)) { + keepon = FALSE; + break; + } + nread = readfile_read; + + while(nread--) { + outbuf[0] = *buffer++; + out_count = 1; + if(outbuf[0] == CURL_IAC) + outbuf[out_count++] = CURL_IAC; + + Curl_write(conn, conn->sock[FIRSTSOCKET], outbuf, + out_count, &bytes_written); + } + } + break; + + case WAIT_OBJECT_0: + if(enum_netevents_func(sockfd, event_handle, &events) + != SOCKET_ERROR) { + if(events.lNetworkEvents & FD_READ) { + /* This reallu OUGHT to check its return code. */ + (void)Curl_read(conn, sockfd, buf, BUFSIZE - 1, &nread); + + telrcv(conn, (unsigned char *)buf, nread); + + fflush(stdout); + + /* Negotiate if the peer has started negotiating, + otherwise don't. We don't want to speak telnet with + non-telnet servers, like POP or SMTP. */ + if(tn->please_negotiate && !tn->already_negotiated) { + negotiate(conn); + tn->already_negotiated = 1; + } + } + + if(events.lNetworkEvents & FD_CLOSE) { + keepon = FALSE; + } + } + break; + } + } + + /* We called WSACreateEvent, so call WSACloseEvent */ + if (close_event_func(event_handle) == FALSE) { + infof(data,"WSACloseEvent failed (%d)",WSAGetLastError()); + } + + /* "Forget" pointers into the library we're about to free */ + create_event_func = NULL; + close_event_func = NULL; + event_select_func = NULL; + enum_netevents_func = NULL; + (void)create_event_func; + (void)close_event_func; + (void)event_select_func; + (void)enum_netevents_func; + + /* We called LoadLibrary, so call FreeLibrary */ + if (!FreeLibrary(wsock2)) + infof(data,"FreeLibrary(wsock2) failed (%d)",GetLastError()); +#else + FD_ZERO (&readfd); /* clear it */ + FD_SET (sockfd, &readfd); + FD_SET (0, &readfd); + + keepfd = readfd; + + while (keepon) { + struct timeval interval; + + readfd = keepfd; /* set this every lap in the loop */ + interval.tv_sec = 1; + interval.tv_usec = 0; + + switch (select (sockfd + 1, &readfd, NULL, NULL, &interval)) { + case -1: /* error, stop reading */ + keepon = FALSE; + continue; + case 0: /* timeout */ + break; + default: /* read! */ + if(FD_ISSET(0, &readfd)) { /* read from stdin */ + unsigned char outbuf[2]; + int out_count = 0; + ssize_t bytes_written; + char *buffer = buf; + + nread = read(0, buf, 255); + + while(nread--) { + outbuf[0] = *buffer++; + out_count = 1; + if(outbuf[0] == CURL_IAC) + outbuf[out_count++] = CURL_IAC; + + Curl_write(conn, conn->sock[FIRSTSOCKET], outbuf, + out_count, &bytes_written); + } + } + + if(FD_ISSET(sockfd, &readfd)) { + /* This OUGHT to check the return code... */ + (void)Curl_read(conn, sockfd, buf, BUFSIZE - 1, &nread); + + /* if we receive 0 or less here, the server closed the connection and + we bail out from this! */ + if (nread <= 0) { + keepon = FALSE; + break; + } + + telrcv(conn, (unsigned char *)buf, nread); + + /* Negotiate if the peer has started negotiating, + otherwise don't. We don't want to speak telnet with + non-telnet servers, like POP or SMTP. */ + if(tn->please_negotiate && !tn->already_negotiated) { + negotiate(conn); + tn->already_negotiated = 1; + } + } + } + if(data->set.timeout) { + struct timeval now; /* current time */ + now = Curl_tvnow(); + if(Curl_tvdiff(now, conn->created)/1000 >= data->set.timeout) { + failf(data, "Time-out"); + code = CURLE_OPERATION_TIMEOUTED; + keepon = FALSE; + } + } + } +#endif + /* mark this as "no further transfer wanted" */ + Curl_Transfer(conn, -1, -1, FALSE, NULL, -1, NULL); + + return code; +} +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/telnet.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/telnet.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/telnet.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/telnet.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,30 @@ +#ifndef __TELNET_H +#define __TELNET_H + +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: telnet.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ +#ifndef CURL_DISABLE_TELNET +CURLcode Curl_telnet(struct connectdata *conn); +CURLcode Curl_telnet_done(struct connectdata *conn, CURLcode); +#endif +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/CMakeLists.txt /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/CMakeLists.txt --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/CMakeLists.txt 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/CMakeLists.txt 2005-06-24 21:00:13.000000000 +0800 @@ -0,0 +1,19 @@ +SET(CURL_TESTS + ftpget + ftpgetresp + ftpupload + getinmemory + persistant + sepheaders + simple + ) + +CONFIGURE_FILE(${LIBCURL_SOURCE_DIR}/Testing/testconfig.h.in + ${LIBCURL_BINARY_DIR}/Testing/testconfig.h) + +INCLUDE_DIRECTORIES(${LIBCURL_BINARY_DIR}/Testing) + +FOREACH(TEST ${CURL_TESTS}) + ADD_EXECUTABLE(${TEST} ${TEST}.c) + TARGET_LINK_LIBRARIES(${TEST} cmcurl) +ENDFOREACH(TEST) diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/curlgtk.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/curlgtk.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/curlgtk.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/curlgtk.c 2003-01-07 10:17:48.000000000 +0800 @@ -0,0 +1,95 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id: curlgtk.c,v 1.1 2003/01/07 02:17:48 andy Exp $ + */ +/* Copyright (c) 2000 David Odin (aka DindinX) for MandrakeSoft */ +/* an attempt to use the curl library in concert with a gtk-threaded application */ + +#include +#include + +#include +#include /* new for v7 */ +#include /* new for v7 */ + +#include + +GtkWidget *Bar; + +size_t my_read_func(void *ptr, size_t size, size_t nmemb, FILE *stream) +{ + return fread(ptr, size, nmemb, stream); +} + +int my_progress_func(GtkWidget *Bar, int t, int d) +{ +/* printf("%d / %d (%g %%)\n", d, t, d*100.0/t);*/ + gdk_threads_enter(); + gtk_progress_set_value(GTK_PROGRESS(Bar), d*100.0/t); + gdk_threads_leave(); + return 0; +} + +void *curl_thread(void *ptr) +{ + CURL *curl; + CURLcode res; + FILE *outfile; + gchar *url = ptr; + + curl = curl_easy_init(); + if(curl) + { + outfile = fopen("/tmp/test.curl", "w"); + + curl_easy_setopt(curl, CURLOPT_URL, url); + curl_easy_setopt(curl, CURLOPT_FILE, outfile); + curl_easy_setopt(curl, CURLOPT_READFUNCTION, my_read_func); + curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, my_progress_func); + curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, Bar); + + res = curl_easy_perform(curl); + + fclose(outfile); + /* always cleanup */ + curl_easy_cleanup(curl); + } + return NULL; +} + +int main(int argc, char **argv) +{ + GtkWidget *Window, *Frame, *Frame2; + GtkAdjustment *adj; + pthread_t curl_tid; + + /* Init thread */ + g_thread_init(NULL); + + gtk_init(&argc, &argv); + Window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + Frame = gtk_frame_new(NULL); + gtk_frame_set_shadow_type(GTK_FRAME(Frame), GTK_SHADOW_OUT); + gtk_container_add(GTK_CONTAINER(Window), Frame); + Frame2 = gtk_frame_new(NULL); + gtk_frame_set_shadow_type(GTK_FRAME(Frame2), GTK_SHADOW_IN); + gtk_container_add(GTK_CONTAINER(Frame), Frame2); + gtk_container_set_border_width(GTK_CONTAINER(Frame2), 5); + adj = (GtkAdjustment*)gtk_adjustment_new(0, 0, 100, 0, 0, 0); + Bar = gtk_progress_bar_new_with_adjustment(adj); + gtk_container_add(GTK_CONTAINER(Frame2), Bar); + gtk_widget_show_all(Window); + + pthread_create(&curl_tid, NULL, curl_thread, argv[1]); + + gdk_threads_enter(); + gtk_main(); + gdk_threads_leave(); + return 0; +} + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/curltest.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/curltest.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/curltest.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/curltest.c 2003-05-02 20:43:59.000000000 +0800 @@ -0,0 +1,143 @@ +/* Prevent warnings on Visual Studio */ +struct _RPC_ASYNC_STATE; + +#include "curl/curl.h" +#include +#include + +int GetFtpFile(void) +{ + int retVal = 0; + CURL *curl; + CURLcode res; + curl = curl_easy_init(); + if(curl) + { + /* Get curl 7.9.2 from sunet.se's FTP site: */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl, CURLOPT_HEADER, 1); + curl_easy_setopt(curl, CURLOPT_URL, + "ftp://public.kitware.com/pub/cmake/cygwin/setup.hint"); + res = curl_easy_perform(curl); + if ( res != 0 ) + { + printf("Error fetching: ftp://public.kitware.com/pub/cmake/cygwin/setup.hint\n"); + retVal = 1; + } + + /* always cleanup */ + curl_easy_cleanup(curl); + } + else + { + printf("Cannot create curl object\n"); + retVal = 1; + } + return retVal; +} + +int GetWebFile(void) +{ + int retVal = 0; + CURL *curl; + CURLcode res; + + char proxy[1024]; + int proxy_type = 0; + + if ( getenv("HTTP_PROXY") ) + { + proxy_type = 1; + if (getenv("HTTP_PROXY_PORT") ) + { + sprintf(proxy, "%s:%s", getenv("HTTP_PROXY"), getenv("HTTP_PROXY_PORT")); + } + else + { + sprintf(proxy, "%s", getenv("HTTP_PROXY")); + } + if ( getenv("HTTP_PROXY_TYPE") ) + { + /* HTTP/SOCKS4/SOCKS5 */ + if ( strcmp(getenv("HTTP_PROXY_TYPE"), "HTTP") == 0 ) + { + proxy_type = 1; + } + else if ( strcmp(getenv("HTTP_PROXY_TYPE"), "SOCKS4") == 0 ) + { + proxy_type = 2; + } + else if ( strcmp(getenv("HTTP_PROXY_TYPE"), "SOCKS5") == 0 ) + { + proxy_type = 3; + } + } + } + + curl = curl_easy_init(); + if(curl) + { + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl, CURLOPT_HEADER, 1); + + /* Using proxy */ + if ( proxy_type > 0 ) + { + curl_easy_setopt(curl, CURLOPT_PROXY, proxy); + switch (proxy_type) + { + case 2: + curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4); + break; + case 3: + curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); + break; + default: + curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); + } + } + + /* get the first document */ + curl_easy_setopt(curl, CURLOPT_URL, "http://www.cmake.org/page1.html"); + res = curl_easy_perform(curl); + if ( res != 0 ) + { + printf("Error fetching: http://www.cmake.org/page1.html\n"); + retVal = 1; + } + + /* get another document from the same server using the same + connection */ + /* + curl_easy_setopt(curl, CURLOPT_URL, "http://www.cmake.org/page2.html"); + res = curl_easy_perform(curl); + if ( res != 0 ) + { + printf("Error fetching: http://www.cmake.org/page2.html\n"); + retVal = 1; + } + */ + + /* always cleanup */ + curl_easy_cleanup(curl); + } + else + { + printf("Cannot create curl object\n"); + retVal = 1; + } + + return retVal; +} + +int main(/*int argc, char **argv*/) +{ + int retVal = 0; + curl_global_init(CURL_GLOBAL_DEFAULT); + retVal += GetWebFile(); + + /* Do not check the output of FTP socks5 cannot handle FTP yet */ + GetFtpFile(); + curl_global_cleanup(); + return retVal; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/ftpget.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/ftpget.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/ftpget.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/ftpget.c 2003-01-07 10:17:48.000000000 +0800 @@ -0,0 +1,83 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id: ftpget.c,v 1.1 2003/01/07 02:17:48 andy Exp $ + */ + +#include "curl/curl.h" +#include "curl/types.h" +#include "curl/easy.h" + +#include "testconfig.h" + +/* + * This is an example showing how to get a single file from an FTP server. + * It delays the actual destination file creation until the first write + * callback so that it won't create an empty file in case the remote file + * doesn't exist or something else fails. + */ + +struct FtpFile { + char *filename; + FILE *stream; +}; + +int my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) +{ + struct FtpFile *out=(struct FtpFile *)stream; + if(out && !out->stream) { + /* open file for writing */ + out->stream=fopen(out->filename, "wb"); + if(!out->stream) + return -1; /* failure, can't open file to write */ + } + return fwrite(buffer, size, nmemb, out->stream); +} + + +int main(void) +{ + CURL *curl; + CURLcode res; + struct FtpFile ftpfile={ + LIBCURL_BINARY_DIR "/Testing/ftpget-download.txt", /* name to store the file as if succesful */ + NULL + }; + + curl_global_init(CURL_GLOBAL_DEFAULT); + + curl = curl_easy_init(); + if(curl) { + /* Get curl 7.9.2 from sunet.se's FTP site: */ + curl_easy_setopt(curl, CURLOPT_URL, + "ftp://public.kitware.com/pub/cmake/cygwin/setup.hint"); + /* Define our callback to get called when there's data to be written */ + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite); + /* Set a pointer to our struct to pass to the callback */ + curl_easy_setopt(curl, CURLOPT_FILE, &ftpfile); + + /* Switch on full protocol/debug output */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE); + + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + + if(CURLE_OK != res) { + /* we failed */ + fprintf(stderr, "curl told us %d\n", res); + } + } + + if(ftpfile.stream) + fclose(ftpfile.stream); /* close the local file */ + + curl_global_cleanup(); + + return 0; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/ftpgetresp.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/ftpgetresp.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/ftpgetresp.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/ftpgetresp.c 2003-01-07 10:17:48.000000000 +0800 @@ -0,0 +1,63 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id: ftpgetresp.c,v 1.1 2003/01/07 02:17:48 andy Exp $ + */ + +#include "curl/curl.h" +#include "curl/types.h" +#include "curl/easy.h" + +#include "testconfig.h" + +/* + * Similar to ftpget.c but this also stores the received response-lines + * in a separate file using our own callback! + * + * This functionality was introduced in libcurl 7.9.3. + */ + +size_t +write_response(void *ptr, size_t size, size_t nmemb, void *data) +{ + FILE *writehere = (FILE *)data; + return fwrite(ptr, size, nmemb, writehere); +} + +int main(int argc, char **argv) +{ + CURL *curl; + CURLcode res; + FILE *ftpfile; + FILE *respfile; + + /* local file name to store the file as */ + ftpfile = fopen(LIBCURL_BINARY_DIR "/Testing/ftpgetresp-list.txt", "wb"); /* b is binary, needed on win32 */ + + /* local file name to store the FTP server's response lines in */ + respfile = fopen(LIBCURL_BINARY_DIR "/Testing/ftpgetresp-responses.txt", "wb"); /* b is binary, needed on win32 */ + + curl_global_init(CURL_GLOBAL_DEFAULT); + + curl = curl_easy_init(); + if(curl) { + /* Get a file listing from sunet */ + curl_easy_setopt(curl, CURLOPT_URL, "ftp://public.kitware.com/"); + curl_easy_setopt(curl, CURLOPT_FILE, ftpfile); + curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, write_response); + curl_easy_setopt(curl, CURLOPT_WRITEHEADER, respfile); + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + + fclose(ftpfile); /* close the local file */ + fclose(respfile); /* close the response file */ + + return 0; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/ftpupload.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/ftpupload.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/ftpupload.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/ftpupload.c 2003-11-04 05:59:15.000000000 +0800 @@ -0,0 +1,92 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id: ftpupload.c,v 1.2 2003/11/03 21:59:15 andy Exp $ + */ + +#include "curl/curl.h" + +#include +#include +#include + +#include "testconfig.h" + +/* + * This example shows an FTP upload, with a rename of the file just after + * a successful upload. + * + * Example based on source code provided by Erick Nuwendam. Thanks! + */ + +#define LOCAL_FILE LIBCURL_SOURCE_DIR "/Testing/ftpupload.c" +#define UPLOAD_FILE_AS "while-uploading.txt" +#define REMOTE_URL "ftp://public.kitware.com/incoming/" UPLOAD_FILE_AS +#define RENAME_FILE_TO "renamed-and-fine.txt" + +int main(int argc, char **argv) +{ + CURL *curl; + CURLcode res; + FILE *ftpfile; + FILE * hd_src ; + int hd ; + struct stat file_info; + + struct curl_slist *headerlist=NULL; + char buf_1 [] = "RNFR " UPLOAD_FILE_AS; + char buf_2 [] = "RNTO " RENAME_FILE_TO; + + /* get the file size of the local file */ + hd = open(LOCAL_FILE, O_RDONLY) ; + fstat(hd, &file_info); + close(hd) ; + + /* get a FILE * of the same file, could also be made with + fdopen() from the previous descriptor, but hey this is just + an example! */ + hd_src = fopen(LOCAL_FILE, "rb"); + + /* In windows, this will init the winsock stuff */ + curl_global_init(CURL_GLOBAL_ALL); + + /* get a curl handle */ + curl = curl_easy_init(); + if(curl) { + /* build a list of commands to pass to libcurl */ + headerlist = curl_slist_append(headerlist, buf_1); + headerlist = curl_slist_append(headerlist, buf_2); + + /* enable uploading */ + curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ; + + /* specify target */ + curl_easy_setopt(curl,CURLOPT_URL, REMOTE_URL); + + /* pass in that last of FTP commands to run after the transfer */ + curl_easy_setopt(curl, CURLOPT_POSTQUOTE, headerlist); + + /* now specify which file to upload */ + curl_easy_setopt(curl, CURLOPT_INFILE, hd_src); + + /* and give the size of the upload (optional) */ + curl_easy_setopt(curl, CURLOPT_INFILESIZE, (long)file_info.st_size); + + /* Now run off and do what you've been told! */ + res = curl_easy_perform(curl); + + /* clean up the FTP commands list */ + curl_slist_free_all (headerlist); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + fclose(hd_src); /* close the local file */ + + curl_global_cleanup(); + return 0; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/getinmemory.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/getinmemory.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/getinmemory.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/getinmemory.c 2003-01-07 10:17:48.000000000 +0800 @@ -0,0 +1,83 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id: getinmemory.c,v 1.1 2003/01/07 02:17:48 andy Exp $ + * + * Example source code to show how the callback function can be used to + * download data into a chunk of memory instead of storing it in a file. + * + * This exact source code has not been verified to work. + */ + +/* to make this work under windows, use the win32-functions from the + win32socket.c file as well */ + +#include "curl/curl.h" +#include "curl/types.h" +#include "curl/easy.h" + +struct MemoryStruct { + char *memory; + size_t size; +}; + +size_t +WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data) +{ + register int realsize = size * nmemb; + struct MemoryStruct *mem = (struct MemoryStruct *)data; + + mem->memory = (char *)realloc(mem->memory, mem->size + realsize + 1); + if (mem->memory) { + memcpy(&(mem->memory[mem->size]), ptr, realsize); + mem->size += realsize; + mem->memory[mem->size] = 0; + } + return realsize; +} + +int main(int argc, char **argv) +{ + CURL *curl_handle; + + struct MemoryStruct chunk; + + chunk.memory=NULL; /* we expect realloc(NULL, size) to work */ + chunk.size = 0; /* no data at this point */ + + curl_global_init(CURL_GLOBAL_DEFAULT); + + /* init the curl session */ + curl_handle = curl_easy_init(); + + /* specify URL to get */ + curl_easy_setopt(curl_handle, CURLOPT_URL, "http://www.cmake.org/HTML/Index.html"); + + /* send all data to this function */ + curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback); + + /* we pass our 'chunk' struct to the callback function */ + curl_easy_setopt(curl_handle, CURLOPT_FILE, (void *)&chunk); + + /* get it! */ + curl_easy_perform(curl_handle); + + /* cleanup curl stuff */ + curl_easy_cleanup(curl_handle); + + /* + * Now, our chunk.memory points to a memory block that is chunk.size + * bytes big and contains the remote file. + * + * Do something nice with it! + */ + + /* For example display it... */ + write(1, chunk.memory, chunk.size); + + return 0; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/http-post.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/http-post.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/http-post.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/http-post.c 2003-01-07 10:17:48.000000000 +0800 @@ -0,0 +1,35 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id: http-post.c,v 1.1 2003/01/07 02:17:48 andy Exp $ + */ + +#include +#include + +int main(void) +{ + CURL *curl; + CURLcode res; + + curl = curl_easy_init(); + if(curl) { + /* First set the URL that is about to receive our POST. This URL can + just as well be a https:// URL if that is what should receive the + data. */ + curl_easy_setopt(curl, CURLOPT_URL, "http://postit.example.com/moo.cgi"); + /* Now specify the POST data */ + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "name=daniel&project=curl"); + + /* Perform the request, res will get the return code */ + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return 0; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/httpput.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/httpput.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/httpput.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/httpput.c 2003-01-07 10:17:48.000000000 +0800 @@ -0,0 +1,100 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id: httpput.c,v 1.1 2003/01/07 02:17:48 andy Exp $ + */ + +#include +#include +#include + +#include + +/* + * This example shows a HTTP PUT operation. PUTs a file given as a command + * line argument to the URL also given on the command line. + * + * This example also uses its own read callback. + */ + +size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream) +{ + size_t retcode; + + /* in real-world cases, this would probably get this data differently + as this fread() stuff is exactly what the library already would do + by default internally */ + retcode = fread(ptr, size, nmemb, stream); + + fprintf(stderr, "*** We read %d bytes from file\n", retcode); + + return retcode; +} + +int main(int argc, char **argv) +{ + CURL *curl; + CURLcode res; + FILE *ftpfile; + FILE * hd_src ; + int hd ; + struct stat file_info; + + char *file; + char *url; + + if(argc < 3) + return 1; + + file= argv[1]; + url = argv[2]; + + /* get the file size of the local file */ + hd = open(file, O_RDONLY) ; + fstat(hd, &file_info); + close(hd) ; + + /* get a FILE * of the same file, could also be made with + fdopen() from the previous descriptor, but hey this is just + an example! */ + hd_src = fopen(file, "rb"); + + /* In windows, this will init the winsock stuff */ + curl_global_init(CURL_GLOBAL_ALL); + + /* get a curl handle */ + curl = curl_easy_init(); + if(curl) { + /* we want to use our own read function */ + curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); + + /* enable uploading */ + curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ; + + /* HTTP PUT please */ + curl_easy_setopt(curl, CURLOPT_PUT, TRUE); + + /* specify target */ + curl_easy_setopt(curl,CURLOPT_URL, url); + + /* now specify which file to upload */ + curl_easy_setopt(curl, CURLOPT_INFILE, hd_src); + + /* and give the size of the upload (optional) */ + curl_easy_setopt(curl, CURLOPT_INFILESIZE, file_info.st_size); + + /* Now run off and do what you've been told! */ + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + fclose(hd_src); /* close the local file */ + + curl_global_cleanup(); + return 0; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/multithread.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/multithread.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/multithread.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/multithread.c 2003-01-07 10:17:48.000000000 +0800 @@ -0,0 +1,70 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id: multithread.c,v 1.1 2003/01/07 02:17:48 andy Exp $ + */ + +/* A multi-threaded example that uses pthreads extensively to fetch + * X remote files at once */ + +#include +#include +#include + +/* silly list of test-URLs */ +char *urls[]= { + "http://curl.haxx.se/", + "ftp://cool.haxx.se/", + "http://www.contactor.se/", + "www.haxx.se" +}; + +void *pull_one_url(void *url) +{ + CURL *curl; + + curl = curl_easy_init(); + + curl_easy_setopt(curl, CURLOPT_URL, url); + curl_easy_perform(curl); + + curl_easy_cleanup(curl); + + return NULL; +} + + +/* + int pthread_create(pthread_t *new_thread_ID, + const pthread_attr_t *attr, + void * (*start_func)(void *), void *arg); +*/ + +int main(int argc, char **argv) +{ + pthread_t tid[4]; + int i; + int error; + for(i=0; i< 4; i++) { + error = pthread_create(&tid[i], + NULL, /* default attributes please */ + pull_one_url, + urls[i]); + if(0 != error) + fprintf(stderr, "Couldn't run thread number %d, errno %d\n", i, error); + else + fprintf(stderr, "Thread %d, gets %s\n", i, urls[i]); + } + + /* now wait for all threads to terminate */ + for(i=0; i< 4; i++) { + error = pthread_join(tid[i], NULL); + fprintf(stderr, "Thread %d terminated\n", i); + } + + return 0; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/persistant.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/persistant.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/persistant.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/persistant.c 2003-01-07 10:17:48.000000000 +0800 @@ -0,0 +1,53 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id: persistant.c,v 1.1 2003/01/07 02:17:48 andy Exp $ + */ + +#include + +#include "curl/curl.h" + +/* to make this work under windows, use the win32-functions from the + docs/examples/win32socket.c file as well */ + +/* This example REQUIRES libcurl 7.7 or later */ +#if (LIBCURL_VERSION_NUM < 0x070700) +#error Too old libcurl version, upgrade or stay away. +#endif + +int main(int argc, char **argv) +{ + CURL *curl; + CURLcode res; + +#ifdef MALLOCDEBUG + /* this sends all memory debug messages to a specified logfile */ + curl_memdebug("memdump"); +#endif + + curl_global_init(CURL_GLOBAL_DEFAULT); + curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl, CURLOPT_HEADER, 1); + + /* get the first document */ + curl_easy_setopt(curl, CURLOPT_URL, "http://www.cmake.org/"); + res = curl_easy_perform(curl); + + /* get another document from the same server using the same + connection */ + curl_easy_setopt(curl, CURLOPT_URL, "http://www.cmake.org/HTML/Index.html"); + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + + return 0; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/postit2.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/postit2.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/postit2.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/postit2.c 2003-01-07 10:17:48.000000000 +0800 @@ -0,0 +1,92 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id: postit2.c,v 1.1 2003/01/07 02:17:48 andy Exp $ + * + * Example code that uploads a file name 'foo' to a remote script that accepts + * "HTML form based" (as described in RFC1738) uploads using HTTP POST. + * + * The imaginary form we'll fill in looks like: + * + *
    + * Enter file: + * Enter file name: + * + *
    + * + * This exact source code has not been verified to work. + */ + +/* to make this work under windows, use the win32-functions from the + win32socket.c file as well */ + +#include +#include + +#include +#include +#include + +#if LIBCURL_VERSION_NUM < 0x070900 +#error "curl_formadd() is not introduced until libcurl 7.9 and later" +#endif + +int main(int argc, char *argv[]) +{ + CURL *curl; + CURLcode res; + + struct HttpPost *formpost=NULL; + struct HttpPost *lastptr=NULL; + struct curl_slist *headerlist=NULL; + char buf[] = "Expect:"; + + /* Fill in the file upload field */ + curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "sendfile", + CURLFORM_FILE, "postit2.c", + CURLFORM_END); + + /* Fill in the filename field */ + curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "filename", + CURLFORM_COPYCONTENTS, "postit2.c", + CURLFORM_END); + + + /* Fill in the submit field too, even if this is rarely needed */ + curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "submit", + CURLFORM_COPYCONTENTS, "send", + CURLFORM_END); + + curl = curl_easy_init(); + /* initalize custom header list (stating that Expect: 100-continue is not + wanted */ + headerlist = curl_slist_append(headerlist, buf); + if(curl) { + /* what URL that receives this POST */ + curl_easy_setopt(curl, CURLOPT_URL, "http://curl.haxx.se/examplepost.cgi"); + if ( (argc == 2) && (!strcmp(argv[1], "noexpectheader")) ) + /* only disable 100-continue header if explicitly requested */ + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); + curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + + /* then cleanup the formpost chain */ + curl_formfree(formpost); + /* free slist */ + curl_slist_free_all (headerlist); + } + return 0; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/sepheaders.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/sepheaders.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/sepheaders.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/sepheaders.c 2003-01-07 10:17:48.000000000 +0800 @@ -0,0 +1,78 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id: sepheaders.c,v 1.1 2003/01/07 02:17:48 andy Exp $ + */ + +/* to make this work under windows, use the win32-functions from the + win32socket.c file as well */ + +#include "curl/curl.h" +#include "curl/types.h" +#include "curl/easy.h" + +#include "testconfig.h" + +size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream) +{ + int written = fwrite(ptr, size, nmemb, (FILE *)stream); + return written; +} + +int main(int argc, char **argv) +{ + CURL *curl_handle; + char *headerfilename = LIBCURL_BINARY_DIR "/Testing/sepheaders-head.out"; + FILE *headerfile; + char *bodyfilename = LIBCURL_BINARY_DIR "/Testing/sepheaders-body.out"; + FILE *bodyfile; + + curl_global_init(CURL_GLOBAL_DEFAULT); + /* init the curl session */ + curl_handle = curl_easy_init(); + + /* set URL to get */ + curl_easy_setopt(curl_handle, CURLOPT_URL, "http://www.cmake.org/HTML/Index.html"); + + /* no progress meter please */ + curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1); + + /* shut up completely */ + curl_easy_setopt(curl_handle, CURLOPT_MUTE, 1); + + /* send all data to this function */ + curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data); + + /* open the files */ + headerfile = fopen(headerfilename,"w"); + if (headerfile == NULL) { + curl_easy_cleanup(curl_handle); + return -1; + } + bodyfile = fopen(bodyfilename,"w"); + if (bodyfile == NULL) { + curl_easy_cleanup(curl_handle); + return -1; + } + + /* we want the headers to this file handle */ + curl_easy_setopt(curl_handle, CURLOPT_WRITEHEADER ,headerfile); + + /* we want the body to this file handle */ + curl_easy_setopt(curl_handle, CURLOPT_FILE ,bodyfile); + + /* get it! */ + curl_easy_perform(curl_handle); + + /* close the header file */ + fclose(headerfile); + + /* cleanup curl stuff */ + curl_easy_cleanup(curl_handle); + + return 0; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/simple.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/simple.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/simple.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/simple.c 2003-01-07 10:17:48.000000000 +0800 @@ -0,0 +1,28 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id: simple.c,v 1.1 2003/01/07 02:17:48 andy Exp $ + */ + +#include "curl/curl.h" + +int main(void) +{ + CURL *curl; + CURLcode res; + + curl_global_init(CURL_GLOBAL_DEFAULT); + curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "http://www.cmake.org/HTML/Index.html"); + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return 0; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/simplessl.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/simplessl.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/simplessl.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/simplessl.c 2003-01-07 10:17:48.000000000 +0800 @@ -0,0 +1,118 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id: simplessl.c,v 1.1 2003/01/07 02:17:48 andy Exp $ + */ + +#include + +#include +#include +#include + + +/* some requirements for this to work: + 1. set pCertFile to the file with the client certificate + 2. if the key is passphrase protected, set pPassphrase to the + passphrase you use + 3. if you are using a crypto engine: + 3.1. set a #define USE_ENGINE + 3.2. set pEngine to the name of the crypto engine you use + 3.3. set pKeyName to the key identifier you want to use + 4. if you don't use a crypto engine: + 4.1. set pKeyName to the file name of your client key + 4.2. if the format of the key file is DER, set pKeyType to "DER" + + !! verify of the server certificate is not implemented here !! + + **** This example only works with libcurl 7.9.3 and later! **** + +*/ + +int main(int argc, char **argv) +{ + CURL *curl; + CURLcode res; + FILE *headerfile; + + const char *pCertFile = "testcert.pem"; + const char *pCACertFile="cacert.pem" + + const char *pKeyName; + const char *pKeyType; + + const char *pEngine; + +#if USE_ENGINE + pKeyName = "rsa_test"; + pKeyType = "ENG"; + pEngine = "chil"; /* for nChiper HSM... */ +#else + pKeyName = "testkey.pem"; + pKeyType = "PEM"; + pEngine = NULL; +#endif + + const char *pPassphrase = NULL; + + headerfile = fopen("dumpit", "w"); + + curl_global_init(CURL_GLOBAL_DEFAULT); + + curl = curl_easy_init(); + if(curl) { + /* what call to write: */ + curl_easy_setopt(curl, CURLOPT_URL, "HTTPS://curl.haxx.se"); + curl_easy_setopt(curl, CURLOPT_WRITEHEADER, headerfile); + + while(1) /* do some ugly short cut... */ + { + if (pEngine) /* use crypto engine */ + { + if (curl_easy_setopt(curl, CURLOPT_SSLENGINE,pEngine) != CURLE_OK) + { /* load the crypto engine */ + fprintf(stderr,"can't set crypto engine\n"); + break; + } + if (curl_easy_setopt(curl, CURLOPT_SSLENGINE_DEFAULT,1) != CURLE_OK) + { /* set the crypto engine as default */ + /* only needed for the first time you load + a engine in a curl object... */ + fprintf(stderr,"can't set crypto engine as default\n"); + break; + } + } + /* cert is stored PEM coded in file... */ + /* since PEM is default, we needn't set it for PEM */ + curl_easy_setopt(curl,CURLOPT_SSLCERTTYPE,"PEM"); + /* set the cert for client authentication */ + curl_easy_setopt(curl,CURLOPT_SSLCERT,pCertFile); + /* sorry, for engine we must set the passphrase + (if the key has one...) */ + if (pPassphrase) + curl_easy_setopt(curl,CURLOPT_SSLKEYPASSWD,pPassphrase); + /* if we use a key stored in a crypto engine, + we must set the key type to "ENG" */ + curl_easy_setopt(curl,CURLOPT_SSLKEYTYPE,pKeyType); + /* set the private key (file or ID in engine) */ + curl_easy_setopt(curl,CURLOPT_SSLKEY,pKeyName); + /* set the file with the certs vaildating the server */ + curl_easy_setopt(curl,CURLOPT_CAINFO,pCACertFile); + /* disconnect if we can't validate server's cert */ + curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,1); + + res = curl_easy_perform(curl); + break; /* we are done... */ + } + /* always cleanup */ + curl_easy_cleanup(curl); + } + + curl_global_cleanup(); + + return 0; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/testconfig.h.in /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/testconfig.h.in --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/testconfig.h.in 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/testconfig.h.in 2003-01-07 10:17:48.000000000 +0800 @@ -0,0 +1,7 @@ +#ifndef __testconfig_h__ +#define __testconfig_h__ + +#define LIBCURL_SOURCE_DIR "${LIBCURL_SOURCE_DIR}" +#define LIBCURL_BINARY_DIR "${LIBCURL_BINARY_DIR}" + +#endif /* __testconfig_h__ */ diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/win32sockets.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/win32sockets.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/Testing/win32sockets.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/Testing/win32sockets.c 2003-01-07 10:17:48.000000000 +0800 @@ -0,0 +1,49 @@ + +/* + * Note: This is only required if you use curl 7.8 or lower, later + * versions provide an option to curl_global_init() that does the + * win32 initialization for you. + */ + +/* + * These are example functions doing socket init that Windows + * require. If you don't use windows, you can safely ignore this crap. + */ + +#include + +void win32_cleanup(void) +{ + WSACleanup(); +} + +int win32_init(void) +{ + WORD wVersionRequested; + WSADATA wsaData; + int err; + wVersionRequested = MAKEWORD(1, 1); + + err = WSAStartup(wVersionRequested, &wsaData); + + if (err != 0) + /* Tell the user that we couldn't find a useable */ + /* winsock.dll. */ + return 1; + + /* Confirm that the Windows Sockets DLL supports 1.1.*/ + /* Note that if the DLL supports versions greater */ + /* than 1.1 in addition to 1.1, it will still return */ + /* 1.1 in wVersion since that is the version we */ + /* requested. */ + + if ( LOBYTE( wsaData.wVersion ) != 1 || + HIBYTE( wsaData.wVersion ) != 1 ) { + /* Tell the user that we couldn't find a useable */ + + /* winsock.dll. */ + WSACleanup(); + return 1; + } + return 0; /* 0 is ok */ +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/timeval.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/timeval.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/timeval.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/timeval.c 2004-10-13 22:45:30.000000000 +0800 @@ -0,0 +1,116 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: timeval.c,v 1.6 2004/10/13 14:45:30 andy Exp $ + ***************************************************************************/ + +#include "timeval.h" + +#ifndef HAVE_GETTIMEOFDAY + +#ifdef WIN32 +#include + +static int gettimeofday(struct timeval *tp, void *nothing) +{ +#ifdef WITHOUT_MM_LIB + SYSTEMTIME st; + time_t tt; + struct tm tmtm; + /* mktime converts local to UTC */ + GetLocalTime (&st); + tmtm.tm_sec = st.wSecond; + tmtm.tm_min = st.wMinute; + tmtm.tm_hour = st.wHour; + tmtm.tm_mday = st.wDay; + tmtm.tm_mon = st.wMonth - 1; + tmtm.tm_year = st.wYear - 1900; + tmtm.tm_isdst = -1; + tt = mktime (&tmtm); + tp->tv_sec = tt; + tp->tv_usec = st.wMilliseconds * 1000; +#else + /** + ** The earlier time calculations using GetLocalTime + ** had a time resolution of 10ms.The timeGetTime, part + ** of multimedia apis offer a better time resolution + ** of 1ms.Need to link against winmm.lib for this + **/ + unsigned long Ticks; + unsigned long Sec; + unsigned long Usec; + Ticks = timeGetTime(); + + Sec = Ticks/1000; + Usec = (Ticks - (Sec*1000))*1000; + tp->tv_sec = Sec; + tp->tv_usec = Usec; +#endif /* WITHOUT_MM_LIB */ + (void)nothing; + return 0; +} +#else /* WIN32 */ +/* non-win32 version of Curl_gettimeofday() */ +static int gettimeofday(struct timeval *tp, void *nothing) +{ + (void)nothing; /* we don't support specific time-zones */ + tp->tv_sec = (long)time(NULL); + tp->tv_usec = 0; + return 0; +} +#endif /* WIN32 */ +#endif /* HAVE_GETTIMEOFDAY */ + +/* Return the current time in a timeval struct */ +struct timeval curlx_tvnow(void) +{ + struct timeval now; + (void)gettimeofday(&now, NULL); + return now; +} + +/* + * Make sure that the first argument is the more recent time, as otherwise + * we'll get a weird negative time-diff back... + * + * Returns: the time difference in number of milliseconds. + */ +long curlx_tvdiff(struct timeval newer, struct timeval older) +{ + return (newer.tv_sec-older.tv_sec)*1000+ + (newer.tv_usec-older.tv_usec)/1000; +} + +/* + * Same as curlx_tvdiff but with full usec resolution. + * + * Returns: the time difference in seconds with subsecond resolution. + */ +double curlx_tvdiff_secs(struct timeval newer, struct timeval older) +{ + return (double)(newer.tv_sec-older.tv_sec)+ + (double)(newer.tv_usec-older.tv_usec)/1000000.0; +} + +/* return the number of seconds in the given input timeval struct */ +long Curl_tvlong(struct timeval t1) +{ + return t1.tv_sec; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/timeval.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/timeval.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/timeval.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/timeval.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,74 @@ +#ifndef __TIMEVAL_H +#define __TIMEVAL_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: timeval.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ + +/* + * CAUTION: this header is designed to work when included by the app-side + * as well as the library. Do not mix with library internals! + */ + +#include "setup.h" + +#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__) +#include +#else +#include +#endif + +#ifndef HAVE_GETTIMEOFDAY +#if !defined(_WINSOCKAPI_) && !defined(__MINGW32__) && !defined(_AMIGASF) && \ + !defined(__LCC__) +struct timeval { + long tv_sec; + long tv_usec; +}; +#endif +#endif + +struct timeval curlx_tvnow(void); + +/* + * Make sure that the first argument (t1) is the more recent time and t2 is + * the older time, as otherwise you get a weird negative time-diff back... + * + * Returns: the time difference in number of milliseconds. + */ +long curlx_tvdiff(struct timeval t1, struct timeval t2); + +/* + * Same as curlx_tvdiff but with full usec resolution. + * + * Returns: the time difference in seconds with subsecond resolution. + */ +double curlx_tvdiff_secs(struct timeval t1, struct timeval t2); + +long Curl_tvlong(struct timeval t1); + +/* These two defines below exist to provide the older API for library + internals only. */ +#define Curl_tvnow() curlx_tvnow() +#define Curl_tvdiff(x,y) curlx_tvdiff(x,y) +#define Curl_tvdiff_secs(x,y) curlx_tvdiff_secs(x,y) + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/transfer.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/transfer.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/transfer.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/transfer.c 2004-10-13 22:45:30.000000000 +0800 @@ -0,0 +1,2191 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: transfer.c,v 1.9 2004/10/13 14:45:30 andy Exp $ + ***************************************************************************/ + +#include "setup.h" + +/* -- WIN32 approved -- */ +#include +#include +#include +#include +#include +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#include + +#include + +#include "strtoofft.h" +#include "strequal.h" + +#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__) +#include +#include +#else +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#include +#ifdef HAVE_ARPA_INET_H +#include +#endif +#ifdef HAVE_NET_IF_H +#include +#endif +#ifdef HAVE_SYS_IOCTL_H +#include +#endif +#include + +#ifdef HAVE_SYS_PARAM_H +#include +#endif + +#ifdef HAVE_SYS_SELECT_H +#include +#endif + +#ifndef HAVE_SELECT +#error "We can't compile without select() support!" +#endif +#ifndef HAVE_SOCKET +#error "We can't compile without socket() support!" +#endif + +#endif + +#include "urldata.h" +#include +#include "netrc.h" + +#include "content_encoding.h" +#include "hostip.h" +#include "transfer.h" +#include "sendf.h" +#include "speedcheck.h" +#include "progress.h" +#include "getdate.h" +#include "http.h" +#include "url.h" +#include "getinfo.h" +#include "ssluse.h" +#include "http_digest.h" +#include "http_ntlm.h" +#include "http_negotiate.h" +#include "share.h" +#include "curl_memory.h" + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +/* The last #include file should be: */ +#include "memdebug.h" + +#define CURL_TIMEOUT_EXPECT_100 1000 /* counting ms here */ + +enum { + KEEP_NONE, + KEEP_READ, + KEEP_WRITE +}; + +/* We keep this static and global since this is read-only and NEVER + changed. It should just remain a blanked-out timeout value. */ +static struct timeval notimeout={0,0}; + +/* + * This function will call the read callback to fill our buffer with data + * to upload. + */ +CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp) +{ + struct SessionHandle *data = conn->data; + size_t buffersize = (size_t)bytes; + int nread; + + if(conn->bits.upload_chunky) { + /* if chunked Transfer-Encoding */ + buffersize -= (8 + 2 + 2); /* 32bit hex + CRLF + CRLF */ + conn->upload_fromhere += 10; /* 32bit hex + CRLF */ + } + + /* this function returns a size_t, so we typecast to int to prevent warnings + with picky compilers */ + nread = (int)conn->fread(conn->upload_fromhere, 1, + buffersize, conn->fread_in); + + if(nread == CURL_READFUNC_ABORT) { + failf(data, "operation aborted by callback\n"); + return CURLE_ABORTED_BY_CALLBACK; + } + + if(!conn->bits.forbidchunk && conn->bits.upload_chunky) { + /* if chunked Transfer-Encoding */ + char hexbuffer[11]; + int hexlen = snprintf(hexbuffer, sizeof(hexbuffer), + "%x\r\n", nread); + /* move buffer pointer */ + conn->upload_fromhere -= hexlen; + nread += hexlen; + + /* copy the prefix to the buffer */ + memcpy(conn->upload_fromhere, hexbuffer, hexlen); + + /* always append CRLF to the data */ + memcpy(conn->upload_fromhere + nread, "\r\n", 2); + + if((nread - hexlen) == 0) { + /* mark this as done once this chunk is transfered */ + conn->keep.upload_done = TRUE; + } + + nread+=2; /* for the added CRLF */ + } + + *nreadp = nread; + + return CURLE_OK; +} + +/* + * checkhttpprefix() + * + * Returns TRUE if member of the list matches prefix of string + */ +static bool +checkhttpprefix(struct SessionHandle *data, + const char *s) +{ + struct curl_slist *head = data->set.http200aliases; + + while (head) { + if (checkprefix(head->data, s)) + return TRUE; + head = head->next; + } + + if(checkprefix("HTTP/", s)) + return TRUE; + + return FALSE; +} + + +/* + * Curl_readwrite() is the low-level function to be called when data is to + * be read and written to/from the connection. + */ +CURLcode Curl_readwrite(struct connectdata *conn, + bool *done) +{ + struct Curl_transfer_keeper *k = &conn->keep; + struct SessionHandle *data = conn->data; + CURLcode result; + ssize_t nread; /* number of bytes read */ + int didwhat=0; + + /* These two are used only if no other select() or _fdset() have been + invoked before this. This typicly happens if you use the multi interface + and call curl_multi_perform() without calling curl_multi_fdset() + first. */ + fd_set extrareadfd; + fd_set extrawritefd; + + fd_set *readfdp = k->readfdp; + fd_set *writefdp = k->writefdp; + curl_off_t contentlength; + + if((k->keepon & KEEP_READ) && !readfdp) { + /* reading is requested, but no socket descriptor pointer was set */ + FD_ZERO(&extrareadfd); + FD_SET(conn->sockfd, &extrareadfd); + readfdp = &extrareadfd; + + /* no write, no exceptions, no timeout */ + select(conn->sockfd+1, readfdp, NULL, NULL, ¬imeout); + } + if((k->keepon & KEEP_WRITE) && !writefdp) { + /* writing is requested, but no socket descriptor pointer was set */ + FD_ZERO(&extrawritefd); + FD_SET(conn->writesockfd, &extrawritefd); + writefdp = &extrawritefd; + + /* no read, no exceptions, no timeout */ + select(conn->writesockfd+1, NULL, writefdp, NULL, ¬imeout); + } + + do { + /* If we still have reading to do, we check if we have a readable + socket. Sometimes the reafdp is NULL, if no fd_set was done using + the multi interface and then we can do nothing but to attempt a + read to be sure. */ + if((k->keepon & KEEP_READ) && + (!readfdp || FD_ISSET(conn->sockfd, readfdp))) { + + bool readdone = TRUE; + + /* This is where we loop until we have read everything there is to + read or we get a EWOULDBLOCK */ + do { + size_t buffersize = data->set.buffer_size? + data->set.buffer_size:BUFSIZE -1; + + /* receive data from the network! */ + int readrc = Curl_read(conn, conn->sockfd, k->buf, buffersize, &nread); + + /* subzero, this would've blocked */ + if(0>readrc) + break; /* get out of loop */ + + /* get the CURLcode from the int */ + result = (CURLcode)readrc; + + if(result>0) + return result; + + if ((k->bytecount == 0) && (k->writebytecount == 0)) { + Curl_pgrsTime(data, TIMER_STARTTRANSFER); + if(k->wait100_after_headers) + /* set time stamp to compare with when waiting for the 100 */ + k->start100 = Curl_tvnow(); + } + + didwhat |= KEEP_READ; + + /* NULL terminate, allowing string ops to be used */ + if (0 < nread) + k->buf[nread] = 0; + + /* if we receive 0 or less here, the server closed the connection and + we bail out from this! */ + else if (0 >= nread) { + k->keepon &= ~KEEP_READ; + FD_ZERO(&k->rkeepfd); + readdone = TRUE; + break; + } + + /* Default buffer to use when we write the buffer, it may be changed + in the flow below before the actual storing is done. */ + k->str = k->buf; + + /* Since this is a two-state thing, we check if we are parsing + headers at the moment or not. */ + if (k->header) { + /* we are in parse-the-header-mode */ + bool stop_reading = FALSE; + + /* header line within buffer loop */ + do { + size_t hbufp_index; + size_t rest_length; + size_t full_length; + int writetype; + + /* str_start is start of line within buf */ + k->str_start = k->str; + + k->end_ptr = strchr (k->str_start, '\n'); + + if (!k->end_ptr) { + /* Not a complete header line within buffer, append the data to + the end of the headerbuff. */ + + if (k->hbuflen + nread >= data->state.headersize) { + /* We enlarge the header buffer as it is too small */ + char *newbuff; + size_t newsize=CURLMAX((k->hbuflen+nread)*3/2, + data->state.headersize*2); + hbufp_index = k->hbufp - data->state.headerbuff; + newbuff = (char *)realloc(data->state.headerbuff, newsize); + if(!newbuff) { + failf (data, "Failed to alloc memory for big header!"); + return CURLE_OUT_OF_MEMORY; + } + data->state.headersize=newsize; + data->state.headerbuff = newbuff; + k->hbufp = data->state.headerbuff + hbufp_index; + } + memcpy(k->hbufp, k->str, nread); + k->hbufp += nread; + k->hbuflen += nread; + if (!k->headerline && (k->hbuflen>5)) { + /* make a first check that this looks like a HTTP header */ + if(!checkhttpprefix(data, data->state.headerbuff)) { + /* this is not the beginning of a HTTP first header line */ + k->header = FALSE; + k->badheader = HEADER_ALLBAD; + break; + } + } + + break; /* read more and try again */ + } + + /* decrease the size of the remaining (supposed) header line */ + rest_length = (k->end_ptr - k->str)+1; + nread -= rest_length; + + k->str = k->end_ptr + 1; /* move past new line */ + + full_length = k->str - k->str_start; + + /* + * We're about to copy a chunk of data to the end of the + * already received header. We make sure that the full string + * fit in the allocated header buffer, or else we enlarge + * it. + */ + if (k->hbuflen + full_length >= + data->state.headersize) { + char *newbuff; + size_t newsize=CURLMAX((k->hbuflen+full_length)*3/2, + data->state.headersize*2); + hbufp_index = k->hbufp - data->state.headerbuff; + newbuff = (char *)realloc(data->state.headerbuff, newsize); + if(!newbuff) { + failf (data, "Failed to alloc memory for big header!"); + return CURLE_OUT_OF_MEMORY; + } + data->state.headersize= newsize; + data->state.headerbuff = newbuff; + k->hbufp = data->state.headerbuff + hbufp_index; + } + + /* copy to end of line */ + strncpy (k->hbufp, k->str_start, full_length); + k->hbufp += full_length; + k->hbuflen += full_length; + *k->hbufp = 0; + k->end_ptr = k->hbufp; + + k->p = data->state.headerbuff; + + /**** + * We now have a FULL header line that p points to + *****/ + + if(!k->headerline) { + /* the first read header */ + if((k->hbuflen>5) && + !checkhttpprefix(data, data->state.headerbuff)) { + /* this is not the beginning of a HTTP first header line */ + k->header = FALSE; + if(nread) + /* since there's more, this is a partial bad header */ + k->badheader = HEADER_PARTHEADER; + else { + /* this was all we read so its all a bad header */ + k->badheader = HEADER_ALLBAD; + nread = (ssize_t)rest_length; + } + break; + } + } + + if (('\n' == *k->p) || ('\r' == *k->p)) { + size_t headerlen; + /* Zero-length header line means end of headers! */ + + if ('\r' == *k->p) + k->p++; /* pass the \r byte */ + if ('\n' == *k->p) + k->p++; /* pass the \n byte */ + + if(100 == k->httpcode) { + /* + * We have made a HTTP PUT or POST and this is 1.1-lingo + * that tells us that the server is OK with this and ready + * to receive the data. + * However, we'll get more headers now so we must get + * back into the header-parsing state! + */ + k->header = TRUE; + k->headerline = 0; /* restart the header line counter */ + /* if we did wait for this do enable write now! */ + if (k->write_after_100_header) { + + k->write_after_100_header = FALSE; + FD_SET (conn->writesockfd, &k->writefd); /* write */ + k->keepon |= KEEP_WRITE; + k->wkeepfd = k->writefd; + } + } + else + k->header = FALSE; /* no more header to parse! */ + + if (417 == k->httpcode) { + /* + * we got: "417 Expectation Failed" this means: + * we have made a HTTP call and our Expect Header + * seems to cause a problem => abort the write operations + * (or prevent them from starting). + */ + k->write_after_100_header = FALSE; + k->keepon &= ~KEEP_WRITE; + FD_ZERO(&k->wkeepfd); + } + +#ifndef CURL_DISABLE_HTTP + /* + * When all the headers have been parsed, see if we should give + * up and return an error. + */ + if (Curl_http_should_fail(conn)) { + failf (data, "The requested URL returned error: %d", + k->httpcode); + return CURLE_HTTP_RETURNED_ERROR; + } +#endif /* CURL_DISABLE_HTTP */ + + /* now, only output this if the header AND body are requested: + */ + writetype = CLIENTWRITE_HEADER; + if (data->set.include_header) + writetype |= CLIENTWRITE_BODY; + + headerlen = k->p - data->state.headerbuff; + + result = Curl_client_write(data, writetype, + data->state.headerbuff, + headerlen); + if(result) + return result; + + data->info.header_size += headerlen; + conn->headerbytecount += headerlen; + + conn->deductheadercount = + (100 == k->httpcode)?conn->headerbytecount:0; + + if (conn->resume_from && + !k->content_range && + (data->set.httpreq==HTTPREQ_GET)) { + if(k->httpcode == 416) { + /* "Requested Range Not Satisfiable" */ + stop_reading = TRUE; + } + else { + /* we wanted to resume a download, although the server + * doesn't seem to support this and we did this with a GET + * (if it wasn't a GET we did a POST or PUT resume) */ + failf (data, "HTTP server doesn't seem to support " + "byte ranges. Cannot resume."); + return CURLE_HTTP_RANGE_ERROR; + } + } +#ifndef CURL_DISABLE_HTTP + if(!stop_reading) { + /* Curl_http_auth_act() checks what authentication methods + * that are available and decides which one (if any) to + * use. It will set 'newurl' if an auth metod was picked. */ + result = Curl_http_auth_act(conn); + + if(result) + return result; + } +#endif /* CURL_DISABLE_HTTP */ + + if(!k->header) { + /* + * really end-of-headers. + * + * If we requested a "no body", this is a good time to get + * out and return home. + */ + if(conn->bits.no_body) + stop_reading = TRUE; + else { + /* If we know the expected size of this document, we set the + maximum download size to the size of the expected + document or else, we won't know when to stop reading! + + Note that we set the download maximum even if we read a + "Connection: close" header, to make sure that + "Content-Length: 0" still prevents us from attempting to + read the (missing) response-body. + */ + /* According to RFC2616 section 4.4, we MUST ignore + Content-Length: headers if we are now receiving data + using chunked Transfer-Encoding. + */ + if(conn->bits.chunk) + conn->size=-1; + + } + if(-1 != conn->size) { + /* We do this operation even if no_body is true, since this + data might be retrieved later with curl_easy_getinfo() + and its CURLINFO_CONTENT_LENGTH_DOWNLOAD option. */ + + Curl_pgrsSetDownloadSize(data, conn->size); + conn->maxdownload = conn->size; + } + /* If max download size is *zero* (nothing) we already + have nothing and can safely return ok now! */ + if(0 == conn->maxdownload) + stop_reading = TRUE; + + if(stop_reading) { + /* we make sure that this socket isn't read more now */ + k->keepon &= ~KEEP_READ; + FD_ZERO(&k->rkeepfd); + } + + break; /* exit header line loop */ + } + + /* We continue reading headers, so reset the line-based + header parsing variables hbufp && hbuflen */ + k->hbufp = data->state.headerbuff; + k->hbuflen = 0; + continue; + } + + /* + * Checks for special headers coming up. + */ + + if (!k->headerline++) { + /* This is the first header, it MUST be the error code line + or else we consiser this to be the body right away! */ + int httpversion_major; + int nc=sscanf(k->p, " HTTP/%d.%d %3d", + &httpversion_major, + &k->httpversion, + &k->httpcode); + if (nc==3) { + k->httpversion += 10 * httpversion_major; + } + else { + /* this is the real world, not a Nirvana + NCSA 1.5.x returns this crap when asked for HTTP/1.1 + */ + nc=sscanf(k->p, " HTTP %3d", &k->httpcode); + k->httpversion = 10; + + /* If user has set option HTTP200ALIASES, + compare header line against list of aliases + */ + if (!nc) { + if (checkhttpprefix(data, k->p)) { + nc = 1; + k->httpcode = 200; + k->httpversion = + (data->set.httpversion==CURL_HTTP_VERSION_1_0)? 10 : 11; + } + } + } + + if (nc) { + data->info.httpcode = k->httpcode; + data->info.httpversion = k->httpversion; + + /* + * This code executes as part of processing the header. As a + * result, it's not totally clear how to interpret the + * response code yet as that depends on what other headers may + * be present. 401 and 407 may be errors, but may be OK + * depending on how authentication is working. Other codes + * are definitely errors, so give up here. + */ + if (data->set.http_fail_on_error && + (k->httpcode >= 400) && + (k->httpcode != 401) && + (k->httpcode != 407)) { + /* serious error, go home! */ + failf (data, "The requested URL returned error: %d", + k->httpcode); + return CURLE_HTTP_RETURNED_ERROR; + } + + if(k->httpversion == 10) + /* Default action for HTTP/1.0 must be to close, unless + we get one of those fancy headers that tell us the + server keeps it open for us! */ + conn->bits.close = TRUE; + + switch(k->httpcode) { + case 204: + /* (quote from RFC2616, section 10.2.5): The server has + * fulfilled the request but does not need to return an + * entity-body ... The 204 response MUST NOT include a + * message-body, and thus is always terminated by the first + * empty line after the header fields. */ + /* FALLTHROUGH */ + case 416: /* Requested Range Not Satisfiable, it has the + Content-Length: set as the "real" document but no + actual response is sent. */ + case 304: + /* (quote from RFC2616, section 10.3.5): The 304 response + * MUST NOT contain a message-body, and thus is always + * terminated by the first empty line after the header + * fields. */ + conn->size=0; + conn->maxdownload=0; + break; + default: + /* nothing */ + break; + } + } + else { + k->header = FALSE; /* this is not a header line */ + break; + } + } + + /* Check for Content-Length: header lines to get size. Ignore + the header completely if we get a 416 response as then we're + resuming a document that we don't get, and this header contains + info about the true size of the document we didn't get now. */ + if ((k->httpcode != 416) && + checkprefix("Content-Length:", k->p)) { + contentlength = curlx_strtoofft(k->p+15, NULL, 10); + if (data->set.max_filesize && + contentlength > data->set.max_filesize) { + failf(data, "Maximum file size exceeded"); + return CURLE_FILESIZE_EXCEEDED; + } + if(contentlength >= 0) + conn->size = contentlength; + else { + /* Negative Content-Length is really odd, and we know it + happens for example when older Apache servers send large + files */ + conn->bits.close = TRUE; + infof(data, "Negative content-length: %" FORMAT_OFF_T + ", closing after transfer\n", contentlength); + } + } + /* check for Content-Type: header lines to get the mime-type */ + else if (checkprefix("Content-Type:", k->p)) { + char *start; + char *end; + size_t len; + + /* Find the first non-space letter */ + for(start=k->p+13; + *start && isspace((int)*start); + start++); + + end = strchr(start, '\r'); + if(!end) + end = strchr(start, '\n'); + + if(end) { + /* skip all trailing space letters */ + for(; isspace((int)*end) && (end > start); end--); + + /* get length of the type */ + len = end-start+1; + + /* allocate memory of a cloned copy */ + Curl_safefree(data->info.contenttype); + + data->info.contenttype = malloc(len + 1); + if (NULL == data->info.contenttype) + return CURLE_OUT_OF_MEMORY; + + /* copy the content-type string */ + memcpy(data->info.contenttype, start, len); + data->info.contenttype[len] = 0; /* zero terminate */ + } + } +#ifndef CURL_DISABLE_HTTP + else if((k->httpversion == 10) && + conn->bits.httpproxy && + Curl_compareheader(k->p, + "Proxy-Connection:", "keep-alive")) { + /* + * When a HTTP/1.0 reply comes when using a proxy, the + * 'Proxy-Connection: keep-alive' line tells us the + * connection will be kept alive for our pleasure. + * Default action for 1.0 is to close. + */ + conn->bits.close = FALSE; /* don't close when done */ + infof(data, "HTTP/1.0 proxy connection set to keep alive!\n"); + } + else if((k->httpversion == 10) && + Curl_compareheader(k->p, "Connection:", "keep-alive")) { + /* + * A HTTP/1.0 reply with the 'Connection: keep-alive' line + * tells us the connection will be kept alive for our + * pleasure. Default action for 1.0 is to close. + * + * [RFC2068, section 19.7.1] */ + conn->bits.close = FALSE; /* don't close when done */ + infof(data, "HTTP/1.0 connection set to keep alive!\n"); + } + else if (Curl_compareheader(k->p, "Connection:", "close")) { + /* + * [RFC 2616, section 8.1.2.1] + * "Connection: close" is HTTP/1.1 language and means that + * the connection will close when this request has been + * served. + */ + conn->bits.close = TRUE; /* close when done */ + } + else if (Curl_compareheader(k->p, + "Transfer-Encoding:", "chunked")) { + /* + * [RFC 2616, section 3.6.1] A 'chunked' transfer encoding + * means that the server will send a series of "chunks". Each + * chunk starts with line with info (including size of the + * coming block) (terminated with CRLF), then a block of data + * with the previously mentioned size. There can be any amount + * of chunks, and a chunk-data set to zero signals the + * end-of-chunks. */ + conn->bits.chunk = TRUE; /* chunks coming our way */ + + /* init our chunky engine */ + Curl_httpchunk_init(conn); + } + else if (checkprefix("Content-Encoding:", k->p) && + data->set.encoding) { + /* + * Process Content-Encoding. Look for the values: identity, + * gzip, deflate, compress, x-gzip and x-compress. x-gzip and + * x-compress are the same as gzip and compress. (Sec 3.5 RFC + * 2616). zlib cannot handle compress. However, errors are + * handled further down when the response body is processed + */ + char *start; + + /* Find the first non-space letter */ + for(start=k->p+17; + *start && isspace((int)*start); + start++); + + /* Record the content-encoding for later use */ + if (checkprefix("identity", start)) + k->content_encoding = IDENTITY; + else if (checkprefix("deflate", start)) + k->content_encoding = DEFLATE; + else if (checkprefix("gzip", start) + || checkprefix("x-gzip", start)) + k->content_encoding = GZIP; + else if (checkprefix("compress", start) + || checkprefix("x-compress", start)) + k->content_encoding = COMPRESS; + } + else if (Curl_compareheader(k->p, "Content-Range:", "bytes")) { + /* Content-Range: bytes [num]- + Content-Range: bytes: [num]- + + The second format was added August 1st 2000 by Igor + Khristophorov since Sun's webserver JavaWebServer/1.1.1 + obviously sends the header this way! :-( */ + + char *ptr = strstr(k->p, "bytes"); + ptr+=5; + + if(*ptr == ':') + /* stupid colon skip */ + ptr++; + + k->offset = curlx_strtoofft(ptr, NULL, 10); + + if (conn->resume_from == k->offset) + /* we asked for a resume and we got it */ + k->content_range = TRUE; + } + else if(data->cookies && + checkprefix("Set-Cookie:", k->p)) { + Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, + CURL_LOCK_ACCESS_SINGLE); + Curl_cookie_add(data, + data->cookies, TRUE, k->p+11, + /* If there is a custom-set Host: name, use it + here, or else use real peer host name. */ + conn->allocptr.cookiehost? + conn->allocptr.cookiehost:conn->host.name, + conn->path); + Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE); + } + else if(checkprefix("Last-Modified:", k->p) && + (data->set.timecondition || data->set.get_filetime) ) { + time_t secs=time(NULL); + k->timeofdoc = curl_getdate(k->p+strlen("Last-Modified:"), + &secs); + if(data->set.get_filetime) + data->info.filetime = k->timeofdoc; + } + else if((checkprefix("WWW-Authenticate:", k->p) && + (401 == k->httpcode)) || + (checkprefix("Proxy-authenticate:", k->p) && + (407 == k->httpcode))) { + result = Curl_http_input_auth(conn, k->httpcode, k->p); + if(result) + return result; + } + else if ((k->httpcode >= 300 && k->httpcode < 400) && + checkprefix("Location:", k->p)) { + if(data->set.http_follow_location) { + /* this is the URL that the server advices us to get instead */ + char *ptr; + char *start=k->p; + char backup; + + start += 9; /* pass "Location:" */ + + /* Skip spaces and tabs. We do this to support multiple + white spaces after the "Location:" keyword. */ + while(*start && isspace((int)*start )) + start++; + + /* Scan through the string from the end to find the last + non-space. k->end_ptr points to the actual terminating zero + letter, move pointer one letter back and start from + there. This logic strips off trailing whitespace, but keeps + any embedded whitespace. */ + ptr = k->end_ptr-1; + while((ptr>=start) && isspace((int)*ptr)) + ptr--; + ptr++; + + backup = *ptr; /* store the ending letter */ + if(ptr != start) { + *ptr = '\0'; /* zero terminate */ + conn->newurl = strdup(start); /* clone string */ + *ptr = backup; /* restore ending letter */ + if(!conn->newurl) + return CURLE_OUT_OF_MEMORY; + } + } + } +#endif /* CURL_DISABLE_HTTP */ + + /* + * End of header-checks. Write them to the client. + */ + + writetype = CLIENTWRITE_HEADER; + if (data->set.include_header) + writetype |= CLIENTWRITE_BODY; + + if(data->set.verbose) + Curl_debug(data, CURLINFO_HEADER_IN, + k->p, k->hbuflen, conn->host.dispname); + + result = Curl_client_write(data, writetype, k->p, k->hbuflen); + if(result) + return result; + + data->info.header_size += k->hbuflen; + conn->headerbytecount += k->hbuflen; + + /* reset hbufp pointer && hbuflen */ + k->hbufp = data->state.headerbuff; + k->hbuflen = 0; + } + while (!stop_reading && *k->str); /* header line within buffer */ + + if(stop_reading) + /* We've stopped dealing with input, get out of the do-while loop */ + break; + + /* We might have reached the end of the header part here, but + there might be a non-header part left in the end of the read + buffer. */ + + } /* end if header mode */ + + /* This is not an 'else if' since it may be a rest from the header + parsing, where the beginning of the buffer is headers and the end + is non-headers. */ + if (k->str && !k->header && (nread > 0)) { + + if(0 == k->bodywrites) { + /* These checks are only made the first time we are about to + write a piece of the body */ + if(conn->protocol&PROT_HTTP) { + /* HTTP-only checks */ + + if (conn->newurl) { + if(conn->bits.close) { + /* Abort after the headers if "follow Location" is set + and we're set to close anyway. */ + k->keepon &= ~KEEP_READ; + FD_ZERO(&k->rkeepfd); + *done = TRUE; + return CURLE_OK; + } + /* We have a new url to load, but since we want to be able + to re-use this connection properly, we read the full + response in "ignore more" */ + k->ignorebody = TRUE; + infof(data, "Ignoring the response-body\n"); + } + if(data->set.timecondition && !conn->range) { + /* A time condition has been set AND no ranges have been + requested. This seems to be what chapter 13.3.4 of + RFC 2616 defines to be the correct action for a + HTTP/1.1 client */ + if((k->timeofdoc > 0) && (data->set.timevalue > 0)) { + switch(data->set.timecondition) { + case CURL_TIMECOND_IFMODSINCE: + default: + if(k->timeofdoc < data->set.timevalue) { + infof(data, + "The requested document is not new enough\n"); + *done = TRUE; + return CURLE_OK; + } + break; + case CURL_TIMECOND_IFUNMODSINCE: + if(k->timeofdoc > data->set.timevalue) { + infof(data, + "The requested document is not old enough\n"); + *done = TRUE; + return CURLE_OK; + } + break; + } /* switch */ + } /* two valid time strings */ + } /* we have a time condition */ + + } /* this is HTTP */ + } /* this is the first time we write a body part */ + k->bodywrites++; + + /* pass data to the debug function before it gets "dechunked" */ + if(data->set.verbose) { + if(k->badheader) { + Curl_debug(data, CURLINFO_DATA_IN, data->state.headerbuff, + k->hbuflen, conn->host.dispname); + if(k->badheader == HEADER_PARTHEADER) + Curl_debug(data, CURLINFO_DATA_IN, k->str, nread, + conn->host.dispname); + } + else + Curl_debug(data, CURLINFO_DATA_IN, k->str, nread, + conn->host.dispname); + } + +#ifndef CURL_DISABLE_HTTP + if(conn->bits.chunk) { + /* + * Bless me father for I have sinned. Here comes a chunked + * transfer flying and we need to decode this properly. While + * the name says read, this function both reads and writes away + * the data. The returned 'nread' holds the number of actual + * data it wrote to the client. */ + CHUNKcode res = + Curl_httpchunk_read(conn, k->str, nread, &nread); + + if(CHUNKE_OK < res) { + if(CHUNKE_WRITE_ERROR == res) { + failf(data, "Failed writing data"); + return CURLE_WRITE_ERROR; + } + failf(data, "Received problem %d in the chunky parser", res); + return CURLE_RECV_ERROR; + } + else if(CHUNKE_STOP == res) { + /* we're done reading chunks! */ + k->keepon &= ~KEEP_READ; /* read no more */ + FD_ZERO(&k->rkeepfd); + + /* There are now possibly N number of bytes at the end of the + str buffer that weren't written to the client, but we don't + care about them right now. */ + } + /* If it returned OK, we just keep going */ + } +#endif /* CURL_DISABLE_HTTP */ + + if((-1 != conn->maxdownload) && + (k->bytecount + nread >= conn->maxdownload)) { + nread = (ssize_t) (conn->maxdownload - k->bytecount); + if(nread < 0 ) /* this should be unusual */ + nread = 0; + + k->keepon &= ~KEEP_READ; /* we're done reading */ + FD_ZERO(&k->rkeepfd); + } + + k->bytecount += nread; + + Curl_pgrsSetDownloadCounter(data, k->bytecount); + + if(!conn->bits.chunk && (nread || k->badheader)) { + /* If this is chunky transfer, it was already written */ + + if(k->badheader && !k->ignorebody) { + /* we parsed a piece of data wrongly assuming it was a header + and now we output it as body instead */ + result = Curl_client_write(data, CLIENTWRITE_BODY, + data->state.headerbuff, + k->hbuflen); + } + if(k->badheader < HEADER_ALLBAD) { + /* This switch handles various content encodings. If there's an + error here, be sure to check over the almost identical code + in http_chunks.c. + Make sure that ALL_CONTENT_ENCODINGS contains all the + encodings handled here. */ +#ifdef HAVE_LIBZ + switch (k->content_encoding) { + case IDENTITY: +#endif + /* This is the default when the server sends no + Content-Encoding header. See Curl_readwrite_init; the + memset() call initializes k->content_encoding to zero. */ + if(!k->ignorebody) + result = Curl_client_write(data, CLIENTWRITE_BODY, k->str, + nread); +#ifdef HAVE_LIBZ + break; + + case DEFLATE: + /* Assume CLIENTWRITE_BODY; headers are not encoded. */ + result = Curl_unencode_deflate_write(data, k, nread); + break; + + case GZIP: + /* Assume CLIENTWRITE_BODY; headers are not encoded. */ + result = Curl_unencode_gzip_write(data, k, nread); + break; + + case COMPRESS: + default: + failf (data, "Unrecognized content encoding type. " + "libcurl understands `identity', `deflate' and `gzip' " + "content encodings."); + result = CURLE_BAD_CONTENT_ENCODING; + break; + } +#endif + } + k->badheader = HEADER_NORMAL; /* taken care of now */ + + if(result) + return result; + } + + } /* if (! header and data to read ) */ + + } while(!readdone); + + } /* if( read from socket ) */ + + /* If we still have writing to do, we check if we have a writable + socket. Sometimes the writefdp is NULL, if no fd_set was done using + the multi interface and then we can do nothing but to attempt a + write to be sure. */ + if((k->keepon & KEEP_WRITE) && + (!writefdp || FD_ISSET(conn->writesockfd, writefdp)) ) { + /* write */ + + int i, si; + ssize_t bytes_written; + bool writedone=TRUE; + + if ((k->bytecount == 0) && (k->writebytecount == 0)) + Curl_pgrsTime(data, TIMER_STARTTRANSFER); + + didwhat |= KEEP_WRITE; + + /* + * We loop here to do the READ and SEND loop until we run out of + * data to send or until we get EWOULDBLOCK back + */ + do { + + /* only read more data if there's no upload data already + present in the upload buffer */ + if(0 == conn->upload_present) { + /* init the "upload from here" pointer */ + conn->upload_fromhere = k->uploadbuf; + + if(!k->upload_done) { + /* HTTP pollution, this should be written nicer to become more + protocol agnostic. */ + int fillcount; + + if(k->wait100_after_headers && + (conn->proto.http->sending == HTTPSEND_BODY)) { + /* If this call is to send body data, we must take some action: + We have sent off the full HTTP 1.1 request, and we shall now + go into the Expect: 100 state and await such a header */ + k->wait100_after_headers = FALSE; /* headers sent */ + k->write_after_100_header = TRUE; /* wait for the header */ + FD_ZERO (&k->writefd); /* clear it */ + k->wkeepfd = k->writefd; /* set the keeper variable */ + k->keepon &= ~KEEP_WRITE; /* disable writing */ + k->start100 = Curl_tvnow(); /* timeout count starts now */ + didwhat &= ~KEEP_WRITE; /* we didn't write anything actually */ + break; + } + + result = Curl_fillreadbuffer(conn, BUFSIZE, &fillcount); + if(result) + return result; + + nread = (ssize_t)fillcount; + } + else + nread = 0; /* we're done uploading/reading */ + + /* the signed int typecase of nread of for systems that has + unsigned size_t */ + if (nread<=0) { + /* done */ + k->keepon &= ~KEEP_WRITE; /* we're done writing */ + FD_ZERO(&k->wkeepfd); + writedone = TRUE; + (void)writedone; + break; + } + + /* store number of bytes available for upload */ + conn->upload_present = nread; + + /* convert LF to CRLF if so asked */ + if (data->set.crlf) { + if(data->state.scratch == NULL) + data->state.scratch = malloc(2*BUFSIZE); + if(data->state.scratch == NULL) { + failf (data, "Failed to alloc scratch buffer!"); + return CURLE_OUT_OF_MEMORY; + } + for(i = 0, si = 0; i < nread; i++, si++) { + if (conn->upload_fromhere[i] == 0x0a) { + data->state.scratch[si++] = 0x0d; + data->state.scratch[si] = 0x0a; + } + else + data->state.scratch[si] = conn->upload_fromhere[i]; + } + if(si != nread) { + /* only perform the special operation if we really did replace + anything */ + nread = si; + + /* upload from the new (replaced) buffer instead */ + conn->upload_fromhere = data->state.scratch; + + /* set the new amount too */ + conn->upload_present = nread; + } + } + } + else { + /* We have a partial buffer left from a previous "round". Use + that instead of reading more data */ + } + + /* write to socket (send away data) */ + result = Curl_write(conn, + conn->writesockfd, /* socket to send to */ + conn->upload_fromhere, /* buffer pointer */ + conn->upload_present, /* buffer size */ + &bytes_written); /* actually send away */ + if(result) + return result; + + if(data->set.verbose) + /* show the data before we change the pointer upload_fromhere */ + Curl_debug(data, CURLINFO_DATA_OUT, conn->upload_fromhere, + bytes_written, conn->host.dispname); + + if(conn->upload_present != bytes_written) { + /* we only wrote a part of the buffer (if anything), deal with it! */ + + /* store the amount of bytes left in the buffer to write */ + conn->upload_present -= bytes_written; + + /* advance the pointer where to find the buffer when the next send + is to happen */ + conn->upload_fromhere += bytes_written; + + writedone = TRUE; /* we are done, stop the loop */ + } + else { + /* we've uploaded that buffer now */ + conn->upload_fromhere = k->uploadbuf; + conn->upload_present = 0; /* no more bytes left */ + + if(k->upload_done) { + /* switch off writing, we're done! */ + k->keepon &= ~KEEP_WRITE; /* we're done writing */ + FD_ZERO(&k->wkeepfd); + writedone = TRUE; + } + } + + k->writebytecount += bytes_written; + Curl_pgrsSetUploadCounter(data, k->writebytecount); + + } while(!writedone); /* loop until we're done writing! */ + + } + + } while(0); /* just to break out from! */ + + k->now = Curl_tvnow(); + if(didwhat) { + /* Update read/write counters */ + if(conn->bytecountp) + *conn->bytecountp = k->bytecount; /* read count */ + if(conn->writebytecountp) + *conn->writebytecountp = k->writebytecount; /* write count */ + } + else { + /* no read no write, this is a timeout? */ + if (k->write_after_100_header) { + /* This should allow some time for the header to arrive, but only a + very short time as otherwise it'll be too much wasted times too + often. */ + + /* Quoting RFC2616, section "8.2.3 Use of the 100 (Continue) Status": + + Therefore, when a client sends this header field to an origin server + (possibly via a proxy) from which it has never seen a 100 (Continue) + status, the client SHOULD NOT wait for an indefinite period before + sending the request body. + + */ + + long ms = Curl_tvdiff(k->now, k->start100); + if(ms > CURL_TIMEOUT_EXPECT_100) { + /* we've waited long enough, continue anyway */ + k->write_after_100_header = FALSE; + FD_SET (conn->writesockfd, &k->writefd); /* write socket */ + k->keepon |= KEEP_WRITE; + k->wkeepfd = k->writefd; + } + } + } + + if(Curl_pgrsUpdate(conn)) + result = CURLE_ABORTED_BY_CALLBACK; + else + result = Curl_speedcheck(data, k->now); + if (result) + return result; + + if (data->set.timeout && + ((Curl_tvdiff(k->now, k->start)/1000) >= data->set.timeout)) { + failf(data, "Operation timed out with %" FORMAT_OFF_T + " out of %" FORMAT_OFF_T " bytes received", + k->bytecount, conn->size); + return CURLE_OPERATION_TIMEOUTED; + } + + if(!k->keepon) { + /* + * The transfer has been performed. Just make some general checks before + * returning. + */ + + if(!(conn->bits.no_body) && (conn->size != -1) && + (k->bytecount != conn->size) && + !conn->newurl) { + failf(data, "transfer closed with %" FORMAT_OFF_T + " bytes remaining to read", + conn->size - k->bytecount); + return CURLE_PARTIAL_FILE; + } + else if(conn->bits.chunk && conn->proto.http->chunk.datasize) { + failf(data, "transfer closed with at least %d bytes remaining", + conn->proto.http->chunk.datasize); + return CURLE_PARTIAL_FILE; + } + if(Curl_pgrsUpdate(conn)) + return CURLE_ABORTED_BY_CALLBACK; + } + + /* Now update the "done" boolean we return */ + *done = !k->keepon; + + return CURLE_OK; +} + + +/* + * Curl_readwrite_init() inits the readwrite session. + */ + +CURLcode Curl_readwrite_init(struct connectdata *conn) +{ + struct SessionHandle *data; + struct Curl_transfer_keeper *k = &conn->keep; + + /* NB: the content encoding software depends on this initialization of + Curl_transfer_keeper. */ + memset(k, 0, sizeof(struct Curl_transfer_keeper)); + + k->start = Curl_tvnow(); /* start time */ + k->now = k->start; /* current time is now */ + k->header = TRUE; /* assume header */ + k->httpversion = -1; /* unknown at this point */ + + data = conn->data; /* there's the root struct */ + k->buf = data->state.buffer; + k->uploadbuf = data->state.uploadbuffer; + k->maxfd = (conn->sockfd>conn->writesockfd? + conn->sockfd:conn->writesockfd)+1; + k->hbufp = data->state.headerbuff; + k->ignorebody=FALSE; + + Curl_pgrsTime(data, TIMER_PRETRANSFER); + Curl_speedinit(data); + + Curl_pgrsSetUploadCounter(data, 0); + Curl_pgrsSetDownloadCounter(data, 0); + + if (!conn->bits.getheader) { + k->header = FALSE; + if(conn->size > 0) + Curl_pgrsSetDownloadSize(data, conn->size); + } + /* we want header and/or body, if neither then don't do this! */ + if(conn->bits.getheader || !conn->bits.no_body) { + + FD_ZERO (&k->readfd); /* clear it */ + if(conn->sockfd != CURL_SOCKET_BAD) { + FD_SET (conn->sockfd, &k->readfd); /* read socket */ + k->keepon |= KEEP_READ; + } + + FD_ZERO (&k->writefd); /* clear it */ + if(conn->writesockfd != CURL_SOCKET_BAD) { + /* HTTP 1.1 magic: + + Even if we require a 100-return code before uploading data, we might + need to write data before that since the REQUEST may not have been + finished sent off just yet. + + Thus, we must check if the request has been sent before we set the + state info where we wait for the 100-return code + */ + if (data->set.expect100header && + (conn->proto.http->sending == HTTPSEND_BODY)) { + /* wait with write until we either got 100-continue or a timeout */ + k->write_after_100_header = TRUE; + k->start100 = k->start; + } + else { + if(data->set.expect100header) + /* when we've sent off the rest of the headers, we must await a + 100-continue */ + k->wait100_after_headers = TRUE; + FD_SET (conn->writesockfd, &k->writefd); /* write socket */ + k->keepon |= KEEP_WRITE; + } + } + + /* get these in backup variables to be able to restore them on each lap in + the select() loop */ + k->rkeepfd = k->readfd; + k->wkeepfd = k->writefd; + + } + + return CURLE_OK; +} + +/* + * Curl_single_fdset() gets called by the multi interface code when the app + * has requested to get the fd_sets for the current connection. This function + * will then be called once for every connection that the multi interface + * keeps track of. This function will only be called for connections that are + * in the proper state to have this information available. + */ +void Curl_single_fdset(struct connectdata *conn, + fd_set *read_fd_set, + fd_set *write_fd_set, + fd_set *exc_fd_set, + int *max_fd) +{ + *max_fd = -1; /* init */ + if(conn->keep.keepon & KEEP_READ) { + FD_SET(conn->sockfd, read_fd_set); + *max_fd = conn->sockfd; + conn->keep.readfdp = read_fd_set; /* store the address of the set */ + } + if(conn->keep.keepon & KEEP_WRITE) { + FD_SET(conn->writesockfd, write_fd_set); + + /* since sockets are curl_socket_t nowadays, we typecast it to int here + to compare it nicely */ + if((int)conn->writesockfd > *max_fd) + *max_fd = conn->writesockfd; + conn->keep.writefdp = write_fd_set; /* store the address of the set */ + } + /* we don't use exceptions, only touch that one to prevent compiler + warnings! */ + *exc_fd_set = *exc_fd_set; +} + + +/* + * Transfer() + * + * This function is what performs the actual transfer. It is capable of + * doing both ways simultaneously. + * The transfer must already have been setup by a call to Curl_Transfer(). + * + * Note that headers are created in a preallocated buffer of a default size. + * That buffer can be enlarged on demand, but it is never shrunken again. + * + * Parts of this function was once written by the friendly Mark Butler + * . + */ + +static CURLcode +Transfer(struct connectdata *conn) +{ + CURLcode result; + struct Curl_transfer_keeper *k = &conn->keep; + bool done=FALSE; + + if(!(conn->protocol & PROT_FILE)) + /* Only do this if we are not transferring FILE:, since the file: treatment + is different*/ + Curl_readwrite_init(conn); + + if((conn->sockfd == CURL_SOCKET_BAD) && + (conn->writesockfd == CURL_SOCKET_BAD)) + /* nothing to read, nothing to write, we're already OK! */ + return CURLE_OK; + + /* we want header and/or body, if neither then don't do this! */ + if(!conn->bits.getheader && conn->bits.no_body) + return CURLE_OK; + + k->writefdp = &k->writefd; /* store the address of the set */ + k->readfdp = &k->readfd; /* store the address of the set */ + + while (!done) { + struct timeval interval; + k->readfd = k->rkeepfd; /* set these every lap in the loop */ + k->writefd = k->wkeepfd; + interval.tv_sec = 1; + interval.tv_usec = 0; + + switch (select (k->maxfd, k->readfdp, k->writefdp, NULL, &interval)) { + case -1: /* select() error, stop reading */ +#ifdef EINTR + /* The EINTR is not serious, and it seems you might get this more + ofen when using the lib in a multi-threaded environment! */ + if(errno == EINTR) + ; + else +#endif + done = TRUE; /* no more read or write */ + continue; + case 0: /* timeout */ + default: /* readable descriptors */ + result = Curl_readwrite(conn, &done); + break; + } + if(result) + return result; + + /* "done" signals to us if the transfer(s) are ready */ + } + + return CURLE_OK; +} + +/* + * Curl_pretransfer() is called immediately before a transfer starts. + */ +CURLcode Curl_pretransfer(struct SessionHandle *data) +{ + if(!data->change.url) + /* we can't do anything wihout URL */ + return CURLE_URL_MALFORMAT; + +#ifdef USE_SSLEAY + { + /* Init the SSL session ID cache here. We do it here since we want to do + it after the *_setopt() calls (that could change the size of the cache) + but before any transfer takes place. */ + CURLcode res = Curl_SSL_InitSessions(data, data->set.ssl.numsessions); + if(res) + return res; + } +#endif + + data->set.followlocation=0; /* reset the location-follow counter */ + data->state.this_is_a_follow = FALSE; /* reset this */ + data->state.errorbuf = FALSE; /* no error has occurred */ + + data->state.authproblem = FALSE; + data->state.authhost.want = data->set.httpauth; + data->state.authproxy.want = data->set.proxyauth; + +#ifndef CURL_DISABLE_HTTP + /* If there was a list of cookie files to read and we haven't done it before, + do it now! */ + if(data->change.cookielist) { + struct curl_slist *list = data->change.cookielist; + Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); + while(list) { + data->cookies = Curl_cookie_init(data, + list->data, + data->cookies, + data->set.cookiesession); + list = list->next; + } + Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE); + curl_slist_free_all(data->change.cookielist); /* clean up list */ + data->change.cookielist = NULL; /* don't do this again! */ + } +#endif /* CURL_DISABLE_HTTP */ + + + /* Allow data->set.use_port to set which port to use. This needs to be + * disabled for example when we follow Location: headers to URLs using + * different ports! */ + data->state.allow_port = TRUE; + +#if defined(HAVE_SIGNAL) && defined(SIGPIPE) && !defined(HAVE_MSG_NOSIGNAL) + /************************************************************* + * Tell signal handler to ignore SIGPIPE + *************************************************************/ + if(!data->set.no_signal) + data->state.prev_signal = signal(SIGPIPE, SIG_IGN); +#endif + + Curl_initinfo(data); /* reset session-specific information "variables" */ + Curl_pgrsStartNow(data); + + return CURLE_OK; +} + +/* + * Curl_posttransfer() is called immediately after a transfer ends + */ +CURLcode Curl_posttransfer(struct SessionHandle *data) +{ +#if defined(HAVE_SIGNAL) && defined(SIGPIPE) && !defined(HAVE_MSG_NOSIGNAL) + /* restore the signal handler for SIGPIPE before we get back */ + if(!data->set.no_signal) + signal(SIGPIPE, data->state.prev_signal); +#else + (void)data; /* unused parameter */ +#endif + + return CURLE_OK; +} + +/* + * strlen_url() returns the length of the given URL if the spaces within the + * URL were properly URL encoded. + */ +static int strlen_url(char *url) +{ + char *ptr; + int newlen=0; + bool left=TRUE; /* left side of the ? */ + + for(ptr=url; *ptr; ptr++) { + switch(*ptr) { + case '?': + left=FALSE; + default: + newlen++; + break; + case ' ': + if(left) + newlen+=3; + else + newlen++; + break; + } + } + return newlen; +} + +/* strcpy_url() copies a url to a output buffer and URL-encodes the spaces in + * the source URL accordingly. + */ +static void strcpy_url(char *output, char *url) +{ + /* we must add this with whitespace-replacing */ + bool left=TRUE; + char *iptr; + char *optr = output; + for(iptr = url; /* read from here */ + *iptr; /* until zero byte */ + iptr++) { + switch(*iptr) { + case '?': + left=FALSE; + default: + *optr++=*iptr; + break; + case ' ': + if(left) { + *optr++='%'; /* add a '%' */ + *optr++='2'; /* add a '2' */ + *optr++='0'; /* add a '0' */ + } + else + *optr++='+'; /* add a '+' here */ + break; + } + } + *optr=0; /* zero terminate output buffer */ + +} + +/* + * Curl_follow() handles the URL redirect magic. Pass in the 'newurl' string + * as given by the remote server and set up the new URL to request. + */ +CURLcode Curl_follow(struct SessionHandle *data, + char *newurl) /* this 'newurl' is the Location: string, + and it must be malloc()ed before passed + here */ +{ + /* Location: redirect */ + char prot[16]; /* URL protocol string storage */ + char letter; /* used for a silly sscanf */ + size_t newlen; + char *newest; + + if (data->set.maxredirs && + (data->set.followlocation >= data->set.maxredirs)) { + failf(data,"Maximum (%d) redirects followed", data->set.maxredirs); + return CURLE_TOO_MANY_REDIRECTS; + } + + /* mark the next request as a followed location: */ + data->state.this_is_a_follow = TRUE; + + data->set.followlocation++; /* count location-followers */ + + if(data->set.http_auto_referer) { + /* We are asked to automatically set the previous URL as the + referer when we get the next URL. We pick the ->url field, + which may or may not be 100% correct */ + + if(data->change.referer_alloc) + /* If we already have an allocated referer, free this first */ + free(data->change.referer); + + data->change.referer = strdup(data->change.url); + data->change.referer_alloc = TRUE; /* yes, free this later */ + } + + if(2 != sscanf(newurl, "%15[^?&/:]://%c", prot, &letter)) { + /*** + *DANG* this is an RFC 2068 violation. The URL is supposed + to be absolute and this doesn't seem to be that! + *** + Instead, we have to TRY to append this new path to the old URL + to the right of the host part. Oh crap, this is doomed to cause + problems in the future... + */ + char *protsep; + char *pathsep; + + char *useurl = newurl; + size_t urllen; + + /* we must make our own copy of the URL to play with, as it may + point to read-only data */ + char *url_clone=strdup(data->change.url); + + if(!url_clone) + return CURLE_OUT_OF_MEMORY; /* skip out of this NOW */ + + /* protsep points to the start of the host name */ + protsep=strstr(url_clone, "//"); + if(!protsep) + protsep=url_clone; + else + protsep+=2; /* pass the slashes */ + + if('/' != newurl[0]) { + int level=0; + + /* First we need to find out if there's a ?-letter in the URL, + and cut it and the right-side of that off */ + pathsep = strrchr(protsep, '?'); + if(pathsep) + *pathsep=0; + + /* we have a relative path to append to the last slash if + there's one available */ + pathsep = strrchr(protsep, '/'); + if(pathsep) + *pathsep=0; + + /* Check if there's any slash after the host name, and if so, + remember that position instead */ + pathsep = strchr(protsep, '/'); + if(pathsep) + protsep = pathsep+1; + else + protsep = NULL; + + /* now deal with one "./" or any amount of "../" in the newurl + and act accordingly */ + + if((useurl[0] == '.') && (useurl[1] == '/')) + useurl+=2; /* just skip the "./" */ + + while((useurl[0] == '.') && + (useurl[1] == '.') && + (useurl[2] == '/')) { + level++; + useurl+=3; /* pass the "../" */ + } + + if(protsep) { + while(level--) { + /* cut off one more level from the right of the original URL */ + pathsep = strrchr(protsep, '/'); + if(pathsep) + *pathsep=0; + else { + *protsep=0; + break; + } + } + } + } + else { + /* We got a new absolute path for this server, cut off from the + first slash */ + pathsep = strchr(protsep, '/'); + if(pathsep) + *pathsep=0; + else { + /* There was no slash. Now, since we might be operating on a badly + formatted URL, such as "http://www.url.com?id=2380" which doesn't + use a slash separator as it is supposed to, we need to check for a + ?-letter as well! */ + pathsep = strchr(protsep, '?'); + if(pathsep) + *pathsep=0; + } + } + + /* If the new part contains a space, this is a mighty stupid redirect + but we still make an effort to do "right". To the left of a '?' + letter we replace each space with %20 while it is replaced with '+' + on the right side of the '?' letter. + */ + newlen = strlen_url(useurl); + + urllen = strlen(url_clone); + + newest=(char *)malloc( urllen + 1 + /* possible slash */ + newlen + 1 /* zero byte */); + + if(!newest) { + free(url_clone); /* don't leak this */ + return CURLE_OUT_OF_MEMORY; /* go out from this */ + } + + /* copy over the root url part */ + memcpy(newest, url_clone, urllen); + + /* check if we need to append a slash */ + if(('/' == useurl[0]) || (protsep && !*protsep)) + ; + else + newest[urllen++]='/'; + + /* then append the new piece on the right side */ + strcpy_url(&newest[urllen], useurl); + + free(newurl); /* newurl is the allocated pointer */ + free(url_clone); + newurl = newest; + } + else { + /* This is an absolute URL, don't allow the custom port number */ + data->state.allow_port = FALSE; + + if(strchr(newurl, ' ')) { + /* This new URL contains at least one space, this is a mighty stupid + redirect but we still make an effort to do "right". */ + newlen = strlen_url(newurl); + + newest = malloc(newlen+1); /* get memory for this */ + if(newest) { + strcpy_url(newest, newurl); /* create a space-free URL */ + + free(newurl); /* that was no good */ + newurl = newest; /* use this instead now */ + } + } + + } + + if(data->change.url_alloc) + free(data->change.url); + else + data->change.url_alloc = TRUE; /* the URL is allocated */ + + data->change.url = newurl; + newurl = NULL; /* don't free! */ + (void)newurl; + + infof(data, "Issue another request to this URL: '%s'\n", data->change.url); + + /* + * We get here when the HTTP code is 300-399 (and 401). We need to perform + * differently based on exactly what return code there was. + * + * News from 7.10.6: we can also get here on a 401 or 407, in case we act on + * a HTTP (proxy-) authentication scheme other than Basic. + */ + switch(data->info.httpcode) { + /* 401 - Act on a www-authentication, we keep on moving and do the + Authorization: XXXX header in the HTTP request code snippet */ + /* 407 - Act on a proxy-authentication, we keep on moving and do the + Proxy-Authorization: XXXX header in the HTTP request code snippet */ + /* 300 - Multiple Choices */ + /* 306 - Not used */ + /* 307 - Temporary Redirect */ + default: /* for all above (and the unknown ones) */ + /* Some codes are explicitly mentioned since I've checked RFC2616 and they + * seem to be OK to POST to. + */ + break; + case 301: /* Moved Permanently */ + /* (quote from RFC2616, section 10.3.2): + * + * Note: When automatically redirecting a POST request after receiving a + * 301 status code, some existing HTTP/1.0 user agents will erroneously + * change it into a GET request. + * + * ---- + * + * Warning: Because most of importants user agents do this obvious RFC2616 + * violation, many webservers expect this misbehavior. So these servers + * often answers to a POST request with an error page. To be sure that + * libcurl gets the page that most user agents would get, libcurl has to + * force GET: + */ + if( data->set.httpreq == HTTPREQ_POST + || data->set.httpreq == HTTPREQ_POST_FORM) { + infof(data, + "Violate RFC 2616/10.3.2 and switch from POST to GET\n"); + data->set.httpreq = HTTPREQ_GET; + } + break; + case 302: /* Found */ + /* (From 10.3.3) + + Note: RFC 1945 and RFC 2068 specify that the client is not allowed + to change the method on the redirected request. However, most + existing user agent implementations treat 302 as if it were a 303 + response, performing a GET on the Location field-value regardless + of the original request method. The status codes 303 and 307 have + been added for servers that wish to make unambiguously clear which + kind of reaction is expected of the client. + + (From 10.3.4) + + Note: Many pre-HTTP/1.1 user agents do not understand the 303 + status. When interoperability with such clients is a concern, the + 302 status code may be used instead, since most user agents react + to a 302 response as described here for 303. + */ + case 303: /* See Other */ + /* Disable both types of POSTs, since doing a second POST when + * following isn't what anyone would want! */ + if(data->set.httpreq != HTTPREQ_GET) { + data->set.httpreq = HTTPREQ_GET; /* enforce GET request */ + infof(data, "Disables POST, goes with %s\n", + data->set.opt_no_body?"HEAD":"GET"); + } + break; + case 304: /* Not Modified */ + /* 304 means we did a conditional request and it was "Not modified". + * We shouldn't get any Location: header in this response! + */ + break; + case 305: /* Use Proxy */ + /* (quote from RFC2616, section 10.3.6): + * "The requested resource MUST be accessed through the proxy given + * by the Location field. The Location field gives the URI of the + * proxy. The recipient is expected to repeat this single request + * via the proxy. 305 responses MUST only be generated by origin + * servers." + */ + break; + } + Curl_pgrsTime(data, TIMER_REDIRECT); + Curl_pgrsResetTimes(data); + + return CURLE_OK; +} + +static CURLcode +Curl_connect_host(struct SessionHandle *data, + struct connectdata **conn) +{ + CURLcode res; + int urlchanged; + + do { + bool async; + Curl_pgrsTime(data, TIMER_STARTSINGLE); + data->change.url_changed = FALSE; + res = Curl_connect(data, conn, &async); + + if((CURLE_OK == res) && async) { + /* Now, if async is TRUE here, we need to wait for the name + to resolve */ + res = Curl_wait_for_resolv(*conn, NULL); + if(CURLE_OK == res) + /* Resolved, continue with the connection */ + res = Curl_async_resolved(*conn); + } + if(res) + break; + + /* If a callback (or something) has altered the URL we should use within + the Curl_connect(), we detect it here and act as if we are redirected + to the new URL */ + urlchanged = data->change.url_changed; + if ((CURLE_OK == res) && urlchanged) { + res = Curl_done(conn, res); + if(CURLE_OK == res) { + char *gotourl = strdup(data->change.url); + res = Curl_follow(data, gotourl); + if(res) + free(gotourl); + } + } + } while (urlchanged && res == CURLE_OK); + + return res; +} + + + +/* + * Curl_perform() is the internal high-level function that gets called by the + * external curl_easy_perform() function. It inits, performs and cleans up a + * single file transfer. + */ +CURLcode Curl_perform(struct SessionHandle *data) +{ + CURLcode res; + CURLcode res2; + struct connectdata *conn=NULL; + char *newurl = NULL; /* possibly a new URL to follow to! */ + + data->state.used_interface = Curl_if_easy; + + res = Curl_pretransfer(data); + if(res) + return res; + + /* + * It is important that there is NO 'return' from this function at any other + * place than falling down to the end of the function! This is because we + * have cleanup stuff that must be done before we get back, and that is only + * performed after this do-while loop. + */ + + do { + res = Curl_connect_host(data, &conn); /* primary connection */ + + if(res == CURLE_OK) { + if (data->set.source_host) /* 3rd party transfer */ + res = Curl_pretransfersec(conn); + else + conn->sec_conn = NULL; + } + + if(res == CURLE_OK) { + + res = Curl_do(&conn); + + /* for non 3rd party transfer only */ + if(res == CURLE_OK && !data->set.source_host) { + res = Transfer(conn); /* now fetch that URL please */ + if(res == CURLE_OK) { + + if((conn->keep.bytecount+conn->headerbytecount == 0) && + conn->bits.reuse) { + /* We got no data and we attempted to re-use a connection. This + might happen if the connection was left alive when we were done + using it before, but that was closed when we wanted to read + from it again. Bad luck. Retry the same request on a fresh + connect! */ + infof(data, "Connection died, retrying a fresh connect\n"); + newurl = strdup(conn->data->change.url); + + conn->bits.close = TRUE; /* close this connection */ + conn->bits.retry = TRUE; /* mark this as a connection we're about + to retry. Marking it this way should + prevent i.e HTTP transfers to return + error just because nothing has been + transfered! */ + } + else + /* + * We must duplicate the new URL here as the connection data + * may be free()ed in the Curl_done() function. + */ + newurl = conn->newurl?strdup(conn->newurl):NULL; + } + else { + /* The transfer phase returned error, we mark the connection to get + * closed to prevent being re-used. This is becasue we can't + * possibly know if the connection is in a good shape or not now. */ + conn->bits.close = TRUE; + + if(CURL_SOCKET_BAD != conn->sock[SECONDARYSOCKET]) { + /* if we failed anywhere, we must clean up the secondary socket if + it was used */ + sclose(conn->sock[SECONDARYSOCKET]); + conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD; + } + } + + /* Always run Curl_done(), even if some of the previous calls + failed, but return the previous (original) error code */ + res2 = Curl_done(&conn, res); + + if(CURLE_OK == res) + res = res2; + } + else + /* Curl_do() failed, clean up left-overs in the done-call */ + res2 = Curl_done(&conn, res); + + (void)res2; + + /* + * Important: 'conn' cannot be used here, since it may have been closed + * in 'Curl_done' or other functions. + */ + + if((res == CURLE_OK) && newurl) { + res = Curl_follow(data, newurl); + if(CURLE_OK == res) { + newurl = NULL; + continue; + } + } + } + break; /* it only reaches here when this shouldn't loop */ + + } while(1); /* loop if Location: */ + + if(newurl) + free(newurl); + + /* run post-transfer uncondionally, but don't clobber the return code if + we already have an error code recorder */ + res2 = Curl_posttransfer(data); + if(!res && res2) + res = res2; + + return res; +} + +/* + * Curl_Transfer() is called to setup some basic properties for the upcoming + * transfer. + */ +CURLcode +Curl_Transfer(struct connectdata *c_conn, /* connection data */ + int sockindex, /* socket index to read from or -1 */ + curl_off_t size, /* -1 if unknown at this point */ + bool getheader, /* TRUE if header parsing is wanted */ + curl_off_t *bytecountp, /* return number of bytes read or NULL */ + int writesockindex, /* socket index to write to, it may very + well be the same we read from. -1 + disables */ + curl_off_t *writecountp /* return number of bytes written or + NULL */ + ) +{ + struct connectdata *conn = (struct connectdata *)c_conn; + if(!conn) + return CURLE_BAD_FUNCTION_ARGUMENT; + + curlassert((sockindex <= 1) && (sockindex >= -1)); + + /* now copy all input parameters */ + conn->sockfd = sockindex==-1? + CURL_SOCKET_BAD:conn->sock[sockindex]; + conn->size = size; + conn->bits.getheader = getheader; + conn->bytecountp = bytecountp; + conn->writesockfd = writesockindex==-1? + CURL_SOCKET_BAD:conn->sock[writesockindex]; + conn->writebytecountp = writecountp; + + return CURLE_OK; + +} + +/* + * Curl_pretransfersec() prepares the secondary connection (used for 3rd party + * FTP transfers). + */ +CURLcode Curl_pretransfersec(struct connectdata *conn) +{ + CURLcode status; + struct SessionHandle *data = conn->data; + struct connectdata *sec_conn = NULL; /* secondary connection */ + + /* update data with source host options */ + char *url = aprintf( "%s://%s/", conn->protostr, data->set.source_host); + + if(!url) + return CURLE_OUT_OF_MEMORY; + + if(data->change.url_alloc) + free(data->change.url); + + data->change.url_alloc = TRUE; + data->change.url = url; + data->set.ftpport = data->set.source_port; + data->set.userpwd = data->set.source_userpwd; + + /* secondary connection */ + status = Curl_connect_host(data, &sec_conn); + if(CURLE_OK == status) { + sec_conn->data = data; + conn->sec_conn = sec_conn; + } + + return status; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/transfer.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/transfer.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/transfer.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/transfer.h 2004-10-05 21:34:19.000000000 +0800 @@ -0,0 +1,52 @@ +#ifndef __TRANSFER_H +#define __TRANSFER_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: transfer.h,v 1.4 2004/10/05 13:34:19 andy Exp $ + ***************************************************************************/ +CURLcode Curl_perform(struct SessionHandle *data); +CURLcode Curl_pretransfer(struct SessionHandle *data); +CURLcode Curl_pretransfersec(struct connectdata *conn); +CURLcode Curl_posttransfer(struct SessionHandle *data); +CURLcode Curl_follow(struct SessionHandle *data, char *newurl); +CURLcode Curl_readwrite(struct connectdata *conn, bool *done); +void Curl_single_fdset(struct connectdata *conn, + fd_set *read_fd_set, + fd_set *write_fd_set, + fd_set *exc_fd_set, + int *max_fd); +CURLcode Curl_readwrite_init(struct connectdata *conn); + +CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp); + +/* This sets up a forthcoming transfer */ +CURLcode +Curl_Transfer (struct connectdata *data, + int sockindex, /* socket index to read from or -1 */ + curl_off_t size, /* -1 if unknown at this point */ + bool getheader, /* TRUE if header parsing is wanted */ + curl_off_t *bytecountp, /* return number of bytes read */ + int writesockindex, /* socket index to write to, it may + very well be the same we read from. + -1 disables */ + curl_off_t *writecountp /* return number of bytes written */ +); +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/url.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/url.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/url.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/url.c 2004-10-13 22:45:30.000000000 +0800 @@ -0,0 +1,3686 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: url.c,v 1.16 2004/10/13 14:45:30 andy Exp $ + ***************************************************************************/ + +/* -- WIN32 approved -- */ + +#include "setup.h" + +#include +#include +#include +#include +#include +#include +#include + +#include + +#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__) +#include +#include +#else +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#include +#ifdef HAVE_ARPA_INET_H +#include +#endif +#ifdef HAVE_NET_IF_H +#include +#endif +#include +#include + +#ifdef HAVE_SYS_PARAM_H +#include +#endif + +#ifdef HAVE_SYS_SELECT_H +#include +#endif + +#ifdef VMS +#include +#include +#endif + +#ifdef HAVE_SETJMP_H +#include +#endif + +#ifndef HAVE_SELECT +#error "We can't compile without select() support!" +#endif +#ifndef HAVE_SOCKET +#error "We can't compile without socket() support!" +#endif + + +#endif + +#ifdef USE_LIBIDN +#include +#include +#ifdef HAVE_IDN_FREE_H +#include +#else +void idn_free (void *ptr); /* prototype from idn-free.h, not provided by + libidn 0.4.5's make install! */ +#endif +#ifndef HAVE_IDN_FREE +/* if idn_free() was not found in this version of libidn, use plain free() + instead */ +#define idn_free(x) (free)(x) +#endif +#endif + +#ifdef HAVE_OPENSSL_ENGINE_H +#include +#endif +#include "urldata.h" +#include "netrc.h" + +#include "formdata.h" +#include "base64.h" +#include "ssluse.h" +#include "hostip.h" +#include "if2ip.h" +#include "transfer.h" +#include "sendf.h" +#include "progress.h" +#include "cookie.h" +#include "strequal.h" +#include "escape.h" +#include "strtok.h" +#include "share.h" +#include "content_encoding.h" +#include "http_digest.h" +#include "http_negotiate.h" + +/* And now for the protocols */ +#include "ftp.h" +#include "dict.h" +#include "telnet.h" +#include "http.h" +#include "file.h" +#include "ldap.h" +#include "url.h" +#include "connect.h" +#include "inet_ntop.h" +#include + +#if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL) +#include "inet_ntoa_r.h" +#endif + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +#ifdef HAVE_KRB4 +#include "security.h" +#endif +#include "curl_memory.h" + +/* The last #include file should be: */ +#include "memdebug.h" + +/* Local static prototypes */ +static long ConnectionKillOne(struct SessionHandle *data); +static bool ConnectionExists(struct SessionHandle *data, + struct connectdata *needle, + struct connectdata **usethis); +static long ConnectionStore(struct SessionHandle *data, + struct connectdata *conn); +static bool safe_strequal(char* str1, char* str2); + +#ifndef USE_ARES +/* not for Win32, unless it is cygwin + not for ares builds */ +#if !defined(WIN32) || defined(__CYGWIN32__) + +#ifndef RETSIGTYPE +#define RETSIGTYPE void +#endif +#ifdef HAVE_SIGSETJMP +extern sigjmp_buf curl_jmpenv; +#endif +static +RETSIGTYPE alarmfunc(int sig) +{ + /* this is for "-ansi -Wall -pedantic" to stop complaining! (rabe) */ + (void)sig; +#ifdef HAVE_SIGSETJMP + siglongjmp(curl_jmpenv, 1); +#endif + return; +} +#endif +#endif /* USE_ARES */ + +void Curl_safefree(void *ptr) +{ + if(ptr) + free(ptr); +} + +/* + * This is the internal function curl_easy_cleanup() calls. This should + * cleanup and free all resources associated with this sessionhandle. + * + * NOTE: if we ever add something that attempts to write to a socket or + * similar here, we must ignore SIGPIPE first. It is currently only done + * when curl_easy_perform() is invoked. + */ + +CURLcode Curl_close(struct SessionHandle *data) +{ + /* Loop through all open connections and kill them one by one */ + while(-1 != ConnectionKillOne(data)); + +#ifdef USE_SSLEAY + /* Close down all open SSL info and sessions */ + Curl_SSL_Close_All(data); +#endif + + if(data->change.cookielist) /* clean up list if any */ + curl_slist_free_all(data->change.cookielist); + + Curl_safefree(data->state.auth_host); + Curl_safefree(data->state.scratch); + + if(data->change.proxy_alloc) + free(data->change.proxy); + + if(data->change.referer_alloc) + free(data->change.referer); + + if(data->change.url_alloc) + free(data->change.url); + + Curl_safefree(data->state.headerbuff); + +#ifndef CURL_DISABLE_HTTP + Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); + if(data->set.cookiejar) { + /* we have a "destination" for all the cookies to get dumped to */ + if(Curl_cookie_output(data->cookies, data->set.cookiejar)) + infof(data, "WARNING: failed to save cookies in %s\n", + data->set.cookiejar); + } + + if( !data->share || (data->cookies != data->share->cookies) ) { + Curl_cookie_cleanup(data->cookies); + } + Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE); + + Curl_digest_cleanup(data); +#endif + + /* free the connection cache */ + free(data->state.connects); + + Curl_safefree(data->info.contenttype); + +#ifdef USE_ARES + /* this destroys the channel and we cannot use it anymore after this */ + ares_destroy(data->state.areschannel); +#endif + + /* No longer a dirty share, if it exists */ + if (data->share) + data->share->dirty--; + + free(data); + return CURLE_OK; +} + +/** + * Curl_open() + * + * @param curl is a pointer to a sessionhandle pointer that gets set by this + * function. + * @return CURLcode + */ + +CURLcode Curl_open(struct SessionHandle **curl) +{ + CURLcode res = CURLE_OK; + struct SessionHandle *data; + /* Very simple start-up: alloc the struct, init it with zeroes and return */ + data = (struct SessionHandle *)calloc(1, sizeof(struct SessionHandle)); + if(!data) + /* this is a very serious error */ + return CURLE_OUT_OF_MEMORY; + +#ifdef USE_ARES + if(ARES_SUCCESS != ares_init(&data->state.areschannel)) { + free(data); + return CURLE_FAILED_INIT; + } + /* make sure that all other returns from this function should destroy the + ares channel before returning error! */ +#endif + + /* We do some initial setup here, all those fields that can't be just 0 */ + + data->state.headerbuff=(char*)malloc(HEADERSIZE); + if(!data->state.headerbuff) + res = CURLE_OUT_OF_MEMORY; + else { + data->state.headersize=HEADERSIZE; + + data->set.out = stdout; /* default output to stdout */ + data->set.in = stdin; /* default input from stdin */ + data->set.err = stderr; /* default stderr to stderr */ + + /* use fwrite as default function to store output */ + data->set.fwrite = (curl_write_callback)fwrite; + + /* use fread as default function to read input */ + data->set.fread = (curl_read_callback)fread; + + data->set.infilesize = -1; /* we don't know any size */ + + data->state.current_speed = -1; /* init to negative == impossible */ + + data->set.httpreq = HTTPREQ_GET; /* Default HTTP request */ + data->set.ftp_use_epsv = TRUE; /* FTP defaults to EPSV operations */ + data->set.ftp_use_eprt = TRUE; /* FTP defaults to EPRT operations */ + + data->set.dns_cache_timeout = 60; /* Timeout every 60 seconds by default */ + + /* make libcurl quiet by default: */ + data->set.hide_progress = TRUE; /* CURLOPT_NOPROGRESS changes these */ + data->progress.flags |= PGRS_HIDE; + + /* Set the default size of the SSL session ID cache */ + data->set.ssl.numsessions = 5; + + data->set.proxyport = 1080; + data->set.proxytype = CURLPROXY_HTTP; /* defaults to HTTP proxy */ + data->set.httpauth = CURLAUTH_BASIC; /* defaults to basic */ + data->set.proxyauth = CURLAUTH_BASIC; /* defaults to basic */ + + /* create an array with connection data struct pointers */ + data->state.numconnects = 5; /* hard-coded right now */ + data->state.connects = (struct connectdata **) + malloc(sizeof(struct connectdata *) * data->state.numconnects); + + if(!data->state.connects) + res = CURLE_OUT_OF_MEMORY; + else + memset(data->state.connects, 0, + sizeof(struct connectdata *)*data->state.numconnects); + + /* + * libcurl 7.10 introduced SSL verification *by default*! This needs to be + * switched off unless wanted. + */ + data->set.ssl.verifypeer = TRUE; + data->set.ssl.verifyhost = 2; +#ifdef CURL_CA_BUNDLE + /* This is our prefered CA cert bundle since install time */ + data->set.ssl.CAfile = (char *)CURL_CA_BUNDLE; +#endif + } + + if(res) { +#ifdef USE_ARES + ares_destroy(data->state.areschannel); +#endif + if(data->state.headerbuff) + free(data->state.headerbuff); + free(data); + data = NULL; + } + + *curl = data; + return CURLE_OK; +} + +CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...) +{ + va_list param; + char *cookiefile; + + va_start(param, option); + + switch(option) { + case CURLOPT_DNS_CACHE_TIMEOUT: + data->set.dns_cache_timeout = va_arg(param, int); + break; + case CURLOPT_DNS_USE_GLOBAL_CACHE: + { + int use_cache = va_arg(param, int); + if (use_cache) { + Curl_global_host_cache_init(); + } + + data->set.global_dns_cache = use_cache; + } + break; + case CURLOPT_SSL_CIPHER_LIST: + /* set a list of cipher we want to use in the SSL connection */ + data->set.ssl.cipher_list = va_arg(param, char *); + break; + + case CURLOPT_RANDOM_FILE: + /* + * This is the path name to a file that contains random data to seed + * the random SSL stuff with. The file is only used for reading. + */ + data->set.ssl.random_file = va_arg(param, char *); + break; + case CURLOPT_EGDSOCKET: + /* + * The Entropy Gathering Daemon socket pathname + */ + data->set.ssl.egdsocket = va_arg(param, char *); + break; + case CURLOPT_MAXCONNECTS: + /* + * Set the absolute number of maximum simultaneous alive connection that + * libcurl is allowed to have. + */ + { + long newconnects= va_arg(param, long); + struct connectdata **newptr; + long i; + + if(newconnects < data->state.numconnects) { + /* Since this number is *decreased* from the existing number, we must + close the possibly open connections that live on the indexes that + are being removed! */ + for(i=newconnects; i< data->state.numconnects; i++) + Curl_disconnect(data->state.connects[i]); + } + if(newconnects) { + newptr= (struct connectdata **) + realloc(data->state.connects, + sizeof(struct connectdata *) * newconnects); + if(!newptr) + /* we closed a few connections in vain, but so what? */ + return CURLE_OUT_OF_MEMORY; + + /* nullify the newly added pointers */ + for(i=data->state.numconnects; istate.connects = newptr; + data->state.numconnects = newconnects; + } + else { + /* zero makes NO cache at all */ + if(data->state.connects) + free(data->state.connects); + data->state.connects=NULL; + data->state.numconnects=0; + } + } + break; + case CURLOPT_FORBID_REUSE: + /* + * When this transfer is done, it must not be left to be reused by a + * subsequent transfer but shall be closed immediately. + */ + data->set.reuse_forbid = va_arg(param, long)?TRUE:FALSE; + break; + case CURLOPT_FRESH_CONNECT: + /* + * This transfer shall not use a previously cached connection but + * should be made with a fresh new connect! + */ + data->set.reuse_fresh = va_arg(param, long)?TRUE:FALSE; + break; + case CURLOPT_VERBOSE: + /* + * Verbose means infof() calls that give a lot of information about + * the connection and transfer procedures as well as internal choices. + */ + data->set.verbose = va_arg(param, long)?TRUE:FALSE; + break; + case CURLOPT_HEADER: + /* + * Set to include the header in the general data output stream. + */ + data->set.include_header = va_arg(param, long)?TRUE:FALSE; + break; + case CURLOPT_NOPROGRESS: + /* + * Shut off the internal supported progress meter + */ + data->set.hide_progress = va_arg(param, long)?TRUE:FALSE; + if(data->set.hide_progress) + data->progress.flags |= PGRS_HIDE; + else + data->progress.flags &= ~PGRS_HIDE; + break; + case CURLOPT_NOBODY: + /* + * Do not include the body part in the output data stream. + */ + data->set.opt_no_body = va_arg(param, long)?TRUE:FALSE; + if(data->set.opt_no_body) + /* in HTTP lingo, this means using the HEAD request */ + data->set.httpreq = HTTPREQ_HEAD; + break; + case CURLOPT_FAILONERROR: + /* + * Don't output the >=300 error code HTML-page, but instead only + * return error. + */ + data->set.http_fail_on_error = va_arg(param, long)?TRUE:FALSE; + break; + case CURLOPT_UPLOAD: + case CURLOPT_PUT: + /* + * We want to sent data to the remote host. If this is HTTP, that equals + * using the PUT request. + */ + data->set.upload = va_arg(param, long)?TRUE:FALSE; + if(data->set.upload) + /* If this is HTTP, PUT is what's needed to "upload" */ + data->set.httpreq = HTTPREQ_PUT; + break; + case CURLOPT_FILETIME: + /* + * Try to get the file time of the remote document. The time will + * later (possibly) become available using curl_easy_getinfo(). + */ + data->set.get_filetime = va_arg(param, long)?TRUE:FALSE; + break; + case CURLOPT_FTP_CREATE_MISSING_DIRS: + /* + * An FTP option that modifies an upload to create missing directories on + * the server. + */ + data->set.ftp_create_missing_dirs = va_arg( param , long )?TRUE:FALSE; + break; + case CURLOPT_FTP_RESPONSE_TIMEOUT: + /* + * An FTP option that specifies how quickly an FTP response must be + * obtained before it is considered failure. + */ + data->set.ftp_response_timeout = va_arg( param , long ); + break; + case CURLOPT_FTPLISTONLY: + /* + * An FTP option that changes the command to one that asks for a list + * only, no file info details. + */ + data->set.ftp_list_only = va_arg(param, long)?TRUE:FALSE; + break; + case CURLOPT_FTPAPPEND: + /* + * We want to upload and append to an existing (FTP) file. + */ + data->set.ftp_append = va_arg(param, long)?TRUE:FALSE; + break; + case CURLOPT_NETRC: + /* + * Parse the $HOME/.netrc file + */ + data->set.use_netrc = (enum CURL_NETRC_OPTION)va_arg(param, long); + break; + case CURLOPT_NETRC_FILE: + /* + * Use this file instead of the $HOME/.netrc file + */ + data->set.netrc_file = va_arg(param, char *); + break; + case CURLOPT_TRANSFERTEXT: + /* + * This option was previously named 'FTPASCII'. Renamed to work with + * more protocols than merely FTP. + * + * Transfer using ASCII (instead of BINARY). + */ + data->set.ftp_ascii = va_arg(param, long)?TRUE:FALSE; + break; + case CURLOPT_TIMECONDITION: + /* + * Set HTTP time condition. This must be one of the defines in the + * curl/curl.h header file. + */ + data->set.timecondition = (curl_TimeCond)va_arg(param, long); + break; + case CURLOPT_TIMEVALUE: + /* + * This is the value to compare with the remote document with the + * method set with CURLOPT_TIMECONDITION + */ + data->set.timevalue = (time_t)va_arg(param, long); + break; + case CURLOPT_SSLVERSION: + /* + * Set explicit SSL version to try to connect with, as some SSL + * implementations are lame. + */ + data->set.ssl.version = va_arg(param, long); + break; + +#ifndef CURL_DISABLE_HTTP + case CURLOPT_AUTOREFERER: + /* + * Switch on automatic referer that gets set if curl follows locations. + */ + data->set.http_auto_referer = va_arg(param, long)?1:0; + break; + + case CURLOPT_ENCODING: + /* + * String to use at the value of Accept-Encoding header. + * + * If the encoding is set to "" we use an Accept-Encoding header that + * encompasses all the encodings we support. + * If the encoding is set to NULL we don't send an Accept-Encoding header + * and ignore an received Content-Encoding header. + * + */ + data->set.encoding = va_arg(param, char *); + if(data->set.encoding && !*data->set.encoding) + data->set.encoding = (char*)ALL_CONTENT_ENCODINGS; + break; + + case CURLOPT_FOLLOWLOCATION: + /* + * Follow Location: header hints on a HTTP-server. + */ + data->set.http_follow_location = va_arg(param, long)?TRUE:FALSE; + break; + + case CURLOPT_UNRESTRICTED_AUTH: + /* + * Send authentication (user+password) when following locations, even when + * hostname changed. + */ + data->set.http_disable_hostname_check_before_authentication = + va_arg(param, long)?TRUE:FALSE; + break; + + case CURLOPT_MAXREDIRS: + /* + * The maximum amount of hops you allow curl to follow Location: + * headers. This should mostly be used to detect never-ending loops. + */ + data->set.maxredirs = va_arg(param, long); + break; + + case CURLOPT_POST: + /* Does this option serve a purpose anymore? Yes it does, when + CURLOPT_POSTFIELDS isn't used and the POST data is read off the + callback! */ + if(va_arg(param, long)) + data->set.httpreq = HTTPREQ_POST; + break; + + case CURLOPT_POSTFIELDS: + /* + * A string with POST data. Makes curl HTTP POST. + */ + data->set.postfields = va_arg(param, char *); + if(data->set.postfields) + data->set.httpreq = HTTPREQ_POST; + break; + + case CURLOPT_POSTFIELDSIZE: + /* + * The size of the POSTFIELD data to prevent libcurl to do strlen() to + * figure it out. Enables binary posts. + */ + data->set.postfieldsize = va_arg(param, long); + break; + + case CURLOPT_POSTFIELDSIZE_LARGE: + /* + * The size of the POSTFIELD data to prevent libcurl to do strlen() to + * figure it out. Enables binary posts. + */ + data->set.postfieldsize = va_arg(param, curl_off_t); + break; + + case CURLOPT_HTTPPOST: + /* + * Set to make us do HTTP POST + */ + data->set.httppost = va_arg(param, struct curl_httppost *); + if(data->set.httppost) + data->set.httpreq = HTTPREQ_POST_FORM; + break; + + case CURLOPT_REFERER: + /* + * String to set in the HTTP Referer: field. + */ + if(data->change.referer_alloc) { + free(data->change.referer); + data->change.referer_alloc = FALSE; + } + data->set.set_referer = va_arg(param, char *); + data->change.referer = data->set.set_referer; + break; + + case CURLOPT_USERAGENT: + /* + * String to use in the HTTP User-Agent field + */ + data->set.useragent = va_arg(param, char *); + break; + + case CURLOPT_HTTPHEADER: + /* + * Set a list with HTTP headers to use (or replace internals with) + */ + data->set.headers = va_arg(param, struct curl_slist *); + break; + + case CURLOPT_HTTP200ALIASES: + /* + * Set a list of aliases for HTTP 200 in response header + */ + data->set.http200aliases = va_arg(param, struct curl_slist *); + break; + + case CURLOPT_COOKIE: + /* + * Cookie string to send to the remote server in the request. + */ + data->set.cookie = va_arg(param, char *); + break; + + case CURLOPT_COOKIEFILE: + /* + * Set cookie file to read and parse. Can be used multiple times. + */ + cookiefile = (char *)va_arg(param, void *); + if(cookiefile) { + struct curl_slist *cl; + /* append the cookie file name to the list of file names, and deal with + them later */ + cl = curl_slist_append(data->change.cookielist, cookiefile); + + if(!cl) + return CURLE_OUT_OF_MEMORY; + + data->change.cookielist = cl; + } + break; + + case CURLOPT_COOKIEJAR: + /* + * Set cookie file name to dump all cookies to when we're done. + */ + data->set.cookiejar = (char *)va_arg(param, void *); + + /* + * Activate the cookie parser. This may or may not already + * have been made. + */ + data->cookies = Curl_cookie_init(data, NULL, data->cookies, + data->set.cookiesession); + break; + + case CURLOPT_COOKIESESSION: + /* + * Set this option to TRUE to start a new "cookie session". It will + * prevent the forthcoming read-cookies-from-file actions to accept + * cookies that are marked as being session cookies, as they belong to a + * previous session. + * + * In the original Netscape cookie spec, "session cookies" are cookies + * with no expire date set. RFC2109 describes the same action if no + * 'Max-Age' is set and RFC2965 includes the RFC2109 description and adds + * a 'Discard' action that can enforce the discard even for cookies that + * have a Max-Age. + * + * We run mostly with the original cookie spec, as hardly anyone implements + * anything else. + */ + data->set.cookiesession = (bool)va_arg(param, long); + break; + + case CURLOPT_HTTPGET: + /* + * Set to force us do HTTP GET + */ + if(va_arg(param, long)) { + data->set.httpreq = HTTPREQ_GET; + data->set.upload = FALSE; /* switch off upload */ + } + break; + + case CURLOPT_HTTP_VERSION: + /* + * This sets a requested HTTP version to be used. The value is one of + * the listed enums in curl/curl.h. + */ + data->set.httpversion = va_arg(param, long); + break; + + case CURLOPT_HTTPPROXYTUNNEL: + /* + * Tunnel operations through the proxy instead of normal proxy use + */ + data->set.tunnel_thru_httpproxy = va_arg(param, long)?TRUE:FALSE; + break; + + case CURLOPT_CUSTOMREQUEST: + /* + * Set a custom string to use as request + */ + data->set.customrequest = va_arg(param, char *); + + /* we don't set + data->set.httpreq = HTTPREQ_CUSTOM; + here, we continue as if we were using the already set type + and this just changes the actual request keyword */ + break; + + case CURLOPT_PROXY: + /* + * Set proxy server:port to use as HTTP proxy. + * + * If the proxy is set to "" we explicitly say that we don't want to use a + * proxy (even though there might be environment variables saying so). + * + * Setting it to NULL, means no proxy but allows the environment variables + * to decide for us. + */ + if(data->change.proxy_alloc) { + /* + * The already set string is allocated, free that first + */ + data->change.proxy_alloc=FALSE;; + free(data->change.proxy); + } + data->set.set_proxy = va_arg(param, char *); + data->change.proxy = data->set.set_proxy; + break; + + case CURLOPT_PROXYPORT: + /* + * Explicitly set HTTP proxy port number. + */ + data->set.proxyport = va_arg(param, long); + break; + + case CURLOPT_HTTPAUTH: + /* + * Set HTTP Authentication type BITMASK. + */ + { + long auth = va_arg(param, long); + /* switch off bits we can't support */ +#ifndef USE_SSLEAY + auth &= ~CURLAUTH_NTLM; /* no NTLM without SSL */ +#endif +#ifndef HAVE_GSSAPI + auth &= ~CURLAUTH_GSSNEGOTIATE; /* no GSS-Negotiate without GSSAPI */ +#endif + if(!auth) + return CURLE_FAILED_INIT; /* no supported types left! */ + + data->set.httpauth = auth; + } + break; + + case CURLOPT_PROXYAUTH: + /* + * Set HTTP Authentication type BITMASK. + */ + { + long auth = va_arg(param, long); + /* switch off bits we can't support */ +#ifndef USE_SSLEAY + auth &= ~CURLAUTH_NTLM; /* no NTLM without SSL */ +#endif +#ifndef HAVE_GSSAPI + auth &= ~CURLAUTH_GSSNEGOTIATE; /* no GSS-Negotiate without GSSAPI */ +#endif + if(!auth) + return CURLE_FAILED_INIT; /* no supported types left! */ + + data->set.proxyauth = auth; + } + break; +#endif /* CURL_DISABLE_HTTP */ + + case CURLOPT_WRITEHEADER: + /* + * Custom pointer to pass the header write callback function + */ + data->set.writeheader = (void *)va_arg(param, void *); + break; + case CURLOPT_ERRORBUFFER: + /* + * Error buffer provided by the caller to get the human readable + * error string in. + */ + data->set.errorbuffer = va_arg(param, char *); + break; + case CURLOPT_FILE: + /* + * FILE pointer to write to or include in the data write callback + */ + data->set.out = va_arg(param, FILE *); + break; + case CURLOPT_FTPPORT: + /* + * Use FTP PORT, this also specifies which IP address to use + */ + data->set.ftpport = va_arg(param, char *); + data->set.ftp_use_port = data->set.ftpport?1:0; + break; + + case CURLOPT_FTP_USE_EPRT: + data->set.ftp_use_eprt = va_arg(param, long)?TRUE:FALSE; + break; + + case CURLOPT_FTP_USE_EPSV: + data->set.ftp_use_epsv = va_arg(param, long)?TRUE:FALSE; + break; + + case CURLOPT_INFILE: + /* + * FILE pointer to read the file to be uploaded from. Or possibly + * used as argument to the read callback. + */ + data->set.in = va_arg(param, FILE *); + break; + case CURLOPT_INFILESIZE: + /* + * If known, this should inform curl about the file size of the + * to-be-uploaded file. + */ + data->set.infilesize = va_arg(param, long); + break; + case CURLOPT_INFILESIZE_LARGE: + /* + * If known, this should inform curl about the file size of the + * to-be-uploaded file. + */ + data->set.infilesize = va_arg(param, curl_off_t); + break; + case CURLOPT_LOW_SPEED_LIMIT: + /* + * The low speed limit that if transfers are below this for + * CURLOPT_LOW_SPEED_TIME, the transfer is aborted. + */ + data->set.low_speed_limit=va_arg(param, long); + break; + case CURLOPT_LOW_SPEED_TIME: + /* + * The low speed time that if transfers are below the set + * CURLOPT_LOW_SPEED_LIMIT during this time, the transfer is aborted. + */ + data->set.low_speed_time=va_arg(param, long); + break; + case CURLOPT_URL: + /* + * The URL to fetch. + */ + if(data->change.url_alloc) { + /* the already set URL is allocated, free it first! */ + free(data->change.url); + data->change.url_alloc=FALSE; + } + data->set.set_url = va_arg(param, char *); + data->change.url = data->set.set_url; + data->change.url_changed = TRUE; + break; + case CURLOPT_PORT: + /* + * The port number to use when getting the URL + */ + data->set.use_port = va_arg(param, long); + break; + case CURLOPT_TIMEOUT: + /* + * The maximum time you allow curl to use for a single transfer + * operation. + */ + data->set.timeout = va_arg(param, long); + break; + case CURLOPT_CONNECTTIMEOUT: + /* + * The maximum time you allow curl to use to connect. + */ + data->set.connecttimeout = va_arg(param, long); + break; + + case CURLOPT_USERPWD: + /* + * user:password to use in the operation + */ + data->set.userpwd = va_arg(param, char *); + break; + case CURLOPT_POSTQUOTE: + /* + * List of RAW FTP commands to use after a transfer + */ + data->set.postquote = va_arg(param, struct curl_slist *); + break; + case CURLOPT_PREQUOTE: + /* + * List of RAW FTP commands to use prior to RETR (Wesley Laxton) + */ + data->set.prequote = va_arg(param, struct curl_slist *); + break; + case CURLOPT_QUOTE: + /* + * List of RAW FTP commands to use before a transfer + */ + data->set.quote = va_arg(param, struct curl_slist *); + break; + case CURLOPT_PROGRESSFUNCTION: + /* + * Progress callback function + */ + data->set.fprogress = va_arg(param, curl_progress_callback); + if(data->set.fprogress) + data->progress.callback = TRUE; /* no longer internal */ + else + data->progress.callback = FALSE; /* NULL enforces internal */ + + break; + case CURLOPT_PROGRESSDATA: + /* + * Custom client data to pass to the progress callback + */ + data->set.progress_client = va_arg(param, void *); + break; + case CURLOPT_PROXYUSERPWD: + /* + * user:password needed to use the proxy + */ + data->set.proxyuserpwd = va_arg(param, char *); + break; + case CURLOPT_RANGE: + /* + * What range of the file you want to transfer + */ + data->set.set_range = va_arg(param, char *); + break; + case CURLOPT_RESUME_FROM: + /* + * Resume transfer at the give file position + */ + data->set.set_resume_from = va_arg(param, long); + break; + case CURLOPT_RESUME_FROM_LARGE: + /* + * Resume transfer at the give file position + */ + data->set.set_resume_from = va_arg(param, curl_off_t); + break; + case CURLOPT_DEBUGFUNCTION: + /* + * stderr write callback. + */ + data->set.fdebug = va_arg(param, curl_debug_callback); + /* + * if the callback provided is NULL, it'll use the default callback + */ + break; + case CURLOPT_DEBUGDATA: + /* + * Set to a void * that should receive all error writes. This + * defaults to CURLOPT_STDERR for normal operations. + */ + data->set.debugdata = va_arg(param, void *); + break; + case CURLOPT_STDERR: + /* + * Set to a FILE * that should receive all error writes. This + * defaults to stderr for normal operations. + */ + data->set.err = va_arg(param, FILE *); + if(!data->set.err) + data->set.err = stderr; + break; + case CURLOPT_HEADERFUNCTION: + /* + * Set header write callback + */ + data->set.fwrite_header = va_arg(param, curl_write_callback); + break; + case CURLOPT_WRITEFUNCTION: + /* + * Set data write callback + */ + data->set.fwrite = va_arg(param, curl_write_callback); + if(!data->set.fwrite) + /* When set to NULL, reset to our internal default function */ + data->set.fwrite = (curl_write_callback)fwrite; + break; + case CURLOPT_READFUNCTION: + /* + * Read data callback + */ + data->set.fread = va_arg(param, curl_read_callback); + if(!data->set.fread) + /* When set to NULL, reset to our internal default function */ + data->set.fread = (curl_read_callback)fread; + break; + case CURLOPT_SSLCERT: + /* + * String that holds file name of the SSL certificate to use + */ + data->set.cert = va_arg(param, char *); + break; + case CURLOPT_SSLCERTTYPE: + /* + * String that holds file type of the SSL certificate to use + */ + data->set.cert_type = va_arg(param, char *); + break; + case CURLOPT_SSLKEY: + /* + * String that holds file name of the SSL certificate to use + */ + data->set.key = va_arg(param, char *); + break; + case CURLOPT_SSLKEYTYPE: + /* + * String that holds file type of the SSL certificate to use + */ + data->set.key_type = va_arg(param, char *); + break; + case CURLOPT_SSLKEYPASSWD: + /* + * String that holds the SSL private key password. + */ + data->set.key_passwd = va_arg(param, char *); + break; + case CURLOPT_SSLENGINE: + /* + * String that holds the SSL crypto engine. + */ +#ifdef HAVE_OPENSSL_ENGINE_H + { + const char *cpTemp = va_arg(param, char *); + ENGINE *e; + if (cpTemp && cpTemp[0]) { + e = ENGINE_by_id(cpTemp); + if (e) { + if (data->engine) { + ENGINE_free(data->engine); + } + data->engine = e; + } + else { + failf(data, "SSL Engine '%s' not found", cpTemp); + return CURLE_SSL_ENGINE_NOTFOUND; + } + } + } + break; +#else + return CURLE_SSL_ENGINE_NOTFOUND; +#endif + case CURLOPT_SSLENGINE_DEFAULT: + /* + * flag to set engine as default. + */ +#ifdef HAVE_OPENSSL_ENGINE_H + if (data->engine) { + if (ENGINE_set_default(data->engine, ENGINE_METHOD_ALL) > 0) { +#ifdef DEBUG + fprintf(stderr,"set default crypto engine\n"); +#endif + } + else { +#ifdef DEBUG + failf(data, "set default crypto engine failed"); +#endif + return CURLE_SSL_ENGINE_SETFAILED; + } + } +#endif + break; + case CURLOPT_CRLF: + /* + * Kludgy option to enable CRLF convertions. Subject for removal. + */ + data->set.crlf = va_arg(param, long)?TRUE:FALSE; + break; + case CURLOPT_INTERFACE: + /* + * Set what interface to bind to when performing an operation and thus + * what from-IP your connection will use. + */ + data->set.device = va_arg(param, char *); + break; + case CURLOPT_KRB4LEVEL: + /* + * A string that defines the krb4 security level. + */ + data->set.krb4_level = va_arg(param, char *); + data->set.krb4=data->set.krb4_level?TRUE:FALSE; + break; + case CURLOPT_SSL_VERIFYPEER: + /* + * Enable peer SSL verifying. + */ + data->set.ssl.verifypeer = va_arg(param, long); + break; + case CURLOPT_SSL_VERIFYHOST: + /* + * Enable verification of the CN contained in the peer certificate + */ + data->set.ssl.verifyhost = va_arg(param, long); + break; + case CURLOPT_SSL_CTX_FUNCTION: + /* + * Set a SSL_CTX callback + */ + data->set.ssl.fsslctx = va_arg(param, curl_ssl_ctx_callback); + break; + case CURLOPT_SSL_CTX_DATA: + /* + * Set a SSL_CTX callback parameter pointer + */ + data->set.ssl.fsslctxp = va_arg(param, void *); + break; + case CURLOPT_CAINFO: + /* + * Set CA info for SSL connection. Specify file name of the CA certificate + */ + data->set.ssl.CAfile = va_arg(param, char *); + break; + case CURLOPT_CAPATH: + /* + * Set CA path info for SSL connection. Specify directory name of the CA + * certificates which have been prepared using openssl c_rehash utility. + */ + /* This does not work on windows. */ + data->set.ssl.CApath = va_arg(param, char *); + break; + case CURLOPT_TELNETOPTIONS: + /* + * Set a linked list of telnet options + */ + data->set.telnet_options = va_arg(param, struct curl_slist *); + break; + + case CURLOPT_BUFFERSIZE: + /* + * The application kindly asks for a differently sized receive buffer. + * If it seems reasonable, we'll use it. + */ + data->set.buffer_size = va_arg(param, long); + + if((data->set.buffer_size> (BUFSIZE -1 )) || + (data->set.buffer_size < 1)) + data->set.buffer_size = 0; /* huge internal default */ + + break; + + case CURLOPT_NOSIGNAL: + /* + * The application asks not to set any signal() or alarm() handlers, + * even when using a timeout. + */ + data->set.no_signal = va_arg(param, long) ? TRUE : FALSE; + break; + + case CURLOPT_SHARE: + { + struct Curl_share *set; + set = va_arg(param, struct Curl_share *); + + /* disconnect from old share, if any */ + if(data->share) { + Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE); + + if(data->share->hostcache == data->hostcache) + data->hostcache = NULL; + + if(data->share->cookies == data->cookies) + data->cookies = NULL; + + data->share->dirty--; + + Curl_share_unlock(data, CURL_LOCK_DATA_SHARE); + data->share = NULL; + } + + /* use new share if it set */ + data->share = set; + if(data->share) { + + Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE); + + data->share->dirty++; + + if(data->share->hostcache) { + /* use shared host cache, first free own one if any */ + if(data->hostcache) + Curl_hash_destroy(data->hostcache); + + data->hostcache = data->share->hostcache; + } +#ifndef CURL_DISABLE_HTTP + if(data->share->cookies) { + /* use shared cookie list, first free own one if any */ + if (data->cookies) + Curl_cookie_cleanup(data->cookies); + data->cookies = data->share->cookies; + } +#endif /* CURL_DISABLE_HTTP */ + Curl_share_unlock(data, CURL_LOCK_DATA_SHARE); + + } +#ifndef CURL_DISABLE_HTTP + /* check cookie list is set */ + if(!data->cookies) + data->cookies = Curl_cookie_init(data, NULL, NULL, TRUE ); +#endif /* CURL_DISABLE_HTTP */ + /* check for host cache not needed, + * it will be done by curl_easy_perform */ + } + break; + + case CURLOPT_PROXYTYPE: + /* + * Set proxy type. HTTP/SOCKS4/SOCKS5 + */ + data->set.proxytype = (curl_proxytype)va_arg(param, long); + break; + + case CURLOPT_PRIVATE: + /* + * Set private data pointer. + */ + data->set.private = va_arg(param, char *); + break; + + case CURLOPT_MAXFILESIZE: + /* + * Set the maximum size of a file to download. + */ + data->set.max_filesize = va_arg(param, long); + break; + + case CURLOPT_FTP_SSL: + /* + * Make FTP transfers attempt to use SSL/TLS. + */ + data->set.ftp_ssl = (curl_ftpssl)va_arg(param, long); + break; + + case CURLOPT_IPRESOLVE: + data->set.ip_version = va_arg(param, long); + break; + + case CURLOPT_MAXFILESIZE_LARGE: + /* + * Set the maximum size of a file to download. + */ + data->set.max_filesize = va_arg(param, curl_off_t); + break; + + case CURLOPT_TCP_NODELAY: + /* + * Enable or disable TCP_NODELAY, which will disable/enable the Nagle + * algorithm + */ + data->set.tcp_nodelay = (bool)va_arg(param, long); + break; + + /*********** 3rd party transfer options ***********/ + case CURLOPT_SOURCE_HOST: + /* + * Use SOURCE HOST + */ + data->set.source_host = va_arg(param, char *); + data->set.printhost = (data->set.source_host != NULL); + break; + + case CURLOPT_SOURCE_PORT: + /* + * Use SOURCE PORT + */ + data->set.source_port = va_arg(param, char *); + break; + + case CURLOPT_SOURCE_USERPWD: + /* + * Use SOURCE USER[:PASSWORD] + */ + data->set.source_userpwd = va_arg(param, char *); + break; + + case CURLOPT_SOURCE_PATH: + /* + * Use SOURCE PATH + */ + data->set.source_path = va_arg(param, char *); + break; + + case CURLOPT_PASV_HOST: + /* + * Indicates whether source or target host is passive + */ + data->set.pasvHost = va_arg(param, long)?CURL_SOURCE_PASV:CURL_TARGET_PASV; + break; + + case CURLOPT_SOURCE_PREQUOTE: + /* + * List of RAW FTP commands to use before a transfer on the source host + */ + data->set.source_prequote = va_arg(param, struct curl_slist *); + break; + + case CURLOPT_SOURCE_POSTQUOTE: + /* + * List of RAW FTP commands to use after a transfer on the source host + */ + data->set.source_postquote = va_arg(param, struct curl_slist *); + break; + + default: + /* unknown tag and its companion, just ignore: */ + return CURLE_FAILED_INIT; /* correct this */ + } + return CURLE_OK; +} + +CURLcode Curl_disconnect(struct connectdata *conn) +{ + struct SessionHandle *data; + if(!conn) + return CURLE_OK; /* this is closed and fine already */ + + data = conn->data; + + /* + * The range string is usually freed in curl_done(), but we might + * get here *instead* if we fail prematurely. Thus we need to be able + * to free this resource here as well. + */ + if(conn->bits.rangestringalloc) { + free(conn->range); + conn->bits.rangestringalloc = FALSE; + } + + if((conn->ntlm.state != NTLMSTATE_NONE) || + (conn->proxyntlm.state != NTLMSTATE_NONE)) { + /* Authentication data is a mix of connection-related and sessionhandle- + related stuff. NTLM is connection-related so when we close the shop + we shall forget. */ + data->state.authhost.done = FALSE; + data->state.authhost.picked = + data->state.authhost.want; + + data->state.authproxy.done = FALSE; + data->state.authproxy.picked = + data->state.authhost.want; + + data->state.authproblem = FALSE; + } + + if(conn->curl_disconnect) + /* This is set if protocol-specific cleanups should be made */ + conn->curl_disconnect(conn); + + if(-1 != conn->connectindex) { + /* unlink ourselves! */ + infof(data, "Closing connection #%ld\n", conn->connectindex); + data->state.connects[conn->connectindex] = NULL; + } + + Curl_safefree(conn->proto.generic); + Curl_safefree(conn->newurl); + Curl_safefree(conn->pathbuffer); /* the URL path buffer */ + + Curl_safefree(conn->host.rawalloc); /* host name buffer */ + Curl_safefree(conn->proxy.rawalloc); /* proxy name buffer */ +#ifdef USE_LIBIDN + if(conn->host.encalloc) + idn_free(conn->host.encalloc); /* encoded host name buffer, must be freed + with idn_free() since this was allocated + by libidn */ + if(conn->proxy.encalloc) + idn_free(conn->proxy.encalloc); /* encoded proxy name buffer, must be + freed with idn_free() since this was + allocated by libidn */ +#endif + Curl_SSL_Close(conn); + + /* close possibly still open sockets */ + if(CURL_SOCKET_BAD != conn->sock[SECONDARYSOCKET]) + sclose(conn->sock[SECONDARYSOCKET]); + if(CURL_SOCKET_BAD != conn->sock[FIRSTSOCKET]) + sclose(conn->sock[FIRSTSOCKET]); + + Curl_safefree(conn->user); + Curl_safefree(conn->passwd); + Curl_safefree(conn->proxyuser); + Curl_safefree(conn->proxypasswd); + Curl_safefree(conn->allocptr.proxyuserpwd); + Curl_safefree(conn->allocptr.uagent); + Curl_safefree(conn->allocptr.userpwd); + Curl_safefree(conn->allocptr.accept_encoding); + Curl_safefree(conn->allocptr.rangeline); + Curl_safefree(conn->allocptr.ref); + Curl_safefree(conn->allocptr.host); + Curl_safefree(conn->allocptr.cookiehost); + +#if defined(USE_ARES) || defined(USE_THREADING_GETHOSTBYNAME) || \ + defined(USE_THREADING_GETADDRINFO) + /* possible left-overs from the async name resolve */ + Curl_safefree(conn->async.hostname); + Curl_safefree(conn->async.os_specific); +#endif + + Curl_free_ssl_config(&conn->ssl_config); + + free(conn); /* free all the connection oriented data */ + + return CURLE_OK; +} + +/* + * This function should return TRUE if the socket is to be assumed to + * be dead. Most commonly this happens when the server has closed the + * connection due to inactivity. + */ +static bool SocketIsDead(curl_socket_t sock) +{ + int sval; + bool ret_val = TRUE; + fd_set check_set; + struct timeval to; + + FD_ZERO(&check_set); + FD_SET(sock, &check_set); + + to.tv_sec = 0; + to.tv_usec = 0; + + sval = select(sock + 1, &check_set, 0, 0, &to); + if(sval == 0) + /* timeout */ + ret_val = FALSE; + + return ret_val; +} + +/* + * Given one filled in connection struct (named needle), this function should + * detect if there already is one that have all the significant details + * exactly the same and thus should be used instead. + */ +static bool +ConnectionExists(struct SessionHandle *data, + struct connectdata *needle, + struct connectdata **usethis) +{ + long i; + struct connectdata *check; + + for(i=0; i< data->state.numconnects; i++) { + bool match = FALSE; + /* + * Note that if we use a HTTP proxy, we check connections to that + * proxy and not to the actual remote server. + */ + check = data->state.connects[i]; + if(!check) + /* NULL pointer means not filled-in entry */ + continue; + + if((needle->protocol&PROT_SSL) != (check->protocol&PROT_SSL)) + /* don't do mixed SSL and non-SSL connections */ + continue; + + if(!needle->bits.httpproxy || needle->protocol&PROT_SSL) { + /* The requested connection does not use a HTTP proxy or it + uses SSL. */ + + if(!(needle->protocol&PROT_SSL) && check->bits.httpproxy) + /* we don't do SSL but the cached connection has a proxy, + then don't match this */ + continue; + + if(strequal(needle->protostr, check->protostr) && + strequal(needle->host.name, check->host.name) && + (needle->remote_port == check->remote_port) ) { + if(needle->protocol & PROT_SSL) { + /* This is SSL, verify that we're using the same + ssl options as well */ + if(!Curl_ssl_config_matches(&needle->ssl_config, + &check->ssl_config)) { + continue; + } + } + if((needle->protocol & PROT_FTP) || + ((needle->protocol & PROT_HTTP) && + (needle->data->state.authhost.want==CURLAUTH_NTLM))) { + /* This is FTP or HTTP+NTLM, verify that we're using the same name + and password as well */ + if(!strequal(needle->user, check->user) || + !strequal(needle->passwd, check->passwd)) { + /* one of them was different */ + continue; + } + } + match = TRUE; + } + } + else { /* The requested needle connection is using a proxy, + is the checked one using the same? */ + if(check->bits.httpproxy && + strequal(needle->proxy.name, check->proxy.name) && + needle->port == check->port) { + /* This is the same proxy connection, use it! */ + match = TRUE; + } + } + + if(match) { + bool dead = SocketIsDead(check->sock[FIRSTSOCKET]); + if(dead) { + /* + */ + infof(data, "Connection %d seems to be dead!\n", i); + Curl_disconnect(check); /* disconnect resources */ + data->state.connects[i]=NULL; /* nothing here */ + + /* There's no need to continue searching, because we only store + one connection for each unique set of identifiers */ + return FALSE; + } + + *usethis = check; + return TRUE; /* yes, we found one to use! */ + } + } + return FALSE; /* no matching connecting exists */ +} + +/* + * This function frees/closes a connection in the connection cache. This + * should take the previously set policy into account when deciding which + * of the connections to kill. + */ +static long +ConnectionKillOne(struct SessionHandle *data) +{ + long i; + struct connectdata *conn; + long highscore=-1; + long connindex=-1; + long score; + struct timeval now; + + now = Curl_tvnow(); + + for(i=0; i< data->state.numconnects; i++) { + conn = data->state.connects[i]; + + if(!conn) + continue; + + /* + * By using the set policy, we score each connection. + */ + switch(data->set.closepolicy) { + case CURLCLOSEPOLICY_LEAST_RECENTLY_USED: + default: + /* + * Set higher score for the age passed since the connection + * was used. + */ + score = Curl_tvdiff(now, conn->now); + break; + case CURLCLOSEPOLICY_OLDEST: + /* + * Set higher score for the age passed since the connection + * was created. + */ + score = Curl_tvdiff(now, conn->created); + break; + } + + if(score > highscore) { + highscore = score; + connindex = i; + } + } + if(connindex >= 0) { + + /* the winner gets the honour of being disconnected */ + (void) Curl_disconnect(data->state.connects[connindex]); + + /* clean the array entry */ + data->state.connects[connindex] = NULL; + } + + return connindex; /* return the available index or -1 */ +} + +/* + * The given input connection struct pointer is to be stored. If the "cache" + * is already full, we must clean out the most suitable using the previously + * set policy. + * + * The given connection should be unique. That must've been checked prior to + * this call. + */ +static long +ConnectionStore(struct SessionHandle *data, + struct connectdata *conn) +{ + long i; + for(i=0; i< data->state.numconnects; i++) { + if(!data->state.connects[i]) + break; + } + if(i == data->state.numconnects) { + /* there was no room available, kill one */ + i = ConnectionKillOne(data); + infof(data, "Connection (#%d) was killed to make room\n", i); + } + + if(-1 != i) { + /* only do this if a true index was returned, if -1 was returned there + is no room in the cache for an unknown reason and we cannot store + this there. */ + data->state.connects[i] = conn; /* fill in this */ + conn->connectindex = i; /* make the child know where the pointer to this + particular data is stored */ + } + return i; +} + +/* + * This function logs in to a SOCKS5 proxy and sends the specifies the final + * desitination server. + */ +static int handleSock5Proxy(const char *proxy_name, + const char *proxy_password, + struct connectdata *conn) +{ + /* + According to the RFC1928, section "6. Replies". This is what a SOCK5 + replies: + + +----+-----+-------+------+----------+----------+ + |VER | REP | RSV | ATYP | BND.ADDR | BND.PORT | + +----+-----+-------+------+----------+----------+ + | 1 | 1 | X'00' | 1 | Variable | 2 | + +----+-----+-------+------+----------+----------+ + + Where: + + o VER protocol version: X'05' + o REP Reply field: + o X'00' succeeded + */ + + unsigned char socksreq[600]; /* room for large user/pw (255 max each) */ + ssize_t actualread; + ssize_t written; + int result; + CURLcode code; + int sock = conn->sock[FIRSTSOCKET]; + + Curl_nonblock(sock, FALSE); + + socksreq[0] = 5; /* version */ + socksreq[1] = (char)(proxy_name ? 2 : 1); /* number of methods (below) */ + socksreq[2] = 0; /* no authentication */ + socksreq[3] = 2; /* username/password */ + + code = Curl_write(conn, sock, (char *)socksreq, (2 + (int)socksreq[1]), + &written); + if ((code != CURLE_OK) || (written != (2 + (int)socksreq[1]))) { + failf(conn->data, "Unable to send initial SOCKS5 request."); + return 1; + } + + result=Curl_read(conn, sock, (char *)socksreq, 2, &actualread); + if ((result != CURLE_OK) || (actualread != 2)) { + failf(conn->data, "Unable to receive initial SOCKS5 response."); + return 1; + } + + if (socksreq[0] != 5) { + failf(conn->data, "Received invalid version in initial SOCKS5 response."); + return 1; + } + if (socksreq[1] == 0) { + /* Nothing to do, no authentication needed */ + ; + } + else if (socksreq[1] == 2) { + /* Needs user name and password */ + int userlen, pwlen, len; + + userlen = (int)strlen(proxy_name); + pwlen = proxy_password?(int)strlen(proxy_password):0; + + /* username/password request looks like + * +----+------+----------+------+----------+ + * |VER | ULEN | UNAME | PLEN | PASSWD | + * +----+------+----------+------+----------+ + * | 1 | 1 | 1 to 255 | 1 | 1 to 255 | + * +----+------+----------+------+----------+ + */ + len = 0; + socksreq[len++] = 1; /* username/pw subnegotiation version */ + socksreq[len++] = (char) userlen; + memcpy(socksreq + len, proxy_name, (int) userlen); + len += userlen; + socksreq[len++] = (char) pwlen; + memcpy(socksreq + len, proxy_password, (int) pwlen); + len += pwlen; + + code = Curl_write(conn, sock, (char *)socksreq, len, &written); + if ((code != CURLE_OK) || (len != written)) { + failf(conn->data, "Failed to send SOCKS5 sub-negotiation request."); + return 1; + } + + result=Curl_read(conn, sock, (char *)socksreq, 2, &actualread); + if ((result != CURLE_OK) || (actualread != 2)) { + failf(conn->data, "Unable to receive SOCKS5 sub-negotiation response."); + return 1; + } + + if ((socksreq[0] != 5) || /* version */ + (socksreq[1] != 0)) { /* status */ + failf(conn->data, "User was rejected by the SOCKS5 server (%d %d).", + socksreq[0], socksreq[1]); + return 1; + } + + /* Everything is good so far, user was authenticated! */ + } + else { + /* error */ + if (socksreq[1] == 1) { + failf(conn->data, + "SOCKS5 GSSAPI per-message authentication is not supported."); + return 1; + } + else if (socksreq[1] == 255) { + if (proxy_name[0] == 0) { + failf(conn->data, + "No authentication method was acceptable. (It is quite likely" + " that the SOCKS5 server wanted a username/password, since none" + " was supplied to the server on this connection.)"); + } + else { + failf(conn->data, "No authentication method was acceptable."); + } + return 1; + } + else { + failf(conn->data, + "Undocumented SOCKS5 mode attempted to be used by server."); + return 1; + } + } + + /* Authentication is complete, now specify destination to the proxy */ + socksreq[0] = 5; /* version (SOCKS5) */ + socksreq[1] = 1; /* connect */ + socksreq[2] = 0; /* must be zero */ + socksreq[3] = 1; /* IPv4 = 1 */ + + { + struct Curl_dns_entry *dns; + Curl_addrinfo *hp=NULL; + int rc = Curl_resolv(conn, conn->host.name, (int)conn->remote_port, &dns); + + if(rc == CURLRESOLV_ERROR) + return 1; + + if(rc == CURLRESOLV_PENDING) + /* this requires that we're in "wait for resolve" state */ + rc = Curl_wait_for_resolv(conn, &dns); + (void)rc; + + /* + * We cannot use 'hostent' as a struct that Curl_resolv() returns. It + * returns a Curl_addrinfo pointer that may not always look the same. + */ + if(dns) + hp=dns->addr; + if (hp) { + char buf[64]; + unsigned short ip[4]; + Curl_printable_address(hp, buf, sizeof(buf)); + + if(4 == sscanf( buf, "%hu.%hu.%hu.%hu", + &ip[0], &ip[1], &ip[2], &ip[3])) { + socksreq[4] = (unsigned char)ip[0]; + socksreq[5] = (unsigned char)ip[1]; + socksreq[6] = (unsigned char)ip[2]; + socksreq[7] = (unsigned char)ip[3]; + } + else + hp = NULL; /* fail! */ + + Curl_resolv_unlock(conn->data, dns); /* not used anymore from now on */ + } + if(!hp) { + failf(conn->data, "Failed to resolve \"%s\" for SOCKS5 connect.", + conn->host.name); + return 1; + } + } + + { + unsigned short s = htons(conn->remote_port); + memcpy(socksreq+8, &s, sizeof(unsigned short)); + } + + { + const int packetsize = 10; + + code = Curl_write(conn, sock, (char *)socksreq, packetsize, &written); + if ((code != CURLE_OK) || (written != packetsize)) { + failf(conn->data, "Failed to send SOCKS5 connect request."); + return 1; + } + + result = Curl_read(conn, sock, (char *)socksreq, packetsize, &actualread); + if ((result != CURLE_OK) || (actualread != packetsize)) { + failf(conn->data, "Failed to receive SOCKS5 connect request ack."); + return 1; + } + + if (socksreq[0] != 5) { /* version */ + failf(conn->data, + "SOCKS5 reply has wrong version, version should be 5."); + return 1; + } + if (socksreq[1] != 0) { /* Anything besides 0 is an error */ + unsigned short sh; + memcpy(&sh, socksreq+8, sizeof(unsigned short)); + + failf(conn->data, + "Can't complete SOCKS5 connection to %d.%d.%d.%d:%d. (%d)", + (unsigned char)socksreq[4], (unsigned char)socksreq[5], + (unsigned char)socksreq[6], (unsigned char)socksreq[7], + (unsigned int)ntohs(sh), + socksreq[1]); + return 1; + } + } + + Curl_nonblock(sock, TRUE); + return 0; /* Proxy was successful! */ +} + +static CURLcode ConnectPlease(struct connectdata *conn, + struct Curl_dns_entry *hostaddr, + bool *connected) +{ + CURLcode result; + Curl_addrinfo *addr; + struct SessionHandle *data = conn->data; + char *hostname = data->change.proxy?conn->proxy.name:conn->host.name; + + infof(data, "About to connect() to %s port %d\n", + hostname, conn->port); + + /************************************************************* + * Connect to server/proxy + *************************************************************/ + result= Curl_connecthost(conn, + hostaddr, + &conn->sock[FIRSTSOCKET], + &addr, + connected); + if(CURLE_OK == result) { + /* All is cool, then we store the current information */ + conn->dns_entry = hostaddr; + conn->ip_addr = addr; + + if (conn->data->set.proxytype == CURLPROXY_SOCKS5) { + return handleSock5Proxy(conn->proxyuser, + conn->proxypasswd, + conn) ? + CURLE_COULDNT_CONNECT : CURLE_OK; + } + else if (conn->data->set.proxytype == CURLPROXY_HTTP) { + /* do nothing here. handled later. */ + } + else { + failf(conn->data, "unknown proxytype option given"); + return CURLE_COULDNT_CONNECT; + } + } + + return result; +} + +/* + * verboseconnect() displays verbose information after a connect + */ +static void verboseconnect(struct connectdata *conn) +{ + struct SessionHandle *data = conn->data; + char addrbuf[256]; + + /* Get a printable version of the network address. */ + Curl_printable_address(conn->ip_addr, addrbuf, sizeof(addrbuf)); + infof(data, "Connected to %s (%s) port %d\n", + conn->bits.httpproxy ? conn->proxy.dispname : conn->host.dispname, + addrbuf[0] ? addrbuf : "??", conn->port); +} + +/* + * We have discovered that the TCP connection has been successful, we can now + * proceed with some action. + * + * If we're using the multi interface, this host address pointer is most + * likely NULL at this point as we can't keep the resolved info around. This + * may call for some reworking, like a reference counter in the struct or + * something. + */ +CURLcode Curl_protocol_connect(struct connectdata *conn) +{ + struct SessionHandle *data = conn->data; + CURLcode result=CURLE_OK; + + if(conn->bits.tcpconnect) + /* We already are connected, get back. This may happen when the connect + worked fine in the first call, like when we connect to a local server + or proxy. */ + return CURLE_OK; + + Curl_pgrsTime(data, TIMER_CONNECT); /* connect done */ + + if(data->set.verbose) + verboseconnect(conn); + + if(conn->curl_connect) { + /* is there a protocol-specific connect() procedure? */ + + /* set start time here for timeout purposes in the + * connect procedure, it is later set again for the + * progress meter purpose */ + conn->now = Curl_tvnow(); + + /* Call the protocol-specific connect function */ + result = conn->curl_connect(conn); + } + + return result; /* pass back status */ +} + +/* + * Helpers for IDNA convertions. + */ +#ifdef USE_LIBIDN +static bool is_ASCII_name (const char *hostname) +{ + const unsigned char *ch = (const unsigned char*)hostname; + + while (*ch) { + if (*ch++ & 0x80) + return FALSE; + } + return TRUE; +} +#endif + +static void fix_hostname(struct connectdata *conn, struct hostname *host) +{ + /* set the name we use to display the host name */ + host->dispname = host->name; + +#ifdef USE_LIBIDN + /************************************************************* + * Check name for non-ASCII and convert hostname to ACE form. + *************************************************************/ + if (!is_ASCII_name(host->name) && + stringprep_check_version(LIBIDN_REQUIRED_VERSION)) { + char *ace_hostname = NULL; + struct SessionHandle *data = conn->data; + int rc = idna_to_ascii_lz(host->name, &ace_hostname, 0); + infof (data, "Input domain encoded as `%s'\n", + stringprep_locale_charset ()); + if (rc != IDNA_SUCCESS) + infof(data, "Failed to convert %s to ACE; IDNA error %d\n", + host->name, rc); + else { + host->encalloc = ace_hostname; + /* change the name pointer to point to the encoded hostname */ + host->name = host->encalloc; + } + } +#else + (void)conn; /* never used */ +#endif +} + + +/** + * CreateConnection() sets up a new connectdata struct, or re-uses an already + * existing one, and resolves host name. + * + * if this function returns CURLE_OK and *async is set to TRUE, the resolve + * response will be coming asynchronously. If *async is FALSE, the name is + * already resolved. + * + * @param data The sessionhandle pointer + * @param in_connect is set to the next connection data pointer + * @param addr is set to the new dns entry for this connection + * @param async is set TRUE/FALSE depending on the nature of this lookup + * @return CURLcode + * @see SetupConnection() + */ + +static CURLcode CreateConnection(struct SessionHandle *data, + struct connectdata **in_connect, + struct Curl_dns_entry **addr, + bool *async) +{ + char *tmp; + CURLcode result=CURLE_OK; + struct connectdata *conn; + struct connectdata *conn_temp; + size_t urllen; + struct Curl_dns_entry *hostaddr; +#if defined(HAVE_ALARM) && !defined(USE_ARES) + unsigned int prev_alarm=0; +#endif + char endbracket; + char user[MAX_CURL_USER_LENGTH]; + char passwd[MAX_CURL_PASSWORD_LENGTH]; + int rc; + bool reuse; + +#ifndef USE_ARES +#ifdef SIGALRM +#ifdef HAVE_SIGACTION + struct sigaction keep_sigact; /* store the old struct here */ + bool keep_copysig=FALSE; /* did copy it? */ +#else +#ifdef HAVE_SIGNAL + void *keep_sigact; /* store the old handler here */ +#endif /* HAVE_SIGNAL */ +#endif /* HAVE_SIGACTION */ +#endif /* SIGALRM */ +#endif /* USE_ARES */ + + *addr = NULL; /* nothing yet */ + *async = FALSE; + + /************************************************************* + * Check input data + *************************************************************/ + + if(!data->change.url) + return CURLE_URL_MALFORMAT; + + /* First, split up the current URL in parts so that we can use the + parts for checking against the already present connections. In order + to not have to modify everything at once, we allocate a temporary + connection data struct and fill in for comparison purposes. */ + + conn = (struct connectdata *)malloc(sizeof(struct connectdata)); + if(!conn) { + *in_connect = NULL; /* clear the pointer */ + return CURLE_OUT_OF_MEMORY; + } + /* We must set the return variable as soon as possible, so that our + parent can cleanup any possible allocs we may have done before + any failure */ + *in_connect = conn; + + /* we have to init the struct */ + memset(conn, 0, sizeof(struct connectdata)); + + /* and we setup a few fields in case we end up actually using this struct */ + conn->data = data; /* remember our daddy */ + conn->sock[FIRSTSOCKET] = CURL_SOCKET_BAD; /* no file descriptor */ + conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD; /* no file descriptor */ + conn->connectindex = -1; /* no index */ + conn->bits.httpproxy = (data->change.proxy && *data->change.proxy && + (data->set.proxytype == CURLPROXY_HTTP))? + TRUE:FALSE; /* http proxy or not */ + + /* Default protocol-independent behavior doesn't support persistant + connections, so we set this to force-close. Protocols that support + this need to set this to FALSE in their "curl_do" functions. */ + conn->bits.close = TRUE; + + /* maxdownload must be -1 on init, as 0 is a valid value! */ + conn->maxdownload = -1; /* might have been used previously! */ + + /* Store creation time to help future close decision making */ + conn->created = Curl_tvnow(); + + conn->bits.use_range = data->set.set_range?TRUE:FALSE; /* range status */ + conn->range = data->set.set_range; /* clone the range setting */ + conn->resume_from = data->set.set_resume_from; /* inherite resume_from */ + + /* Set the start time temporary to this creation time to allow easier + timeout checks before the transfer has started for real. The start time + is later set "for real" using Curl_pgrsStartNow(). */ + conn->data->progress.start = conn->created; + + conn->bits.user_passwd = data->set.userpwd?1:0; + conn->bits.proxy_user_passwd = data->set.proxyuserpwd?1:0; + conn->bits.no_body = data->set.opt_no_body; + conn->bits.tunnel_proxy = data->set.tunnel_thru_httpproxy; + + /* This initing continues below, see the comment "Continue connectdata + * initialization here" */ + + /*********************************************************** + * We need to allocate memory to store the path in. We get the size of the + * full URL to be sure, and we need to make it at least 256 bytes since + * other parts of the code will rely on this fact + ***********************************************************/ +#define LEAST_PATH_ALLOC 256 + urllen=strlen(data->change.url); + if(urllen < LEAST_PATH_ALLOC) + urllen=LEAST_PATH_ALLOC; + + conn->pathbuffer=(char *)malloc(urllen); + if(NULL == conn->pathbuffer) + return CURLE_OUT_OF_MEMORY; /* really bad error */ + conn->path = conn->pathbuffer; + + conn->host.rawalloc=(char *)malloc(urllen); + if(NULL == conn->host.rawalloc) + return CURLE_OUT_OF_MEMORY; + conn->host.name = conn->host.rawalloc; + + /************************************************************* + * Parse the URL. + * + * We need to parse the url even when using the proxy, because we will need + * the hostname and port in case we are trying to SSL connect through the + * proxy -- and we don't know if we will need to use SSL until we parse the + * url ... + ************************************************************/ + if((2 == sscanf(data->change.url, "%15[^:]:%[^\n]", + conn->protostr, + conn->path)) && strequal(conn->protostr, "file")) { + if(conn->path[0] == '/' && conn->path[1] == '/') { + /* Allow omitted hostname (e.g. file:/). This is not strictly + * speaking a valid file: URL by RFC 1738, but treating file:/ as + * file://localhost/ is similar to how other schemes treat missing + * hostnames. See RFC 1808. */ + + /* This cannot be done with strcpy() in a portable manner, since the + memory areas overlap! */ + memmove(conn->path, conn->path + 2, strlen(conn->path + 2)+1); + } + /* + * we deal with file:/// differently since it supports no + * hostname other than "localhost" and "127.0.0.1", which is unique among + * the URL protocols specified in RFC 1738 + */ + if(conn->path[0] != '/') { + /* the URL included a host name, we ignore host names in file:// URLs + as the standards don't define what to do with them */ + char *ptr=strchr(conn->path, '/'); + if(ptr) { + /* there was a slash present + + RFC1738 (section 3.1, page 5) says: + + The rest of the locator consists of data specific to the scheme, + and is known as the "url-path". It supplies the details of how the + specified resource can be accessed. Note that the "/" between the + host (or port) and the url-path is NOT part of the url-path. + + As most agents use file://localhost/foo to get '/foo' although the + slash preceeding foo is a separator and not a slash for the path, + a URL as file://localhost//foo must be valid as well, to refer to + the same file with an absolute path. + */ + + if(ptr[1] && ('/' == ptr[1])) + /* if there was two slashes, we skip the first one as that is then + used truly as a separator */ + ptr++; + + /* This cannot be made with strcpy, as the memory chunks overlap! */ + memmove(conn->path, ptr, strlen(ptr)+1); + } + } + + strcpy(conn->protostr, "file"); /* store protocol string lowercase */ + } + else { + /* Set default path */ + strcpy(conn->path, "/"); + + /* We need to search for '/' OR '?' - whichever comes first after host + * name but before the path. We need to change that to handle things like + * http://example.com?param= (notice the missing '/'). Later we'll insert + * that missing slash at the beginning of the path. + */ + if (2 > sscanf(data->change.url, + "%15[^\n:]://%[^\n/?]%[^\n]", + conn->protostr, + conn->host.name, conn->path)) { + + /* + * The URL was badly formatted, let's try the browser-style _without_ + * protocol specified like 'http://'. + */ + if((1 > sscanf(data->change.url, "%[^\n/?]%[^\n]", + conn->host.name, conn->path)) ) { + /* + * We couldn't even get this format. + */ + failf(data, " malformed"); + return CURLE_URL_MALFORMAT; + } + + /* + * Since there was no protocol part specified, we guess what protocol it + * is based on the first letters of the server name. + */ + + /* Note: if you add a new protocol, please update the list in + * lib/version.c too! */ + + if(checkprefix("GOPHER", conn->host.name)) + strcpy(conn->protostr, "gopher"); +#ifdef USE_SSLEAY + else if(checkprefix("HTTPS", conn->host.name)) + strcpy(conn->protostr, "https"); + else if(checkprefix("FTPS", conn->host.name)) + strcpy(conn->protostr, "ftps"); +#endif /* USE_SSLEAY */ + else if(checkprefix("FTP", conn->host.name)) + strcpy(conn->protostr, "ftp"); + else if(checkprefix("TELNET", conn->host.name)) + strcpy(conn->protostr, "telnet"); + else if (checkprefix("DICT", conn->host.name)) + strcpy(conn->protostr, "DICT"); + else if (checkprefix("LDAP", conn->host.name)) + strcpy(conn->protostr, "LDAP"); + else { + strcpy(conn->protostr, "http"); + } + + conn->protocol |= PROT_MISSING; /* not given in URL */ + } + } + + /* If the URL is malformatted (missing a '/' after hostname before path) we + * insert a slash here. The only letter except '/' we accept to start a path + * is '?'. + */ + if(conn->path[0] == '?') { + /* We need this function to deal with overlapping memory areas. We know + that the memory area 'path' points to is 'urllen' bytes big and that + is bigger than the path. Use +1 to move the zero byte too. */ + memmove(&conn->path[1], conn->path, strlen(conn->path)+1); + conn->path[0] = '/'; + } + + /* + * So if the URL was A://B/C, + * conn->protostr is A + * conn->host.name is B + * conn->path is /C + */ + + /************************************************************* + * Take care of proxy authentication stuff + *************************************************************/ + if(conn->bits.proxy_user_passwd) { + char proxyuser[MAX_CURL_USER_LENGTH]=""; + char proxypasswd[MAX_CURL_PASSWORD_LENGTH]=""; + + sscanf(data->set.proxyuserpwd, + "%" MAX_CURL_USER_LENGTH_TXT "[^:]:" + "%" MAX_CURL_PASSWORD_LENGTH_TXT "[^\n]", + proxyuser, proxypasswd); + + conn->proxyuser = strdup(proxyuser); + if(!conn->proxyuser) + return CURLE_OUT_OF_MEMORY; + + conn->proxypasswd = strdup(proxypasswd); + if(!conn->proxypasswd) + return CURLE_OUT_OF_MEMORY; + } + + /************************************************************* + * Detect what (if any) proxy to use + *************************************************************/ + if(!data->change.proxy) { + /* If proxy was not specified, we check for default proxy environment + * variables, to enable i.e Lynx compliance: + * + * http_proxy=http://some.server.dom:port/ + * https_proxy=http://some.server.dom:port/ + * ftp_proxy=http://some.server.dom:port/ + * gopher_proxy=http://some.server.dom:port/ + * no_proxy=domain1.dom,host.domain2.dom + * (a comma-separated list of hosts which should + * not be proxied, or an asterisk to override + * all proxy variables) + * all_proxy=http://some.server.dom:port/ + * (seems to exist for the CERN www lib. Probably + * the first to check for.) + * + * For compatibility, the all-uppercase versions of these variables are + * checked if the lowercase versions don't exist. + */ + char *no_proxy; + char *no_proxy_tok_buf; + char *proxy=NULL; + char proxy_env[128]; + (void)proxy; + + no_proxy=curl_getenv("no_proxy"); + if(!no_proxy) + no_proxy=curl_getenv("NO_PROXY"); + + if(!no_proxy || !strequal("*", no_proxy)) { + /* NO_PROXY wasn't specified or it wasn't just an asterisk */ + char *nope; + + nope=no_proxy?strtok_r(no_proxy, ", ", &no_proxy_tok_buf):NULL; + while(nope) { + size_t namelen; + char *endptr = strchr(conn->host.name, ':'); + if(endptr) + namelen=endptr-conn->host.name; + else + namelen=strlen(conn->host.name); + + if(strlen(nope) <= namelen) { + char *checkn= + conn->host.name + namelen - strlen(nope); + if(checkprefix(nope, checkn)) { + /* no proxy for this host! */ + break; + } + } + nope=strtok_r(NULL, ", ", &no_proxy_tok_buf); + } + if(!nope) { + /* It was not listed as without proxy */ + char *protop = conn->protostr; + char *envp = proxy_env; + char *prox; + + /* Now, build _proxy and check for such a one to use */ + while(*protop) + *envp++ = tolower((int)*protop++); + + /* append _proxy */ + strcpy(envp, "_proxy"); + + /* read the protocol proxy: */ + prox=curl_getenv(proxy_env); + + /* + * We don't try the uppercase version of HTTP_PROXY because of + * security reasons: + * + * When curl is used in a webserver application + * environment (cgi or php), this environment variable can + * be controlled by the web server user by setting the + * http header 'Proxy:' to some value. + * + * This can cause 'internal' http/ftp requests to be + * arbitrarily redirected by any external attacker. + */ + if(!prox && !strequal("http_proxy", proxy_env)) { + /* There was no lowercase variable, try the uppercase version: */ + for(envp = proxy_env; *envp; envp++) + *envp = toupper((int)*envp); + prox=curl_getenv(proxy_env); + } + + if(prox && *prox) { /* don't count "" strings */ + proxy = prox; /* use this */ + } + else { + proxy = curl_getenv("all_proxy"); /* default proxy to use */ + if(!proxy) + proxy=curl_getenv("ALL_PROXY"); + } + + if(proxy && *proxy) { + /* we have a proxy here to set */ + char *ptr; + char proxyuser[MAX_CURL_USER_LENGTH]; + char proxypasswd[MAX_CURL_PASSWORD_LENGTH]; + + char *fineptr; + + /* skip the possible protocol piece */ + ptr=strstr(proxy, "://"); + if(ptr) + ptr += 3; + else + ptr = proxy; + + fineptr = ptr; + + /* check for an @-letter */ + ptr = strchr(ptr, '@'); + if(ptr && (2 == sscanf(fineptr, + "%" MAX_CURL_USER_LENGTH_TXT"[^:]:" + "%" MAX_CURL_PASSWORD_LENGTH_TXT "[^@]", + proxyuser, proxypasswd))) { + CURLcode res = CURLE_OK; + + /* found user and password, rip them out */ + Curl_safefree(conn->proxyuser); + conn->proxyuser = strdup(proxyuser); + + if(!conn->proxyuser) + res = CURLE_OUT_OF_MEMORY; + else { + Curl_safefree(conn->proxypasswd); + conn->proxypasswd = strdup(proxypasswd); + + if(!conn->proxypasswd) + res = CURLE_OUT_OF_MEMORY; + } + + if(CURLE_OK == res) { + conn->bits.proxy_user_passwd = TRUE; /* enable it */ + ptr = strdup(ptr+1); /* the right side of the @-letter */ + + if(ptr) { + free(proxy); /* free the former proxy string */ + proxy = ptr; /* now use this instead */ + } + else + res = CURLE_OUT_OF_MEMORY; + } + + if(res) { + free(proxy); /* free the allocated proxy string */ + return res; + } + } + + data->change.proxy = proxy; + data->change.proxy_alloc=TRUE; /* this needs to be freed later */ + conn->bits.httpproxy = TRUE; + } + } /* if (!nope) - it wasn't specified non-proxy */ + } /* NO_PROXY wasn't specified or '*' */ + if(no_proxy) + free(no_proxy); + } /* if not using proxy */ + + /************************************************************* + * No protocol part in URL was used, add it! + *************************************************************/ + if(conn->protocol&PROT_MISSING) { + /* We're guessing prefixes here and if we're told to use a proxy or if + we're gonna follow a Location: later or... then we need the protocol + part added so that we have a valid URL. */ + char *reurl; + + reurl = aprintf("%s://%s", conn->protostr, data->change.url); + + if(!reurl) + return CURLE_OUT_OF_MEMORY; + + data->change.url = reurl; + data->change.url_alloc = TRUE; /* free this later */ + conn->protocol &= ~PROT_MISSING; /* switch that one off again */ + } + +#ifndef CURL_DISABLE_HTTP + /************************************************************ + * RESUME on a HTTP page is a tricky business. First, let's just check that + * 'range' isn't used, then set the range parameter and leave the resume as + * it is to inform about this situation for later use. We will then + * "attempt" to resume, and if we're talking to a HTTP/1.1 (or later) + * server, we will get the document resumed. If we talk to a HTTP/1.0 + * server, we just fail since we can't rewind the file writing from within + * this function. + ***********************************************************/ + if(conn->resume_from) { + if(!conn->bits.use_range) { + /* if it already was in use, we just skip this */ + conn->range = aprintf("%" FORMAT_OFF_T "-", conn->resume_from); + if(!conn->range) + return CURLE_OUT_OF_MEMORY; + conn->bits.rangestringalloc = TRUE; /* mark as allocated */ + conn->bits.use_range = 1; /* switch on range usage */ + } + } +#endif + /************************************************************* + * Setup internals depending on protocol + *************************************************************/ + + if (strequal(conn->protostr, "HTTP")) { +#ifndef CURL_DISABLE_HTTP + conn->port = (data->set.use_port && data->state.allow_port)? + data->set.use_port:PORT_HTTP; + conn->remote_port = PORT_HTTP; + conn->protocol |= PROT_HTTP; + conn->curl_do = Curl_http; + conn->curl_do_more = NULL; + conn->curl_done = Curl_http_done; + conn->curl_connect = Curl_http_connect; +#else + failf(data, LIBCURL_NAME + " was built with HTTP disabled, http: not supported!"); + return CURLE_UNSUPPORTED_PROTOCOL; +#endif + } + else if (strequal(conn->protostr, "HTTPS")) { +#if defined(USE_SSLEAY) && !defined(CURL_DISABLE_HTTP) + + conn->port = (data->set.use_port && data->state.allow_port)? + data->set.use_port:PORT_HTTPS; + conn->remote_port = PORT_HTTPS; + conn->protocol |= PROT_HTTP|PROT_HTTPS|PROT_SSL; + + conn->curl_do = Curl_http; + conn->curl_do_more = NULL; + conn->curl_done = Curl_http_done; + conn->curl_connect = Curl_http_connect; + +#else /* USE_SSLEAY */ + failf(data, LIBCURL_NAME + " was built with SSL disabled, https: not supported!"); + return CURLE_UNSUPPORTED_PROTOCOL; +#endif /* !USE_SSLEAY */ + } + else if (strequal(conn->protostr, "GOPHER")) { +#ifndef CURL_DISABLE_GOPHER + conn->port = (data->set.use_port && data->state.allow_port)? + data->set.use_port:PORT_GOPHER; + conn->remote_port = PORT_GOPHER; + /* Skip // in path if present */ + if (isdigit((int)conn->path[1])) { + conn->path = strchr(&conn->path[1], '/'); + if (conn->path == NULL) + conn->path = conn->pathbuffer; + } + conn->protocol |= PROT_GOPHER; + conn->curl_do = Curl_http; + conn->curl_do_more = NULL; + conn->curl_done = Curl_http_done; +#else + failf(data, LIBCURL_NAME + " was built with GOPHER disabled, gopher: not supported!"); +#endif + } + else if(strequal(conn->protostr, "FTP") || + strequal(conn->protostr, "FTPS")) { + +#ifndef CURL_DISABLE_FTP + char *type; + int port = PORT_FTP; + + if(strequal(conn->protostr, "FTPS")) { +#ifdef USE_SSLEAY + conn->protocol |= PROT_FTPS|PROT_SSL; + conn->ssl[SECONDARYSOCKET].use = TRUE; /* send data securely */ + port = PORT_FTPS; +#else + failf(data, LIBCURL_NAME + " was built with SSL disabled, ftps: not supported!"); + return CURLE_UNSUPPORTED_PROTOCOL; +#endif /* !USE_SSLEAY */ + } + + conn->port = (data->set.use_port && data->state.allow_port)? + data->set.use_port:port; + conn->remote_port = port; + conn->protocol |= PROT_FTP; + + if(data->change.proxy && + *data->change.proxy && + !data->set.tunnel_thru_httpproxy) { + /* Unless we have asked to tunnel ftp operations through the proxy, we + switch and use HTTP operations only */ + if(conn->protocol & PROT_FTPS) { + /* FTPS is a hacked protocol and does not work through your + ordinary http proxy! */ + failf(data, "ftps does not work through http proxy!"); + return CURLE_UNSUPPORTED_PROTOCOL; + } +#ifndef CURL_DISABLE_HTTP + conn->curl_do = Curl_http; + conn->curl_done = Curl_http_done; +#else + failf(data, "FTP over http proxy requires HTTP support built-in!"); + return CURLE_UNSUPPORTED_PROTOCOL; +#endif + } + else { + conn->curl_do = Curl_ftp; + conn->curl_do_more = Curl_ftp_nextconnect; + conn->curl_done = Curl_ftp_done; + conn->curl_connect = Curl_ftp_connect; + conn->curl_disconnect = Curl_ftp_disconnect; + } + + conn->path++; /* don't include the initial slash */ + + /* FTP URLs support an extension like ";type=" that + * we'll try to get now! */ + type=strstr(conn->path, ";type="); + if(!type) { + type=strstr(conn->host.rawalloc, ";type="); + } + if(type) { + char command; + *type=0; /* it was in the middle of the hostname */ + command = toupper((int)type[6]); + switch(command) { + case 'A': /* ASCII mode */ + data->set.ftp_ascii = 1; + break; + case 'D': /* directory mode */ + data->set.ftp_list_only = 1; + break; + case 'I': /* binary mode */ + default: + /* switch off ASCII */ + data->set.ftp_ascii = 0; + break; + } + } +#else /* CURL_DISABLE_FTP */ + failf(data, LIBCURL_NAME + " was built with FTP disabled, ftp/ftps: not supported!"); + return CURLE_UNSUPPORTED_PROTOCOL; +#endif + } + else if(strequal(conn->protostr, "TELNET")) { +#ifndef CURL_DISABLE_TELNET + /* telnet testing factory */ + conn->protocol |= PROT_TELNET; + + conn->port = (data->set.use_port && data->state.allow_port)? + data->set.use_port: PORT_TELNET; + conn->remote_port = PORT_TELNET; + conn->curl_do = Curl_telnet; + conn->curl_done = Curl_telnet_done; +#else + failf(data, LIBCURL_NAME + " was built with TELNET disabled!"); +#endif + } + else if (strequal(conn->protostr, "DICT")) { +#ifndef CURL_DISABLE_DICT + conn->protocol |= PROT_DICT; + conn->port = (data->set.use_port && data->state.allow_port)? + data->set.use_port:PORT_DICT; + conn->remote_port = PORT_DICT; + conn->curl_do = Curl_dict; + conn->curl_done = NULL; /* no DICT-specific done */ +#else + failf(data, LIBCURL_NAME + " was built with DICT disabled!"); +#endif + } + else if (strequal(conn->protostr, "LDAP")) { +#ifndef CURL_DISABLE_LDAP + conn->protocol |= PROT_LDAP; + conn->port = (data->set.use_port && data->state.allow_port)? + data->set.use_port:PORT_LDAP; + conn->remote_port = PORT_LDAP; + conn->curl_do = Curl_ldap; + conn->curl_done = NULL; /* no LDAP-specific done */ +#else + failf(data, LIBCURL_NAME + " was built with LDAP disabled!"); +#endif + } + else if (strequal(conn->protostr, "FILE")) { +#ifndef CURL_DISABLE_FILE + conn->protocol |= PROT_FILE; + + conn->curl_do = Curl_file; + conn->curl_done = Curl_file_done; + + /* anyway, this is supposed to be the connect function so we better + at least check that the file is present here! */ + result = Curl_file_connect(conn); + + /* Setup a "faked" transfer that'll do nothing */ + if(CURLE_OK == result) { + conn->bits.tcpconnect = TRUE; /* we are "connected */ + result = Curl_Transfer(conn, -1, -1, FALSE, NULL, /* no download */ + -1, NULL); /* no upload */ + } + + return result; +#else + failf(data, LIBCURL_NAME + " was built with FILE disabled!"); +#endif + } + else { + /* We fell through all checks and thus we don't support the specified + protocol */ + failf(data, "Unsupported protocol: %s", conn->protostr); + return CURLE_UNSUPPORTED_PROTOCOL; + } + + /************************************************************* + * Figure out the remote port number + * + * No matter if we use a proxy or not, we have to figure out the remote + * port number of various reasons. + * + * To be able to detect port number flawlessly, we must not confuse them + * IPv6-specified addresses in the [0::1] style. (RFC2732) + * + * The conn->host.name is currently [user:passwd@]host[:port] where host + * could be a hostname, IPv4 address or IPv6 address. + *************************************************************/ + if((1 == sscanf(conn->host.name, "[%*39[0-9a-fA-F:.]%c", &endbracket)) && + (']' == endbracket)) { + /* this is a RFC2732-style specified IP-address */ + conn->bits.ipv6_ip = TRUE; + + conn->host.name++; /* pass the starting bracket */ + tmp = strchr(conn->host.name, ']'); + *tmp = 0; /* zero terminate */ + tmp++; /* pass the ending bracket */ + if(':' != *tmp) + tmp = NULL; /* no port number available */ + } + else + tmp = strrchr(conn->host.name, ':'); + + if (tmp) { + char *rest; + unsigned long port; + + port=strtoul(tmp+1, &rest, 10); /* Port number must be decimal */ + + if (rest != (tmp+1) && *rest == '\0') { + /* The colon really did have only digits after it, + * so it is either a port number or a mistake */ + + if (port > 0xffff) { /* Single unix standard says port numbers are + * 16 bits long */ + failf(data, "Port number too large: %lu", port); + return CURLE_URL_MALFORMAT; + } + + *tmp = '\0'; /* cut off the name there */ + conn->remote_port = (unsigned short)port; + } + } + + if(data->change.proxy && *data->change.proxy) { + /* If this is supposed to use a proxy, we need to figure out the proxy + host name name, so that we can re-use an existing connection + that may exist registered to the same proxy host. */ + + char *prox_portno; + char *endofprot; + + /* We need to make a duplicate of the proxy so that we can modify the + string safely. */ + char *proxydup=strdup(data->change.proxy); + + /* We use 'proxyptr' to point to the proxy name from now on... */ + char *proxyptr=proxydup; + + if(NULL == proxydup) { + failf(data, "memory shortage"); + return CURLE_OUT_OF_MEMORY; + } + + /* Daniel Dec 10, 1998: + We do the proxy host string parsing here. We want the host name and the + port name. Accept a protocol:// prefix, even though it should just be + ignored. */ + + /* 1. skip the protocol part if present */ + endofprot=strstr(proxyptr, "://"); + if(endofprot) { + proxyptr = endofprot+3; + } + + /* allow user to specify proxy.server.com:1080 if desired */ + prox_portno = strchr (proxyptr, ':'); + if (prox_portno) { + *prox_portno = 0x0; /* cut off number from host name */ + prox_portno ++; + /* now set the local port number */ + conn->port = atoi(prox_portno); + } + else if(data->set.proxyport) { + /* None given in the proxy string, then get the default one if it is + given */ + conn->port = data->set.proxyport; + } + + /* now, clone the cleaned proxy host name */ + conn->proxy.rawalloc = strdup(proxyptr); + conn->proxy.name = conn->proxy.rawalloc; + + free(proxydup); /* free the duplicate pointer and not the modified */ + if(!conn->proxy.rawalloc) + return CURLE_OUT_OF_MEMORY; + } + + /************************************************************* + * If the protcol is using SSL and HTTP proxy is used, we set + * the tunnel_proxy bit. + *************************************************************/ + if((conn->protocol&PROT_SSL) && conn->bits.httpproxy) + conn->bits.tunnel_proxy = TRUE; + + /************************************************************* + * Take care of user and password authentication stuff + *************************************************************/ + + /* + * Inputs: data->set.userpwd (CURLOPT_USERPWD) + * data->set.fpasswd (CURLOPT_PASSWDFUNCTION) + * data->set.use_netrc (CURLOPT_NETRC) + * conn->host.name + * netrc file + * hard-coded defaults + * + * Outputs: (almost :- all currently undefined) + * conn->bits.user_passwd - non-zero if non-default passwords exist + * conn->user - non-zero length if defined + * conn->passwd - ditto + * conn->host.name - remove user name and password + */ + + /* At this point, we're hoping all the other special cases have + * been taken care of, so conn->host.name is at most + * [user[:password]]@]hostname + * + * We need somewhere to put the embedded details, so do that first. + */ + + user[0] =0; /* to make everything well-defined */ + passwd[0]=0; + + if (conn->protocol & (PROT_FTP|PROT_HTTP)) { + /* This is a FTP or HTTP URL, we will now try to extract the possible + * user+password pair in a string like: + * ftp://user:password@ftp.my.site:8021/README */ + char *ptr=strchr(conn->host.name, '@'); + char *userpass = conn->host.name; + if(ptr != NULL) { + /* there's a user+password given here, to the left of the @ */ + + conn->host.name = ++ptr; + + /* So the hostname is sane. Only bother interpreting the + * results if we could care. It could still be wasted + * work because it might be overtaken by the programmatically + * set user/passwd, but doing that first adds more cases here :-( + */ + + if (data->set.use_netrc != CURL_NETRC_REQUIRED) { + /* We could use the one in the URL */ + + conn->bits.user_passwd = 1; /* enable user+password */ + + if(*userpass != ':') { + /* the name is given, get user+password */ + sscanf(userpass, "%127[^:@]:%127[^@]", + user, passwd); + } + else + /* no name given, get the password only */ + sscanf(userpass, ":%127[^@]", passwd); + + if(user[0]) { + char *newname=curl_unescape(user, 0); + if(!newname) + return CURLE_OUT_OF_MEMORY; + if(strlen(newname) < sizeof(user)) + strcpy(user, newname); + + /* if the new name is longer than accepted, then just use + the unconverted name, it'll be wrong but what the heck */ + free(newname); + } + if (passwd[0]) { + /* we have a password found in the URL, decode it! */ + char *newpasswd=curl_unescape(passwd, 0); + if(!newpasswd) + return CURLE_OUT_OF_MEMORY; + if(strlen(newpasswd) < sizeof(passwd)) + strcpy(passwd, newpasswd); + + free(newpasswd); + } + } + } + } + + /* Programmatically set password: + * - always applies, if available + * - takes precedence over the values we just set above + * so scribble it over the top. + * User-supplied passwords are assumed not to need unescaping. + * + * user_password is set in "inherite initial knowledge' above, + * so it doesn't have to be set in this block + */ + if (data->set.userpwd != NULL) { + /* the name is given, get user+password */ + sscanf(data->set.userpwd, + "%" MAX_CURL_USER_LENGTH_TXT "[^:]:" + "%" MAX_CURL_PASSWORD_LENGTH_TXT "[^\n]", + user, passwd); + } + + if (data->set.use_netrc != CURL_NETRC_IGNORED) { + if(Curl_parsenetrc(conn->host.name, + user, passwd, + data->set.netrc_file)) { + infof(data, "Couldn't find host %s in the .netrc file, using defaults\n", + conn->host.name); + } + else + conn->bits.user_passwd = 1; /* enable user+password */ + } + + /* If our protocol needs a password and we have none, use the defaults */ + if ( (conn->protocol & PROT_FTP) && + !conn->bits.user_passwd) { + + conn->user = strdup(CURL_DEFAULT_USER); + conn->passwd = strdup(CURL_DEFAULT_PASSWORD); + /* This is the default password, so DON'T set conn->bits.user_passwd */ + } + else { + /* store user + password, zero-length if not set */ + conn->user = strdup(user); + conn->passwd = strdup(passwd); + } + if(!conn->user || !conn->passwd) + return CURLE_OUT_OF_MEMORY; + + /************************************************************* + * Check the current list of connections to see if we can + * re-use an already existing one or if we have to create a + * new one. + *************************************************************/ + + /* get a cloned copy of the SSL config situation stored in the + connection struct */ + if(!Curl_clone_ssl_config(&data->set.ssl, &conn->ssl_config)) + return CURLE_OUT_OF_MEMORY; + + /* reuse_fresh is TRUE if we are told to use a new connection by force, but + we only acknowledge this option if this is not a re-used connection + already (which happens due to follow-location or during a HTTP + authentication phase). */ + if(data->set.reuse_fresh && !data->state.this_is_a_follow) + reuse = FALSE; + else + reuse = ConnectionExists(data, conn, &conn_temp); + + if(reuse) { + /* + * We already have a connection for this, we got the former connection + * in the conn_temp variable and thus we need to cleanup the one we + * just allocated before we can move along and use the previously + * existing one. + */ + struct connectdata *old_conn = conn; + + if(old_conn->proxy.rawalloc) + free(old_conn->proxy.rawalloc); + + /* free the SSL config struct from this connection struct as this was + allocated in vain and is targeted for destruction */ + Curl_free_ssl_config(&conn->ssl_config); + + conn = conn_temp; /* use this connection from now on */ + + /* get the user+password information from the old_conn struct since it may + * be new for this request even when we re-use an existing connection */ + conn->bits.user_passwd = old_conn->bits.user_passwd; + conn->bits.proxy_user_passwd = old_conn->bits.proxy_user_passwd; + + /* host can change, when doing keepalive with a proxy ! */ + if (conn->bits.httpproxy) { + free(conn->host.rawalloc); + conn->host=old_conn->host; + } + + /* get the newly set value, not the old one */ + conn->bits.no_body = old_conn->bits.no_body; + + if (!conn->bits.httpproxy) + free(old_conn->host.rawalloc); /* free the newly allocated name buffer */ + + free(conn->pathbuffer); /* free the newly allocated path pointer */ + conn->pathbuffer = old_conn->pathbuffer; /* use the old one */ + conn->path = old_conn->path; + + /* re-use init */ + conn->bits.reuse = TRUE; /* yes, we're re-using here */ + conn->bits.chunk = FALSE; /* always assume not chunked unless told + otherwise */ + conn->maxdownload = -1; /* might have been used previously! */ + + Curl_safefree(old_conn->user); + Curl_safefree(old_conn->passwd); + Curl_safefree(old_conn->proxyuser); + Curl_safefree(old_conn->proxypasswd); + + if(old_conn->bits.rangestringalloc) + free(old_conn->range); + + free(old_conn); /* we don't need this anymore */ + + /* + * If we're doing a resumed transfer, we need to setup our stuff + * properly. + */ + conn->resume_from = data->set.set_resume_from; + if (conn->resume_from) { + if (conn->bits.rangestringalloc == TRUE) + free(conn->range); + conn->range = aprintf("%" FORMAT_OFF_T "-", conn->resume_from); + if(!conn->range) + return CURLE_OUT_OF_MEMORY; + + /* tell ourselves to fetch this range */ + conn->bits.use_range = TRUE; /* enable range download */ + conn->bits.rangestringalloc = TRUE; /* mark range string allocated */ + } + else if (data->set.set_range) { + /* There is a range, but is not a resume, useful for random ftp access */ + conn->range = strdup(data->set.set_range); + if(!conn->range) + return CURLE_OUT_OF_MEMORY; + conn->bits.rangestringalloc = TRUE; /* mark range string allocated */ + conn->bits.use_range = TRUE; /* enable range download */ + } + else + conn->bits.use_range = FALSE; /* disable range download */ + + *in_connect = conn; /* return this instead! */ + + infof(data, "Re-using existing connection! (#%ld) with host %s\n", + conn->connectindex, + conn->bits.httpproxy?conn->proxy.dispname:conn->host.dispname); + } + else { + /* + * This is a brand new connection, so let's store it in the connection + * cache of ours! + */ + ConnectionStore(data, conn); + } + + /* Continue connectdata initialization here. + * + * Inherit the proper values from the urldata struct AFTER we have arranged + * the persistant conncetion stuff */ + conn->fread = data->set.fread; + conn->fread_in = data->set.in; + + conn->bits.upload_chunky = + ((conn->protocol&PROT_HTTP) && + data->set.upload && + (data->set.infilesize == -1) && + (data->set.httpversion != CURL_HTTP_VERSION_1_0))? + /* HTTP, upload, unknown file size and not HTTP 1.0 */ + TRUE: + /* else, no chunky upload */ + FALSE; + +#ifndef USE_ARES + /************************************************************* + * Set timeout if that is being used, and we're not using an asynchronous + * name resolve. + *************************************************************/ + if((data->set.timeout || data->set.connecttimeout) && !data->set.no_signal) { + /************************************************************* + * Set signal handler to catch SIGALRM + * Store the old value to be able to set it back later! + *************************************************************/ + +#ifdef SIGALRM +#ifdef HAVE_SIGACTION + struct sigaction sigact; + sigaction(SIGALRM, NULL, &sigact); + keep_sigact = sigact; + keep_copysig = TRUE; /* yes, we have a copy */ + sigact.sa_handler = alarmfunc; +#ifdef SA_RESTART + /* HPUX doesn't have SA_RESTART but defaults to that behaviour! */ + sigact.sa_flags &= ~SA_RESTART; +#endif + /* now set the new struct */ + sigaction(SIGALRM, &sigact, NULL); +#else /* HAVE_SIGACTION */ + /* no sigaction(), revert to the much lamer signal() */ +#ifdef HAVE_SIGNAL + keep_sigact = signal(SIGALRM, alarmfunc); +#endif +#endif /* HAVE_SIGACTION */ + + /* We set the timeout on the name resolving phase first, separately from + * the download/upload part to allow a maximum time on everything. This is + * a signal-based timeout, why it won't work and shouldn't be used in + * multi-threaded environments. */ + +#ifdef HAVE_ALARM + /* alarm() makes a signal get sent when the timeout fires off, and that + will abort system calls */ + prev_alarm = alarm(data->set.connecttimeout? + data->set.connecttimeout: + data->set.timeout); + /* We can expect the conn->created time to be "now", as that was just + recently set in the beginning of this function and nothing slow + has been done since then until now. */ +#endif +#endif /* SIGALRM */ + } +#endif /* USE_ARES */ + + /************************************************************* + * Resolve the name of the server or proxy + *************************************************************/ + if(conn->bits.reuse) { + /* re-used connection, no resolving is necessary */ + hostaddr = NULL; + conn->dns_entry = NULL; /* we don't connect now so we don't have any fresh + dns entry struct to point to */ + + if (conn->bits.httpproxy) + fix_hostname(conn, &conn->host); + } + else { + /* this is a fresh connect */ + + /* set a pointer to the hostname we display */ + fix_hostname(conn, &conn->host); + + if(!data->change.proxy || !*data->change.proxy) { + /* If not connecting via a proxy, extract the port from the URL, if it is + * there, thus overriding any defaults that might have been set above. */ + conn->port = conn->remote_port; /* it is the same port */ + + /* Resolve target host right on */ + rc = Curl_resolv(conn, conn->host.name, (int)conn->port, &hostaddr); + if(rc == CURLRESOLV_PENDING) + *async = TRUE; + + else if(!hostaddr) { + failf(data, "Couldn't resolve host '%s'", conn->host.dispname); + result = CURLE_COULDNT_RESOLVE_HOST; + /* don't return yet, we need to clean up the timeout first */ + } + } + else { + /* This is a proxy that hasn't been resolved yet. */ + + /* IDN-fix the proxy name */ + fix_hostname(conn, &conn->proxy); + + /* resolve proxy */ + rc = Curl_resolv(conn, conn->proxy.name, (int)conn->port, &hostaddr); + + if(rc == CURLRESOLV_PENDING) + *async = TRUE; + + else if(!hostaddr) { + failf(data, "Couldn't resolve proxy '%s'", conn->proxy.dispname); + result = CURLE_COULDNT_RESOLVE_PROXY; + /* don't return yet, we need to clean up the timeout first */ + } + } + } + *addr = hostaddr; + +#if defined(HAVE_ALARM) && defined(SIGALRM) && !defined(USE_ARES) + if((data->set.timeout || data->set.connecttimeout) && !data->set.no_signal) { +#ifdef HAVE_SIGACTION + if(keep_copysig) { + /* we got a struct as it looked before, now put that one back nice + and clean */ + sigaction(SIGALRM, &keep_sigact, NULL); /* put it back */ + } +#else +#ifdef HAVE_SIGNAL + /* restore the previous SIGALRM handler */ + signal(SIGALRM, keep_sigact); +#endif +#endif /* HAVE_SIGACTION */ + + /* switch back the alarm() to either zero or to what it was before minus + the time we spent until now! */ + if(prev_alarm) { + /* there was an alarm() set before us, now put it back */ + unsigned long elapsed_ms = Curl_tvdiff(Curl_tvnow(), conn->created); + unsigned long alarm_set; + + /* the alarm period is counted in even number of seconds */ + alarm_set = prev_alarm - elapsed_ms/1000; + + if(!alarm_set || + ((alarm_set >= 0x80000000) && (prev_alarm < 0x80000000)) ) { + /* if the alarm time-left reached zero or turned "negative" (counted + with unsigned values), we should fire off a SIGALRM here, but we + won't, and zero would be to switch it off so we never set it to + less than 1! */ + alarm(1); + result = CURLE_OPERATION_TIMEOUTED; + failf(data, "Previous alarm fired off!"); + } + else + alarm((unsigned int)alarm_set); + } + else + alarm(0); /* just shut it off */ + } +#endif + + return result; +} + +/* SetupConnection() should be called after the name resolve initiated in + * CreateConnection() is all done. + */ + +static CURLcode SetupConnection(struct connectdata *conn, + struct Curl_dns_entry *hostaddr) +{ + struct SessionHandle *data = conn->data; + CURLcode result=CURLE_OK; + + Curl_pgrsTime(data, TIMER_NAMELOOKUP); + + if(conn->protocol & PROT_FILE) + /* There's nothing in this function to setup if we're only doing + a file:// transfer */ + return result; + + /************************************************************* + * Send user-agent to HTTP proxies even if the target protocol + * isn't HTTP. + *************************************************************/ + if((conn->protocol&PROT_HTTP) || + (data->change.proxy && *data->change.proxy)) { + if(data->set.useragent) { + Curl_safefree(conn->allocptr.uagent); + conn->allocptr.uagent = + aprintf("User-Agent: %s\015\012", data->set.useragent); + if(!conn->allocptr.uagent) + return CURLE_OUT_OF_MEMORY; + } + } + + if(data->set.encoding) { + Curl_safefree(conn->allocptr.accept_encoding); + conn->allocptr.accept_encoding = + aprintf("Accept-Encoding: %s\015\012", data->set.encoding); + if(!conn->allocptr.accept_encoding) + return CURLE_OUT_OF_MEMORY; + } + + conn->bytecount = 0; + conn->headerbytecount = 0; + + if(CURL_SOCKET_BAD == conn->sock[FIRSTSOCKET]) { + bool connected; + + /* Connect only if not already connected! */ + result = ConnectPlease(conn, hostaddr, &connected); + + if(connected) { + result = Curl_protocol_connect(conn); + if(CURLE_OK == result) + conn->bits.tcpconnect = TRUE; + } + else + conn->bits.tcpconnect = FALSE; + + + if(CURLE_OK != result) + return result; + } + else { + Curl_pgrsTime(data, TIMER_CONNECT); /* we're connected already */ + conn->bits.tcpconnect = TRUE; + if(data->set.verbose) + verboseconnect(conn); + } + + conn->now = Curl_tvnow(); /* time this *after* the connect is done, we + set this here perhaps a second time */ + +#ifdef __EMX__ + /* 20000330 mgs + * the check is quite a hack... + * we're calling _fsetmode to fix the problem with fwrite converting newline + * characters (you get mangled text files, and corrupted binary files when + * you download to stdout and redirect it to a file). */ + + if ((data->set.out)->_handle == NULL) { + _fsetmode(stdout, "b"); + } +#endif + + return CURLE_OK; +} + +CURLcode Curl_connect(struct SessionHandle *data, + struct connectdata **in_connect, + bool *asyncp) +{ + CURLcode code; + struct Curl_dns_entry *dns; + + *asyncp = FALSE; /* assume synchronous resolves by default */ + + /* call the stuff that needs to be called */ + code = CreateConnection(data, in_connect, &dns, asyncp); + + if(CURLE_OK == code) { + /* no error */ + if(dns || !*asyncp) + /* If an address is available it means that we already have the name + resolved, OR it isn't async. + If so => continue connecting from here */ + code = SetupConnection(*in_connect, dns); + /* else + response will be received and treated async wise */ + } + + if(CURLE_OK != code) { + /* We're not allowed to return failure with memory left allocated + in the connectdata struct, free those here */ + if(*in_connect) { + Curl_disconnect(*in_connect); /* close the connection */ + *in_connect = NULL; /* return a NULL */ + } + } + + return code; +} + +/* Call this function after Curl_connect() has returned async=TRUE and + then a successful name resolve has been received */ +CURLcode Curl_async_resolved(struct connectdata *conn) +{ +#if defined(USE_ARES) || defined(USE_THREADING_GETHOSTBYNAME) || \ + defined(USE_THREADING_GETADDRINFO) + CURLcode code = SetupConnection(conn, conn->async.dns); + + if(code) + /* We're not allowed to return failure with memory left allocated + in the connectdata struct, free those here */ + Curl_disconnect(conn); /* close the connection */ + + return code; +#else + (void)conn; + return CURLE_OK; +#endif +} + + +CURLcode Curl_done(struct connectdata **connp, + CURLcode status) /* an error if this is called after an + error was detected */ +{ + CURLcode result; + struct connectdata *conn = *connp; + struct SessionHandle *data=conn->data; + + /* cleanups done even if the connection is re-used */ + + if(conn->bits.rangestringalloc) { + free(conn->range); + conn->bits.rangestringalloc = FALSE; + } + + /* Cleanup possible redirect junk */ + if(conn->newurl) { + free(conn->newurl); + conn->newurl = NULL; + } + + if(conn->dns_entry) + Curl_resolv_unlock(conn->data, conn->dns_entry); /* done with this */ + +#if defined(CURLDEBUG) && defined(AGGRESIVE_TEST) + /* scan for DNS cache entries still marked as in use */ + Curl_hash_apply(data->hostcache, + NULL, Curl_scan_cache_used); +#endif + + Curl_hostcache_prune(data); /* kill old DNS cache entries */ + + /* this calls the protocol-specific function pointer previously set */ + if(conn->curl_done) + result = conn->curl_done(conn, status); + else + result = CURLE_OK; + + Curl_pgrsDone(conn); /* done with the operation */ + + /* if data->set.reuse_forbid is TRUE, it means the libcurl client has + forced us to close this no matter what we think. + + if conn->bits.close is TRUE, it means that the connection should be + closed in spite of all our efforts to be nice, due to protocol + restrictions in our or the server's end */ + if(data->set.reuse_forbid || conn->bits.close) { + CURLcode res2; + res2 = Curl_disconnect(conn); /* close the connection */ + + *connp = NULL; /* to make the caller of this function better detect that + this was actually killed here */ + + /* If we had an error already, make sure we return that one. But + if we got a new error, return that. */ + if(!result && res2) + result = res2; + } + else + infof(data, "Connection #%ld to host %s left intact\n", + conn->connectindex, + conn->bits.httpproxy?conn->proxy.dispname:conn->host.dispname); + + return result; +} + +CURLcode Curl_do(struct connectdata **connp) +{ + CURLcode result=CURLE_OK; + struct connectdata *conn = *connp; + struct SessionHandle *data=conn->data; + + conn->bits.do_more = FALSE; /* by default there's no curl_do_more() to use */ + + if(conn->curl_do) { + /* generic protocol-specific function pointer set in curl_connect() */ + result = conn->curl_do(conn); + + /* This was formerly done in transfer.c, but we better do it here */ + + if((CURLE_SEND_ERROR == result) && conn->bits.reuse) { + /* This was a re-use of a connection and we got a write error in the + * DO-phase. Then we DISCONNECT this connection and have another attempt + * to CONNECT and then DO again! The retry cannot possibly find another + * connection to re-use, since we only keep one possible connection for + * each. */ + + infof(data, "Re-used connection seems dead, get a new one\n"); + + conn->bits.close = TRUE; /* enforce close of this connection */ + result = Curl_done(&conn, result); /* we are so done with this */ + + /* conn may no longer be a good pointer */ + + if(CURLE_OK == result) { + bool async; + /* Now, redo the connect and get a new connection */ + result = Curl_connect(data, connp, &async); + if(CURLE_OK == result) { + /* We have connected or sent away a name resolve query fine */ + + conn = *connp; /* setup conn to again point to something nice */ + if(async) { + /* Now, if async is TRUE here, we need to wait for the name + to resolve */ + result = Curl_wait_for_resolv(conn, NULL); + if(result) + return result; + + /* Resolved, continue with the connection */ + result = Curl_async_resolved(conn); + if(result) + return result; + } + + /* ... finally back to actually retry the DO phase */ + result = conn->curl_do(conn); + } + } + } + } + return result; +} + +CURLcode Curl_do_more(struct connectdata *conn) +{ + CURLcode result=CURLE_OK; + + if(conn->curl_do_more) + result = conn->curl_do_more(conn); + + return result; +} + +static bool safe_strequal(char* str1, char* str2) +{ + if(str1 && str2) + /* both pointers point to something then compare them */ + return strequal(str1, str2); + else + /* if both pointers are NULL then treat them as equal */ + return (!str1 && !str2); +} + +bool +Curl_ssl_config_matches(struct ssl_config_data* data, + struct ssl_config_data* needle) +{ + if((data->version == needle->version) && + (data->verifypeer == needle->verifypeer) && + (data->verifyhost == needle->verifyhost) && + safe_strequal(data->CApath, needle->CApath) && + safe_strequal(data->CAfile, needle->CAfile) && + safe_strequal(data->random_file, needle->random_file) && + safe_strequal(data->egdsocket, needle->egdsocket) && + safe_strequal(data->cipher_list, needle->cipher_list)) + return TRUE; + + return FALSE; +} + +bool +Curl_clone_ssl_config(struct ssl_config_data *source, + struct ssl_config_data *dest) +{ + dest->verifyhost = source->verifyhost; + dest->verifypeer = source->verifypeer; + dest->version = source->version; + + if(source->CAfile) { + dest->CAfile = strdup(source->CAfile); + if(!dest->CAfile) + return FALSE; + } + + if(source->CApath) { + dest->CApath = strdup(source->CApath); + if(!dest->CApath) + return FALSE; + } + + if(source->cipher_list) { + dest->cipher_list = strdup(source->cipher_list); + if(!dest->cipher_list) + return FALSE; + } + + if(source->egdsocket) { + dest->egdsocket = strdup(source->egdsocket); + if(!dest->egdsocket) + return FALSE; + } + + if(source->random_file) { + dest->random_file = strdup(source->random_file); + if(!dest->random_file) + return FALSE; + } + + return TRUE; +} + +void Curl_free_ssl_config(struct ssl_config_data* sslc) +{ + if(sslc->CAfile) + free(sslc->CAfile); + + if(sslc->CApath) + free(sslc->CApath); + + if(sslc->cipher_list) + free(sslc->cipher_list); + + if(sslc->egdsocket) + free(sslc->egdsocket); + + if(sslc->random_file) + free(sslc->random_file); +} + diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/urldata.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/urldata.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/urldata.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/urldata.h 2005-03-17 02:26:36.000000000 +0800 @@ -0,0 +1,962 @@ +#ifndef __URLDATA_H +#define __URLDATA_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: urldata.h,v 1.6 2005/03/16 18:26:36 andy Exp $ + ***************************************************************************/ + +/* This file is for lib internal stuff */ + +#include "setup.h" + +#define PORT_FTP 21 +#define PORT_FTPS 990 +#define PORT_TELNET 23 +#define PORT_GOPHER 70 +#define PORT_HTTP 80 +#define PORT_HTTPS 443 +#define PORT_DICT 2628 +#define PORT_LDAP 389 + +#define DICT_MATCH "/MATCH:" +#define DICT_MATCH2 "/M:" +#define DICT_MATCH3 "/FIND:" +#define DICT_DEFINE "/DEFINE:" +#define DICT_DEFINE2 "/D:" +#define DICT_DEFINE3 "/LOOKUP:" + +#define CURL_DEFAULT_USER "anonymous" +#define CURL_DEFAULT_PASSWORD "curl_by_daniel@haxx.se" + +#include "cookie.h" +#include "formdata.h" + +#ifdef USE_SSLEAY +/* SSLeay stuff usually in /usr/local/ssl/include */ +#ifdef USE_OPENSSL +#include "openssl/rsa.h" +#include "openssl/crypto.h" +#include "openssl/x509.h" +#include "openssl/pem.h" +#include "openssl/ssl.h" +#include "openssl/err.h" +#ifdef HAVE_OPENSSL_ENGINE_H +#include +#endif +#else +#include "rsa.h" +#include "crypto.h" +#include "x509.h" +#include "pem.h" +#include "ssl.h" +#include "err.h" +#endif +#endif + +#ifdef HAVE_NETINET_IN_H +#include +#endif + +#include "timeval.h" + +#ifdef HAVE_ZLIB_H +#include /* for content-encoding */ +#endif + +#ifdef CURL_SPECIAL_ZLIB_H +#include CURL_SPECIAL_ZLIB_H +#endif + +#ifdef USE_ARES +#include +#endif + +#include + +#include "http_chunks.h" /* for the structs and enum stuff */ +#include "hostip.h" +#include "hash.h" + +#ifdef HAVE_GSSAPI +#ifdef HAVE_GSSMIT +#include +#include +#else +#include +#endif +#endif + +/* Download buffer size, keep it fairly big for speed reasons */ +#define BUFSIZE CURL_MAX_WRITE_SIZE + +/* Initial size of the buffer to store headers in, it'll be enlarged in case + of need. */ +#define HEADERSIZE 256 + +/* Just a convenience macro to get the larger value out of two given. + We prefix with CURL to prevent name collisions. */ +#define CURLMAX(x,y) ((x)>(y)?(x):(y)) + +#ifdef HAVE_KRB4 +/* Types needed for krb4-ftp connections */ +struct krb4buffer { + void *data; + size_t size; + size_t index; + int eof_flag; +}; +enum protection_level { + prot_clear, + prot_safe, + prot_confidential, + prot_private +}; +#endif + +/* struct for data related to each SSL connection */ +struct ssl_connect_data { + bool use; /* use ssl encrypted communications TRUE/FALSE */ +#ifdef USE_SSLEAY + /* these ones requires specific SSL-types */ + SSL_CTX* ctx; + SSL* handle; + X509* server_cert; +#endif /* USE_SSLEAY */ +}; + +struct ssl_config_data { + long version; /* what version the client wants to use */ + long certverifyresult; /* result from the certificate verification */ + long verifypeer; /* set TRUE if this is desired */ + long verifyhost; /* 0: no verify + 1: check that CN exists + 2: CN must match hostname */ + char *CApath; /* DOES NOT WORK ON WINDOWS */ + char *CAfile; /* cerficate to verify peer against */ + char *random_file; /* path to file containing "random" data */ + char *egdsocket; /* path to file containing the EGD daemon socket */ + char *cipher_list; /* list of ciphers to use */ + long numsessions; /* SSL session id cache size */ + curl_ssl_ctx_callback fsslctx; /* function to initialize ssl ctx */ + void *fsslctxp; /*parameter for call back */ +}; + +/* information stored about one single SSL session */ +struct curl_ssl_session { + char *name; /* host name for which this ID was used */ + void *sessionid; /* as returned from the SSL layer */ + long age; /* just a number, the higher the more recent */ + unsigned short remote_port; /* remote port to connect to */ + struct ssl_config_data ssl_config; /* setup for this session */ +}; + +/* Struct used for Digest challenge-response authentication */ +struct digestdata { + char *nonce; + char *cnonce; + char *realm; + int algo; + bool stale; /* set true for re-negotiation */ + char *opaque; + char *qop; + char *algorithm; + int nc; /* nounce count */ +}; + +typedef enum { + NTLMSTATE_NONE, + NTLMSTATE_TYPE1, + NTLMSTATE_TYPE2, + NTLMSTATE_TYPE3, + NTLMSTATE_LAST +} curlntlm; + +/* for 3rd party transfers to decide which side that issues PASV */ +typedef enum { + CURL_TARGET_PASV, + CURL_SOURCE_PASV +} curl_pasv_side; + +/* Struct used for NTLM challenge-response authentication */ +struct ntlmdata { + curlntlm state; + unsigned char nonce[8]; +}; + +#ifdef HAVE_GSSAPI +struct negotiatedata { + bool gss; /* Whether we're processing GSS-Negotiate or Negotiate */ + const char* protocol; /* "GSS-Negotiate" or "Negotiate" */ + OM_uint32 status; + gss_ctx_id_t context; + gss_name_t server_name; + gss_buffer_desc output_token; +}; +#endif + +/**************************************************************************** + * HTTP unique setup + ***************************************************************************/ +struct HTTP { + struct FormData *sendit; + curl_off_t postsize; /* off_t to handle large file sizes */ + char *postdata; + + const char *p_pragma; /* Pragma: string */ + const char *p_accept; /* Accept: string */ + curl_off_t readbytecount; + curl_off_t writebytecount; + + /* For FORM posting */ + struct Form form; + struct Curl_chunker chunk; + + struct back { + curl_read_callback fread; /* backup storage for fread pointer */ + void *fread_in; /* backup storage for fread_in pointer */ + char *postdata; + curl_off_t postsize; + } backup; + + enum { + HTTPSEND_NADA, /* init */ + HTTPSEND_REQUEST, /* sending a request */ + HTTPSEND_BODY, /* sending body */ + HTTPSEND_LAST /* never use this */ + } sending; + + void *send_buffer; /* used if the request couldn't be sent in one chunk, + points to an allocated send_buffer struct */ +}; + +/**************************************************************************** + * FTP unique setup + ***************************************************************************/ +struct FTP { + curl_off_t *bytecountp; + char *user; /* user name string */ + char *passwd; /* password string */ + char *urlpath; /* the originally given path part of the URL */ + char **dirs; /* realloc()ed array for path components */ + int dirdepth; /* number of entries used in the 'dirs' array */ + int diralloc; /* number of entries allocated for the 'dirs' array */ + char *file; /* decoded file */ + + char *entrypath; /* the PWD reply when we logged on */ + + char *cache; /* data cache between getresponse()-calls */ + curl_off_t cache_size; /* size of cache in bytes */ + bool dont_check; /* Set to TRUE to prevent the final (post-transfer) + file size and 226/250 status check. It should still + read the line, just ignore the result. */ + bool no_transfer; /* nothing was transfered, (possibly because a resumed + transfer already was complete) */ + long response_time; /* When no timeout is given, this is the amount of + seconds we await for an FTP response. Initialized + in Curl_ftp_connect() */ + bool ctl_valid; /* Tells Curl_ftp_quit() whether or not to do + anything. If the connection has timed out or + been closed, this should be FALSE when it gets + to Curl_ftp_quit() */ +}; + +/**************************************************************************** + * FILE unique setup + ***************************************************************************/ +struct FILEPROTO { + char *path; /* the path we operate on */ + char *freepath; /* pointer to the allocated block we must free, this might + differ from the 'path' pointer */ + int fd; /* open file descriptor to read from! */ +}; + +/* + * Boolean values that concerns this connection. + */ +struct ConnectBits { + bool close; /* if set, we close the connection after this request */ + bool reuse; /* if set, this is a re-used connection */ + bool chunk; /* if set, this is a chunked transfer-encoding */ + bool httpproxy; /* if set, this transfer is done through a http proxy */ + bool user_passwd; /* do we use user+password for this connection? */ + bool proxy_user_passwd; /* user+password for the proxy? */ + bool ipv6_ip; /* we communicate with a remove site specified with pure IPv6 + IP address */ + bool use_range; + bool rangestringalloc; /* the range string is malloc()'ed */ + + bool do_more; /* this is set TRUE if the ->curl_do_more() function is + supposed to be called, after ->curl_do() */ + + bool upload_chunky; /* set TRUE if we are doing chunked transfer-encoding + on upload */ + bool getheader; /* TRUE if header parsing is wanted */ + + bool forbidchunk; /* used only to explicitly forbid chunk-upload for + specific upload buffers. See readmoredata() in + http.c for details. */ + bool tcpconnect; /* the tcp stream (or simimlar) is connected, this + is set the first time on the first connect function + call */ + bool retry; /* this connection is about to get closed and then + re-attempted at another connection. */ + bool no_body; /* CURLOPT_NO_BODY (or similar) was set */ + bool tunnel_proxy; /* if CONNECT is used to "tunnel" through the proxy. + This is implicit when SSL-protocols are used through + proxies, but can also be enabled explicitly by + apps */ + bool authprobe; /* set TRUE when this transfer is done to probe for auth + types, as when asking for "any" type when speaking + HTTP */ +}; + +struct hostname { + char *rawalloc; /* allocated "raw" version of the name */ + char *encalloc; /* allocated IDN-encoded version of the name */ + char *name; /* name to use internally, might be encoded, might be raw */ + char *dispname; /* name to display, as 'name' might be encoded */ +}; + +/* + * This struct is all the previously local variables from Curl_perform() moved + * to struct to allow the function to return and get re-invoked better without + * losing state. + */ + +struct Curl_transfer_keeper { + curl_off_t bytecount; /* total number of bytes read */ + curl_off_t writebytecount; /* number of bytes written */ + struct timeval start; /* transfer started at this time */ + struct timeval now; /* current time */ + bool header; /* incoming data has HTTP header */ + enum { + HEADER_NORMAL, /* no bad header at all */ + HEADER_PARTHEADER, /* part of the chunk is a bad header, the rest + is normal data */ + HEADER_ALLBAD /* all was believed to be header */ + } badheader; /* the header was deemed bad and will be + written as body */ + int headerline; /* counts header lines to better track the + first one */ + char *hbufp; /* points at *end* of header line */ + size_t hbuflen; + char *str; /* within buf */ + char *str_start; /* within buf */ + char *end_ptr; /* within buf */ + char *p; /* within headerbuff */ + bool content_range; /* set TRUE if Content-Range: was found */ + curl_off_t offset; /* possible resume offset read from the + Content-Range: header */ + int httpcode; /* error code from the 'HTTP/1.? XXX' line */ + int httpversion; /* the HTTP version*10 */ + struct timeval start100; /* time stamp to wait for the 100 code from */ + bool write_after_100_header; /* TRUE = we enable the write after we + received a 100-continue/timeout or + FALSE = directly */ + bool wait100_after_headers; /* TRUE = after the request-headers have been + sent off properly, we go into the wait100 + state, FALSE = don't */ + int content_encoding; /* What content encoding. sec 3.5, RFC2616. */ + +#define IDENTITY 0 /* No encoding */ +#define DEFLATE 1 /* zlib delfate [RFC 1950 & 1951] */ +#define GZIP 2 /* gzip algorithm [RFC 1952] */ +#define COMPRESS 3 /* Not handled, added for completeness */ + +#ifdef HAVE_LIBZ + bool zlib_init; /* True if zlib already initialized; + undefined if Content-Encoding header. */ + z_stream z; /* State structure for zlib. */ +#endif + + time_t timeofdoc; + long bodywrites; + + char *buf; + char *uploadbuf; + curl_socket_t maxfd; + + /* pointers to the actual descriptors we check */ + fd_set *readfdp; + fd_set *writefdp; + + /* the file descriptors to play with */ + fd_set readfd; + fd_set writefd; + fd_set rkeepfd; + fd_set wkeepfd; + int keepon; + + bool upload_done; /* set to TRUE when doing chunked transfer-encoding upload + and we're uploading the last chunk */ + + bool ignorebody; /* we read a response-body but we ignore it! */ +}; + +#if defined(USE_ARES) || defined(USE_THREADING_GETHOSTBYNAME) || \ + defined(USE_THREADING_GETADDRINFO) +struct Curl_async { + char *hostname; + int port; + struct Curl_dns_entry *dns; + bool done; /* set TRUE when the lookup is complete */ + int status; /* if done is TRUE, this is the status from the callback */ + void *os_specific; /* 'struct thread_data' for Windows */ +}; +#endif + +#define FIRSTSOCKET 0 +#define SECONDARYSOCKET 1 + +/* + * The connectdata struct contains all fields and variables that should be + * unique for an entire connection. + */ +struct connectdata { + /**** Fields set when inited and not modified again */ + struct SessionHandle *data; /* link to the root CURL struct */ + long connectindex; /* what index in the connects index this particular + struct has */ + + long protocol; /* PROT_* flags concerning the protocol set */ +#define PROT_MISSING (1<<0) +#define PROT_GOPHER (1<<1) +#define PROT_HTTP (1<<2) +#define PROT_HTTPS (1<<3) +#define PROT_FTP (1<<4) +#define PROT_TELNET (1<<5) +#define PROT_DICT (1<<6) +#define PROT_LDAP (1<<7) +#define PROT_FILE (1<<8) +#define PROT_FTPS (1<<9) +#define PROT_SSL (1<<10) /* protocol requires SSL */ + + /* the particular host we use, in two different ways */ + struct Curl_dns_entry *dns_entry; + Curl_addrinfo *ip_addr; /* the particular IP we connected to */ + + char protostr[16]; /* store the protocol string in this buffer */ + + struct hostname host; + struct hostname proxy; + + char *pathbuffer;/* allocated buffer to store the URL's path part in */ + char *path; /* path to use, points to somewhere within the pathbuffer + area */ + long port; /* which port to use locally */ + unsigned short remote_port; /* what remote port to connect to, + not the proxy port! */ + curl_off_t bytecount; + long headerbytecount; /* only count received headers */ + long deductheadercount; /* this amount of bytes doesn't count when we check + if anything has been transfered at the end of + a connection. We use this counter to make only + a 100 reply (without a following second response + code) result in a CURLE_GOT_NOTHING error code */ + + char *range; /* range, if used. See README for detailed specification on + this syntax. */ + curl_off_t resume_from; /* continue [ftp] transfer from here */ + + char *user; /* user name string, allocated */ + char *passwd; /* password string, allocated */ + + char *proxyuser; /* proxy user name string, allocated */ + char *proxypasswd; /* proxy password string, allocated */ + + struct timeval now; /* "current" time */ + struct timeval created; /* creation time */ + curl_socket_t sock[2]; /* two sockets, the second is used for the data + transfer when doing FTP */ + curl_off_t maxdownload; /* in bytes, the maximum amount of data to fetch, 0 + means unlimited */ + + struct ssl_connect_data ssl[2]; /* this is for ssl-stuff */ + struct ssl_config_data ssl_config; + + struct ConnectBits bits; /* various state-flags for this connection */ + + /* These two functions MUST be set by the curl_connect() function to be + be protocol dependent */ + CURLcode (*curl_do)(struct connectdata *); + CURLcode (*curl_done)(struct connectdata *, CURLcode); + + /* If the curl_do() function is better made in two halves, this + * curl_do_more() function will be called afterwards, if set. For example + * for doing the FTP stuff after the PASV/PORT command. + */ + CURLcode (*curl_do_more)(struct connectdata *); + + /* This function *MAY* be set to a protocol-dependent function that is run + * after the connect() and everything is done, as a step in the connection. + */ + CURLcode (*curl_connect)(struct connectdata *); + + /* This function *MAY* be set to a protocol-dependent function that is run + * by the curl_disconnect(), as a step in the disconnection. + */ + CURLcode (*curl_disconnect)(struct connectdata *); + + /* This function *MAY* be set to a protocol-dependent function that is run + * in the curl_close() function if protocol-specific cleanups are required. + */ + CURLcode (*curl_close)(struct connectdata *); + + /**** curl_get() phase fields */ + + /* READ stuff */ + curl_socket_t sockfd; /* socket to read from or CURL_SOCKET_BAD */ + curl_off_t size; /* -1 if unknown at this point */ + curl_off_t *bytecountp; /* return number of bytes read or NULL */ + + /* WRITE stuff */ + curl_socket_t writesockfd; /* socket to write to, it may very + well be the same we read from. + CURL_SOCKET_BAD disables */ + curl_off_t *writebytecountp; /* return number of bytes written or NULL */ + + /** Dynamicly allocated strings, may need to be freed before this **/ + /** struct is killed. **/ + struct dynamically_allocated_data { + char *proxyuserpwd; /* free later if not NULL! */ + char *uagent; /* free later if not NULL! */ + char *accept_encoding; /* free later if not NULL! */ + char *userpwd; /* free later if not NULL! */ + char *rangeline; /* free later if not NULL! */ + char *ref; /* free later if not NULL! */ + char *host; /* free later if not NULL */ + char *cookiehost; /* free later if not NULL */ + } allocptr; + + char *newurl; /* This can only be set if a Location: was in the + document headers */ + +#ifdef HAVE_KRB4 + enum protection_level command_prot; + enum protection_level data_prot; + enum protection_level request_data_prot; + + size_t buffer_size; + + struct krb4buffer in_buffer, out_buffer; + int sec_complete; + void *app_data; + + struct Curl_sec_client_mech *mech; + struct sockaddr_in local_addr; + +#endif + + /*************** Request - specific items ************/ + /* previously this was in the urldata struct */ + union { + struct HTTP *http; + struct HTTP *gopher; /* alias, just for the sake of being more readable */ + struct HTTP *https; /* alias, just for the sake of being more readable */ + struct FTP *ftp; + struct FILEPROTO *file; + void *telnet; /* private for telnet.c-eyes only */ + void *generic; + } proto; + + /* This struct is inited when needed */ + struct Curl_transfer_keeper keep; + + /* 'upload_present' is used to keep a byte counter of how much data there is + still left in the buffer, aimed for upload. */ + ssize_t upload_present; + + /* 'upload_fromhere' is used as a read-pointer when we uploaded parts of a + buffer, so the next read should read from where this pointer points to, + and the 'upload_present' contains the number of bytes available at this + position */ + char *upload_fromhere; + + curl_read_callback fread; /* function that reads the input */ + void *fread_in; /* pointer to pass to the fread() above */ + + struct ntlmdata ntlm; /* NTLM differs from other authentication schemes + because it authenticates connections, not + single requests! */ + struct ntlmdata proxyntlm; /* NTLM data for proxy */ + + char syserr_buf [256]; /* buffer for Curl_strerror() */ + +#if defined(USE_ARES) || defined(USE_THREADING_GETHOSTBYNAME) || \ + defined(USE_THREADING_GETADDRINFO) + /* data used for the asynch name resolve callback */ + struct Curl_async async; +#endif + struct connectdata *sec_conn; /* secondary connection for 3rd party + transfer */ +}; + +/* The end of connectdata. */ + +/* + * Struct to keep statistical and informational data. + */ +struct PureInfo { + int httpcode; /* Recent HTTP or FTP response code */ + int httpproxycode; + int httpversion; + long filetime; /* If requested, this is might get set. Set to -1 if the time + was unretrievable. We cannot have this of type time_t, + since time_t is unsigned on several platforms such as + OpenVMS. */ + long header_size; /* size of read header(s) in bytes */ + long request_size; /* the amount of bytes sent in the request(s) */ + + long proxyauthavail; + long httpauthavail; + + char *contenttype; /* the content type of the object */ +}; + + +struct Progress { + long lastshow; /* time() of the last displayed progress meter or NULL to + force redraw at next call */ + curl_off_t size_dl; /* total expected size */ + curl_off_t size_ul; /* total expected size */ + curl_off_t downloaded; /* transfered so far */ + curl_off_t uploaded; /* transfered so far */ + + curl_off_t current_speed; /* uses the currently fastest transfer */ + + bool callback; /* set when progress callback is used */ + int width; /* screen width at download start */ + int flags; /* see progress.h */ + + double timespent; + + curl_off_t dlspeed; + curl_off_t ulspeed; + + double t_nslookup; + double t_connect; + double t_pretransfer; + double t_starttransfer; + double t_redirect; + + struct timeval start; + struct timeval t_startsingle; +#define CURR_TIME (5+1) /* 6 entries for 5 seconds */ + + curl_off_t speeder[ CURR_TIME ]; + struct timeval speeder_time[ CURR_TIME ]; + int speeder_c; +}; + +typedef enum { + HTTPREQ_NONE, /* first in list */ + HTTPREQ_GET, + HTTPREQ_POST, + HTTPREQ_POST_FORM, /* we make a difference internally */ + HTTPREQ_PUT, + HTTPREQ_HEAD, + HTTPREQ_CUSTOM, + HTTPREQ_LAST /* last in list */ +} Curl_HttpReq; + +/* + * Values that are generated, temporary or calculated internally for a + * "session handle" must be defined within the 'struct urlstate'. This struct + * will be used within the SessionHandle struct. When the 'SessionHandle' + * struct is cloned, this data MUST NOT be copied. + * + * Remember that any "state" information goes globally for the curl handle. + * Session-data MUST be put in the connectdata struct and here. */ +#define MAX_CURL_USER_LENGTH 256 +#define MAX_CURL_PASSWORD_LENGTH 256 +#define MAX_CURL_USER_LENGTH_TXT "255" +#define MAX_CURL_PASSWORD_LENGTH_TXT "255" + +struct auth { + long want; /* Bitmask set to the authentication methods wanted by the app + (with CURLOPT_HTTPAUTH or CURLOPT_PROXYAUTH). */ + long picked; + long avail; /* bitmask for what the server reports to support for this + resource */ + bool done; /* TRUE when the auth phase is done and ready to do the *actual* + request */ +}; + +struct UrlState { + enum { + Curl_if_none, + Curl_if_easy, + Curl_if_multi + } used_interface; + + /* buffers to store authentication data in, as parsed from input options */ + struct timeval keeps_speed; /* for the progress meter really */ + + /* 'connects' will be an allocated array with pointers. If the pointer is + set, it holds an allocated connection. */ + struct connectdata **connects; + long numconnects; /* size of the 'connects' array */ + + char *headerbuff; /* allocated buffer to store headers in */ + size_t headersize; /* size of the allocation */ + + char buffer[BUFSIZE+1]; /* download buffer */ + char uploadbuffer[BUFSIZE+1]; /* upload buffer */ + curl_off_t current_speed; /* the ProgressShow() funcion sets this, + bytes / second */ + bool this_is_a_follow; /* this is a followed Location: request */ + + char *auth_host; /* if set, this should be the host name that we will + sent authorization to, no else. Used to make Location: + following not keep sending user+password... This is + strdup() data. + */ + + struct curl_ssl_session *session; /* array of 'numsessions' size */ + long sessionage; /* number of the most recent session */ + + char *scratch; /* huge buffer[BUFSIZE*2] when doing upload CRLF replacing */ + bool errorbuf; /* Set to TRUE if the error buffer is already filled in. + This must be set to FALSE every time _easy_perform() is + called. */ + +#ifdef HAVE_SIGNAL + /* storage for the previous bag^H^H^HSIGPIPE signal handler :-) */ + void (*prev_signal)(int sig); +#endif + bool allow_port; /* Is set.use_port allowed to take effect or not. This + is always set TRUE when curl_easy_perform() is called. */ + + struct digestdata digest; + struct digestdata proxydigest; + +#ifdef HAVE_GSSAPI + struct negotiatedata negotiate; +#endif + + struct auth authhost; + struct auth authproxy; + + bool authproblem; /* TRUE if there's some problem authenticating */ +#ifdef USE_ARES + ares_channel areschannel; /* for name resolves */ +#endif +}; + + +/* + * This 'DynamicStatic' struct defines dynamic states that actually change + * values in the 'UserDefined' area, which MUST be taken into consideration + * if the UserDefined struct is cloned or similar. You can probably just + * copy these, but each one indicate a special action on other data. + */ + +struct DynamicStatic { + char *url; /* work URL, copied from UserDefined */ + bool url_alloc; /* URL string is malloc()'ed */ + bool url_changed; /* set on CURL_OPT_URL, used to detect if the URL was + changed after the connect phase, as we allow callback + to change it and if so, we reconnect to use the new + URL instead */ + char *proxy; /* work proxy, copied from UserDefined */ + bool proxy_alloc; /* http proxy string is malloc()'ed */ + char *referer; /* referer string */ + bool referer_alloc; /* referer sting is malloc()ed */ + struct curl_slist *cookielist; /* list of cookie files set by + curl_easy_setopt(COOKIEFILE) calls */ +}; + +/* + * This 'UserDefined' struct must only contain data that is set once to go + * for many (perhaps) independent connections. Values that are generated or + * calculated internally for the "session handle" MUST be defined within the + * 'struct urlstate' instead. The only exceptions MUST note the changes in + * the 'DynamicStatic' struct. + */ + +struct UserDefined { + FILE *err; /* the stderr user data goes here */ + void *debugdata; /* the data that will be passed to fdebug */ + char *errorbuffer; /* store failure messages in here */ + char *proxyuserpwd; /* Proxy , if used */ + long proxyport; /* If non-zero, use this port number by default. If the + proxy string features a ":[port]" that one will override + this. */ + void *out; /* the fetched file goes here */ + void *in; /* the uploaded file is read from here */ + void *writeheader; /* write the header to this is non-NULL */ + char *set_url; /* what original URL to work on */ + char *set_proxy; /* proxy to use */ + long use_port; /* which port to use (when not using default) */ + char *userpwd; /* , if used */ + long httpauth; /* what kind of HTTP authentication to use (bitmask) */ + long proxyauth; /* what kind of proxy authentication to use (bitmask) */ + char *set_range; /* range, if used. See README for detailed specification + on this syntax. */ + long followlocation; /* as in HTTP Location: */ + long maxredirs; /* maximum no. of http(s) redirects to follow */ + char *set_referer; /* custom string */ + bool free_referer; /* set TRUE if 'referer' points to a string we + allocated */ + char *useragent; /* User-Agent string */ + char *encoding; /* Accept-Encoding string */ + char *postfields; /* if POST, set the fields' values here */ + curl_off_t postfieldsize; /* if POST, this might have a size to use instead + of strlen(), and then the data *may* be binary + (contain zero bytes) */ + char *ftpport; /* port to send with the FTP PORT command */ + char *device; /* network interface to use */ + curl_write_callback fwrite; /* function that stores the output */ + curl_write_callback fwrite_header; /* function that stores headers */ + curl_read_callback fread; /* function that reads the input */ + curl_progress_callback fprogress; /* function for progress information */ + curl_debug_callback fdebug; /* function that write informational data */ + void *progress_client; /* pointer to pass to the progress callback */ + long timeout; /* in seconds, 0 means no timeout */ + long connecttimeout; /* in seconds, 0 means no timeout */ + long ftp_response_timeout; /* in seconds, 0 means no timeout */ + curl_off_t infilesize; /* size of file to upload, -1 means unknown */ + long low_speed_limit; /* bytes/second */ + long low_speed_time; /* number of seconds */ + curl_off_t set_resume_from; /* continue [ftp] transfer from here */ + char *cookie; /* HTTP cookie string to send */ + struct curl_slist *headers; /* linked list of extra headers */ + struct curl_httppost *httppost; /* linked list of POST data */ + char *cert; /* certificate */ + char *cert_type; /* format for certificate (default: PEM) */ + char *key; /* private key */ + char *key_type; /* format for private key (default: PEM) */ + char *key_passwd; /* plain text private key password */ + char *crypto_engine; /* name of the crypto engine to use */ + char *cookiejar; /* dump all cookies to this file */ + bool cookiesession; /* new cookie session? */ + bool crlf; /* convert crlf on ftp upload(?) */ + struct curl_slist *quote; /* after connection is established */ + struct curl_slist *postquote; /* after the transfer */ + struct curl_slist *prequote; /* before the transfer, after type */ + struct curl_slist *source_prequote; /* in 3rd party transfer mode - before + the transfer on source host */ + struct curl_slist *source_postquote; /* in 3rd party transfer mode - after + the transfer on source host */ + struct curl_slist *telnet_options; /* linked list of telnet options */ + curl_TimeCond timecondition; /* kind of time/date comparison */ + time_t timevalue; /* what time to compare with */ + curl_closepolicy closepolicy; /* connection cache close concept */ + Curl_HttpReq httpreq; /* what kind of HTTP request (if any) is this */ + char *customrequest; /* HTTP/FTP request to use */ + long httpversion; /* when non-zero, a specific HTTP version requested to + be used in the library's request(s) */ + char *auth_host; /* if set, this is the allocated string to the host name + * to which to send the authorization data to, and no other + * host (which location-following otherwise could lead to) + */ + char *krb4_level; /* what security level */ + struct ssl_config_data ssl; /* user defined SSL stuff */ + + curl_proxytype proxytype; /* what kind of proxy that is in use */ + + int dns_cache_timeout; /* DNS cache timeout */ + long buffer_size; /* size of receive buffer to use */ + + char *private; /* Private data */ + + struct curl_slist *http200aliases; /* linked list of aliases for http200 */ + + long ip_version; + + curl_off_t max_filesize; /* Maximum file size to download */ + + char *source_host; /* for 3rd party transfer */ + char *source_port; /* for 3rd party transfer */ + char *source_userpwd; /* for 3rd party transfer */ + char *source_path; /* for 3rd party transfer */ + curl_pasv_side pasvHost; /* for 3rd party transfer indicates passive host */ + +/* Here follows boolean settings that define how to behave during + this session. They are STATIC, set by libcurl users or at least initially + and they don't change during operations. */ + + bool printhost; /* printing host name in debug info */ + bool get_filetime; + bool tunnel_thru_httpproxy; + bool ftp_append; + bool ftp_ascii; + bool ftp_list_only; + bool ftp_create_missing_dirs; + bool ftp_use_port; + bool hide_progress; + bool http_fail_on_error; + bool http_follow_location; + bool http_disable_hostname_check_before_authentication; + bool include_header; /* include received protocol headers in data output */ + bool http_set_referer; + bool http_auto_referer; /* set "correct" referer when following location: */ + bool opt_no_body; /* as set with CURLOPT_NO_BODY */ + bool set_port; + bool upload; + enum CURL_NETRC_OPTION + use_netrc; /* defined in include/curl.h */ + char *netrc_file; /* if not NULL, use this instead of trying to find + $HOME/.netrc */ + bool verbose; + bool krb4; /* kerberos4 connection requested */ + bool reuse_forbid; /* forbidden to be reused, close after use */ + bool reuse_fresh; /* do not re-use an existing connection */ + bool expect100header; /* TRUE if we added Expect: 100-continue */ + bool ftp_use_epsv; /* if EPSV is to be attempted or not */ + bool ftp_use_eprt; /* if EPRT is to be attempted or not */ + curl_ftpssl ftp_ssl; /* if AUTH TLS is to be attempted etc */ + bool no_signal; /* do not use any signal/alarm handler */ + bool global_dns_cache; /* subject for future removal */ + bool tcp_nodelay; /* whether to enable TCP_NODELAY or not */ + +}; + +/* + * In August 2001, this struct was redesigned and is since stricter than + * before. The 'connectdata' struct MUST have all the connection oriented + * stuff as we may now have several simultaneous connections and connection + * structs in memory. + * + * From now on, the 'SessionHandle' must only contain data that is set once to + * go for many (perhaps) independent connections. Values that are generated or + * calculated internally for the "session handle" must be defined within the + * 'struct urlstate' instead. */ + +struct SessionHandle { + curl_hash *hostcache; + struct Curl_share *share; /* Share, handles global variable mutexing */ + struct UserDefined set; /* values set by the libcurl user */ + struct DynamicStatic change; /* possibly modified userdefined data */ + + struct CookieInfo *cookies; /* the cookies, read from files and servers */ + struct Progress progress; /* for all the progress meter data */ + struct UrlState state; /* struct for fields used for state info and + other dynamic purposes */ + struct PureInfo info; /* stats, reports and info data */ +#if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H) + ENGINE* engine; +#endif /* USE_SSLEAY */ +}; + +#define LIBCURL_NAME "libcurl" + +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/url.h /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/url.h --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/url.h 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/url.h 2004-10-05 21:34:20.000000000 +0800 @@ -0,0 +1,47 @@ +#ifndef __URL_H +#define __URL_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: url.h,v 1.4 2004/10/05 13:34:20 andy Exp $ + ***************************************************************************/ + +/* + * Prototypes for library-wide functions provided by url.c + */ + +CURLcode Curl_open(struct SessionHandle **curl); +CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...); +CURLcode Curl_close(struct SessionHandle *data); /* opposite of curl_open() */ +CURLcode Curl_connect(struct SessionHandle *, struct connectdata **, + bool *async); +CURLcode Curl_async_resolved(struct connectdata *conn); +CURLcode Curl_do(struct connectdata **); +CURLcode Curl_do_more(struct connectdata *); +CURLcode Curl_done(struct connectdata **, CURLcode); +CURLcode Curl_disconnect(struct connectdata *); +CURLcode Curl_protocol_connect(struct connectdata *conn); +bool Curl_ssl_config_matches(struct ssl_config_data* data, + struct ssl_config_data* needle); +bool Curl_clone_ssl_config(struct ssl_config_data* source, + struct ssl_config_data* dest); +void Curl_free_ssl_config(struct ssl_config_data* sslc); +void Curl_safefree(void *ptr); +#endif diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/version.c /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/version.c --- /tmp/107n8sR4i4/cmake-2.2.3/Source/CTest/Curl/version.c 1970-01-01 08:00:00.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/CTest/Curl/version.c 2004-10-13 22:45:30.000000000 +0800 @@ -0,0 +1,261 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: version.c,v 1.7 2004/10/13 14:45:30 andy Exp $ + ***************************************************************************/ + +#include "setup.h" + +#include +#include + +#include +#include "urldata.h" + +#define _MPRINTF_REPLACE /* use the internal *printf() functions */ +#include + +#ifdef USE_ARES +#include +#endif + +#ifdef USE_LIBIDN +#include +#endif + +#ifdef USE_SSLEAY +static int getssl_version(char *ptr, size_t left, long *num) +{ + +#if (SSLEAY_VERSION_NUMBER >= 0x905000) + { + char sub[2]; + unsigned long ssleay_value; + sub[1]='\0'; + ssleay_value=SSLeay(); + *num = (long)ssleay_value; + if(ssleay_value < 0x906000) { + ssleay_value=SSLEAY_VERSION_NUMBER; + sub[0]='\0'; + } + else { + if(ssleay_value&0xff0) { + sub[0]=(char)((ssleay_value>>4)&0xff) + 'a' -1; + } + else + sub[0]='\0'; + } + + return snprintf(ptr, left, " OpenSSL/%lx.%lx.%lx%s", + (ssleay_value>>28)&0xf, + (ssleay_value>>20)&0xff, + (ssleay_value>>12)&0xff, + sub); + } + +#else + *num = SSLEAY_VERSION_NUMBER; +#if (SSLEAY_VERSION_NUMBER >= 0x900000) + return snprintf(ptr, left, " OpenSSL/%lx.%lx.%lx", + (SSLEAY_VERSION_NUMBER>>28)&0xff, + (SSLEAY_VERSION_NUMBER>>20)&0xff, + (SSLEAY_VERSION_NUMBER>>12)&0xf); +#else + { + char sub[2]; + sub[1]='\0'; + if(SSLEAY_VERSION_NUMBER&0x0f) { + sub[0]=(SSLEAY_VERSION_NUMBER&0x0f) + 'a' -1; + } + else + sub[0]='\0'; + + return snprintf(ptr, left, " SSL/%x.%x.%x%s", + (SSLEAY_VERSION_NUMBER>>12)&0xff, + (SSLEAY_VERSION_NUMBER>>8)&0xf, + (SSLEAY_VERSION_NUMBER>>4)&0xf, sub); + } +#endif +#endif +} + +#endif + +char *curl_version(void) +{ + static char version[200]; + char *ptr=version; + /* to prevent compier warnings, we only declare len if we have code + that uses it */ +#if defined(USE_SSLEAY) || defined(HAVE_LIBZ) || defined(USE_ARES) || \ + defined(USE_LIBIDN) + int len; +#endif + size_t left = sizeof(version); + strcpy(ptr, LIBCURL_NAME "/" LIBCURL_VERSION ); + ptr=strchr(ptr, '\0'); + left -= strlen(ptr); + (void)left; + +#ifdef USE_SSLEAY + { + long num; + len = getssl_version(ptr, left, &num); + left -= len; + ptr += len; + } +#endif + +#ifdef HAVE_LIBZ + len = snprintf(ptr, left, " zlib/%s", zlibVersion()); + left -= len; + ptr += len; +#endif +#ifdef USE_ARES + /* this function is only present in c-ares, not in the original ares */ + len = snprintf(ptr, left, " c-ares/%s", ares_version(NULL)); + left -= len; + ptr += len; +#endif +#ifdef USE_LIBIDN + if(stringprep_check_version(LIBIDN_REQUIRED_VERSION)) { + len = snprintf(ptr, left, " libidn/%s", stringprep_check_version(NULL)); + left -= len; + ptr += len; + } +#endif + + return version; +} + +/* data for curl_version_info */ + +static const char *protocols[] = { +#ifndef CURL_DISABLE_FTP + "ftp", +#endif +#ifndef CURL_DISABLE_GOPHER + "gopher", +#endif +#ifndef CURL_DISABLE_TELNET + "telnet", +#endif +#ifndef CURL_DISABLE_DICT + "dict", +#endif +#ifndef CURL_DISABLE_LDAP + "ldap", +#endif +#ifndef CURL_DISABLE_HTTP + "http", +#endif +#ifndef CURL_DISABLE_FILE + "file", +#endif + +#ifdef USE_SSLEAY +#ifndef CURL_DISABLE_HTTP + "https", +#endif +#ifndef CURL_DISABLE_FTP + "ftps", +#endif +#endif + NULL +}; + +static curl_version_info_data version_info = { + CURLVERSION_NOW, + LIBCURL_VERSION, + LIBCURL_VERSION_NUM, + OS, /* as found by configure or set by hand at build-time */ + 0 /* features is 0 by default */ +#ifdef ENABLE_IPV6 + | CURL_VERSION_IPV6 +#endif +#ifdef HAVE_KRB4 + | CURL_VERSION_KERBEROS4 +#endif +#ifdef USE_SSLEAY + | CURL_VERSION_SSL + | CURL_VERSION_NTLM /* since this requires OpenSSL */ +#endif +#ifdef HAVE_LIBZ + | CURL_VERSION_LIBZ +#endif +#ifdef HAVE_GSSAPI + | CURL_VERSION_GSSNEGOTIATE +#endif +#ifdef CURLDEBUG + | CURL_VERSION_DEBUG +#endif +#ifdef USE_ARES + | CURL_VERSION_ASYNCHDNS +#endif +#ifdef HAVE_SPNEGO + | CURL_VERSION_SPNEGO +#endif +#if defined(ENABLE_64BIT) && (SIZEOF_CURL_OFF_T > 4) + | CURL_VERSION_LARGEFILE +#endif + , + NULL, /* ssl_version */ + 0, /* ssl_version_num */ + NULL, /* zlib_version */ + protocols, + NULL, /* c-ares version */ + 0, /* c-ares version numerical */ + NULL, /* libidn version */ +}; + +curl_version_info_data *curl_version_info(CURLversion stamp) +{ +#ifdef USE_SSLEAY + static char ssl_buffer[80]; + long num; + getssl_version(ssl_buffer, sizeof(ssl_buffer), &num); + + version_info.ssl_version = ssl_buffer; + version_info.ssl_version_num = num; + /* SSL stuff is left zero if undefined */ +#endif + +#ifdef HAVE_LIBZ + version_info.libz_version = zlibVersion(); + /* libz left NULL if non-existing */ +#endif +#ifdef USE_ARES + { + int aresnum; + version_info.ares = ares_version(&aresnum); + version_info.ares_num = aresnum; + } +#endif +#ifdef USE_LIBIDN + /* This returns a version string if we use the given version or later, + otherwise it returns NULL */ + version_info.libidn = stringprep_check_version(LIBIDN_REQUIRED_VERSION); + if(version_info.libidn) + version_info.features |= CURL_VERSION_IDN; +#endif + (void)stamp; /* avoid compiler warnings, we don't use this */ + + return &version_info; +} diff -Nru /tmp/107n8sR4i4/cmake-2.2.3/Source/ctest.cxx /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/ctest.cxx --- /tmp/107n8sR4i4/cmake-2.2.3/Source/ctest.cxx 2005-11-24 01:33:39.000000000 +0800 +++ /tmp/2JlptO5AlS/cmake-2.3.4-20060317/Source/ctest.cxx 2006-03-10 00:57:43.000000000 +0800 @@ -3,14 +3,14 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: ctest.cxx,v $ Language: C++ - Date: $Date: 2005/11/23 17:33:39 $ - Version: $Revision: 1.83.2.2 $ + Date: $Date: 2006/03/09 16:57:43 $ + Version: $Revision: 1.88 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -62,45 +62,51 @@ "Test output is normally suppressed and only summary information is " "displayed. This option will show even more test output."}, {"--debug", "Displaying more verbose internals of CTest.", - "This feature will result in large number of output that is mostly useful " - "for debugging dashboard problems."}, + "This feature will result in large number of output that is mostly " + "useful for debugging dashboard problems."}, {"-Q,--quiet", "Make ctest quiet.", - "This option will suppress all the output. The output log file will still be " - "generated if the --output-log is specified. Options such as --verbose, " - "--extra-verbose, and --debug are ignored if --quiet is specified."}, + "This option will suppress all the output. The output log file will " + "still be generated if the --output-log is specified. Options such " + "as --verbose, --extra-verbose, and --debug are ignored if --quiet is " + "specified."}, {"-O , --output-log ", "Output to log file", "This option tells ctest to write all its output to a log file."}, {"-N,--show-only", "Disable actual execution of tests.", "This option tells ctest to list the tests that would be run but not " "actually run them. Useful in conjunction with the -R and -E options."}, - {"-R , --tests-regex ", "Run tests matching regular expression.", + {"-R , --tests-regex ", "Run tests matching regular " + "expression.", "This option tells ctest to run only the tests whose names match the " "given regular expression."}, - {"-E , --exclude-regex ", "Exclude tests matching regular expression.", + {"-E , --exclude-regex ", "Exclude tests matching regular " + "expression.", "This option tells ctest to NOT run the tests whose names match the " "given regular expression."}, {"-D , --dashboard ", "Execute dashboard test", "This option tells ctest to perform act as a Dart client and perform " - "a dashboard test. All tests are , where Mode can be Experimental, " - "Nightly, and Continuous, and Test can be Start, Update, Configure, " - "Build, Test, Coverage, and Submit."}, + "a dashboard test. All tests are , where Mode can be " + "Experimental, Nightly, and Continuous, and Test can be Start, Update, " + "Configure, Build, Test, Coverage, and Submit."}, {"-M , --test-model ", "Sets the model for a dashboard", "This option tells ctest to act as a Dart client " "where the TestModel can be Experimental, " "Nightly, and Continuous. Combining -M and -T is similar to -D"}, - {"-T , --test-action ", "Sets the dashboard action to perform", + {"-T , --test-action ", "Sets the dashboard action to " + "perform", "This option tells ctest to act as a Dart client " "and perform some action such as start, build, test etc. " "Combining -M and -T is similar to -D"}, - {"-S